com.horstmann.violet.framework
Class ShapeEdge

java.lang.Object
  extended by com.horstmann.violet.framework.ShapeEdge
All Implemented Interfaces:
Edge, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
NoteEdge, ObjectReferenceEdge, SegmentedLineEdge, StateTransitionEdge

public abstract class ShapeEdge
extends java.lang.Object

A class that assumes that an edge can yield its shape and then takes advantage of the fact that containment testing can be done by stroking the shape with a fat stroke. NOTE: Ideally, you should be able to draw the same shape that is used for containment testing. However, in JDK 1.4, BasicStroke.createStrokedShape returns shitty-looking shapes.

See Also:
Serialized Form

Constructor Summary
ShapeEdge()
           
 
Method Summary
 java.lang.Object clone()
           
 void connect(Node s, Node e)
          Connect this edge to two nodes.
 boolean contains(java.awt.geom.Point2D aPoint)
          Tests whether the edge contains a point.
 java.awt.geom.Rectangle2D getBounds(java.awt.Graphics2D g2)
          Gets the smallest rectangle that bounds this edge.
 java.awt.geom.Line2D getConnectionPoints()
          Gets the points at which this edge is connected to its nodes.
 Node getEnd()
          Gets the ending node.
abstract  java.awt.Shape getShape()
          Returns the path that should be stroked to draw this edge.
 Node getStart()
          Gets the starting node.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.horstmann.violet.framework.Edge
draw
 

Constructor Detail

ShapeEdge

public ShapeEdge()
Method Detail

getShape

public abstract java.awt.Shape getShape()
Returns the path that should be stroked to draw this edge. The path does not include arrow tips or labels.

Returns:
a path along the edge

getBounds

public java.awt.geom.Rectangle2D getBounds(java.awt.Graphics2D g2)
Description copied from interface: Edge
Gets the smallest rectangle that bounds this edge. The bounding rectangle contains all labels.

Specified by:
getBounds in interface Edge
Returns:
the bounding rectangle

contains

public boolean contains(java.awt.geom.Point2D aPoint)
Description copied from interface: Edge
Tests whether the edge contains a point.

Parameters:
aPoint - the point to test
Returns:
true if this edge contains aPoint

clone

public java.lang.Object clone()
Specified by:
clone in interface Edge
Overrides:
clone in class java.lang.Object

connect

public void connect(Node s,
                    Node e)
Description copied from interface: Edge
Connect this edge to two nodes.

Specified by:
connect in interface Edge
Parameters:
s - the starting node
e - the ending node

getStart

public Node getStart()
Description copied from interface: Edge
Gets the starting node.

Specified by:
getStart in interface Edge
Returns:
the starting node

getEnd

public Node getEnd()
Description copied from interface: Edge
Gets the ending node.

Specified by:
getEnd in interface Edge
Returns:
the ending node

getConnectionPoints

public java.awt.geom.Line2D getConnectionPoints()
Description copied from interface: Edge
Gets the points at which this edge is connected to its nodes.

Specified by:
getConnectionPoints in interface Edge
Returns:
a line joining the two connection points