001package horstmann.ch08_graphed; 002import java.awt.Graphics2D; 003import java.awt.geom.Point2D; 004import java.awt.geom.Rectangle2D; 005 006/** 007 An inivisible node that is used in the toolbar to draw an 008 edge. 009 */ 010@SuppressWarnings("serial") 011public class PointNode implements Node 012{ 013 /** 014 Constructs a point node with coordinates (0, 0) 015 */ 016 public PointNode() 017 { 018 point = new Point2D.Double(); 019 } 020 021 public void draw(Graphics2D g2) 022 { 023 } 024 025 public void translate(double dx, double dy) 026 { 027 point.setLocation(point.getX() + dx, 028 point.getY() + dy); 029 } 030 031 public boolean contains(Point2D p) 032 { 033 return false; 034 } 035 036 public Rectangle2D getBounds() 037 { 038 return new Rectangle2D.Double(point.getX(), 039 point.getY(), 0, 0); 040 } 041 042 public Point2D getConnectionPoint(Point2D other) 043 { 044 return point; 045 } 046 047 public Object clone() 048 { 049 try 050 { 051 return super.clone(); 052 } 053 catch (CloneNotSupportedException exception) 054 { 055 return null; 056 } 057 } 058 059 private Point2D point; 060}