001package horstmann.ch08_graphed2; 002import java.awt.Graphics2D; 003import java.awt.geom.Line2D; 004import java.awt.geom.Point2D; 005import java.awt.geom.Rectangle2D; 006import java.io.Serializable; 007 008/** 009 An edge in a graph. 010 */ 011public interface Edge extends Serializable, Cloneable 012{ 013 /** 014 Draw the edge. 015 @param g2 the graphics context 016 */ 017 void draw(Graphics2D g2); 018 019 /** 020 Tests whether the edge contains a point. 021 @param aPoint the point to test 022 @return true if this edge contains aPoint 023 */ 024 boolean contains(Point2D aPoint); 025 026 /** 027 Connects this edge to two nodes. 028 @param aStart the starting node 029 @param anEnd the ending node 030 */ 031 void connect(Node aStart, Node anEnd); 032 033 /** 034 Gets the starting node. 035 @return the starting node 036 */ 037 Node getStart(); 038 039 /** 040 Gets the ending node. 041 @return the ending node 042 */ 043 Node getEnd(); 044 045 /** 046 Gets the points at which this edge is connected to 047 its nodes. 048 @return a line joining the two connection points 049 */ 050 Line2D getConnectionPoints(); 051 052 /** 053 Gets the smallest rectangle that bounds this edge. 054 The bounding rectangle contains all labels. 055 @return the bounding rectangle 056 */ 057 Rectangle2D getBounds(Graphics2D g2); 058 059 Object clone(); 060} 061