From 6fc55bb82c0308884ce4d983776fce213b15e280 Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 27 Mar 2017 16:45:02 +1300 Subject: [PATCH] Added toggle for fps #story[463] --- .../seng302/controllers/CanvasController.java | 19 ++++++++++++++----- src/main/resources/RaceView.fxml | 5 +++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/seng302/controllers/CanvasController.java b/src/main/java/seng302/controllers/CanvasController.java index 87421576..84709f81 100644 --- a/src/main/java/seng302/controllers/CanvasController.java +++ b/src/main/java/seng302/controllers/CanvasController.java @@ -45,7 +45,7 @@ public class CanvasController { @FXML private BoatPositionController teamPositionsController; @FXML - private CheckBox toggleAnnotation; + private CheckBox toggleAnnotation, toggleFps; private Race race; private GraphicsContext gc; @@ -61,6 +61,7 @@ public class CanvasController { private final int SCALE = 16000; private boolean annotationCheck = true; + private boolean displayFps = true; ///test private HashSet headingTest = new HashSet<>(); @@ -149,6 +150,12 @@ public class CanvasController { annotationCheck = !annotationCheck; } }); + toggleFps.selectedProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { + displayFps = !displayFps; + } + }); //set wind direction!!!!!!! can't find another place to put my code --haoming double windDirection = new ConfigParser("/config.xml").getWindDirection(); @@ -267,10 +274,12 @@ public class CanvasController { } private void drawFps(int fps){ - gc.setFill(Color.BLACK); - gc.setFont(new Font(14)); - gc.setLineWidth(3); - gc.fillText(fps + " FPS", 5, 20); + if (displayFps){ + gc.setFill(Color.BLACK); + gc.setFont(new Font(14)); + gc.setLineWidth(3); + gc.fillText(fps + " FPS", 5, 20); + } } /** diff --git a/src/main/resources/RaceView.fxml b/src/main/resources/RaceView.fxml index 9c8b7add..c36a95d5 100644 --- a/src/main/resources/RaceView.fxml +++ b/src/main/resources/RaceView.fxml @@ -25,7 +25,7 @@ - + +