Replaced mark arrow listener with animation timer.

#story[1195]
main
Connor Taylor-Brown 8 years ago
parent de9f4e22eb
commit b8c4582d2a

@ -82,7 +82,7 @@ public class RaceController extends Controller {
private ObservableList<Subject3D> viewSubjects;
private Subject3D nextMarkArrow;
private ChangeListener<? super GPSCoordinate> pointToMark;
private AnimationTimer pointToMark;
/**
* The arrow controller.
@ -367,17 +367,19 @@ public class RaceController extends Controller {
try {
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
this.pointToMark = (o, prev, curr) -> {
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
nextMarkArrow.setX(view3D.getPivot().getX());
nextMarkArrow.setY(view3D.getPivot().getY());
nextMarkArrow.setZ(view3D.getPivot().getZ() + 10);
nextMarkArrow.setHeading(headingToMark.degrees());
};
this.pointToMark = new AnimationTimer() {
@Override
public void handle(long now) {
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
boat.positionProperty().addListener(pointToMark);
nextMarkArrow.setX(view3D.getPivot().getX());
nextMarkArrow.setY(view3D.getPivot().getY());
nextMarkArrow.setZ(view3D.getPivot().getZ() + 10);
nextMarkArrow.setHeading(headingToMark.degrees());
}
};
pointToMark.start();
} catch (BoatNotFoundException e) {
e.printStackTrace();
}
@ -385,13 +387,7 @@ public class RaceController extends Controller {
private void removeThirdPersonAnnotations(Subject3D subject3D) {
viewSubjects.remove(nextMarkArrow);
try {
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
boat.positionProperty().removeListener(pointToMark);
} catch (BoatNotFoundException e) {
e.printStackTrace();
}
pointToMark.stop();
}
/**

Loading…
Cancel
Save