Class SegmentationPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.visualization.segmentation.SegmentationPanel
-
- All Implemented Interfaces:
CleanUpHandler
,UndoListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,ChangeListener
public class SegmentationPanel extends BasePanel implements ChangeListener, UndoListener, CleanUpHandler
Panel for performing segmentation annotations.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SegmentationPanel.ContainerSettings
The settings used when setting up from a container.static class
SegmentationPanel.LayerVisibility
What layers should be selected.-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected Tool
m_ActiveTool
the active tool.protected BaseFlatButton
m_ButtonAddUndo
the button for adding an undo.protected BaseButton
m_ButtonLayersAll
the buttons for enabling all layers.protected BaseButton
m_ButtonLayersInvert
the buttons for inverting selected layers.protected BaseButton
m_ButtonLayersNone
the buttons for disabling all layers.protected BaseFlatButton
m_ButtonRedo
the button for performing a redo.protected BaseFlatButton
m_ButtonUndo
the button for performing an undo.protected BaseFlatButton
m_ButtonZoom
the button for applying the zoom.protected BaseFlatButton
m_ButtonZoomBestFit
the button for best fit zoom.protected BaseFlatButton
m_ButtonZoomClear
the button for clearing zoom.protected BaseFlatButton
m_ButtonZoomIn
the button for zooming in.protected BaseFlatButton
m_ButtonZoomOut
the button for zooming out.protected SegmentationPanel.ContainerSettings
m_ContainerSettings
whether separate layers were used.protected KeyListener
m_LastKeyListener
the last key listener in use.protected MouseListener
m_LastMouseListener
the last mouse listener in use.protected MouseMotionListener
m_LastMouseMotionListener
the last mouse motion listener in use.protected LayerManager
m_Manager
layer manager.protected PaintOperation
m_PaintOperation
the paint operation in use.protected CanvasPanel
m_PanelCanvas
the panel for drawing.protected BasePanel
m_PanelCenter
the center panel.protected BasePanel
m_PanelLayers
the layers panel.protected BasePanel
m_PanelLeft
the left panel.protected JPanel
m_PanelToolButtons
the panel with the buttons.protected BasePanel
m_PanelToolOptions
the panel for displaying the tool options.protected BasePanel
m_PanelTools
the tools panel.protected BaseScrollPane
m_ScrollPane
the JScrollPane that embeds the canvas panel.protected BaseSplitPane
m_SplitPaneLeft
the main split pane.protected BaseSplitPane
m_SplitPaneRight
the left split pane.protected BaseSplitPane
m_SplitPaneTools
the split pane for the tools.protected NumberTextField
m_TextZoom
the text field for the zoom.protected List<Tool>
m_Tools
the tools.static double
ZOOM_FACTOR
the zoom factor to use.-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description SegmentationPanel()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addUndoPoint()
Adds an undo point.void
bestFitZoom()
Fits the image.void
cleanUp()
Cleans up data structures, frees up memory.void
clearZoom()
Clears the zoom.protected static SegmentationPanel
combinedTest(String[] args)
Generates a panel with a combined layer.protected void
finishInit()
Finishes the initialization.void
fromContainer(ImageSegmentationContainer segcont, SegmentationPanel.ContainerSettings contSettings, List<AbstractLayer.AbstractLayerState> lastSettings, LoggingObject logger)
Retrieves the layers from the container.void
fromContainer(ImageSegmentationContainer segcont, String[] labels, boolean useSeparateLayers, ColorProvider colorProvider, float alpha, boolean allowLayerRemoval, boolean allowLayerActions, SegmentationPanel.LayerVisibility layerVisibility, List<AbstractLayer.AbstractLayerState> lastSettings, LoggingObject logger)
Retrieves the layers from the container.Tool
getActiveTool()
Returns the currently active tool.CanvasPanel
getCanvasPanel()
Returns the underlying canvas panel.SegmentationPanel.ContainerSettings
getContainerSettings()
Returns the last settings used when calling fromContainer.int
getLeftDividerLocation()
Returns the left divider location.LayerManager
getManager()
Returns the layer manager.PaintOperation
getPaintOperation()
Returns the paint operation.int
getRightDividerLocation()
Returns the right divider location.BaseScrollPane
getScrollPane()
Returns the scrollpane.int
getToolButtonColumns()
Returns the number of columns used for the tool buttons.Undo
getUndo()
Returns the underlying undo handler.double
getZoom()
Returns the current zoom in use.protected void
initGUI()
Initializes the widgets.protected void
initialize()
Initializes the members.boolean
isAutomaticUndoEnabled()
Returns whether automatic undos are enabled.boolean
isToolPanelVisible()
Returns whether the tools panel is visible.static void
main(String[] args)
For testing only.protected void
notifyTools()
Notifies the tools that annotations have changed.protected static SegmentationPanel
overlayTest(String[] args)
Generates a panel with separate overlay layers.void
redo()
Performs a redo.void
setAutomaticUndoEnabled(boolean value)
Sets whether automatic undos are enabled.void
setLeftDividerLocation(double value)
Sets the proportional location for the left divider.void
setLeftDividerLocation(int value)
Sets the location of the left divider.void
setRightDividerLocation(double value)
Sets the proportional location for the right divider.void
setRightDividerLocation(int value)
Sets the location of the right divider.void
setToolButtonColumns(int columns)
Sets the number of columns used for the tool buttons.void
setToolPanelVisible(boolean value)
Hides or shows the tools panel.void
setZoom(double value)
Sets the zoom to use.void
stateChanged(ChangeEvent e)
Gets called when the layers have changed somehow.ImageSegmentationContainer
toContainer()
Turns the layers into a container.ImageSegmentationContainer
toContainer(boolean useSeparateLayers)
Turns the layers into a container.void
undo()
Performs an undo.void
undoOccurred(UndoEvent e)
An undo event, like add or remove, has occurred.void
update()
Updates buttons and manager.protected void
updateButtons()
Updates the state of the buttons.protected void
updateLayerInfo()
Updates information about layers.void
zoomIn()
Zooms in.void
zoomOut()
Zooms out.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, printErrorMessage, printException, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
ZOOM_FACTOR
public static final double ZOOM_FACTOR
the zoom factor to use.- See Also:
- Constant Field Values
-
m_Manager
protected LayerManager m_Manager
layer manager.
-
m_TextZoom
protected NumberTextField m_TextZoom
the text field for the zoom.
-
m_ButtonZoomClear
protected BaseFlatButton m_ButtonZoomClear
the button for clearing zoom.
-
m_ButtonZoomIn
protected BaseFlatButton m_ButtonZoomIn
the button for zooming in.
-
m_ButtonZoomOut
protected BaseFlatButton m_ButtonZoomOut
the button for zooming out.
-
m_ButtonZoomBestFit
protected BaseFlatButton m_ButtonZoomBestFit
the button for best fit zoom.
-
m_ButtonZoom
protected BaseFlatButton m_ButtonZoom
the button for applying the zoom.
-
m_ButtonAddUndo
protected BaseFlatButton m_ButtonAddUndo
the button for adding an undo.
-
m_ButtonUndo
protected BaseFlatButton m_ButtonUndo
the button for performing an undo.
-
m_ButtonRedo
protected BaseFlatButton m_ButtonRedo
the button for performing a redo.
-
m_SplitPaneLeft
protected BaseSplitPane m_SplitPaneLeft
the main split pane.
-
m_SplitPaneRight
protected BaseSplitPane m_SplitPaneRight
the left split pane.
-
m_PanelLeft
protected BasePanel m_PanelLeft
the left panel.
-
m_PanelLayers
protected BasePanel m_PanelLayers
the layers panel.
-
m_ButtonLayersAll
protected BaseButton m_ButtonLayersAll
the buttons for enabling all layers.
-
m_ButtonLayersNone
protected BaseButton m_ButtonLayersNone
the buttons for disabling all layers.
-
m_ButtonLayersInvert
protected BaseButton m_ButtonLayersInvert
the buttons for inverting selected layers.
-
m_PanelTools
protected BasePanel m_PanelTools
the tools panel.
-
m_SplitPaneTools
protected BaseSplitPane m_SplitPaneTools
the split pane for the tools.
-
m_PanelToolOptions
protected BasePanel m_PanelToolOptions
the panel for displaying the tool options.
-
m_PanelCenter
protected BasePanel m_PanelCenter
the center panel.
-
m_ScrollPane
protected BaseScrollPane m_ScrollPane
the JScrollPane that embeds the canvas panel.
-
m_PanelCanvas
protected CanvasPanel m_PanelCanvas
the panel for drawing.
-
m_LastMouseListener
protected MouseListener m_LastMouseListener
the last mouse listener in use.
-
m_LastMouseMotionListener
protected MouseMotionListener m_LastMouseMotionListener
the last mouse motion listener in use.
-
m_LastKeyListener
protected KeyListener m_LastKeyListener
the last key listener in use.
-
m_PaintOperation
protected PaintOperation m_PaintOperation
the paint operation in use.
-
m_ActiveTool
protected Tool m_ActiveTool
the active tool.
-
m_PanelToolButtons
protected JPanel m_PanelToolButtons
the panel with the buttons.
-
m_ContainerSettings
protected SegmentationPanel.ContainerSettings m_ContainerSettings
whether separate layers were used.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classBasePanel
-
finishInit
protected void finishInit()
Finishes the initialization.- Overrides:
finishInit
in classBasePanel
-
getManager
public LayerManager getManager()
Returns the layer manager.- Returns:
- the manager
-
getPaintOperation
public PaintOperation getPaintOperation()
Returns the paint operation.- Returns:
- the operation
-
getScrollPane
public BaseScrollPane getScrollPane()
Returns the scrollpane.- Returns:
- the scroll pane
-
stateChanged
public void stateChanged(ChangeEvent e)
Gets called when the layers have changed somehow.- Specified by:
stateChanged
in interfaceChangeListener
- Parameters:
e
- the event
-
updateButtons
protected void updateButtons()
Updates the state of the buttons.
-
updateLayerInfo
protected void updateLayerInfo()
Updates information about layers.
-
getUndo
public Undo getUndo()
Returns the underlying undo handler.- Returns:
- the Undo
-
addUndoPoint
public void addUndoPoint()
Adds an undo point.
-
undo
public void undo()
Performs an undo.
-
redo
public void redo()
Performs a redo.
-
undoOccurred
public void undoOccurred(UndoEvent e)
An undo event, like add or remove, has occurred.- Specified by:
undoOccurred
in interfaceUndoListener
- Parameters:
e
- the trigger event
-
notifyTools
protected void notifyTools()
Notifies the tools that annotations have changed.
-
update
public void update()
Updates buttons and manager.
-
setZoom
public void setZoom(double value)
Sets the zoom to use.- Parameters:
value
- the zoom (100 = original size)
-
getZoom
public double getZoom()
Returns the current zoom in use.- Returns:
- the zoom (100 = original size)
-
clearZoom
public void clearZoom()
Clears the zoom.
-
zoomIn
public void zoomIn()
Zooms in.
-
zoomOut
public void zoomOut()
Zooms out.
-
bestFitZoom
public void bestFitZoom()
Fits the image.
-
setLeftDividerLocation
public void setLeftDividerLocation(int value)
Sets the location of the left divider.- Parameters:
value
- the position in pixels
-
setLeftDividerLocation
public void setLeftDividerLocation(double value)
Sets the proportional location for the left divider.- Parameters:
value
- the location (0-1)
-
getLeftDividerLocation
public int getLeftDividerLocation()
Returns the left divider location.- Returns:
- the position in pixels
-
setRightDividerLocation
public void setRightDividerLocation(int value)
Sets the location of the right divider.- Parameters:
value
- the position in pixels
-
setRightDividerLocation
public void setRightDividerLocation(double value)
Sets the proportional location for the right divider.- Parameters:
value
- the location (0-1)
-
getRightDividerLocation
public int getRightDividerLocation()
Returns the right divider location.- Returns:
- the position in pixels
-
setToolButtonColumns
public void setToolButtonColumns(int columns)
Sets the number of columns used for the tool buttons.- Parameters:
columns
- the columns
-
getToolButtonColumns
public int getToolButtonColumns()
Returns the number of columns used for the tool buttons.- Returns:
- the columns
-
setAutomaticUndoEnabled
public void setAutomaticUndoEnabled(boolean value)
Sets whether automatic undos are enabled.- Parameters:
value
- true if enabled
-
isAutomaticUndoEnabled
public boolean isAutomaticUndoEnabled()
Returns whether automatic undos are enabled.- Returns:
- true if enabled
-
getContainerSettings
public SegmentationPanel.ContainerSettings getContainerSettings()
Returns the last settings used when calling fromContainer.- Returns:
- the settings, null if not available
- See Also:
fromContainer(ImageSegmentationContainer, String[], boolean, ColorProvider, float, boolean, boolean, LayerVisibility, List, LoggingObject)
-
fromContainer
public void fromContainer(ImageSegmentationContainer segcont, SegmentationPanel.ContainerSettings contSettings, List<AbstractLayer.AbstractLayerState> lastSettings, LoggingObject logger)
Retrieves the layers from the container.- Parameters:
segcont
- the container to usecontSettings
- the last settings used when calling fromContainerlastSettings
- the previous settings, can be nulllogger
- the logging object to use, can be null
-
fromContainer
public void fromContainer(ImageSegmentationContainer segcont, String[] labels, boolean useSeparateLayers, ColorProvider colorProvider, float alpha, boolean allowLayerRemoval, boolean allowLayerActions, SegmentationPanel.LayerVisibility layerVisibility, List<AbstractLayer.AbstractLayerState> lastSettings, LoggingObject logger)
Retrieves the layers from the container.- Parameters:
segcont
- the container to uselabels
- the labels to useuseSeparateLayers
- whether to use separate layers or combined layerscolorProvider
- for generating the colors for the layers, will be reset in this methodalpha
- the default alpha value to useallowLayerRemoval
- whether layers can be removedallowLayerActions
- whether actions are allowedlayerVisibility
- the visibility to uselastSettings
- the previous settings, can be nulllogger
- the logging object to use, can be null
-
toContainer
public ImageSegmentationContainer toContainer()
Turns the layers into a container. Uses any previously set value whether separate layers were used.- Returns:
- the generated container
- See Also:
m_ContainerSettings
-
toContainer
public ImageSegmentationContainer toContainer(boolean useSeparateLayers)
Turns the layers into a container.- Parameters:
useSeparateLayers
- whether to use separate layers or combined layers- Returns:
- the generated container
-
getCanvasPanel
public CanvasPanel getCanvasPanel()
Returns the underlying canvas panel.- Returns:
- the canvas
-
setToolPanelVisible
public void setToolPanelVisible(boolean value)
Hides or shows the tools panel.- Parameters:
value
- true if to show
-
isToolPanelVisible
public boolean isToolPanelVisible()
Returns whether the tools panel is visible.- Returns:
- true if visible
-
getActiveTool
public Tool getActiveTool()
Returns the currently active tool.- Returns:
- the active tool, null if not available
-
overlayTest
protected static SegmentationPanel overlayTest(String[] args)
Generates a panel with separate overlay layers.- Parameters:
args
- the files to load- Returns:
- the panel
-
combinedTest
protected static SegmentationPanel combinedTest(String[] args)
Generates a panel with a combined layer.- Parameters:
args
- the files to load- Returns:
- the panel
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
main
public static void main(String[] args)
For testing only.- Parameters:
args
- the files to load
-
-