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,FlowContextHandler,UndoListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,ChangeListener
public class SegmentationPanel extends BasePanel implements ChangeListener, UndoListener, CleanUpHandler, FlowContextHandler
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 classSegmentationPanel.ContainerSettingsThe settings used when setting up from a container.static classSegmentationPanel.LayerVisibilityWhat 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 Toolm_ActiveToolthe active tool.protected KeyListenerm_BaseKeyListenerthe base key listener.protected BaseFlatButtonm_ButtonAddUndothe button for adding an undo.protected BaseFlatButtonm_ButtonHelpthe button for help.protected BaseButtonm_ButtonLayersAllthe buttons for enabling all layers.protected BaseButtonm_ButtonLayersInvertthe buttons for inverting selected layers.protected BaseButtonm_ButtonLayersNonethe buttons for disabling all layers.protected BaseFlatButtonm_ButtonMaxMinthe button for maximize/minimize.protected BaseFlatButtonm_ButtonRedothe button for performing a redo.protected BaseFlatButtonm_ButtonRotateLeftthe button for rotating left.protected BaseFlatButtonm_ButtonRotateRightthe button for rotating right.protected BaseFlatButtonm_ButtonStopFlowthe button for stopping the flow.protected BaseFlatButtonm_ButtonUndothe button for performing an undo.protected BaseFlatButtonm_ButtonZoomthe button for applying the zoom.protected BaseFlatButtonm_ButtonZoomBestFitthe button for best fit zoom.protected BaseFlatButtonm_ButtonZoomClearthe button for clearing zoom.protected BaseFlatButtonm_ButtonZoomInthe button for zooming in.protected BaseFlatButtonm_ButtonZoomOutthe button for zooming out.protected SegmentationPanel.ContainerSettingsm_ContainerSettingswhether separate layers were used.protected Actorm_FlowContextthe flow context.protected KeyListenerm_LastKeyListenerthe last key listener in use.protected MouseListenerm_LastMouseListenerthe last mouse listener in use.protected MouseMotionListenerm_LastMouseMotionListenerthe last mouse motion listener in use.protected LayerManagerm_Managerlayer manager.protected PaintOperationm_PaintOperationthe paint operation in use.protected CanvasPanelm_PanelCanvasthe panel for drawing.protected BasePanelm_PanelCenterthe center panel.protected BasePanelm_PanelLayersthe layers panel.protected BasePanelm_PanelLeftthe left panel.protected JPanelm_PanelToolButtonsthe panel with the buttons.protected BasePanelm_PanelToolOptionsthe panel for displaying the tool options.protected BasePanelm_PanelToolsthe tools panel.protected BaseScrollPanem_ScrollPanethe JScrollPane that embeds the canvas panel.protected BaseSplitPanem_SplitPaneLeftthe main split pane.protected BaseSplitPanem_SplitPaneRightthe left split pane.protected BaseSplitPanem_SplitPaneToolsthe split pane for the tools.protected NumberTextFieldm_TextZoomthe text field for the zoom.protected Set<ChangeListener>m_ToolOptionsUpdatedListenerslisteners for when tool options get updated.protected List<Tool>m_Toolsthe tools.static doubleZOOM_FACTORthe zoom factor to use.-
Fields inherited from class adams.gui.core.BasePanel
m_FileChooser
-
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 voidaddToolOptionsUpdatedListener(ChangeListener l)Adds the listener for when tool options have been updated.voidaddUndoPoint()Adds an undo point.protected voidbeforeShow()Hook method just before the panel is made visible.voidbestFitZoom()Fits the image.voidcleanUp()Cleans up data structures, frees up memory.voidclearZoom()Clears the zoom.protected static SegmentationPanelcombinedTest(String[] args)Generates a panel with a combined layer.protected voidfinishInit()Finishes the initialization.voidfromContainer(ImageSegmentationContainer segcont, SegmentationPanel.ContainerSettings contSettings, List<AbstractLayer.AbstractLayerState> lastSettings, LoggingObject logger)Retrieves the layers from the container.voidfromContainer(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.ToolgetActiveTool()Returns the currently active tool.CanvasPanelgetCanvasPanel()Returns the underlying canvas panel.SegmentationPanel.ContainerSettingsgetContainerSettings()Returns the last settings used when calling fromContainer.ActorgetFlowContext()Returns the flow context, if any.intgetLeftDividerLocation()Returns the left divider location.LayerManagergetManager()Returns the layer manager.PaintOperationgetPaintOperation()Returns the paint operation.intgetRightDividerLocation()Returns the right divider location.BaseScrollPanegetScrollPane()Returns the scrollpane.intgetToolButtonColumns()Returns the number of columns used for the tool buttons.Map<String,Object>getToolOptions()Retrieves the current options.UndogetUndo()Returns the underlying undo handler.doublegetZoom()Returns the current zoom in use.Stringhelp()Returns the help string.protected voidinitGUI()Initializes the widgets.protected voidinitialize()Initializes the members.booleanisAutomaticUndoEnabled()Returns whether automatic undos are enabled.booleanisHelpVisible()Returns whether the help button is visible.booleanisMaxMinVisible()Returns whether the max/min button is visible.booleanisStopFlowButtonVisible()Returns whether to show the stop flow button.booleanisToolPanelVisible()Returns whether the tools panel is visible.voidloadToolOptions(PlaceholderFile optionsFile, LoggingSupporter logger)Restores the tool options from the JSON file.static voidmain(String[] args)For testing only.protected voidnotifyTools()Notifies the tools that annotations have changed.protected static SegmentationPaneloverlayTest(String[] args)Generates a panel with separate overlay layers.voidredo()Performs a redo.voidremoveToolOptionsUpdatedListener(ChangeListener l)Removes the listener for when tool options have been updated.protected BufferedImagerevertRotation(BufferedImage img, int rotation)Reverts any rotation, if necessary.voidrotate(int degrees)Rotates the view by the specified amount of degrees.voidsaveToolOptions(PlaceholderFile optionsFile, LoggingSupporter logger)Saves the tool options to the specified JSON file.voidsetAutomaticUndoEnabled(boolean value)Sets whether automatic undos are enabled.voidsetFlowContext(Actor value)Sets the flow context.voidsetHelpVisible(boolean value)Sets whether the help button is visible.voidsetLeftDividerLocation(double value)Sets the proportional location for the left divider.voidsetLeftDividerLocation(int value)Sets the location of the left divider.voidsetMaxMinVisible(boolean value)Sets whether the max/min button is visible.voidsetRightDividerLocation(double value)Sets the proportional location for the right divider.voidsetRightDividerLocation(int value)Sets the location of the right divider.voidsetStopFlowButtonVisible(boolean value)Sets whether to show the stop flow button.voidsetToolButtonColumns(int columns)Sets the number of columns used for the tool buttons.voidsetToolOptions(Map<String,Object> value)Updates the tools with these options.voidsetToolPanelVisible(boolean value)Hides or shows the tools panel.voidsetZoom(double value)Sets the zoom to use.voidshowHelp()Displays the help in a dialog.voidstateChanged(ChangeEvent e)Gets called when the layers have changed somehow.voidstopFlow()Stops the flow execution, if a flow context is set and the stop button visible.ImageSegmentationContainertoContainer()Turns the layers into a container.ImageSegmentationContainertoContainer(boolean useSeparateLayers)Turns the layers into a container.voidtoggleWindowSize()Toggles the window size between normal and maximized.voidtoolOptionsUpdated()Gets called when the options in a tool got updated.voidundo()Performs an undo.voidundoOccurred(UndoEvent e)An undo event, like add or remove, has occurred.voidupdate()Updates buttons and manager.protected voidupdateButtons()Updates the state of the buttons.protected voidupdateLayerInfo()Updates information about layers.voidzoomIn()Zooms in.voidzoomOut()Zooms out.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, closeParent, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, printErrorMessage, printException, saveComponent, 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_ButtonRotateLeft
protected BaseFlatButton m_ButtonRotateLeft
the button for rotating left.
-
m_ButtonRotateRight
protected BaseFlatButton m_ButtonRotateRight
the button for rotating right.
-
m_ButtonStopFlow
protected BaseFlatButton m_ButtonStopFlow
the button for stopping the flow.
-
m_ButtonMaxMin
protected BaseFlatButton m_ButtonMaxMin
the button for maximize/minimize.
-
m_ButtonHelp
protected BaseFlatButton m_ButtonHelp
the button for help.
-
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_BaseKeyListener
protected KeyListener m_BaseKeyListener
the base key listener.
-
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.
-
m_ToolOptionsUpdatedListeners
protected Set<ChangeListener> m_ToolOptionsUpdatedListeners
listeners for when tool options get updated.
-
m_FlowContext
protected Actor m_FlowContext
the flow context.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classBasePanel
-
finishInit
protected void finishInit()
Finishes the initialization.- Overrides:
finishInitin classBasePanel
-
beforeShow
protected void beforeShow()
Hook method just before the panel is made visible.- Overrides:
beforeShowin classBasePanel
-
setFlowContext
public void setFlowContext(Actor value)
Sets the flow context.- Specified by:
setFlowContextin interfaceFlowContextHandler- Parameters:
value- the actor
-
getFlowContext
public Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContextin interfaceFlowContextHandler- Returns:
- the actor, null if none available
-
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:
stateChangedin 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:
undoOccurredin interfaceUndoListener- Parameters:
e- the trigger event
-
setStopFlowButtonVisible
public void setStopFlowButtonVisible(boolean value)
Sets whether to show the stop flow button.- Parameters:
value- true if to show
-
isStopFlowButtonVisible
public boolean isStopFlowButtonVisible()
Returns whether to show the stop flow button.- Returns:
- true if to show
-
stopFlow
public void stopFlow()
Stops the flow execution, if a flow context is set and the stop button visible.
-
rotate
public void rotate(int degrees)
Rotates the view by the specified amount of degrees.- Parameters:
degrees- the degrees to rotate by
-
setMaxMinVisible
public void setMaxMinVisible(boolean value)
Sets whether the max/min button is visible.- Parameters:
value- true if visible
-
isMaxMinVisible
public boolean isMaxMinVisible()
Returns whether the max/min button is visible.- Returns:
- true if visible
-
toggleWindowSize
public void toggleWindowSize()
Toggles the window size between normal and maximized.
-
setHelpVisible
public void setHelpVisible(boolean value)
Sets whether the help button is visible.- Parameters:
value- true if visible
-
isHelpVisible
public boolean isHelpVisible()
Returns whether the help button is visible.- Returns:
- true if visible
-
help
public String help()
Returns the help string.- Returns:
- the help
-
showHelp
public void showHelp()
Displays the help in a dialog.
-
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
-
revertRotation
protected BufferedImage revertRotation(BufferedImage img, int rotation)
Reverts any rotation, if necessary.- Parameters:
img- the image to processrotation- the rotation in degrees- Returns:
- the (potentially) updated image
-
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
-
addToolOptionsUpdatedListener
public void addToolOptionsUpdatedListener(ChangeListener l)
Adds the listener for when tool options have been updated.- Parameters:
l- the listener to add
-
removeToolOptionsUpdatedListener
public void removeToolOptionsUpdatedListener(ChangeListener l)
Removes the listener for when tool options have been updated.- Parameters:
l- the listener to remove
-
toolOptionsUpdated
public void toolOptionsUpdated()
Gets called when the options in a tool got updated.
-
setToolOptions
public void setToolOptions(Map<String,Object> value)
Updates the tools with these options.- Parameters:
value- the options to use for updating the tools
-
getToolOptions
public Map<String,Object> getToolOptions()
Retrieves the current options.- Returns:
- the options for the tools
-
saveToolOptions
public void saveToolOptions(PlaceholderFile optionsFile, LoggingSupporter logger)
Saves the tool options to the specified JSON file.- Parameters:
optionsFile- the JSON file to save tologger- for logging messages
-
loadToolOptions
public void loadToolOptions(PlaceholderFile optionsFile, LoggingSupporter logger)
Restores the tool options from the JSON file.- Parameters:
optionsFile- the JSON file to load/parselogger- for logging messages
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceCleanUpHandler
-
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
-
main
public static void main(String[] args)
For testing only.- Parameters:
args- the files to load
-
-