Class ButtonManager

java.lang.Object
com.example.brickpaint.ButtonManager

public class ButtonManager extends Object
Sets up all toolbar buttons for the application as well as their graphics, layout, listeners, and methods
Author:
matde
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    javafx.scene.control.Label
     
    javafx.scene.control.ComboBox<Integer>
    allows the user to enter or select a value for the current canvas's height
    javafx.scene.control.ColorPicker
     
    javafx.scene.control.ComboBox<Integer>
    allows the user to enter or select a value for the current canvas's width
    javafx.scene.control.Spinner<Double>
     
    javafx.scene.control.ChoiceBox<BrickTools>
     
    javafx.scene.control.ComboBox<Integer>
     
    javafx.scene.control.ComboBox<Integer>
    allows the user to enter or select a value for the number of sides the polygon tools should have
    final org.controlsfx.control.ToggleSwitch
     
    final org.controlsfx.control.ToggleSwitch
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ButtonManager(javafx.scene.control.ToolBar parent, BrickPaintController cont)
    Default Constructor for the Button Manager, creates all the buttons with parameters and lays them out in a predefined manner
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Changes the mouse cursor based on the selected tool
    javafx.scene.image.Image
    Internal Method used to fetch the canvas image from this class
    Will return the currently selected toggle button as an enum type
    protected void
    handleCHeight(javafx.event.ActionEvent event)
    Updates the current canvas's height when the user changes its value
    void
    handleCopy(javafx.event.ActionEvent event)
    Calls the copy method in the current canvas when the copy button is pressed and the selection tool is active, otherwise it will set the selection tool to be active
    void
    handleCrop(javafx.event.ActionEvent event)
    Calls the crop method in the current canvas when the crop button is pressed and the selection tool is active, otherwise it will set the selection tool to be active
    void
    handleCut(javafx.event.ActionEvent event)
    Calls the cut method in the current canvas when the paste button is pressed and the selection tool is active, otherwise it will set the selection tool to be active
    protected void
    handleCWidth(javafx.event.ActionEvent event)
    Updates the current canvas's width when the user changes its value
    void
    handleFlipH(javafx.event.ActionEvent event)
    Will mirror the selected area across the x axis or if no area is selected it will mirror the entire canvas
    void
    handleFlipV(javafx.event.ActionEvent event)
    Will mirror the selected area across the y axis or if no area is selected it will mirror the entire canvas
    void
    handleOpenFolder(javafx.event.ActionEvent event)
    Opens the default images directory in the user's file explorer
    void
    handlePaste(javafx.event.ActionEvent event)
    Calls the paste method in the current canvas when the paste button is pressed
    void
    handleRotateL(javafx.event.ActionEvent event)
    Rotates the selected image 90 degrees to the left or if no area is selected will rotate the entire canvas
    void
    handleRotateR(javafx.event.ActionEvent event)
    Rotates the selected image 90 degrees to the right or if no area is selected will rotate the entire canvas
    void
    Sets the current selected tool to the standard mouse pointer
    void
    Will start the auto save thread if not already started, if it exists already it will cancel the thread's scheduled execution and create a new one, essentially resetting the autosave timer.
    void
     
    void
     
    void
    Internal Method Used to update the canvas image from this class
    void
     

    Methods inherited from class java.lang.Object

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

    • tAutoSave

      public final org.controlsfx.control.ToggleSwitch tAutoSave
    • tFillShapes

      public final org.controlsfx.control.ToggleSwitch tFillShapes
    • aSaveTime

      public javafx.scene.control.Label aSaveTime
    • lineWidth

      public javafx.scene.control.ComboBox<Integer> lineWidth
    • lineStyle

      public javafx.scene.control.ChoiceBox<BrickTools> lineStyle
    • cWidth

      public javafx.scene.control.ComboBox<Integer> cWidth
      allows the user to enter or select a value for the current canvas's width
    • cHeight

      public javafx.scene.control.ComboBox<Integer> cHeight
      allows the user to enter or select a value for the current canvas's height
    • polySides

      public javafx.scene.control.ComboBox<Integer> polySides
      allows the user to enter or select a value for the number of sides the polygon tools should have
    • fillSensitivity

      public javafx.scene.control.Spinner<Double> fillSensitivity
    • colorPicker

      public javafx.scene.control.ColorPicker colorPicker
  • Constructor Details

    • ButtonManager

      public ButtonManager(javafx.scene.control.ToolBar parent, BrickPaintController cont)
      Default Constructor for the Button Manager, creates all the buttons with parameters and lays them out in a predefined manner
      Parameters:
      parent - The toolbar to create the buttons under
      cont - The controller class in charge of the application
  • Method Details

    • startAutoSave

      public void startAutoSave()
      Will start the auto save thread if not already started, if it exists already it will cancel the thread's scheduled execution and create a new one, essentially resetting the autosave timer.
    • getSelectedToggle

      public BrickTools getSelectedToggle()
      Will return the currently selected toggle button as an enum type
      Returns:
      type BrickTools
    • handlePaste

      public void handlePaste(javafx.event.ActionEvent event)
      Calls the paste method in the current canvas when the paste button is pressed
      Parameters:
      event - Button event
    • handleCut

      public void handleCut(javafx.event.ActionEvent event)
      Calls the cut method in the current canvas when the paste button is pressed and the selection tool is active, otherwise it will set the selection tool to be active
      Parameters:
      event - Button event
    • handleCopy

      public void handleCopy(javafx.event.ActionEvent event)
      Calls the copy method in the current canvas when the copy button is pressed and the selection tool is active, otherwise it will set the selection tool to be active
      Parameters:
      event - Button event
    • handleCrop

      public void handleCrop(javafx.event.ActionEvent event)
      Calls the crop method in the current canvas when the crop button is pressed and the selection tool is active, otherwise it will set the selection tool to be active
      Parameters:
      event - Button event
    • handleFlipV

      public void handleFlipV(javafx.event.ActionEvent event)
      Will mirror the selected area across the y axis or if no area is selected it will mirror the entire canvas
      Parameters:
      event - Button event
    • handleFlipH

      public void handleFlipH(javafx.event.ActionEvent event)
      Will mirror the selected area across the x axis or if no area is selected it will mirror the entire canvas
      Parameters:
      event - Button event
    • handleRotateR

      public void handleRotateR(javafx.event.ActionEvent event)
      Rotates the selected image 90 degrees to the right or if no area is selected will rotate the entire canvas
      Parameters:
      event - Button event
    • handleRotateL

      public void handleRotateL(javafx.event.ActionEvent event)
      Rotates the selected image 90 degrees to the left or if no area is selected will rotate the entire canvas
      Parameters:
      event - Button event
    • handleOpenFolder

      public void handleOpenFolder(javafx.event.ActionEvent event)
      Opens the default images directory in the user's file explorer
      Parameters:
      event - Button event
    • resetToggles

      public void resetToggles()
      Sets the current selected tool to the standard mouse pointer
    • changeCursor

      public void changeCursor()
      Changes the mouse cursor based on the selected tool
    • handleCWidth

      protected void handleCWidth(javafx.event.ActionEvent event)
      Updates the current canvas's width when the user changes its value
      Parameters:
      event - Button Event
    • handleCHeight

      protected void handleCHeight(javafx.event.ActionEvent event)
      Updates the current canvas's height when the user changes its value
      Parameters:
      event - Button Event
    • updateCanvas

      public void updateCanvas(BufferedImage image)
      Internal Method Used to update the canvas image from this class
      Parameters:
      image - The image to replace the canvas with
    • updateServer

      public void updateServer()
    • toggleClientUiSilent

      public void toggleClientUiSilent(boolean on)
    • toggleServerUiSilent

      public void toggleServerUiSilent(boolean on)
    • getCanvasImage

      public javafx.scene.image.Image getCanvasImage()
      Internal Method used to fetch the canvas image from this class
      Returns:
      Image of current canvas