Class GuiButtonController

java.lang.Object
edu.ntnu.stud.chaosgame.controller.game.GuiButtonController

public class GuiButtonController extends Object
Controller class for handling GUI button actions. It notifies registered observers when a button is pressed.
  • Field Details

    • gui

      private final ChaosGameGui gui
      The GUI this controller is associated with.
    • timeline

      private final javafx.animation.Timeline timeline
      The timeline for the game.
    • popupButtonController

      private final PopupButtonController popupButtonController
      The controller for the popup buttons.
    • observers

      private final List<GuiButtonObserver> observers
      The list of observers.
    • fileHandler

      private final ChaosGameFileHandler fileHandler
      The file handler for the chaos game.
    • game

      private ChaosGame game
      The chaos game.
    • factory

      private ChaosGameDescriptionFactory factory
      The factory for the chaos game descriptions.
    • chaosCanvas

      private ChaosCanvas chaosCanvas
      The canvas for the chaos game.
    • currentImagePath

      private final String currentImagePath
      The current image path.
    • stepCounter

      private int stepCounter
      The step counter for the game.
    • reusableImage

      private final javafx.scene.image.WritableImage reusableImage
      The reusable image for the canvas.
  • Constructor Details

    • GuiButtonController

      public GuiButtonController(ChaosGame game, ChaosGameGui gui)
      Constructs a GuiButtonController with the given game and GUI.
      Parameters:
      game - the Chaos Game model.
      gui - the Chaos Game GUI.
  • Method Details

    • addObserver

      public void addObserver(GuiButtonObserver observer)
      Adds an observer to the list of observers.
      Parameters:
      observer - the observer to add.
    • notifyStartButtonPressed

      private void notifyStartButtonPressed()
      Notifies all observers that the start button has been pressed.
    • notifyStopButtonPressed

      private void notifyStopButtonPressed()
      Notifies all observers that the stop button has been pressed.
    • notifyClearButtonPressed

      private void notifyClearButtonPressed()
      Notifies all observers that the clear button has been pressed.
    • notifyQuitButtonPressed

      private void notifyQuitButtonPressed()
      Notifies all observers that the quit button has been pressed.
    • notifySaveImageButtonPressed

      private void notifySaveImageButtonPressed()
      Notifies all observers that the save image button has been pressed.
    • notifyLoadFractalFromFileButtonPressed

      private void notifyLoadFractalFromFileButtonPressed()
      Notifies all observers that the load fractal from file button has been pressed.
    • notifyWriteToFileButtonPressed

      private void notifyWriteToFileButtonPressed()
      Notifies all observers that the write to file button has been pressed.
    • notifyModifyGameButtonPressed

      private void notifyModifyGameButtonPressed()
      Notifies all observers that the modify game button has been pressed.
    • startGame

      public void startGame()
      Starts the game.
    • stopGame

      public void stopGame()
      Stops the game.
    • clearCanvas

      public void clearCanvas()
      Clears the canvas.
    • quitGame

      public void quitGame()
      Quits the game.
    • saveImage

      public void saveImage()
      Saves the image.
    • toBufferedImage

      private BufferedImage toBufferedImage(javafx.scene.image.WritableImage image)
      Converts a WritableImage to a BufferedImage.
      Parameters:
      image - the WritableImage to convert.
      Returns:
      the converted BufferedImage.
    • loadFractalFromFile

      public void loadFractalFromFile()
      Loads a fractal from a file.
    • writeFractalToFile

      public void writeFractalToFile()
      Writes the fractal to a file.
    • modifyGame

      public void modifyGame()
      Modifies the game based on the selected transformation.
    • initializeDescriptionComboBox

      private void initializeDescriptionComboBox()
      Initializes the description combo box.
    • updateDescriptionComboBox

      public void updateDescriptionComboBox()
      Update the description of the chaos game..
    • drawChaosGame

      public void drawChaosGame()
      Draws the chaos game on the canvas.
    • updateDescription

      public void updateDescription(int index)
      Updates the description of the chaos game.
      Parameters:
      index - the index of the new description in the list of factory descriptions.