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 a8611eaa962e46543df0c60cfe296e2b5dc470c1..5c06b2bafd001525e511aa4e6758eda57d1632ff 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 @@ -195,7 +195,9 @@ public class GuiButtonController { private void initializeMainButtons() { gui.getStartButton().setOnAction(event -> startGame()); gui.getStopButton().setOnAction(event -> stopGame()); + gui.getClearButton().setOnAction(event -> clearImageView()); + gui.getQuitButton().setOnAction(event -> quitGame()); gui.getColorCheckBox().setOnAction(event -> game.setUseColor(gui.getColorCheckBox().isSelected())); 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 401fe2f6bb9d50f3eb26b6b3e944a19268d5ca69..7a62aee18db1ac770ff154bb86ec7cd6e026ecbd 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java @@ -8,11 +8,8 @@ import edu.ntnu.stud.chaosgame.controller.utility.Formatter; import edu.ntnu.stud.chaosgame.model.data.Vector2D; import edu.ntnu.stud.chaosgame.model.generators.ChaosGameDescriptionFactory; -import java.util.Objects; -import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.animation.TranslateTransition; -import javafx.application.Platform; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; @@ -21,10 +18,17 @@ import javafx.scene.canvas.GraphicsContext; import javafx.scene.control.*; import javafx.scene.image.Image; import javafx.scene.image.ImageView; + import javafx.scene.image.WritableImage; import javafx.scene.layout.*; import javafx.scene.paint.Color; import javafx.scene.text.Font; + +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Region; +import javafx.scene.layout.VBox; + import javafx.stage.Stage; import javafx.stage.Window; import javafx.util.Duration; @@ -106,8 +110,18 @@ public class ChaosGameGui implements ChaosGameObserver { * The start, stop, new, clear, quit and show sidebar buttons for the GUI. */ private Button startButton; + + /** + * The stop button for the GUI. + */ private Button stopButton; + + + /** + * The button for clearing + */ private Button clearButton; + private Button quitButton; private Button sideMenuButton; @@ -152,16 +166,18 @@ public class ChaosGameGui implements ChaosGameObserver { */ private GuiButtonController controller; - - - + /** + * Constructor for the ChaosGameGui. + * + * @param primaryStage the primary stage for the GUI. + * @throws IOException if the GUI fails to initialize. + */ public ChaosGameGui(Stage primaryStage) throws IOException { this.primaryStage = primaryStage; this.initializeComponents(); this.initializeGameComponents(); this.controller = new GuiButtonController(game, this); // Initialize controller here - primaryStage.setTitle("Fractal Chaos Game"); primaryStage.setScene(scene); primaryStage.setOnShown(event -> this.imageView.requestFocus()); @@ -193,11 +209,6 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty()); //this.timeline = new Timeline(new KeyFrame(Duration.seconds(0.05), event -> controller.drawChaosGame())); this.initializeImageView(); - - // Side menu - - - //this.initializeMainButtons(); this.initializeFractalButtons(); this.initializeSideMenu(); @@ -333,7 +344,7 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty()); // Create Canvas Buttons this.startButton = new Button("Start"); this.stopButton = new Button("Stop"); - this.clearButton = new Button("Clear"); + this.clearButton = new Button("New"); this.quitButton = new Button("Quit"); //this.sideMenuButton = new Button("Side Menu"); @@ -465,6 +476,7 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty()); // Add spacing sideMenu.getChildren().add(space); + sideMenu.getChildren().addAll(startButton,stopButton, clearButton); @@ -587,9 +599,6 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty()); this.imageView.setImage(inputView); } - - - /** * Update the canvas and set a new zoom factor for the image view based on the ratio * between the old and new canvas heights. @@ -654,6 +663,7 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty()); public Button getClearButton() { return this.clearButton; } + public Button getQuitButton() { return this.quitButton; } @@ -697,4 +707,5 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty()); // Redraw the fractal to fit the new canvas size controller.drawChaosGame(); } + }