Class AbstractTool
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.gui.visualization.object.tools.AbstractTool
-
- All Implemented Interfaces:
CleanUpHandler
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,SizeOfHandler
,Tool
,Serializable
- Direct Known Subclasses:
AbstractToolWithParameterPanel
public abstract class AbstractTool extends CustomLoggingLevelObject implements Tool
Ancestor for tools.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected CanvasPanel
m_CanvasPanel
the canvas panel to operate on.protected ToolKeyAdapter
m_KeyListener
the key listener.protected ToolMouseAdapter
m_Listener
the mouse listener.protected boolean
m_Modified
whether the settings are currently modified.protected ToolMouseMotionAdapter
m_MotionListener
the mouse motion listener.protected BasePanel
m_PanelFullOptions
the full option panel.protected BasePanel
m_PanelOptions
the options panel.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTool()
Initializes the tool.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
activate()
Gets called to activate the tool.void
apply(BaseFlatButton button)
Applies the settings (if valid).protected String
checkBeforeApply()
Checks the parameters before applying them.void
cleanUp()
Cleans up data structures, frees up memory.protected BaseFlatButton
createApplyButton()
Generates the apply button.protected abstract Cursor
createCursor()
Creates the mouse cursor to use.protected ToolKeyAdapter
createKeyListener()
Creates the key listener to use.protected abstract ToolMouseAdapter
createMouseListener()
Creates the mouse listener to use.protected abstract ToolMouseMotionAdapter
createMouseMotionListener()
Creates the mouse motion listener to use.protected abstract BasePanel
createOptionPanel()
Creates the panel for setting the options.void
deactivate()
Gets called to deactivate the tool.protected abstract void
doApply()
Applies the settings.CanvasPanel
getCanvas()
Returns the currently set canvas panel.Cursor
getCursor()
Returns the mouse cursor to use.BufferedImage
getImage()
Returns the current image.ToolKeyAdapter
getKeyListener()
Returns the mouse listener to use.ToolMouseAdapter
getMouseListener()
Returns the mouse listener to use.ToolMouseMotionAdapter
getMouseMotionListener()
Returns the mouse motion listener to use.BasePanel
getOptionPanel()
Returns the panel for setting the options.double
getZoom()
Returns the current zoom.boolean
hasImage()
Checks whether an image is currently available.protected void
initialize()
Initializes the members.boolean
isModified()
Returns whether the settings are currently modified.protected void
setApplyButtonState(BaseFlatButton button, boolean modified)
Sets the state of the "Apply" button according to the modified flag.void
setCanvas(CanvasPanel value)
Sets the panel to use.void
update()
Called when image or annotations change.-
Methods inherited from class adams.core.logging.CustomLoggingLevelObject
setLoggingLevel
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface adams.core.GlobalInfoSupporter
globalInfo
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
-
-
-
Field Detail
-
m_CanvasPanel
protected CanvasPanel m_CanvasPanel
the canvas panel to operate on.
-
m_Listener
protected ToolMouseAdapter m_Listener
the mouse listener.
-
m_MotionListener
protected ToolMouseMotionAdapter m_MotionListener
the mouse motion listener.
-
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.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.
-
setCanvas
public void setCanvas(CanvasPanel value)
Sets the panel to use.
-
getCanvas
public CanvasPanel getCanvas()
Returns the currently set canvas panel.
-
hasImage
public boolean hasImage()
Checks whether an image is currently available.
-
getImage
public BufferedImage getImage()
Returns the current image.
-
getZoom
public double getZoom()
Returns the current zoom.
-
createCursor
protected abstract Cursor createCursor()
Creates the mouse cursor to use.- Returns:
- the cursor
-
getCursor
public Cursor getCursor()
Returns the mouse cursor to use.
-
createMouseListener
protected abstract ToolMouseAdapter createMouseListener()
Creates the mouse listener to use.- Returns:
- the listener, null if not applicable
-
getMouseListener
public ToolMouseAdapter getMouseListener()
Returns the mouse listener to use.- Specified by:
getMouseListener
in interfaceTool
- Returns:
- the listener
-
createMouseMotionListener
protected abstract ToolMouseMotionAdapter createMouseMotionListener()
Creates the mouse motion listener to use.- Returns:
- the listener, null if not applicable
-
getMouseMotionListener
public ToolMouseMotionAdapter getMouseMotionListener()
Returns the mouse motion listener to use.- Specified by:
getMouseMotionListener
in interfaceTool
- Returns:
- the listener
-
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 interfaceTool
- 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.
-
apply
public void apply(BaseFlatButton button)
Applies the settings (if valid).- See Also:
doApply()
,checkBeforeApply()
-
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 updatemodified
- whether applying needs doing or not
-
isModified
public boolean isModified()
Returns whether the settings are currently modified.- Specified by:
isModified
in interfaceTool
- 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 interfaceTool
- Returns:
- the options panel
-
activate
public void activate()
Gets called to activate the tool.
Default implementation repaints the canvas.
-
deactivate
public void deactivate()
Gets called to deactivate the tool.
Default implementation does nothing.- Specified by:
deactivate
in interfaceTool
-
update
public void update()
Called when image or annotations change.
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
-