01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package horstmann.ch08_graphed;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;

/**
   An edge in a graph.
 */
public interface Edge extends Serializable, Cloneable
{
  /**
      Draw the edge.
      @param g2 the graphics context
   */
  void draw(Graphics2D g2);

  /**
      Tests whether the edge contains a point.
      @param aPoint the point to test
      @return true if this edge contains aPoint
   */
  boolean contains(Point2D aPoint);

  /**
      Connects this edge to two nodes.
      @param aStart the starting node
      @param anEnd the ending node
   */
  void connect(Node aStart, Node anEnd);

  /**
      Gets the starting node.
      @return the starting node
   */
  Node getStart();

  /**
      Gets the ending node.
      @return the ending node
   */
  Node getEnd();

  /**
      Gets the points at which this edge is connected to
      its nodes.
      @return a line joining the two connection points
   */
  Line2D getConnectionPoints();

  /**
      Gets the smallest rectangle that bounds this edge.
      The bounding rectangle contains all labels.
      @return the bounding rectangle
   */
  Rectangle2D getBounds(Graphics2D g2);

  Object clone();
}