From 0fdf71334710022b349f215a7c23ff9325db4c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=BChler?= <17296905+buehlefs@users.noreply.github.com> Date: Wed, 2 Oct 2019 15:56:27 +0200 Subject: [PATCH] Add reset for zoom on task switch --- .../icge/simulation/internal/StandardSimulationProxy.java | 1 + .../informatik/fius/icge/ui/PlayfieldDrawer.java | 5 +++++ .../fius/icge/ui/internal/SwingPlayfieldDrawer.java | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationProxy.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationProxy.java index 178a33d3a..4b133f51c 100644 --- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationProxy.java +++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationProxy.java @@ -197,6 +197,7 @@ public void setTaskSelectorListener(TaskSelectorListener listener) { @Override public void selectedTaskChange(String element) { if (!element.equals(this.currentTaskName)) { + this.gameWindow.getPlayfieldDrawer().resetZoomAndPan(); this.switchTask(element); } } diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/PlayfieldDrawer.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/PlayfieldDrawer.java index 0c7f9533c..4b101f0e5 100644 --- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/PlayfieldDrawer.java +++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/PlayfieldDrawer.java @@ -36,4 +36,9 @@ public interface PlayfieldDrawer { * The number of the current tick */ void draw(long tickCount); + + /** + * Reset Zoom and Pan applied by the user to the default values. + */ + public void resetZoomAndPan(); } diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingPlayfieldDrawer.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingPlayfieldDrawer.java index 8f7e91037..6471ad94c 100644 --- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingPlayfieldDrawer.java +++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingPlayfieldDrawer.java @@ -227,6 +227,13 @@ public void draw(long tickCount) { this.repaintManager.setDoubleBufferingEnabled(bufferEnabled); } + @Override + public void resetZoomAndPan() { + this.scale = 1.0; + this.offsetX = SwingPlayfieldDrawer.CELL_SIZE; + this.offsetY = SwingPlayfieldDrawer.CELL_SIZE; + } + @Override public Dimension getPreferredSize() { return new Dimension(800, 600);