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

java.lang.Object
  extended by javax.swing.ImageIcon
      extended by br.usp.ime.klava.segmentit.gui.ZoomableImageIcon
          extended by br.usp.ime.klava.segmentit.gui.MarkersEditor
All Implemented Interfaces:
java.io.Serializable, javax.accessibility.Accessible, javax.swing.Icon

public class MarkersEditor
extends ZoomableImageIcon

Implements a canvas where markers can be edited.

Author:
Bruno Klava
See Also:
Serialized Form

Constructor Summary
MarkersEditor(int width, int height)
          Constructs a MarkersEditor that stores a markers image of the given dimensions.
 
Method Summary
 void clean()
          Cleans the existing markers.
 void erase(int x, int y)
          Erases markers of any color using the current diameter.
 void eraseColor(int x, int y)
          Erases markers of the current color using the current diameter.
 void eraseNonUniqueLabeledBasins(PrimitiveCatchmentBasinsGraph graph)
          Erases the intersection of the markers with the primitive catchment basins crossed by multiple markers.
 void erasePreviousMarkers(PrimitiveCatchmentBasinsGraph graph)
          Erases the intersection of the previous markers with the primitive catchment basins (vertices of graph) crossed by the last marker created/edited.
 java.awt.Color getBrushColor()
          Returns the color of the brush.
 java.awt.Color getColor(int x, int y)
          Returns the color of the pixel localized at (x, y).
 void loadMarkers(java.awt.Image image)
          Overrides the existing markers with the given image.
 void loadMarkers(java.awt.Image image, boolean override)
          Sets an image to be used as markers.
 void paint(int x, int y)
          Paints markers using the brush with the current color and diameter.
 void setBrushColor(java.awt.Color color)
          Sets the color of the brush.
 void setBrushDiameter(int diameter)
          Sets the diameter of the brush.
 boolean stopPainting()
          Stops painting/erasing markers.
 
Methods inherited from class br.usp.ime.klava.segmentit.gui.ZoomableImageIcon
getZoomLevel, paintIcon, setOpacity, setZoomLevel
 
Methods inherited from class javax.swing.ImageIcon
getAccessibleContext, getDescription, getIconHeight, getIconWidth, getImage, getImageLoadStatus, getImageObserver, setDescription, setImage, setImageObserver, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MarkersEditor

public MarkersEditor(int width,
                     int height)
Constructs a MarkersEditor that stores a markers image of the given dimensions.

Parameters:
width - the width of the markers image
height - the height of the markers image
Method Detail

loadMarkers

public void loadMarkers(java.awt.Image image)
Overrides the existing markers with the given image.

Parameters:
image - an image to be used as markers

loadMarkers

public void loadMarkers(java.awt.Image image,
                        boolean override)
Sets an image to be used as markers.

Parameters:
image - an image to be used as markers
override - true if the existing markers should be removed, false if the image should be drawn over existing markers.

clean

public void clean()
Cleans the existing markers.


setBrushColor

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

Parameters:
color - the color of the brush

getBrushColor

public java.awt.Color getBrushColor()
Returns the color of the brush.

Returns:
the color of the brush

setBrushDiameter

public void setBrushDiameter(int diameter)
Sets the diameter of the brush.

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

paint

public void paint(int x,
                  int y)
Paints markers using the brush with the current color and diameter.

Parameters:
x - the x-coordinate of the brush
y - the y-coordinate of the brush

erase

public void erase(int x,
                  int y)
Erases markers of any color using the current diameter.

Parameters:
x - the x-coordinate of the brush
y - the y-coordinate of the brush

eraseColor

public void eraseColor(int x,
                       int y)
Erases markers of the current color using the current diameter.

Parameters:
x - the x-coordinate of the brush
y - the y-coordinate of the brush

stopPainting

public boolean stopPainting()
Stops painting/erasing markers.

Returns:
true if it was in an editing state

getColor

public java.awt.Color getColor(int x,
                               int y)
Returns the color of the pixel localized at (x, y).

Parameters:
x - the x-coordinate of the pixel
y - the y-coordinate of the pixel
Returns:
the Color of the marker localized at (x ,y), null if the pixel is transparent

erasePreviousMarkers

public void erasePreviousMarkers(PrimitiveCatchmentBasinsGraph graph)
Erases the intersection of the previous markers with the primitive catchment basins (vertices of graph) crossed by the last marker created/edited.

Parameters:
graph - a PrimitiveCatchmentBasinsGraph

eraseNonUniqueLabeledBasins

public void eraseNonUniqueLabeledBasins(PrimitiveCatchmentBasinsGraph graph)
Erases the intersection of the markers with the primitive catchment basins crossed by multiple markers.

Parameters:
graph - a PrimitiveCatchmentBasinsGraph