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,Clear,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 ToolKeyAdapterm_KeyListenerthe key listener.protected ToolMouseAdapterm_Listenerthe mouse listener.protected ToolMouseMotionAdapterm_MotionListenerthe mouse motion listener.protected PaintOperationm_PaintOperationthe paint operation.protected CanvasPanelm_PanelCanvasthe canvas panel to operate on.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.voidannotationsChanged()Hook method for when new annotations have been set.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.protected PaintOperationcreatePaintOperation()Creates the paint operation to use.voiddeactivate()Gets called to deactivate the tool.protected abstract voiddoApply()Applies the settings.ColorgetActiveColor()Returns the active color.CombinedLayer.CombinedSubLayergetActiveCombinedSubLayer()Returns the active combined sub layer.BufferedImagegetActiveImage()Returns the active image.OverlayLayergetActiveOverlay()Returns the active overlay layer.CanvasPanelgetCanvas()Returns the currently set canvas panel.CursorgetCursor()Returns the mouse cursor to use.ToolKeyAdaptergetKeyListener()Returns the mouse listener to use.LayerManagergetLayerManager()Returns the layer manager.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.PaintOperationgetPaintOperation()Returns the paint operation for the tool.protected StringgetUnmodifiedIcon()Returns the icon name for the unmodified state.doublegetZoom()Returns the current zoom.booleanhasActiveCombinedSubLayer()Returns whether an active combined sub layer is present.booleanhasActiveOverlay()Returns whether an active overlay layer is present.booleanhasAnyActive()Returns whether any active layer is present.protected voidinitialize()Initializes the members.booleanisAutomaticUndoEnabled()Returns whether automatic undo is enabled.protected voidsetApplyButtonState(BaseFlatButton button, boolean modified)Sets the state of the "Apply" button according to the modified flag.voidsetCanvas(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:
getLayerManagerin interfaceTool- Returns:
- the layer manager, null if not available
-
hasAnyActive
public boolean hasAnyActive()
Returns whether any active layer is present.- Specified by:
hasAnyActivein 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:
hasActiveOverlayin interfaceTool- Returns:
- true if available
-
getActiveOverlay
public OverlayLayer getActiveOverlay()
Returns the active overlay layer.- Specified by:
getActiveOverlayin interfaceTool- Returns:
- the layer, null if none available
-
hasActiveCombinedSubLayer
public boolean hasActiveCombinedSubLayer()
Returns whether an active combined sub layer is present.- Specified by:
hasActiveCombinedSubLayerin interfaceTool- Returns:
- true if available
-
getActiveCombinedSubLayer
public CombinedLayer.CombinedSubLayer getActiveCombinedSubLayer()
Returns the active combined sub layer.- Specified by:
getActiveCombinedSubLayerin interfaceTool- Returns:
- the layer, null if none available
-
getActiveImage
public BufferedImage getActiveImage()
Returns the active image.- Specified by:
getActiveImagein interfaceTool- Returns:
- the image or null if none active
-
getActiveColor
public Color getActiveColor()
Returns the active color.- Specified by:
getActiveColorin 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:
isAutomaticUndoEnabledin 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:
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
-
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:
getPaintOperationin 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 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
-
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 does nothing.
-
deactivate
public void deactivate()
Gets called to deactivate the tool.
Default implementation does nothing.- Specified by:
deactivatein interfaceTool
-
annotationsChanged
public void annotationsChanged()
Hook method for when new annotations have been set.- Specified by:
annotationsChangedin interfaceTool
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceCleanUpHandler
-
-