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 CanvasPanelm_CanvasPanelthe canvas panel to operate on.protected ToolKeyAdapterm_KeyListenerthe key listener.protected ToolMouseAdapterm_Listenerthe mouse listener.protected booleanm_Modifiedwhether the settings are currently modified.protected ToolMouseMotionAdapterm_MotionListenerthe mouse motion listener.protected BasePanelm_PanelFullOptionsthe full option panel.protected BasePanelm_PanelOptionsthe options panel.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractTool()Initializes the tool.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidactivate()Gets called to activate the tool.booleanapply(BaseFlatButton button)Applies the settings (if valid).protected StringcheckBeforeApply()Checks the parameters before applying them.voidcleanUp()Cleans up data structures, frees up memory.protected BaseFlatButtoncreateApplyButton()Generates the apply button.protected abstract CursorcreateCursor()Creates the mouse cursor to use.protected ToolKeyAdaptercreateKeyListener()Creates the key listener to use.protected abstract ToolMouseAdaptercreateMouseListener()Creates the mouse listener to use.protected abstract ToolMouseMotionAdaptercreateMouseMotionListener()Creates the mouse motion listener to use.protected abstract BasePanelcreateOptionPanel()Creates the panel for setting the options.voiddeactivate()Gets called to deactivate the tool.protected abstract voiddoApply()Applies the settings.CanvasPanelgetCanvas()Returns the currently set canvas panel.CursorgetCursor()Returns the mouse cursor to use.BufferedImagegetImage()Returns the current image.ToolKeyAdaptergetKeyListener()Returns the mouse listener to use.protected StringgetModifiedIcon()Returns the icon name for the modified state.ToolMouseAdaptergetMouseListener()Returns the mouse listener to use.ToolMouseMotionAdaptergetMouseMotionListener()Returns the mouse motion listener to use.BasePanelgetOptionPanel()Returns the panel for setting the options.protected StringgetUnmodifiedIcon()Returns the icon name for the unmodified state.doublegetZoom()Returns the current zoom.booleanhasImage()Checks whether an image is currently available.protected voidinitialize()Initializes the members.booleanisModified()Returns whether the settings are currently modified.protected voidsetApplyButtonState(BaseFlatButton button, boolean modified)Sets the state of the "Apply" button according to the modified flag.voidsetCanvas(CanvasPanel value)Sets the panel to use.voidupdate()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:
getMouseListenerin 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:
getMouseMotionListenerin 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:
getKeyListenerin 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 boolean apply(BaseFlatButton button)
Applies the settings (if valid).- Returns:
- true if applied
- See Also:
doApply(),checkBeforeApply()
-
getUnmodifiedIcon
protected String getUnmodifiedIcon()
Returns the icon name for the unmodified state.- Returns:
- the image name
-
getModifiedIcon
protected String getModifiedIcon()
Returns the icon name for the modified state.- Returns:
- the image name
-
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:
isModifiedin 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:
getOptionPanelin 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:
deactivatein interfaceTool
-
update
public void update()
Called when image or annotations change.
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceCleanUpHandler
-
-