java.lang.Object
com.example.brickpaint.CanvasPanel
Manages all the drawing Sub-nodes for the overarching canvas, may have multiple instances to create multiple canvases
- Author:
- matde
-
Field Summary
FieldsModifier and TypeFieldDescriptionjavafx.scene.canvas.CanvasThe main canvas that will be used for drawing ect.final StringThe Name of the Paneljavafx.scene.layout.AnchorPaneTop level pane of the actual canvas objects and their corresponding stack panefinal javafx.scene.SnapshotParametersjavafx.scene.layout.StackPaneThe root Node that all the canvas components are created underjavafx.scene.control.ScrollPaneThe viewport (ScrollPane) that the entire canvas panel will reside withinjavafx.scene.canvas.CanvasA dummy canvas used to draw objects with a live preview before they are drawn on the real canvasManages Undo and Redo operations on this canvas -
Constructor Summary
ConstructorsConstructorDescriptionCanvasPanel(javafx.scene.control.TabPane tPane, String name, BrickKeys keys, BrickPaintController controllerIn) Default Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidclearAll()Clears the canvas paneljavafx.scene.image.ImageHelper method which returns the canvas as an imagevoidFloodFill(double x, double y) Preforms a flood/bucket fill operation on the canvas at the specified pointvoidmirror(boolean horizontal) Will mirror the entire canvas vertically or horizontally based on the boolean inputvoidonScroll(javafx.scene.input.ScrollEvent event) Handles zooming/scaling the canvasPanel with the AnimatedZoomOperator classvoidrotate(boolean right) Will rotate the entire canvas right or left 90 degrees based on the boolean inputvoidWrites the currently selected image to the system clipboardvoidResizes the canvas to the selected imagevoidWrites the currently selected image to the system clipboard and removes that area from the canvasvoidselectionMirror(boolean horizontal) Will mirror the selection vertically or horizontally based on the boolean inputvoidDraws the currently selected image to the canvas at the mouse position or top left of the canvasvoidselectionRotate(boolean right) Will rotate the selection right or left 90 degrees based on the boolean inputvoidsetSizeX(double x) Sets the width of all necessary nodes in the canvas panelvoidsetSizeY(double y) Sets the height of all necessary nodes in the canvas panelvoidConfigures all the settings of this Canvas Panel, should be called immediately after instantiationvoidUpdates the size number of the current canvas in the toolbar
-
Field Details
-
Name
The Name of the Panel -
parameters
public final javafx.scene.SnapshotParameters parameters -
root
public javafx.scene.layout.StackPane rootThe root Node that all the canvas components are created under -
canvas
public javafx.scene.canvas.Canvas canvasThe main canvas that will be used for drawing ect. -
scrollPane
public javafx.scene.control.ScrollPane scrollPaneThe viewport (ScrollPane) that the entire canvas panel will reside within -
sketchCanvas
public javafx.scene.canvas.Canvas sketchCanvasA dummy canvas used to draw objects with a live preview before they are drawn on the real canvas -
pane
public javafx.scene.layout.AnchorPane paneTop level pane of the actual canvas objects and their corresponding stack pane -
undoManager
Manages Undo and Redo operations on this canvas
-
-
Constructor Details
-
CanvasPanel
public CanvasPanel(javafx.scene.control.TabPane tPane, String name, BrickKeys keys, BrickPaintController controllerIn) Default Constructor- Parameters:
tPane- The parent of this classname- The Name of the Canvas Panelkeys- The instance of BrickKeys used for key bindscontrollerIn- The controller class for this canvas
-
-
Method Details
-
Setup
Configures all the settings of this Canvas Panel, should be called immediately after instantiation- Parameters:
keys- The instance of BrickKeys that this class should usename- The name of the CanvasPanel
-
UpdateSize
public void UpdateSize()Updates the size number of the current canvas in the toolbar -
fetchImage
public javafx.scene.image.Image fetchImage()Helper method which returns the canvas as an image- Returns:
- Image of canvas
-
setSizeX
public void setSizeX(double x) Sets the width of all necessary nodes in the canvas panel- Parameters:
x- new width
-
setSizeY
public void setSizeY(double y) Sets the height of all necessary nodes in the canvas panel- Parameters:
y- new height
-
FloodFill
public void FloodFill(double x, double y) Preforms a flood/bucket fill operation on the canvas at the specified point- Parameters:
x- The x position of the point to start the flood filly- The y position of the point to start the flood fill
-
selectionCopy
public void selectionCopy()Writes the currently selected image to the system clipboard -
selectionCut
public void selectionCut()Writes the currently selected image to the system clipboard and removes that area from the canvas -
selectionPaste
public void selectionPaste()Draws the currently selected image to the canvas at the mouse position or top left of the canvas -
selectionCrop
public void selectionCrop()Resizes the canvas to the selected image -
selectionMirror
public void selectionMirror(boolean horizontal) Will mirror the selection vertically or horizontally based on the boolean input- Parameters:
horizontal- Mirrors horizontally if true else will mirror vertically
-
mirror
public void mirror(boolean horizontal) Will mirror the entire canvas vertically or horizontally based on the boolean input- Parameters:
horizontal- Mirrors horizontally if true else will mirror vertically
-
selectionRotate
public void selectionRotate(boolean right) Will rotate the selection right or left 90 degrees based on the boolean input- Parameters:
right- Rotates right if true else rotates left
-
rotate
public void rotate(boolean right) Will rotate the entire canvas right or left 90 degrees based on the boolean input- Parameters:
right- Rotates right if true else rotates left
-
clearAll
public void clearAll()Clears the canvas panel -
onScroll
public void onScroll(javafx.scene.input.ScrollEvent event) Handles zooming/scaling the canvasPanel with the AnimatedZoomOperator class- Parameters:
event- Scroll event from Input class
-