Class ChaosGameGui

java.lang.Object
edu.ntnu.stud.chaosgame.view.ChaosGameGui
All Implemented Interfaces:
ChaosGameObserver, GuiButtonObserver

public class ChaosGameGui extends Object implements ChaosGameObserver, GuiButtonObserver
Class representing the GUI for a ChaosGame, implementing a ChaosGameObserver interface to receive updates from the ChaosGame.
  • Field Details

    • primaryStage

      private final javafx.stage.Stage primaryStage
      The primary stage for the GUI.
    • aspectRatio

      private final double aspectRatio
      The aspect ratio of the GUI.
    • controller

      private final GuiButtonController controller
      The controller for the GUI.
    • canvas

      private javafx.scene.canvas.Canvas canvas
      The canvas for this GUI.
    • chaosCanvas

      private ChaosCanvas chaosCanvas
      The ChaosCanvas for this GUI.
    • description

      private ChaosGameDescription description
      The ChaosGameDescription.
    • factory

      private ChaosGameDescriptionFactory factory
      The ChaosGameDescriptionFactory.
    • imageView

      private ChaosGameImageView imageView
      The ImageView for the GUI.
    • scene

      private javafx.scene.Scene scene
      The Scene for the GUI.
    • width

      private int width
      The width of the GUI.
    • height

      private int height
      The height of the GUI.
    • game

      private ChaosGame game
      The ChaosGame for this GUI.
    • borderPane

      private javafx.scene.layout.BorderPane borderPane
      The BorderPane for the GUI.
    • sideMenu

      private javafx.scene.layout.VBox sideMenu
      The side menu for the GUI.
    • startButton

      private javafx.scene.control.Button startButton
      The start, stop, new, clear, quit and show sidebar buttons for the GUI.
    • stopButton

      private javafx.scene.control.Button stopButton
      The stop button for the GUI.
    • clearButton

      private javafx.scene.control.Button clearButton
      The button for clearing the canvas and starting a new fractal.
    • quitButton

      private javafx.scene.control.Button quitButton
      The quit button for the GUI.
    • sideMenuButton

      private javafx.scene.control.Button sideMenuButton
      The side menu button for the GUI.
    • loadFractalFromFileButton

      private javafx.scene.control.Button loadFractalFromFileButton
      The load fractal from file and write fractal to file buttons for the GUI.
    • writeFractalToFileButton

      private javafx.scene.control.Button writeFractalToFileButton
      The write fractal to file button for the GUI.
    • modifyGameButton

      private javafx.scene.control.Button modifyGameButton
      The button which opens a menu to modify the game.
    • descriptionComboBox

      private javafx.scene.control.ComboBox<String> descriptionComboBox
      A description ComboBox for choosing different fractal descriptions.
    • stepCountTextField

      private javafx.scene.control.TextField stepCountTextField
      The step count text field for the GUI.
    • iterationLimitTextField

      private javafx.scene.control.TextField iterationLimitTextField
      The iteration limiter text field for the GUI.
    • colorCheckBox

      private javafx.scene.control.CheckBox colorCheckBox
      The color check box for the GUI.
    • saveImageButton

      private javafx.scene.control.Button saveImageButton
      Button to save an image of the fractal.
    • scrollPane

      private javafx.scene.control.ScrollPane scrollPane
      ScrollPane for side menu.
  • Constructor Details

    • ChaosGameGui

      public ChaosGameGui(javafx.stage.Stage primaryStage) throws IOException
      Constructor for the ChaosGameGui.
      Parameters:
      primaryStage - the primary stage for the GUI.
      Throws:
      IOException - if the GUI fails to initialize.
  • Method Details

    • initializeComponents

      private void initializeComponents()
      Initialize the components of the GUI.
    • initializeGameComponents

      private void initializeGameComponents()
      Initialize the components related to the chaos game itself.
    • initializeImageView

      private void initializeImageView()
      Initialize components related to the image view and zoom function.
    • clearImageView

      public void clearImageView()
      Color the entire image view white.
    • initializeFractalComponents

      private void initializeFractalComponents()
      Initialize the buttons related to managing the fractals.
    • initializeSideMenu

      private void initializeSideMenu()
      Initialize the side menu for the GUI, including all its buttons and other components.
    • initializeSideButtonHandler

      private void initializeSideButtonHandler()
      Initialise the side bar button handler, allowing the user to show or hide the right sidebar.
    • getImageView

      public javafx.scene.image.ImageView getImageView()
      Get the image view of this GUI.
      Returns:
      the image view.
    • updateCanvas

      public void updateCanvas(ChaosCanvas canvas)
      Update the canvas and set a new zoom factor for the image view based on the ratio between the old and new canvas heights.
      Specified by:
      updateCanvas in interface ChaosGameObserver
      Parameters:
      canvas - the canvas to update with.
    • updateGame

      public void updateGame(ChaosGame game)
      Update the observer based on changes to the chaos game. changed depending on how we implement the UI. The update method may need to be split.
      Specified by:
      updateGame in interface ChaosGameObserver
      Parameters:
      game - the game this observer is monitoring.
    • onStartButtonPressed

      public void onStartButtonPressed()
      Description copied from interface: GuiButtonObserver
      Used when start-button is pressed.
      Specified by:
      onStartButtonPressed in interface GuiButtonObserver
    • onStopButtonPressed

      public void onStopButtonPressed()
      Handle the stop button being pressed.
      Specified by:
      onStopButtonPressed in interface GuiButtonObserver
    • onClearButtonPressed

      public void onClearButtonPressed()
      Handle the clear button being pressed.
      Specified by:
      onClearButtonPressed in interface GuiButtonObserver
    • onQuitButtonPressed

      public void onQuitButtonPressed()
      Handle the quit button being pressed.
      Specified by:
      onQuitButtonPressed in interface GuiButtonObserver
    • onSaveImageButtonPressed

      public void onSaveImageButtonPressed()
      Handle the save image button being pressed.
      Specified by:
      onSaveImageButtonPressed in interface GuiButtonObserver
    • onLoadFractalFromFileButtonPressed

      public void onLoadFractalFromFileButtonPressed()
      Handle the load fractal from file button being pressed.
      Specified by:
      onLoadFractalFromFileButtonPressed in interface GuiButtonObserver
    • onWriteToFileButtonPressed

      public void onWriteToFileButtonPressed()
      Handle the write fractal to file button being pressed.
      Specified by:
      onWriteToFileButtonPressed in interface GuiButtonObserver
    • onModifyGameButtonPressed

      public void onModifyGameButtonPressed()
      Handle the modify game button being pressed.
      Specified by:
      onModifyGameButtonPressed in interface GuiButtonObserver
    • getStepCountTextField

      public javafx.scene.control.TextField getStepCountTextField()
      Get the step count text field for this GUI.
      Returns:
      the step count text field.
    • getIterationLimitTextField

      public javafx.scene.control.TextField getIterationLimitTextField()
      Get the iteration limit text field for this GUI.
      Returns:
      the iteration limit text field.
    • getColorCheckBox

      public javafx.scene.control.CheckBox getColorCheckBox()
      Get the color check box for this GUI.
      Returns:
      the color check box.
    • getCanvas

      public javafx.scene.canvas.Canvas getCanvas()
      Get the canvas for this GUI.
      Returns:
      the canvas.
    • getStartButton

      public javafx.scene.control.Button getStartButton()
      Get the start button for this GUI.
      Returns:
      the start button.
    • getStopButton

      public javafx.scene.control.Button getStopButton()
      Get the stop button for this GUI.
      Returns:
      the stop button.
    • getClearButton

      public javafx.scene.control.Button getClearButton()
      Get the clear button for this GUI.
      Returns:
      the clear button.
    • getQuitButton

      public javafx.scene.control.Button getQuitButton()
      Get the quit button for this GUI.
      Returns:
      the quit button.
    • getWriteToFileButton

      public javafx.scene.control.Button getWriteToFileButton()
      Get the write fractal to file button.
      Returns:
      the write fractal to file button.
    • getStage

      public javafx.stage.Window getStage()
      Get the primary stage for this GUI.
      Returns:
      the primary stage.
    • resizeCanvas

      private void resizeCanvas()
      Resize the canvas to fit the new dimensions of the scene.
    • getLoadFractalFromFileButton

      public javafx.scene.control.Button getLoadFractalFromFileButton()
      Get the load fractal from file button.
      Returns:
      the load fractal from file button.
    • getModifyGameButton

      public javafx.scene.control.Button getModifyGameButton()
      Get the modify game button.
      Returns:
      the modify game button.
    • getDescriptionComboBox

      public javafx.scene.control.ComboBox getDescriptionComboBox()
      Get the description combo box.
      Returns:
      the description combo box.
    • getSaveImageButton

      public javafx.scene.control.Button getSaveImageButton()
      Get the save image button.
      Returns:
      the save image button.