jsky.image.graphics
Class ImageLabel

java.lang.Object
  extended by diva.canvas.AbstractFigure
      extended by diva.canvas.toolbox.LabelFigure
          extended by jsky.image.graphics.ImageLabel
All Implemented Interfaces:
diva.canvas.CanvasComponent, diva.canvas.Figure, diva.canvas.VisibleComponent, diva.util.UserObjectContainer, CanvasFigure

public class ImageLabel
extends diva.canvas.toolbox.LabelFigure
implements CanvasFigure

Represents a label figure drawn on the image.

Version:
$Revision: 1.1 $
Author:
Allan Brighton

Field Summary
protected  java.lang.Object clientData
          An arbitrary object to store with the figure for later reference
protected  java.awt.Composite composite
          Make sure composites from other figures are not used here
protected  CanvasFigureListenerManager listenerManager
          Manages a list of listeners for figure events
protected  java.util.LinkedList slaves
          Optional linked list of slave figures, which should be moved with this figure.
 
Fields inherited from interface jsky.graphics.CanvasFigure
DESELECTED, MOVED, RESIZED, SELECTED
 
Constructor Summary
ImageLabel(java.lang.String text, java.awt.geom.Point2D.Double pos, java.awt.Paint fill, java.awt.Font font, diva.canvas.interactor.Interactor interactor)
          Create an image figure with the given shape, fill, outline and line width.
 
Method Summary
 void addCanvasFigureListener(CanvasFigureListener listener)
          Add a listener for events on the canvas figure
 void addSlave(CanvasFigure fig)
          Add a slave figure.
 void fireCanvasFigureEvent(int eventType)
          Fire an event on the canvas figure.
 java.awt.geom.Point2D getAnchorPoint()
          Get the location at which the anchor is currently located.
 java.awt.geom.Rectangle2D getBoundsWithoutLabel()
          Return the bounds of this figure, ignoring the label, if there is one.
 java.lang.Object getClientData()
          Return the client data object, or null if none was set
 boolean isSelected()
          Return true if the figure is selected.
 void paint(java.awt.Graphics2D g)
          Paint the label.
 void removeCanvasFigureListener(CanvasFigureListener listener)
          Remove a listener for events on the canvas figure
 void setClientData(java.lang.Object o)
          Store an arbitrary object with the figure for later reference
 void setVisible(boolean flag)
          Set the visibility flag of this object.
 void translate(double x, double y)
          Translate the figure with by the given distance.
 
Methods inherited from class diva.canvas.toolbox.LabelFigure
autoAnchor, getAnchor, getBounds, getFillPaint, getFont, getFontName, getOrigin, getPadding, getShape, getSize, getString, getStyle, setAnchor, setFillPaint, setFont, setFontName, setPadding, setSize, setString, setStyle, setTransform, transform, translateTo, translateTo
 
Methods inherited from class diva.canvas.AbstractFigure
contains, getInteractor, getLayer, getParent, getToolTipText, getTransformContext, getUserObject, hit, intersects, isVisible, paint, repaint, repaint, setInteractor, setParent, setToolTipText, setUserObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jsky.graphics.CanvasFigure
getBounds, isVisible
 

Field Detail

clientData

protected java.lang.Object clientData
An arbitrary object to store with the figure for later reference


listenerManager

protected CanvasFigureListenerManager listenerManager
Manages a list of listeners for figure events


slaves

protected java.util.LinkedList slaves
Optional linked list of slave figures, which should be moved with this figure.


composite

protected java.awt.Composite composite
Make sure composites from other figures are not used here

Constructor Detail

ImageLabel

public ImageLabel(java.lang.String text,
                  java.awt.geom.Point2D.Double pos,
                  java.awt.Paint fill,
                  java.awt.Font font,
                  diva.canvas.interactor.Interactor interactor)
Create an image figure with the given shape, fill, outline and line width.

Parameters:
text - the text of the label to draw
pos - the label position
fill - the paint to use to draw the text
font - the font to use for the label
interactor - determines the behavior of the figure (may be null)
Method Detail

setClientData

public void setClientData(java.lang.Object o)
Store an arbitrary object with the figure for later reference

Specified by:
setClientData in interface CanvasFigure

getClientData

public java.lang.Object getClientData()
Return the client data object, or null if none was set

Specified by:
getClientData in interface CanvasFigure

getBoundsWithoutLabel

public java.awt.geom.Rectangle2D getBoundsWithoutLabel()
Return the bounds of this figure, ignoring the label, if there is one.

Specified by:
getBoundsWithoutLabel in interface CanvasFigure

isSelected

public boolean isSelected()
Return true if the figure is selected.

Specified by:
isSelected in interface CanvasFigure

paint

public void paint(java.awt.Graphics2D g)
Paint the label.

Specified by:
paint in interface diva.canvas.VisibleComponent
Overrides:
paint in class diva.canvas.toolbox.LabelFigure

setVisible

public void setVisible(boolean flag)
Set the visibility flag of this object. If the flag is false, then the object will not be painted on the screen.

Specified by:
setVisible in interface diva.canvas.VisibleComponent
Specified by:
setVisible in interface CanvasFigure
Overrides:
setVisible in class diva.canvas.AbstractFigure

addCanvasFigureListener

public void addCanvasFigureListener(CanvasFigureListener listener)
Add a listener for events on the canvas figure

Specified by:
addCanvasFigureListener in interface CanvasFigure

removeCanvasFigureListener

public void removeCanvasFigureListener(CanvasFigureListener listener)
Remove a listener for events on the canvas figure

Specified by:
removeCanvasFigureListener in interface CanvasFigure

fireCanvasFigureEvent

public void fireCanvasFigureEvent(int eventType)
Fire an event on the canvas figure.

Specified by:
fireCanvasFigureEvent in interface CanvasFigure
Parameters:
eventType - one of the CanvasFigure constants: SELECTED, DESELECTED, RESIZED, MOVED

addSlave

public void addSlave(CanvasFigure fig)
Add a slave figure. When this figure is moved, the slaves will also move.

Specified by:
addSlave in interface CanvasFigure

translate

public void translate(double x,
                      double y)
Translate the figure with by the given distance. As much as possible, this method attempts to preserve the type of the shape: if the shape of this figure is an of RectangularShape or Polyline, then the shape may be modified directly. Otherwise, a general transformation is used that loses the type of the shape, converting it into a GeneralPath.

Specified by:
translate in interface diva.canvas.Figure
Overrides:
translate in class diva.canvas.AbstractFigure

getAnchorPoint

public java.awt.geom.Point2D getAnchorPoint()
Get the location at which the anchor is currently located. This method looks at the anchor and padding attributes to figure out the point.

Overrides:
getAnchorPoint in class diva.canvas.toolbox.LabelFigure