From d2e55bf96436fe06432f6595986a29e8448f6070 Mon Sep 17 00:00:00 2001 From: Haoming Yin Date: Wed, 24 May 2017 19:33:24 +1200 Subject: [PATCH] Removed the FPS background, and lowered the update frequency so it doesn't flip too fast. #story[923] --- .../seng302/controllers/CanvasController.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/seng302/controllers/CanvasController.java b/src/main/java/seng302/controllers/CanvasController.java index 6fa9b773..647a2488 100644 --- a/src/main/java/seng302/controllers/CanvasController.java +++ b/src/main/java/seng302/controllers/CanvasController.java @@ -120,6 +120,9 @@ public class CanvasController { initializeMarks(); timer = new AnimationTimer() { + private int UPDATE_FPM_PERIOD = 50; // update FPM label every 50 frames + private int updateFPMCounter = 100; + @Override public void handle(long now) { @@ -135,7 +138,10 @@ public class CanvasController { elapsedNanos = now - oldFrameTime ; long elapsedNanosPerFrame = elapsedNanos / frameTimes.length ; frameRate = 1_000_000_000.0 / elapsedNanosPerFrame ; - drawFps(frameRate.intValue()); + if (updateFPMCounter++ > UPDATE_FPM_PERIOD) { + updateFPMCounter = 0; + drawFps(frameRate.intValue()); + } } // TODO: 1/05/17 cir27 - Make the RaceObjects update on the actual delay. @@ -348,17 +354,14 @@ public class CanvasController { private void drawFps(int fps){ if (raceViewController.isDisplayFps()){ - gc.clearRect(5,5,50,20); - gc.setFill(Color.SKYBLUE); - gc.fillRect(4,4,51,21); - gc.setFill(Color.BLACK); - gc.setFont(new Font(14)); - gc.setLineWidth(3); + gc.clearRect(5, 5, 60, 30); + gc.setFont(new Font(16)); + gc.setLineWidth(4); + gc.setGlobalAlpha(0.75); gc.fillText(fps + " FPS", 5, 20); + gc.setGlobalAlpha(0.5); } else { - gc.clearRect(5,5,50,20); - gc.setFill(Color.SKYBLUE); - gc.fillRect(4,4,51,21); + gc.clearRect(5,5,60,30); } }