Class AbstractTool
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.gui.visualization.segmentation.tool.AbstractTool
-
- All Implemented Interfaces:
CleanUpHandler
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,SizeOfHandler
,Tool
,Serializable
- Direct Known Subclasses:
AbstractToolWithParameterPanel
,Pointer
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 ToolKeyAdapter
m_KeyListener
the key listener.protected ToolMouseAdapter
m_Listener
the mouse listener.protected ToolMouseMotionAdapter
m_MotionListener
the mouse motion listener.protected PaintOperation
m_PaintOperation
the paint operation.protected CanvasPanel
m_PanelCanvas
the canvas panel to operate on.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
annotationsChanged()
Hook method for when new annotations have been set.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.protected PaintOperation
createPaintOperation()
Creates the paint operation to use.void
deactivate()
Gets called to deactivate the tool.protected abstract void
doApply()
Applies the settings.Color
getActiveColor()
Returns the active color.CombinedLayer.CombinedSubLayer
getActiveCombinedSubLayer()
Returns the active combined sub layer.BufferedImage
getActiveImage()
Returns the active image.OverlayLayer
getActiveOverlay()
Returns the active overlay layer.CanvasPanel
getCanvas()
Returns the currently set canvas panel.Cursor
getCursor()
Returns the mouse cursor to use.ToolKeyAdapter
getKeyListener()
Returns the mouse listener to use.LayerManager
getLayerManager()
Returns the layer manager.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.PaintOperation
getPaintOperation()
Returns the paint operation for the tool.double
getZoom()
Returns the current zoom.boolean
hasActiveCombinedSubLayer()
Returns whether an active combined sub layer is present.boolean
hasActiveOverlay()
Returns whether an active overlay layer is present.boolean
hasAnyActive()
Returns whether any active layer is present.protected void
initialize()
Initializes the members.boolean
isAutomaticUndoEnabled()
Returns whether automatic undo is enabled.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 canvas panel to use.-
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_PanelCanvas
protected CanvasPanel m_PanelCanvas
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_PaintOperation
protected PaintOperation m_PaintOperation
the paint operation.
-
m_PanelOptions
protected BasePanel m_PanelOptions
the options panel.
-
m_PanelFullOptions
protected BasePanel m_PanelFullOptions
the full option panel.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.
-
setCanvas
public void setCanvas(CanvasPanel value)
Sets the canvas panel to use.
-
getCanvas
public CanvasPanel getCanvas()
Returns the currently set canvas panel.
-
getLayerManager
public LayerManager getLayerManager()
Returns the layer manager.- Specified by:
getLayerManager
in interfaceTool
- Returns:
- the layer manager, null if not available
-
hasAnyActive
public boolean hasAnyActive()
Returns whether any active layer is present.- Specified by:
hasAnyActive
in interfaceTool
- Returns:
- true if an active layer present
- See Also:
hasActiveOverlay()
,hasActiveCombinedSubLayer()
-
hasActiveOverlay
public boolean hasActiveOverlay()
Returns whether an active overlay layer is present.- Specified by:
hasActiveOverlay
in interfaceTool
- Returns:
- true if available
-
getActiveOverlay
public OverlayLayer getActiveOverlay()
Returns the active overlay layer.- Specified by:
getActiveOverlay
in interfaceTool
- Returns:
- the layer, null if none available
-
hasActiveCombinedSubLayer
public boolean hasActiveCombinedSubLayer()
Returns whether an active combined sub layer is present.- Specified by:
hasActiveCombinedSubLayer
in interfaceTool
- Returns:
- true if available
-
getActiveCombinedSubLayer
public CombinedLayer.CombinedSubLayer getActiveCombinedSubLayer()
Returns the active combined sub layer.- Specified by:
getActiveCombinedSubLayer
in interfaceTool
- Returns:
- the layer, null if none available
-
getActiveImage
public BufferedImage getActiveImage()
Returns the active image.- Specified by:
getActiveImage
in interfaceTool
- Returns:
- the image or null if none active
-
getActiveColor
public Color getActiveColor()
Returns the active color.- Specified by:
getActiveColor
in interfaceTool
- Returns:
- the color or null if none active
-
getZoom
public double getZoom()
Returns the current zoom.
-
isAutomaticUndoEnabled
public boolean isAutomaticUndoEnabled()
Returns whether automatic undo is enabled.- Specified by:
isAutomaticUndoEnabled
in interfaceTool
- Returns:
- true if enabled
-
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
-
createPaintOperation
protected PaintOperation createPaintOperation()
Creates the paint operation to use.
Default implementation just returns theNullOperation
.- Returns:
- the operation
-
getPaintOperation
public PaintOperation getPaintOperation()
Returns the paint operation for the tool.- Specified by:
getPaintOperation
in interfaceTool
- Returns:
- the paint operation
-
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
-
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 does nothing.
-
deactivate
public void deactivate()
Gets called to deactivate the tool.
Default implementation does nothing.- Specified by:
deactivate
in interfaceTool
-
annotationsChanged
public void annotationsChanged()
Hook method for when new annotations have been set.- Specified by:
annotationsChanged
in interfaceTool
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
-