Source of Node.java


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

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

 17:    /**
 18:       Translates the node by a given amount.
 19:       @param dx the amount to translate in the x-direction
 20:       @param dy the amount to translate in the y-direction
 21:    */
 22:    void translate(double dx, double dy);

 24:    /**
 25:       Tests whether the node contains a point.
 26:       @param aPoint the point to test
 27:       @return true if this node contains aPoint
 28:    */
 29:    boolean contains(Point2D aPoint);

 31:    /**
 32:       Get the best connection point to connect this node 
 33:       with another node. This should be a point on the boundary
 34:       of the shape of this node.
 35:       @param aPoint an exterior point that is to be joined
 36:       with this node
 37:       @return the recommended connection point
 38:    */
 39:    Point2D getConnectionPoint(Point2D aPoint);

 41:    /**
 42:       Get the bounding rectangle of the shape of this node
 43:       @return the bounding rectangle
 44:    */
 45:    Rectangle2D getBounds();

 47:    Object clone();
 48: }