diff --git a/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java b/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java index ca8b5e046ca230d8f4a02ad59db43193ebfeddf8..6c43421f6da4d7e342374ef00743ff978e81d73a 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java @@ -175,7 +175,7 @@ public class GuiButtonController { /** * Clear the image view. */ - public void clearImageView() { + public void clearCanvas() { chaosCanvas.clearCanvas(); GraphicsContext gc = gui.getCanvas().getGraphicsContext2D(); gc.clearRect(0, 0, gui.getCanvas().getWidth(), gui.getCanvas().getHeight()); @@ -197,7 +197,7 @@ public class GuiButtonController { gui.getStartButton().setOnAction(event -> startGame()); gui.getStopButton().setOnAction(event -> stopGame()); - gui.getClearButton().setOnAction(event -> clearImageView()); + gui.getClearButton().setOnAction(event -> clearCanvas()); gui.getQuitButton().setOnAction(event -> quitGame()); gui.getColorCheckBox().setOnAction(event -> game.setUseColor(gui.getColorCheckBox().isSelected())); @@ -219,7 +219,7 @@ public class GuiButtonController { chaosCanvas.clearCanvas(); gui.getCanvas().getGraphicsContext2D().clearRect(0, 0, gui.getCanvas().getGraphicsContext2D(). getCanvas().getWidth(), gui.getCanvas().getGraphicsContext2D().getCanvas().getHeight()); - clearImageView(); + clearCanvas(); chaosCanvas.clearCanvas(); // Get the new description and create a new ChaosCanvas diff --git a/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java b/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java index c6f3aba3bb344648462ca04250cbe4a9ad658a2e..9ec860a28b9ec12d326c18fd388c609fb74ca8f4 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java @@ -339,6 +339,7 @@ public class ChaosGameGui implements ChaosGameObserver { descriptionComboBox.getSelectionModel().selectedItemProperty() .addListener((observable, oldValue, newValue) -> { for (int i = 0; i < factory.getDescriptions().size(); i++) { + ChaosGameDescription description = factory.getDescriptions().get(i); if (description.getName().equals(newValue)) { controller.updateDescription(i); break;