java.lang.Object
com.example.brickpaint.ButtonManager
Sets up all toolbar buttons for the application as well as their graphics, layout, listeners, and methods
- Author:
- matde
-
Field Summary
FieldsModifier and TypeFieldDescriptionjavafx.scene.control.Labeljavafx.scene.control.ComboBox<Integer>allows the user to enter or select a value for the current canvas's heightjavafx.scene.control.ColorPickerjavafx.scene.control.ComboBox<Integer>allows the user to enter or select a value for the current canvas's widthjavafx.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 havefinal org.controlsfx.control.ToggleSwitchfinal org.controlsfx.control.ToggleSwitch -
Constructor Summary
ConstructorsConstructorDescriptionButtonManager(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 TypeMethodDescriptionvoidChanges the mouse cursor based on the selected tooljavafx.scene.image.ImageInternal Method used to fetch the canvas image from this classWill return the currently selected toggle button as an enum typeprotected voidhandleCHeight(javafx.event.ActionEvent event) Updates the current canvas's height when the user changes its valuevoidhandleCopy(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 activevoidhandleCrop(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 activevoidhandleCut(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 activeprotected voidhandleCWidth(javafx.event.ActionEvent event) Updates the current canvas's width when the user changes its valuevoidhandleFlipH(javafx.event.ActionEvent event) Will mirror the selected area across the x axis or if no area is selected it will mirror the entire canvasvoidhandleFlipV(javafx.event.ActionEvent event) Will mirror the selected area across the y axis or if no area is selected it will mirror the entire canvasvoidhandleOpenFolder(javafx.event.ActionEvent event) Opens the default images directory in the user's file explorervoidhandlePaste(javafx.event.ActionEvent event) Calls the paste method in the current canvas when the paste button is pressedvoidhandleRotateL(javafx.event.ActionEvent event) Rotates the selected image 90 degrees to the left or if no area is selected will rotate the entire canvasvoidhandleRotateR(javafx.event.ActionEvent event) Rotates the selected image 90 degrees to the right or if no area is selected will rotate the entire canvasvoidSets the current selected tool to the standard mouse pointervoidWill 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.voidtoggleClientUiSilent(boolean on) voidtoggleServerUiSilent(boolean on) voidupdateCanvas(BufferedImage image) Internal Method Used to update the canvas image from this classvoid
-
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
-
lineStyle
-
cWidth
allows the user to enter or select a value for the current canvas's width -
cHeight
allows the user to enter or select a value for the current canvas's height -
polySides
allows the user to enter or select a value for the number of sides the polygon tools should have -
fillSensitivity
-
colorPicker
public javafx.scene.control.ColorPicker colorPicker
-
-
Constructor Details
-
ButtonManager
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 undercont- 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
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
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
-