Skip to content
Snippets Groups Projects
Commit b90e5086 authored by Håvard Daleng's avatar Håvard Daleng
Browse files

Rebased

parent 9800fa14
No related branches found
No related tags found
No related merge requests found
......@@ -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()));
......
......@@ -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();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment