public class ShapeTool extends Tool
Modifier and Type | Field and Description |
---|---|
private Drawer.Shapes |
currentShape
The currently-selected shape
|
private boolean |
fillShapes
Whether to fill shapes when drawn
|
private double[] |
lastPos
The position of the mouse when it was pressed
|
private Paint |
paint
The main class of the program
|
Constructor and Description |
---|
ShapeTool(javafx.scene.control.Button button,
javafx.scene.control.CheckMenuItem menuItem,
Paint paint)
Create a ShapeTool
|
Modifier and Type | Method and Description |
---|---|
private void |
doShape(javafx.scene.input.MouseEvent event,
PaintController controller)
Update the drawn shape on the draw canvas
|
boolean |
getFillShapes() |
void |
handleMouse(javafx.scene.input.MouseEvent e,
javafx.event.EventType<? extends javafx.scene.input.MouseEvent> type,
PaintController controller)
Handles canvas mouse events while this tool is selected
|
void |
setCurrentShape(Drawer.Shapes shape)
Set the currently-selected shape
|
void |
setFillShapes(boolean fill)
Set whether to fill shapes when drawn
|
getButton, getMenuItem, matches
private Paint paint
private Drawer.Shapes currentShape
private boolean fillShapes
private double[] lastPos
public ShapeTool(javafx.scene.control.Button button, javafx.scene.control.CheckMenuItem menuItem, Paint paint)
button
- the tool button corresponding to this toolmenuItem
- the menu item corresponding to this toolpaint
- the main class of the programpublic void handleMouse(javafx.scene.input.MouseEvent e, javafx.event.EventType<? extends javafx.scene.input.MouseEvent> type, PaintController controller)
Tool
handleMouse
in class Tool
e
- the mouse eventtype
- the type of the mouse eventcontroller
- the program's controllerprivate void doShape(javafx.scene.input.MouseEvent event, PaintController controller)
event
- the mouse event from the usercontroller
- the controller corresponding to the canvas on which the update should be drawnpublic void setCurrentShape(Drawer.Shapes shape)
shape
- the new shapepublic void setFillShapes(boolean fill)
fill
- whether to fill shapespublic boolean getFillShapes()