Replaced mark arrow listener with animation timer.

#story[1195]
This commit is contained in:
Connor Taylor-Brown
2017-09-14 12:06:47 +12:00
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());
this.pointToMark = new AnimationTimer() {
@Override
public void handle(long now) {
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());
nextMarkArrow.setX(view3D.getPivot().getX());
nextMarkArrow.setY(view3D.getPivot().getY());
nextMarkArrow.setZ(view3D.getPivot().getZ() + 10);
nextMarkArrow.setHeading(headingToMark.degrees());
}
};
boat.positionProperty().addListener(pointToMark);
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();
}
/**