Added drawing to fx thread

#fix
This commit is contained in:
Calum
2017-09-28 14:57:52 +13:00
parent c98297ea79
commit e1ebbc71c1
2 changed files with 11 additions and 14 deletions
@@ -43,12 +43,14 @@ public class MiniMap extends MapPreview {
boatIcons.put(yacht, boatIcon);
boatIcon.getTransforms().add(new Rotate(0));
yacht.addLocationListener((boat, lat, lon, heading, sailIn, velocity) -> {
Platform.runLater(() -> {
Polygon bi = boatIcons.get(boat);
Point2D p2d = scaledPoint.findScaledXY(lat, lon);
bi.setLayoutX(p2d.getX());
bi.setLayoutY(p2d.getY());
((Rotate) bi.getTransforms().get(0)).setAngle(heading);
});
});
}
Platform.runLater(() -> {
gameObjects.getChildren().addAll(boatIcons.values());
@@ -28,8 +28,7 @@ public class Marker2D extends Group {
mark.setRadius(5);
mark.setCenterX(0);
mark.setCenterY(0);
Platform.runLater(() -> this.getChildren()
.addAll(mark, new Group())); //Empty group placeholder or arrows.
Platform.runLater(() -> this.getChildren().add(mark));
}
/**
@@ -82,13 +81,9 @@ public class Marker2D extends Group {
private void showArrow(List<Group> arrowList, int arrowListIndex) {
if (arrowListIndex < arrowList.size()) {
if (arrowListIndex == 1) {
;
}
Platform.runLater(() -> {
this.getChildren().remove(1);
this.getChildren().add(arrowList.get(arrowListIndex));
});
Platform.runLater(() ->
this.getChildren().setAll(mark, arrowList.get(arrowListIndex))
);
}
}