01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
package horstmann.ch08_graphed;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;

/**
   An edge that is shaped like a straight line.
 */
@SuppressWarnings("serial")
public class LineEdge extends AbstractEdge
{
  public void draw(Graphics2D g2)
  {
    g2.draw(getConnectionPoints());
  }

  public boolean contains(Point2D aPoint)
  {
    final double MAX_DIST = 2;
    return getConnectionPoints().ptSegDist(aPoint)
        < MAX_DIST;
  }
}