Source of PointNode.java


  1: import java.awt.*;
  2: import java.awt.geom.*;

  4: /**
  5:    An inivisible node that is used in the toolbar to draw an
  6:    edge.
  7: */
  8: public class PointNode implements Node
  9: {
 10:    /**
 11:       Constructs a point node with coordinates (0, 0)
 12:    */
 13:    public PointNode()
 14:    {
 15:       point = new Point2D.Double();
 16:    }

 18:    public void draw(Graphics2D g2)
 19:    {
 20:    }

 22:    public void translate(double dx, double dy)
 23:    {
 24:       point.setLocation(point.getX() + dx,
 25:          point.getY() + dy);
 26:    }

 28:    public boolean contains(Point2D p)
 29:    {
 30:       return false;
 31:    }

 33:    public Rectangle2D getBounds()
 34:    {
 35:       return new Rectangle2D.Double(point.getX(), 
 36:          point.getY(), 0, 0);
 37:    }

 39:    public Point2D getConnectionPoint(Point2D other)
 40:    {
 41:       return point;
 42:    }

 44:    public Object clone()
 45:    {
 46:       try
 47:       {
 48:          return super.clone();
 49:       }
 50:       catch (CloneNotSupportedException exception)
 51:       {
 52:          return null;
 53:       }
 54:    }

 56:    private Point2D point;
 57: }