Source of Edge.java


  1: import java.awt.Graphics2D;
  2: import java.awt.geom.Line2D;
  3: import java.awt.geom.Point2D;
  4: import java.awt.geom.Rectangle2D;
  5: import java.io.Serializable;

  7: /**
  8:    An edge in a graph.
  9: */
 10: public interface Edge extends Serializable, Cloneable
 11: {
 12:    /**
 13:       Draw the edge.
 14:       @param g2 the graphics context
 15:    */
 16:    void draw(Graphics2D g2);

 18:    /**
 19:       Tests whether the edge contains a point.
 20:       @param aPoint the point to test
 21:       @return true if this edge contains aPoint
 22:    */
 23:    boolean contains(Point2D aPoint);

 25:    /**
 26:       Connects this edge to two nodes.
 27:       @param aStart the starting node
 28:       @param anEnd the ending node
 29:    */
 30:    void connect(Node aStart, Node anEnd);

 32:    /**
 33:       Gets the starting node.
 34:       @return the starting node
 35:    */
 36:    Node getStart();

 38:    /**
 39:       Gets the ending node.
 40:       @return the ending node
 41:    */
 42:    Node getEnd();

 44:    /**
 45:       Gets the points at which this edge is connected to
 46:       its nodes.
 47:       @return a line joining the two connection points
 48:    */
 49:    Line2D getConnectionPoints();

 51:    /**
 52:       Gets the smallest rectangle that bounds this edge.
 53:       The bounding rectangle contains all labels.
 54:       @return the bounding rectangle
 55:    */
 56:    Rectangle2D getBounds(Graphics2D g2);

 58:    Object clone();
 59: }