Class AbstractTool

    • Field Detail

      • m_CanvasPanel

        protected CanvasPanel m_CanvasPanel
        the canvas panel to operate on.
      • m_KeyListener

        protected ToolKeyAdapter m_KeyListener
        the key listener.
      • m_PanelOptions

        protected BasePanel m_PanelOptions
        the options panel.
      • m_PanelFullOptions

        protected BasePanel m_PanelFullOptions
        the full option panel.
      • m_Modified

        protected boolean m_Modified
        whether the settings are currently modified.
    • Constructor Detail

      • AbstractTool

        protected AbstractTool()
        Initializes the tool.
    • Method Detail

      • initialize

        protected void initialize()
        Initializes the members.
      • setCanvas

        public void setCanvas​(CanvasPanel value)
        Sets the panel to use.
        Specified by:
        setCanvas in interface Tool
        Parameters:
        value - the panel
      • getCanvas

        public CanvasPanel getCanvas()
        Returns the currently set canvas panel.
        Specified by:
        getCanvas in interface Tool
        Returns:
        the panel, null if none set
      • hasImage

        public boolean hasImage()
        Checks whether an image is currently available.
        Specified by:
        hasImage in interface Tool
        Returns:
        true if available
      • getImage

        public BufferedImage getImage()
        Returns the current image.
        Specified by:
        getImage in interface Tool
        Returns:
        the image or null if none available
      • getZoom

        public double getZoom()
        Returns the current zoom.
        Specified by:
        getZoom in interface Tool
        Returns:
        the zoom (1.0 = 100%)
      • createCursor

        protected abstract Cursor createCursor()
        Creates the mouse cursor to use.
        Returns:
        the cursor
      • getCursor

        public Cursor getCursor()
        Returns the mouse cursor to use.
        Specified by:
        getCursor in interface Tool
        Returns:
        the cursor
      • createMouseListener

        protected abstract ToolMouseAdapter createMouseListener()
        Creates the mouse listener to use.
        Returns:
        the listener, null if not applicable
      • createMouseMotionListener

        protected abstract ToolMouseMotionAdapter createMouseMotionListener()
        Creates the mouse motion listener to use.
        Returns:
        the listener, null if not applicable
      • createKeyListener

        protected ToolKeyAdapter createKeyListener()
        Creates the key listener to use.
        Default implementation just returns null.
        Returns:
        the listener, null if not applicable
      • getKeyListener

        public ToolKeyAdapter getKeyListener()
        Returns the mouse listener to use.
        Specified by:
        getKeyListener in interface Tool
        Returns:
        the listener
      • checkBeforeApply

        protected String checkBeforeApply()
        Checks the parameters before applying them.
        Default implementation just returns null.
        Returns:
        null if checks passed, otherwise error message (gets displayed in GUI)
      • doApply

        protected abstract void doApply()
        Applies the settings.
      • createApplyButton

        protected BaseFlatButton createApplyButton()
        Generates the apply button.
        Returns:
        the button
      • setApplyButtonState

        protected void setApplyButtonState​(BaseFlatButton button,
                                           boolean modified)
        Sets the state of the "Apply" button according to the modified flag.
        Parameters:
        button - the button to update
        modified - whether applying needs doing or not
      • isModified

        public boolean isModified()
        Returns whether the settings are currently modified.
        Specified by:
        isModified in interface Tool
        Returns:
        true if modified
      • createOptionPanel

        protected abstract BasePanel createOptionPanel()
        Creates the panel for setting the options.
        Returns:
        the options panel
      • getOptionPanel

        public BasePanel getOptionPanel()
        Returns the panel for setting the options.
        Specified by:
        getOptionPanel in interface Tool
        Returns:
        the options panel
      • activate

        public void activate()
        Gets called to activate the tool.
        Default implementation repaints the canvas.
        Specified by:
        activate in interface Tool
      • deactivate

        public void deactivate()
        Gets called to deactivate the tool.
        Default implementation does nothing.
        Specified by:
        deactivate in interface Tool
      • update

        public void update()
        Called when image or annotations change.
        Specified by:
        update in interface Tool
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.
        Specified by:
        cleanUp in interface CleanUpHandler