001package horstmann.ch08_umleditor;
002import java.awt.Graphics2D;
003import java.awt.geom.Point2D;
004import java.awt.geom.Rectangle2D;
005import java.io.Serializable;
006
007/**
008   A node in a graph.
009 */
010public interface Node extends Serializable, Cloneable
011{
012        /**
013      Draw the node.
014      @param g2 the graphics context
015         */
016        void draw(Graphics2D g2);
017
018        /**
019      Translates the node by a given amount.
020      @param dx the amount to translate in the x-direction
021      @param dy the amount to translate in the y-direction
022         */
023        void translate(double dx, double dy);
024
025        /**
026      Tests whether the node contains a point.
027      @param aPoint the point to test
028      @return true if this node contains aPoint
029         */
030        boolean contains(Point2D aPoint);
031
032        /**
033      Get the best connection point to connect this node
034      with another node. This should be a point on the boundary
035      of the shape of this node.
036      @param aPoint an exterior point that is to be joined
037      with this node
038      @return the recommended connection point
039         */
040        Point2D getConnectionPoint(Point2D aPoint);
041
042        /**
043      Get the bounding rectangle of the shape of this node
044      @return the bounding rectangle
045         */
046        Rectangle2D getBounds();
047
048        Object clone();
049}