Tokens now appear client side

#story[1250]
This commit is contained in:
William Muir
2017-08-29 17:17:06 +12:00
parent 1c866ea8c2
commit dc19310849
3 changed files with 30 additions and 2 deletions
@@ -35,6 +35,7 @@ import seng302.model.Limit;
import seng302.model.mark.CompoundMark;
import seng302.model.mark.Corner;
import seng302.model.mark.Mark;
import seng302.model.token.Token;
import seng302.utilities.GeoUtility;
import seng302.visualiser.fxObjects.AnnotationBox;
import seng302.visualiser.fxObjects.BoatObject;
@@ -82,6 +83,7 @@ public class GameView extends Pane {
private Group boatObjectGroup = new Group();
private Group trails = new Group();
private Group markers = new Group();
private Group tokens = new Group();
private List<CompoundMark> course = new ArrayList<>();
private ImageView mapImage = new ImageView();
@@ -141,6 +143,7 @@ public class GameView extends Pane {
gameObjects.add(mapImage);
gameObjects.add(raceBorder);
gameObjects.add(markers);
gameObjects.add(tokens);
initializeTimer();
}
@@ -435,6 +438,28 @@ public class GameView extends Pane {
raceBorder.getPoints().setAll(boundaryPoints);
}
/**
* Replaces all tokens in the course with those passed in
*
* @param newTokens the tokens to be put on the course.
*/
public void updateTokens(List<Token> newTokens) {
List<Marker> mapTokens = new ArrayList<>();
for (Token token : newTokens) {
Point2D location = findScaledXY(token.getLat(), token.getLng());
Marker thisMarker = new Marker(Color.YELLOW);
thisMarker.setLayoutX(location.getX());
thisMarker.setLayoutY(location.getY());
mapTokens.add(thisMarker);
}
Platform.runLater(() -> {
tokens.getChildren().clear();
tokens.getChildren().addAll(mapTokens);
});
}
// TODO: 16/08/17 initialize zooming internal to GameView only
/**
* Enables zoom. Has to be called after this is added to a scene.