Class BrickPaintController

java.lang.Object
com.example.brickpaint.BrickPaintController

public class BrickPaintController extends Object
Main controller class for the BrickPaint application, handles the FXML methods and variables for the stage
Author:
matde
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The instance of ButtonManager which contains the tool GUI for this controller
    The current instance of the canvas where all drawing occurs within the paint app
    static final org.apache.logging.log4j.Logger
     
    protected javafx.scene.control.TabPane
    The node that manages all the canvas panel tabs within the application
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Creates a new canvas panel instance and adds it to the scene as a tab
    static double
    clamp(double val, double min, double max)
    Helper function which return a value restricted between min and max
    static int
    clamp(int val, int min, int max)
    Helper function which return a value restricted between min and max
    Returns the current canvas panel that is selected in the Tab pane
    Returns the current tool selection from the button manager as a BrickTools enum value
    protected void
    Handles the action when a close button is pressed
    protected void
    Creates a prompt to confirm clearing the current canvas
    protected void
    Handles inserting an image into the imageVeiw component, utilizes the file explorer and BrickImage class
    protected void
    Creates a new window based off of the About Brick FXML file and controller
    protected void
    Resets the scale and position of the current canvas
    protected void
    Handles saving an image from the canvasPanel, if it has not yet been saved will call SaveAs instead
    protected void
    Handles saving an image to a user created file from the canvasPanel
    protected void
    OnClose(javafx.stage.WindowEvent event)
    This method is called or invoked whenever the program is going to be closed
    protected void
    Will iterate through all open tabs and save them as a png using the name of the tab
    protected void
    Called when the program starts from the application class

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      public static final org.apache.logging.log4j.Logger logger
    • canvasPanels

      public List<CanvasPanel> canvasPanels
      The current instance of the canvas where all drawing occurs within the paint app
    • buttonManager

      public ButtonManager buttonManager
      The instance of ButtonManager which contains the tool GUI for this controller
    • tabs

      protected javafx.scene.control.TabPane tabs
      The node that manages all the canvas panel tabs within the application
  • Constructor Details

    • BrickPaintController

      public BrickPaintController()
  • Method Details

    • clamp

      public static double clamp(double val, double min, double max)
      Helper function which return a value restricted between min and max
      Parameters:
      val - The double to evaluate
      min - The minimum value which to return
      max - The maximum value which to return
      Returns:
      Double value between min and max
    • clamp

      public static int clamp(int val, int min, int max)
      Helper function which return a value restricted between min and max
      Parameters:
      val - The int to evaluate
      min - The minimum value which to return
      max - The maximum value which to return
      Returns:
      Integer value between min and max
    • Start

      protected void Start()
      Called when the program starts from the application class
    • addTab

      protected void addTab()
      Creates a new canvas panel instance and adds it to the scene as a tab
    • getCanvas

      public CanvasPanel getCanvas()
      Returns the current canvas panel that is selected in the Tab pane
      Returns:
      CanvasPanel
    • getToolType

      public BrickTools getToolType()
      Returns the current tool selection from the button manager as a BrickTools enum value
      Returns:
      int
    • handleButtonClose

      protected void handleButtonClose()
      Handles the action when a close button is pressed
    • handleResetView

      protected void handleResetView()
      Resets the scale and position of the current canvas
    • handleClear

      protected void handleClear()
      Creates a prompt to confirm clearing the current canvas
    • handleInsertImage

      protected void handleInsertImage()
      Handles inserting an image into the imageVeiw component, utilizes the file explorer and BrickImage class
    • handleSaveImage

      protected void handleSaveImage()
      Handles saving an image from the canvasPanel, if it has not yet been saved will call SaveAs instead
    • handleSaveImageAs

      protected void handleSaveImageAs()
      Handles saving an image to a user created file from the canvasPanel
    • saveAll

      protected void saveAll()
      Will iterate through all open tabs and save them as a png using the name of the tab
    • handleOpenAboutMenu

      protected void handleOpenAboutMenu()
      Creates a new window based off of the About Brick FXML file and controller
    • OnClose

      protected void OnClose(javafx.stage.WindowEvent event)
      This method is called or invoked whenever the program is going to be closed
      Parameters:
      event - Window event from the Event Class