com.rolemodelsoft.drawlet.shapes.lines
Class Arrow

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.basics.AbstractPaintable
        |
        +--com.rolemodelsoft.drawlet.basics.AbstractFigure
              |
              +--com.rolemodelsoft.drawlet.shapes.AbstractShape
                    |
                    +--com.rolemodelsoft.drawlet.shapes.lines.Arrow

public class Arrow
extends AbstractShape
implements RelatedLocationListener

Arrows are a basic adornment for AdornedLines.

See Also:
Serialized Form

Field Summary
protected  ArrowStyle arrowStyle
          The ArrowStyle which defines how to draw this Arrow.
protected  int direction
          The direction of the arrow
static int FORWARD
          Defines which end of the line we are attached to.
protected  java.beans.PropertyChangeEvent lastEvent
           
protected  LineFigure line
          The LineFigure we are attached to.
protected  java.awt.Polygon polygon
          The polygon defining the arrow head
static int REVERSE
          Defines which end of the line we are attached to.
 
Fields inherited from class com.rolemodelsoft.drawlet.basics.AbstractFigure
listeners, locationListeners
 
Constructor Summary
Arrow(LineFigure line)
          Construct a new arrow initialized with the given LineFigure.
Arrow(LineFigure line, int direction)
          Construct a new arrow initialized with the given LineFigure and direction.
 
Method Summary
protected  void basicReshape(int x, int y, int width, int height)
          Reshapes the Arrow to the specified bounding box.
protected  void basicTranslate(int x, int y)
          Shifts the receiver by the specified values.
protected  ArrowStyle defaultArrowStyle()
          Answer the default shape for the arrow.
protected  int defaultDirection()
          Answer the default direction for the arrow.
protected  java.awt.Polygon defaultPolygon()
          Answer the default shape for the arrow.
protected  Locator getArrowLocator(Locator loc)
          Answer the proper Locator for the given values.
 ArrowStyle getArrowStyle()
          Answer the ArrowStyle that defines how to draw the arrow.
 java.awt.Rectangle getBounds()
          Answer the bounds of the receiver.
protected  int getDestinationIndex()
          Answers the index of the destination, depending on the direction of the receiver.
protected  Locator getDestinationLocator()
          Answers the Locator of the destination, depending on the direction of the receiver.
protected  int getDirection()
          Answers the direction of the receiver.
 Handle[] getHandles()
          Answer the handles associated with the receiver.
protected  java.awt.Polygon getPolygon()
          Answer the polygon that defines the arrow.
protected  int getSourceIndex()
          Answers the index of the source, depending on the direction of the receiver.
protected  Locator getSourceLocator()
          Answers the Locator of the source, depending on the direction of the receiver.
 void locationChanged(java.beans.PropertyChangeEvent evt)
          Update because the location of my line has changed.
 void paint(java.awt.Graphics g)
          Paints the Arrow.
 void relationChanged(java.beans.PropertyChangeEvent event)
          Update because the relation of my line has changed.
protected  void resetLocationCache()
          Flush caches with respect to determining location.
 void shapeChanged(java.beans.PropertyChangeEvent evt)
          Update because the shape of my line has changed.
 void sizeChanged(java.beans.PropertyChangeEvent evt)
          Update because the size of my line has changed.
protected  void updateShape()
          The line has notified the receiver of a change.
 
Methods inherited from class com.rolemodelsoft.drawlet.shapes.AbstractShape
basicResize, resetBoundsCache, resetSizeCache, reshapedPolygon, reshapedPolygon, setBounds, setSize
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractFigure
addPropertyChangeListener, addRelatedLocationListener, basicMove, changedLocation, changedShape, changedSize, contains, contains, contains, deleteLocationListeners, disconnect, duplicate, duplicateIn, editTool, estimatedDuplicateSize, figureFromLocator, fireLocationChange, firePropertyChange, firePropertyChange, fireRelationChange, fireShapeChange, fireSizeChange, getLocation, getLocator, getStyle, intersects, intersects, isObsolete, isWithin, isWithin, locatorAt, move, move, postDuplicate, relatedLocationListeners, removePropertyChangeListener, removeRelatedLocationListener, requestConnection, setSize, setStyle, translate
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractPaintable
getBottom, getHeight, getLeft, getRight, getSize, getTop, getWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

line

protected LineFigure line
The LineFigure we are attached to.

FORWARD

public static final int FORWARD
Defines which end of the line we are attached to.

REVERSE

public static final int REVERSE
Defines which end of the line we are attached to.

direction

protected int direction
The direction of the arrow

polygon

protected transient java.awt.Polygon polygon
The polygon defining the arrow head

arrowStyle

protected ArrowStyle arrowStyle
The ArrowStyle which defines how to draw this Arrow.

lastEvent

protected java.beans.PropertyChangeEvent lastEvent
Constructor Detail

Arrow

public Arrow(LineFigure line)
Construct a new arrow initialized with the given LineFigure.
Parameters:
line - the LineFigure to attach to.

Arrow

public Arrow(LineFigure line,
             int direction)
Construct a new arrow initialized with the given LineFigure and direction.
Parameters:
line - the LineFigure to attach to.
the - direction for the Arrow.
Method Detail

basicReshape

protected void basicReshape(int x,
                            int y,
                            int width,
                            int height)
Reshapes the Arrow to the specified bounding box. Does nothing by default.
Overrides:
basicReshape in class AbstractShape
Parameters:
x - the x coordinate
y - the y coordinate
width - the width of the figure
height - the height of the figure
See Also:
getBounds()

basicTranslate

protected void basicTranslate(int x,
                              int y)
Shifts the receiver by the specified values. Don't think this is legal if we are attached to a line.
Overrides:
basicTranslate in class AbstractFigure
Parameters:
x - the amount to shift horizontally.
y - the amount to shift vertically.

defaultArrowStyle

protected ArrowStyle defaultArrowStyle()
Answer the default shape for the arrow.
Returns:
a Polygon representing the default shape for the arrow.

defaultDirection

protected int defaultDirection()
Answer the default direction for the arrow.
Returns:
an integer representing the default direction for the arrow.

defaultPolygon

protected java.awt.Polygon defaultPolygon()
Answer the default shape for the arrow.
Returns:
a Polygon representing the default shape for the arrow.

getArrowLocator

protected Locator getArrowLocator(Locator loc)
Answer the proper Locator for the given values.
Parameters:
source - the first Locator to calculate from.
destination - the second Locator to calculate from.
offset - the amount the Locator should be offset.
Returns:
a Locator calculated from the given values.

getArrowStyle

public ArrowStyle getArrowStyle()
Answer the ArrowStyle that defines how to draw the arrow.
Returns:
the ArrowStyle defining how to draw the arrow.

getBounds

public java.awt.Rectangle getBounds()
Answer the bounds of the receiver.
Overrides:
getBounds in class AbstractFigure
Returns:
a Rectangle representing the receiver's bounds.

getDestinationIndex

protected int getDestinationIndex()
Answers the index of the destination, depending on the direction of the receiver.
Returns:
an integer representing the index of the destination.

getDestinationLocator

protected Locator getDestinationLocator()
Answers the Locator of the destination, depending on the direction of the receiver.
Returns:
the Locator of the destination.

getDirection

protected int getDirection()
Answers the direction of the receiver.
Returns:
the integer representing the direction (+1 or -1).

getHandles

public Handle[] getHandles()
Answer the handles associated with the receiver. A better way to do this would be with a Strategy... maybe next release.
Overrides:
getHandles in class AbstractShape
Returns:
an array containing the Handles associated with the receiver.

getPolygon

protected java.awt.Polygon getPolygon()
Answer the polygon that defines the arrow.
Returns:
the Polygon defining the arrow.

getSourceIndex

protected int getSourceIndex()
Answers the index of the source, depending on the direction of the receiver.
Returns:
an integer representing the index of the source.

getSourceLocator

protected Locator getSourceLocator()
Answers the Locator of the source, depending on the direction of the receiver.
Returns:
the Locator of the source.

locationChanged

public void locationChanged(java.beans.PropertyChangeEvent evt)
Update because the location of my line has changed.
Specified by:
locationChanged in interface RelatedLocationListener
Tags copied from interface: RelatedLocationListener
Parameters:
event - PropertyChangeEvent

paint

public void paint(java.awt.Graphics g)
Paints the Arrow.
Overrides:
paint in class AbstractFigure
Tags copied from class: AbstractFigure
Parameters:
g - the specified Graphics window

relationChanged

public void relationChanged(java.beans.PropertyChangeEvent event)
Update because the relation of my line has changed.
Specified by:
relationChanged in interface RelatedLocationListener
Tags copied from interface: RelatedLocationListener
Parameters:
event - PropertyChangeEvent

resetLocationCache

protected void resetLocationCache()
Flush caches with respect to determining location. This is a hook method. Subclasses may wish to override.
Overrides:
resetLocationCache in class AbstractFigure

shapeChanged

public void shapeChanged(java.beans.PropertyChangeEvent evt)
Update because the shape of my line has changed.
Specified by:
shapeChanged in interface RelatedLocationListener
Tags copied from interface: RelatedLocationListener
Parameters:
event - PropertyChangeEvent

sizeChanged

public void sizeChanged(java.beans.PropertyChangeEvent evt)
Update because the size of my line has changed.
Specified by:
sizeChanged in interface RelatedLocationListener
Tags copied from interface: RelatedLocationListener
Parameters:
event - PropertyChangeEvent

updateShape

protected void updateShape()
The line has notified the receiver of a change. Assume our location has changed due to some movement/reshaping of the line.