1 import java.awt.*;
2 import java.awt.geom.*;
3 import java.io.*;
4
5 /**
6 A node in a graph.
7 */
8 public interface Node extends Serializable, Cloneable
9 {
10 /**
11 Draw the node.
12 @param g2 the graphics context
13 */
14 void draw(Graphics2D g2);
15
16 /**
17 Translates the node by a given amount.
18 @param dx the amount to translate in the x-direction
19 @param dy the amount to translate in the y-direction
20 */
21 void translate(double dx, double dy);
22
23 /**
24 Tests whether the node contains a point.
25 @param aPoint the point to test
26 @return true if this node contains aPoint
27 */
28 boolean contains(Point2D aPoint);
29
30 /**
31 Get the best connection point to connect this node
32 with another node. This should be a point on the boundary
33 of the shape of this node.
34 @param aPoint an exterior point that is to be joined
35 with this node
36 @return the recommended connection point
37 */
38 Point2D getConnectionPoint(Point2D aPoint);
39
40 /**
41 Get the bounding rectangle of the shape of this node
42 @return the bounding rectangle
43 */
44 Rectangle2D getBounds();
45
46 Object clone();
47 }