diff --git a/racevisionGame/src/main/java/visualiser/Controllers/NextMarkController.java b/racevisionGame/src/main/java/visualiser/Controllers/NextMarkController.java index 7370246f..20da6f3c 100644 --- a/racevisionGame/src/main/java/visualiser/Controllers/NextMarkController.java +++ b/racevisionGame/src/main/java/visualiser/Controllers/NextMarkController.java @@ -49,9 +49,13 @@ public class NextMarkController { AnimationTimer arrow2d = new AnimationTimer() { @Override public void handle(long now) { - CompoundMark target = boat.getCurrentLeg().getEndCompoundMark(); - Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate()); - arrowStackPane2d.setRotate(headingToMark.degrees()); + if (boat.getCurrentLeg().getEndCompoundMark() != null) { + CompoundMark target = boat.getCurrentLeg().getEndCompoundMark(); + Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate()); + arrowStackPane2d.setRotate(headingToMark.degrees()); + } else { + stop(); + } } }; arrow2d.start(); @@ -73,10 +77,14 @@ public class NextMarkController { AnimationTimer arrow3d = new AnimationTimer() { @Override public void handle(long now) { - arrow.getTransforms().clear(); - double zRotation = calculateZRotate(); - arrow.setRotate(calculateXRotate(zRotation)); - arrow.getTransforms().add(new Rotate(zRotation, new Point3D(0, 0, 1))); + if (boat.getCurrentLeg().getEndCompoundMark() != null) { + arrow.getTransforms().clear(); + double zRotation = calculateZRotate(); + arrow.setRotate(calculateXRotate(zRotation)); + arrow.getTransforms().add(new Rotate(zRotation, new Point3D(0, 0, 1))); + } else { + stop(); + } } }; arrow3d.start();