br.usp.ime.klava.segmentit.gui
Class SegmentationDocument

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JInternalFrame
                  extended by br.usp.ime.klava.segmentit.gui.SegmentationDocument
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class SegmentationDocument
extends javax.swing.JInternalFrame
implements java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseWheelListener, java.awt.event.MouseMotionListener, javax.swing.event.ChangeListener

Stores an image to be segmented. Represents a document that can be edited in the SegmentationContainer.

Author:
Bruno Klava
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JInternalFrame
javax.swing.JInternalFrame.JDesktopIcon
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JInternalFrame
CONTENT_PANE_PROPERTY, FRAME_ICON_PROPERTY, GLASS_PANE_PROPERTY, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, LAYERED_PANE_PROPERTY, MENU_BAR_PROPERTY, ROOT_PANE_PROPERTY, TITLE_PROPERTY
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SegmentationDocument(java.awt.image.BufferedImage image, java.lang.String documentName, Filter filter, boolean hideFilteredImage)
          Constructor for the SegmentationDocument.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Turns on/off the visibility of the layers and enables/disables the sliders: Basins opacity; Filtered image contrast.
 void cleanMarkers()
          Cleans the existing markers.
 java.awt.Color getBackgroundColor()
          Returns the background color.
 java.awt.image.BufferedImage getBasinsImage()
          Returns the segmentation result (catchment basins).
 java.awt.Color getBrushesColor()
          Returns the color of the brushes.
 ColorSpace getColorSpace()
          Returns the ColosSpace used to paint the basins.
 Connectivity getConnectivity()
          Returns the Connectivity being used.
 java.lang.String getDocumentName()
          Returns the document name.
 Filter getFilter()
          Returns the Filter being used.
 Granularity getGranularity()
          Returns the Granularity being used.
 java.awt.image.BufferedImage getInputImage()
          Returns the input image.
 javax.swing.JPanel getLayers()
          Returns the layers panel.
 java.awt.image.BufferedImage getMarkersImage()
          Returns the markers image.
 java.awt.image.BufferedImage getSegmentedImage()
          Returns the segmentation result superimposing the visible layers.
 java.awt.Color getWatershedColor()
          Returns the color of the watershed lines.
 boolean isColorImage()
          Returns if the input image is a color image.
 boolean isRedoAvailable()
          Returns if it is possible to redo an action.
 boolean isUndoAvailable()
          Returns if it is possible to undo an action.
 void loadPartition(java.awt.image.BufferedImage desiredPartition)
          Loads desiredPartition as the selected partition by unifying the labels within each PrimitiveCatchmentBasin in it and then creating markers that recovers the resultant partition.
 void mouseClicked(java.awt.event.MouseEvent e)
          Does nothing.
 void mouseDragged(java.awt.event.MouseEvent event)
          Executes some actions depending on the selected tool and the mouse button utilized.
 void mouseEntered(java.awt.event.MouseEvent evento)
          Selects this SegmentationDocument if it is the active document (to get the focus previously hold by the toolbox or the layers panel).
 void mouseExited(java.awt.event.MouseEvent e)
          Does nothing.
 void mouseMoved(java.awt.event.MouseEvent e)
          Does nothing.
 void mousePressed(java.awt.event.MouseEvent event)
          Executes some actions depending on the selected tool and the mouse button utilized.
 void mouseReleased(java.awt.event.MouseEvent e)
          Executes some actions depending on the selected tool and the mouse button utilized.
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
          Performs a zoom-in or a zoom-out depending on the wheel rotation.
 void redo()
          Redoes an action, if possible.
 void segment()
          Executes the watershed from markers algorithm, storing the previous state in the history.
 void segment(boolean storeState)
          Executes the watershed from markers algorithm.
 void setBackgroundColor(java.awt.Color color)
          Sets the background color to be used.
 void setBrushesColor(java.awt.Color color)
          Sets the color of the brushes.
 void setBrushesDiameter(int diameter)
          Sets the diameter of the brushes.
 void setColorSpace(ColorSpace colorSpace)
          Sets the ColorSpace to be used to paint the basins.
 void setConnectivity(Connectivity connectivity)
          Sets the Connectivity to be used.
 void setFilter(Filter filter)
          Sets the Filter to be used.
 void setFilteredImage(java.awt.image.BufferedImage image, Filter filter)
          Sets the Filter to be used and an image obtained with it.
 void setGranularity(Granularity granularity)
          Sets the Granularity to be used.
 void setMarkersImage(java.awt.image.BufferedImage image)
          Sets an image to be used as markers.
static void setSegmentViaHierarchyBuilder(SegmentViaHierarchyBuilderIF segmentViaHierarchyBuilder)
          Sets a SegmentViaHierarchyBuilderIF to build SegmentViaHierarchy in this SegmentationDocument
 void setTool(Tool tool)
          Sets the tool being used.
 void setWatershedColor(java.awt.Color color)
          Sets the color of the watershed lines.
 void setZoomLevel(double zoomLevel)
          Sets the zoom to the given zoomLevel.
 void stateChanged(javax.swing.event.ChangeEvent e)
          Changes the basins opacity or the filtered image contrast if the corresponding slider is moved.
 void undo()
          Undoes an action, if possible.
 void zoomReset()
          Sets the zoom to 100%.
 
Methods inherited from class javax.swing.JInternalFrame
addInternalFrameListener, dispose, doDefaultCloseAction, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isSelected, moveToBack, moveToFront, pack, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setSelected, setTitle, setUI, show, toBack, toFront, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SegmentationDocument

public SegmentationDocument(java.awt.image.BufferedImage image,
                            java.lang.String documentName,
                            Filter filter,
                            boolean hideFilteredImage)
Constructor for the SegmentationDocument.

Parameters:
image - the image to be segmented
documentName - the name of the document
filter - the Filter to be used
hideFilteredImage - if the filtered image must start hidden
Method Detail

getDocumentName

public java.lang.String getDocumentName()
Returns the document name.

Returns:
the document name

isColorImage

public boolean isColorImage()
Returns if the input image is a color image.

Returns:
true if the input image is a color image

getFilter

public Filter getFilter()
Returns the Filter being used.

Returns:
the Filter being used

setFilter

public void setFilter(Filter filter)
Sets the Filter to be used.

Parameters:
filter - the Filter to be used

setFilteredImage

public void setFilteredImage(java.awt.image.BufferedImage image,
                             Filter filter)
Sets the Filter to be used and an image obtained with it.

Parameters:
image - an image obtained by the Filter
filter - the Filter used to obtain the given image

getConnectivity

public Connectivity getConnectivity()
Returns the Connectivity being used.

Returns:
the Connectivity being used

setConnectivity

public void setConnectivity(Connectivity connectivity)
Sets the Connectivity to be used.

Parameters:
connectivity - the Connectivity to be used

getGranularity

public Granularity getGranularity()
Returns the Granularity being used.

Returns:
the Granularity being used

setGranularity

public void setGranularity(Granularity granularity)
Sets the Granularity to be used.

Parameters:
granularity - the Granularity to be used

getInputImage

public java.awt.image.BufferedImage getInputImage()
Returns the input image.

Returns:
the input image

setMarkersImage

public void setMarkersImage(java.awt.image.BufferedImage image)
Sets an image to be used as markers.

Parameters:
image - an image to be used as markers

getMarkersImage

public java.awt.image.BufferedImage getMarkersImage()
Returns the markers image.

Returns:
the markers image

cleanMarkers

public void cleanMarkers()
Cleans the existing markers.


setBrushesDiameter

public void setBrushesDiameter(int diameter)
Sets the diameter of the brushes.

Parameters:
diameter - the diameter (in pixels) of the brushes

setTool

public void setTool(Tool tool)
Sets the tool being used.

Parameters:
tool - the tool being used

getLayers

public javax.swing.JPanel getLayers()
Returns the layers panel.

Returns:
the layers panel

getBackgroundColor

public java.awt.Color getBackgroundColor()
Returns the background color.

Returns:
the background color

setBackgroundColor

public void setBackgroundColor(java.awt.Color color)
Sets the background color to be used.

Parameters:
color - the background color to be used

getBrushesColor

public java.awt.Color getBrushesColor()
Returns the color of the brushes.

Returns:
the color of the brushes

setBrushesColor

public void setBrushesColor(java.awt.Color color)
Sets the color of the brushes.

Parameters:
color - the color of the brushes

getWatershedColor

public java.awt.Color getWatershedColor()
Returns the color of the watershed lines.

Returns:
the color of the watershed lines

setWatershedColor

public void setWatershedColor(java.awt.Color color)
Sets the color of the watershed lines.

Parameters:
color - the color of the watershed lines

getColorSpace

public ColorSpace getColorSpace()
Returns the ColosSpace used to paint the basins.

Returns:
the ColosSpace used to paint the basins

setColorSpace

public void setColorSpace(ColorSpace colorSpace)
Sets the ColorSpace to be used to paint the basins.

Parameters:
colorSpace - the ColorSpace to be used to paint the basins

segment

public void segment()
Executes the watershed from markers algorithm, storing the previous state in the history.


segment

public void segment(boolean storeState)
Executes the watershed from markers algorithm.

Parameters:
storeState - true if the previous state must be stored in the history

setZoomLevel

public void setZoomLevel(double zoomLevel)
Sets the zoom to the given zoomLevel.

Parameters:
zoomLevel - a scale to be used as zoom

zoomReset

public void zoomReset()
Sets the zoom to 100%.


getSegmentedImage

public java.awt.image.BufferedImage getSegmentedImage()
Returns the segmentation result superimposing the visible layers.

Returns:
the segmentation result superimposing the visible layers:
  • background;
  • filtered image;
  • original image;
  • basins;
  • markers;
  • watershed lines.

getBasinsImage

public java.awt.image.BufferedImage getBasinsImage()
Returns the segmentation result (catchment basins).

Returns:
the segmentation result (catchment basins)

isUndoAvailable

public boolean isUndoAvailable()
Returns if it is possible to undo an action.

Returns:
true if it is possible to undo an action

undo

public void undo()
Undoes an action, if possible.


isRedoAvailable

public boolean isRedoAvailable()
Returns if it is possible to redo an action.

Returns:
true if it is possible to redo an action

redo

public void redo()
Redoes an action, if possible.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Turns on/off the visibility of the layers and enables/disables the sliders: if the corresponding layer is visible.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent event)
Executes some actions depending on the selected tool and the mouse button utilized.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent event)
Executes some actions depending on the selected tool and the mouse button utilized.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Executes some actions depending on the selected tool and the mouse button utilized.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evento)
Selects this SegmentationDocument if it is the active document (to get the focus previously hold by the toolbox or the layers panel).

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Does nothing.

Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Does nothing.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Does nothing.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Performs a zoom-in or a zoom-out depending on the wheel rotation.

Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Changes the basins opacity or the filtered image contrast if the corresponding slider is moved.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener

loadPartition

public void loadPartition(java.awt.image.BufferedImage desiredPartition)
Loads desiredPartition as the selected partition by unifying the labels within each PrimitiveCatchmentBasin in it and then creating markers that recovers the resultant partition.

Parameters:
desiredPartition - a desired partition

setSegmentViaHierarchyBuilder

public static void setSegmentViaHierarchyBuilder(SegmentViaHierarchyBuilderIF segmentViaHierarchyBuilder)
Sets a SegmentViaHierarchyBuilderIF to build SegmentViaHierarchy in this SegmentationDocument

Parameters:
segmentViaHierarchyBuilder - an implementation of SegmentViaHierarchyBuilderIF