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

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by br.usp.ime.klava.segmentit.gui.SegmentationContainer
All Implemented Interfaces:
ToolContainer, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener, javax.swing.event.InternalFrameListener, javax.swing.event.MenuListener, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class SegmentationContainer
extends javax.swing.JFrame
implements java.awt.event.MouseListener, java.awt.event.ActionListener, javax.swing.event.ChangeListener, javax.swing.event.InternalFrameListener, javax.swing.event.MenuListener, ToolContainer

The main class of the tool GUI.

Author:
Bruno Klava
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JFrame
EXIT_ON_CLOSE
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
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, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Executes some actions fired by buttons or menus: Segment; change brush color; filtering.
 void arrangeWorkspace()
          Puts the toolbox in the upper-left corner, the layer panel in the upper-right corner and arranges the open SegmentationDocuments in cascade.
 SegmentationDocument createSegmentationDocument(java.awt.image.BufferedImage image, java.lang.String name)
          Creates a SegmentationDocument that displays the image to be segmented.
 void error(java.lang.Exception exception)
          Display a dialog with the error message given by exception.getLocalizedMessage().
 void error(java.lang.String message)
          Display a dialog with the error message message.
 SegmentationDocument getActiveDocument()
          Returns the active SegmentationDocument.
 Connectivity getConnectivity()
          Returns the Connectivity being used.
 Granularity getGranularity()
          Returns the Granularity being used.
static SegmentationContainer getInstance()
          Returns the unique instance of SegmentationContainer.
 void internalFrameActivated(javax.swing.event.InternalFrameEvent event)
          Adds the SegmentationDocument being activated to the top of the opened documents, adds its layers to the layers panel, sets some states of the tools and enables/disables some actions if necessary.
 void internalFrameClosed(javax.swing.event.InternalFrameEvent e)
          Does nothing.
 void internalFrameClosing(javax.swing.event.InternalFrameEvent e)
          Removes the SegmentationDocument to be closed and its layers from the layers panel, enabling/disabling some actions if necessary.
 void internalFrameDeactivated(javax.swing.event.InternalFrameEvent e)
          Does nothing.
 void internalFrameDeiconified(javax.swing.event.InternalFrameEvent e)
          Does nothing.
 void internalFrameIconified(javax.swing.event.InternalFrameEvent e)
          Does nothing.
 void internalFrameOpened(javax.swing.event.InternalFrameEvent e)
          Does nothing.
 boolean isSegmentAutomatically()
          Returns if the segment automatically option is selected.
static void main(java.lang.String[] args)
          Main method that starts the tool GUI.
 void menuCanceled(javax.swing.event.MenuEvent e)
          Does nothing.
 void menuDeselected(javax.swing.event.MenuEvent e)
          Does nothing.
 void menuSelected(javax.swing.event.MenuEvent e)
          Enables/disables the appropriated filters based if the active SegmentationDocument contains a color or a gray level image.
 void mouseClicked(java.awt.event.MouseEvent event)
          Executes some actions fired by multiples mouse clicks on tools: Erase all markers; reset zoom.
 void mouseEntered(java.awt.event.MouseEvent event)
          Activates the JInternalFrame of the layers panel or the toolbox if the mouse enters one of them.
 void mouseExited(java.awt.event.MouseEvent evento)
          Does nothing.
 void mousePressed(java.awt.event.MouseEvent e)
          Does nothing.
 void mouseReleased(java.awt.event.MouseEvent e)
          Does nothing.
 void setBrushColor(java.awt.Color color)
          Sets the color of the brushes.
 void setColorSpace(ColorSpace colorSpace)
          Sets the colorSpace to paint the regions of the partition of the active SegmentationDocument.
 void setConnectivity(Connectivity connectivity)
          Sets the Connectivity.
 void setFilteredImage(java.awt.image.BufferedImage image, Filter filter)
          Sets the image, obtained by the filter, as the filtered image of the active SegmentationDocument.
 void setGranularity(Granularity granularity)
          Sets the Granularity.
 void setMarkersImage(java.awt.image.BufferedImage image)
          Sets image as the markers image of the active SegmentationDocument.
 void setSelectedTool(Tool tool)
          Sets the selected Tool.
 void stateChanged(javax.swing.event.ChangeEvent event)
          Changes the diameter of the brush when the corresponding slider is used.
 void updateUndoRedoState()
          Enables or disables the Undo and Redo actions depending on the existence and the state of the active document.
 
Methods inherited from class javax.swing.JFrame
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Method Detail

getInstance

public static SegmentationContainer getInstance()
Returns the unique instance of SegmentationContainer.

Returns:
the unique instance of SegmentationContainer

main

public static void main(java.lang.String[] args)
Main method that starts the tool GUI.

Parameters:
args - path to files to be opened as SegmentationDocuments

getActiveDocument

public SegmentationDocument getActiveDocument()
Returns the active SegmentationDocument.

Returns:
the active SegmentationDocument, null if there is no SegmentationDocument opened

arrangeWorkspace

public void arrangeWorkspace()
Puts the toolbox in the upper-left corner, the layer panel in the upper-right corner and arranges the open SegmentationDocuments in cascade.


getConnectivity

public Connectivity getConnectivity()
Returns the Connectivity being used.

Returns:
the Connectivity being used

setConnectivity

public void setConnectivity(Connectivity connectivity)
Sets the Connectivity.

Parameters:
connectivity - 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.

Parameters:
granularity - Granularity to be used

setSelectedTool

public void setSelectedTool(Tool tool)
Description copied from interface: ToolContainer
Sets the selected Tool.

Specified by:
setSelectedTool in interface ToolContainer
Parameters:
tool - the Tool to be used

isSegmentAutomatically

public boolean isSegmentAutomatically()
Returns if the segment automatically option is selected.

Returns:
true if the segment automatically option is selected

setBrushColor

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

Parameters:
color - the Color to be set to the brushes

createSegmentationDocument

public SegmentationDocument createSegmentationDocument(java.awt.image.BufferedImage image,
                                                       java.lang.String name)
Creates a SegmentationDocument that displays the image to be segmented.

Parameters:
image - the image to be segmented
name - the name of the SegmentationDocument
Returns:
the SegmentationDocument created

updateUndoRedoState

public void updateUndoRedoState()
Enables or disables the Undo and Redo actions depending on the existence and the state of the active document.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Executes some actions fired by buttons or menus:

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

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent event)
Changes the diameter of the brush when the corresponding slider is used.

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

internalFrameClosing

public void internalFrameClosing(javax.swing.event.InternalFrameEvent e)
Removes the SegmentationDocument to be closed and its layers from the layers panel, enabling/disabling some actions if necessary.

Specified by:
internalFrameClosing in interface javax.swing.event.InternalFrameListener

internalFrameClosed

public void internalFrameClosed(javax.swing.event.InternalFrameEvent e)
Does nothing.

Specified by:
internalFrameClosed in interface javax.swing.event.InternalFrameListener

internalFrameOpened

public void internalFrameOpened(javax.swing.event.InternalFrameEvent e)
Does nothing.

Specified by:
internalFrameOpened in interface javax.swing.event.InternalFrameListener

internalFrameIconified

public void internalFrameIconified(javax.swing.event.InternalFrameEvent e)
Does nothing.

Specified by:
internalFrameIconified in interface javax.swing.event.InternalFrameListener

internalFrameDeiconified

public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent e)
Does nothing.

Specified by:
internalFrameDeiconified in interface javax.swing.event.InternalFrameListener

internalFrameActivated

public void internalFrameActivated(javax.swing.event.InternalFrameEvent event)
Adds the SegmentationDocument being activated to the top of the opened documents, adds its layers to the layers panel, sets some states of the tools and enables/disables some actions if necessary.

Specified by:
internalFrameActivated in interface javax.swing.event.InternalFrameListener

internalFrameDeactivated

public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent e)
Does nothing.

Specified by:
internalFrameDeactivated in interface javax.swing.event.InternalFrameListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent event)
Executes some actions fired by multiples mouse clicks on tools:

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

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent event)
Activates the JInternalFrame of the layers panel or the toolbox if the mouse enters one of them.

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

mouseExited

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

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

mousePressed

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

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

mouseReleased

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

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

menuCanceled

public void menuCanceled(javax.swing.event.MenuEvent e)
Does nothing.

Specified by:
menuCanceled in interface javax.swing.event.MenuListener

menuDeselected

public void menuDeselected(javax.swing.event.MenuEvent e)
Does nothing.

Specified by:
menuDeselected in interface javax.swing.event.MenuListener

menuSelected

public void menuSelected(javax.swing.event.MenuEvent e)
Enables/disables the appropriated filters based if the active SegmentationDocument contains a color or a gray level image.

Specified by:
menuSelected in interface javax.swing.event.MenuListener

setMarkersImage

public void setMarkersImage(java.awt.image.BufferedImage image)
Sets image as the markers image of the active SegmentationDocument.

Parameters:
image - the image to be used as markers

setFilteredImage

public void setFilteredImage(java.awt.image.BufferedImage image,
                             Filter filter)
Sets the image, obtained by the filter, as the filtered image of the active SegmentationDocument. Can be used by the method chooseParameters of a ParameterizedFilter.

Parameters:
image - the filtered image obtained by the filter
filter - the filter used to obtain the image
See Also:
ParameterizedFilter.chooseParameters(BufferedImage)

setColorSpace

public void setColorSpace(ColorSpace colorSpace)
Sets the colorSpace to paint the regions of the partition of the active SegmentationDocument.

Parameters:
colorSpace - a ColorSpace to paint the regions of the partition of the active SegmentationDocument.

error

public void error(java.lang.String message)
Display a dialog with the error message message.

Parameters:
message - the error message

error

public void error(java.lang.Exception exception)
Display a dialog with the error message given by exception.getLocalizedMessage().

Parameters:
exception - a Exception with an error message