Package JavaFX
Class SIMPController
- java.lang.Object
-
- JavaFX.SIMPController
-
public class SIMPController extends java.lang.ObjectSIMPController controls all interactions between the user and the GUI.- Author:
- Leonardo-Rocha, GabrielChiquetto
-
-
Field Summary
Fields Modifier and Type Field Description private javafx.scene.control.SliderbrushSizeSliderFXML BrushSize insertText field.private javafx.scene.control.TextFieldbrushSizeTextFXML BrushSize insertText field.private javafx.scene.canvas.CanvascanvasFXML Canvas.javafx.scene.control.ToggleButtoncircleFXML circle toggle button.private javafx.scene.control.ColorPickercolorPickerFXML Color picker.private java.io.FilecurrentFileCurrent file being used.private DrawabledrawableDrawable shape interface.private javafx.scene.control.ToggleButtoneraserFXML eraser toggle button.private javafx.stage.FileChooserfileChooserFile chooser reference.private javafx.scene.control.ToggleButtonfillColorFXML fillColor toggle button.private javafx.scene.canvas.GraphicsContextgraphicsContextCanvas graphicsContext.private javafx.scene.control.ToggleButtoninsertTextFXML insertText toggle button.private java.util.List<DrawAction>nextMoveNext move DrawAction List to be used on Redo action.private javafx.scene.control.ToggleButtonpencilFXML pencil toggle button.private java.util.List<DrawAction>previousMovePrevious move DrawAction List to be used on Undo action.private javafx.stage.StageprimaryStageApplication primaryStage.private java.util.Map<java.lang.String,java.io.File>recentFilesMap for recent files opened.private javafx.scene.control.MenurecentFilesMenujavafx.scene.control.ToggleButtonrectangleFXML square toggle button.private javafx.scene.control.ButtonredoFXML Redo button.javafx.scene.control.ToggleButtonstraightLineFXML straightLine toggle button.private javafx.scene.control.ButtonundoFXML Undo button.
-
Constructor Summary
Constructors Constructor Description SIMPController()
-
Method Summary
Modifier and Type Method Description voidaddDrawAction(javafx.scene.paint.Color fillColor, double size, double x, double y)Add a DrawAction to the nextMove list.javafx.scene.canvas.CanvasgetCanvas()Canvas getter.private java.lang.StringgetFileFormat()Parse the file name.java.util.Map<java.lang.String,java.io.File>getRecentFiles()Log of recent files.voidinitialize()Special signature method initialize.voidonBrushSizeSliderChanged()Brush Size Slider action.voidonBrushSizeTextChanged()Brush Size Text action.voidonExit()Exit button action.voidonNew(javafx.event.ActionEvent actionEvent)New button action.voidonOpen(javafx.event.ActionEvent actionEvent)Open button action.voidonRedo()Redo button action.voidonSave()Save button action.voidonSaveAs()SaveAs button action.voidonUndo()Undo button action.private voidopenImage(java.io.File file)private voidsetExtensionFilters()Set the extension filters in the file chooser so the user can select only the allowed file extensions.voidsetPrimaryStage(javafx.stage.Stage primaryStage)Stage setter.voidsetRecentFiles(java.util.Map<java.lang.String,java.io.File> recentFiles)voidsetupRecentFilesMenu()
-
-
-
Field Detail
-
canvas
private javafx.scene.canvas.Canvas canvas
FXML Canvas.
-
recentFilesMenu
private javafx.scene.control.Menu recentFilesMenu
-
undo
private javafx.scene.control.Button undo
FXML Undo button.
-
redo
private javafx.scene.control.Button redo
FXML Redo button.
-
brushSizeSlider
private javafx.scene.control.Slider brushSizeSlider
FXML BrushSize insertText field.
-
brushSizeText
private javafx.scene.control.TextField brushSizeText
FXML BrushSize insertText field.
-
colorPicker
private javafx.scene.control.ColorPicker colorPicker
FXML Color picker.
-
pencil
private javafx.scene.control.ToggleButton pencil
FXML pencil toggle button.
-
eraser
private javafx.scene.control.ToggleButton eraser
FXML eraser toggle button.
-
fillColor
private javafx.scene.control.ToggleButton fillColor
FXML fillColor toggle button.
-
insertText
private javafx.scene.control.ToggleButton insertText
FXML insertText toggle button.
-
straightLine
public javafx.scene.control.ToggleButton straightLine
FXML straightLine toggle button.
-
rectangle
public javafx.scene.control.ToggleButton rectangle
FXML square toggle button.
-
circle
public javafx.scene.control.ToggleButton circle
FXML circle toggle button.
-
graphicsContext
private javafx.scene.canvas.GraphicsContext graphicsContext
Canvas graphicsContext.
-
fileChooser
private javafx.stage.FileChooser fileChooser
File chooser reference.
-
recentFiles
private java.util.Map<java.lang.String,java.io.File> recentFiles
Map for recent files opened.
-
primaryStage
private javafx.stage.Stage primaryStage
Application primaryStage.
-
currentFile
private java.io.File currentFile
Current file being used.
-
previousMove
private java.util.List<DrawAction> previousMove
Previous move DrawAction List to be used on Undo action.
-
nextMove
private java.util.List<DrawAction> nextMove
Next move DrawAction List to be used on Redo action.
-
drawable
private Drawable drawable
Drawable shape interface.
-
-
Method Detail
-
initialize
public void initialize()
Special signature method initialize. Instantiates some variables and bind the mouse actions.
-
setupRecentFilesMenu
public void setupRecentFilesMenu()
-
setExtensionFilters
private void setExtensionFilters()
Set the extension filters in the file chooser so the user can select only the allowed file extensions.
-
onNew
public void onNew(javafx.event.ActionEvent actionEvent)
New button action. Ask the user to save or not the current changes and then clear the canvas.- Parameters:
actionEvent- onAction event.
-
onOpen
public void onOpen(javafx.event.ActionEvent actionEvent)
Open button action. Opens the file chooser and draw the chosen image in the canvas.- Parameters:
actionEvent- onAction event.
-
openImage
private void openImage(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
onSave
public void onSave()
Save button action. If the image was open or already saved, save the changes on it. Otherwise, call onSaveAs().
-
onSaveAs
public void onSaveAs()
SaveAs button action. Opens the file chooser and save the image in the chosen directory.
-
onExit
public void onExit()
Exit button action. Calls Platform.exit() to close the program.
-
onUndo
public void onUndo()
Undo button action. Undo the last draw movement.
-
onRedo
public void onRedo()
Redo button action. Redo the last draw movement.
-
onBrushSizeSliderChanged
public void onBrushSizeSliderChanged()
Brush Size Slider action. Updates the text according to the slider value.
-
onBrushSizeTextChanged
public void onBrushSizeTextChanged()
Brush Size Text action. Updates the slider according to the text value.
-
getFileFormat
private java.lang.String getFileFormat()
Parse the file name.- Returns:
- the file format/extension.
-
addDrawAction
public void addDrawAction(javafx.scene.paint.Color fillColor, double size, double x, double y)Add a DrawAction to the nextMove list.- Parameters:
fillColor- color set on the ColorPicker.size- size of the rectangle.x- position x of the rectangle in the canvas.y- position y of the rectangle in the canvas.
-
getCanvas
public javafx.scene.canvas.Canvas getCanvas()
Canvas getter.- Returns:
- canvas.
-
setPrimaryStage
public void setPrimaryStage(javafx.stage.Stage primaryStage)
Stage setter.- Parameters:
primaryStage- reference to set.
-
getRecentFiles
public java.util.Map<java.lang.String,java.io.File> getRecentFiles()
Log of recent files.- Returns:
- Map of the recent files.
-
setRecentFiles
public void setRecentFiles(java.util.Map<java.lang.String,java.io.File> recentFiles)
-
-