Package JavaFX

Class SIMPController


  • public class SIMPController
    extends java.lang.Object
    SIMPController 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.Slider brushSizeSlider
      FXML BrushSize insertText field.
      private javafx.scene.control.TextField brushSizeText
      FXML BrushSize insertText field.
      private javafx.scene.canvas.Canvas canvas
      FXML Canvas.
      javafx.scene.control.ToggleButton circle
      FXML circle toggle button.
      private javafx.scene.control.ColorPicker colorPicker
      FXML Color picker.
      private java.io.File currentFile
      Current file being used.
      private Drawable drawable
      Drawable shape interface.
      private javafx.scene.control.ToggleButton eraser
      FXML eraser toggle button.
      private javafx.stage.FileChooser fileChooser
      File chooser reference.
      private javafx.scene.control.ToggleButton fillColor
      FXML fillColor toggle button.
      private javafx.scene.canvas.GraphicsContext graphicsContext
      Canvas graphicsContext.
      private javafx.scene.control.ToggleButton insertText
      FXML insertText toggle button.
      private java.util.List<DrawAction> nextMove
      Next move DrawAction List to be used on Redo action.
      private javafx.scene.control.ToggleButton pencil
      FXML pencil toggle button.
      private java.util.List<DrawAction> previousMove
      Previous move DrawAction List to be used on Undo action.
      private javafx.stage.Stage primaryStage
      Application primaryStage.
      private java.util.Map<java.lang.String,​java.io.File> recentFiles
      Map for recent files opened.
      private javafx.scene.control.Menu recentFilesMenu  
      javafx.scene.control.ToggleButton rectangle
      FXML square toggle button.
      private javafx.scene.control.Button redo
      FXML Redo button.
      javafx.scene.control.ToggleButton straightLine
      FXML straightLine toggle button.
      private javafx.scene.control.Button undo
      FXML Undo button.
    • Constructor Summary

      Constructors 
      Constructor Description
      SIMPController()  
    • Method Summary

      Modifier and Type Method Description
      void addDrawAction​(javafx.scene.paint.Color fillColor, double size, double x, double y)
      Add a DrawAction to the nextMove list.
      javafx.scene.canvas.Canvas getCanvas()
      Canvas getter.
      private java.lang.String getFileFormat()
      Parse the file name.
      java.util.Map<java.lang.String,​java.io.File> getRecentFiles()
      Log of recent files.
      void initialize()
      Special signature method initialize.
      void onBrushSizeSliderChanged()
      Brush Size Slider action.
      void onBrushSizeTextChanged()
      Brush Size Text action.
      void onExit()
      Exit button action.
      void onNew​(javafx.event.ActionEvent actionEvent)
      New button action.
      void onOpen​(javafx.event.ActionEvent actionEvent)
      Open button action.
      void onRedo()
      Redo button action.
      void onSave()
      Save button action.
      void onSaveAs()
      SaveAs button action.
      void onUndo()
      Undo button action.
      private void openImage​(java.io.File file)  
      private void setExtensionFilters()
      Set the extension filters in the file chooser so the user can select only the allowed file extensions.
      void setPrimaryStage​(javafx.stage.Stage primaryStage)
      Stage setter.
      void setRecentFiles​(java.util.Map<java.lang.String,​java.io.File> recentFiles)  
      void setupRecentFilesMenu()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.
    • Constructor Detail

      • SIMPController

        public SIMPController()
    • 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)