java.lang.Object
com.example.brickpaint.BrickPaintController
Main controller class for the BrickPaint application, handles the FXML methods and variables for the stage
- Author:
- matde
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe instance of ButtonManager which contains the tool GUI for this controllerThe current instance of the canvas where all drawing occurs within the paint appstatic final org.apache.logging.log4j.Loggerprotected javafx.scene.control.TabPaneThe node that manages all the canvas panel tabs within the application -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddTab()Creates a new canvas panel instance and adds it to the scene as a tabstatic doubleclamp(double val, double min, double max) Helper function which return a value restricted between min and maxstatic intclamp(int val, int min, int max) Helper function which return a value restricted between min and maxReturns the current canvas panel that is selected in the Tab paneReturns the current tool selection from the button manager as a BrickTools enum valueprotected voidHandles the action when a close button is pressedprotected voidCreates a prompt to confirm clearing the current canvasprotected voidHandles inserting an image into the imageVeiw component, utilizes the file explorer and BrickImage classprotected voidCreates a new window based off of the About Brick FXML file and controllerprotected voidResets the scale and position of the current canvasprotected voidHandles saving an image from the canvasPanel, if it has not yet been saved will call SaveAs insteadprotected voidHandles saving an image to a user created file from the canvasPanelprotected voidOnClose(javafx.stage.WindowEvent event) This method is called or invoked whenever the program is going to be closedprotected voidsaveAll()Will iterate through all open tabs and save them as a png using the name of the tabprotected voidStart()Called when the program starts from the application class
-
Field Details
-
logger
public static final org.apache.logging.log4j.Logger logger -
canvasPanels
The current instance of the canvas where all drawing occurs within the paint app -
buttonManager
The instance of ButtonManager which contains the tool GUI for this controller -
tabs
protected javafx.scene.control.TabPane tabsThe 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 evaluatemin- The minimum value which to returnmax- 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 evaluatemin- The minimum value which to returnmax- 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
Returns the current canvas panel that is selected in the Tab pane- Returns:
- CanvasPanel
-
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
-