jimm.datavision
Class Point

java.lang.Object
  extended by java.util.Observable
      extended by jimm.datavision.Point
All Implemented Interfaces:
Writeable

public class Point
extends java.util.Observable
implements Writeable

A point with double coordinates.

Author:
Jim Menard, jimm@io.com

Field Summary
 double x
          Warning: though public, treat as read-only.
 double y
          Warning: though public, treat as read-only.
 
Constructor Summary
Point()
          Constructor.
Point(double x, double y)
          Constructor.
Point(java.awt.Point p)
          Constructor.
Point(Point p)
          Constructor.
 
Method Summary
 double distanceTo(Point p)
          Returns the distance from this point to another.
 double getX()
          Returns the x coordinate.
 double getY()
          Returns the y coordinate.
 void setX(double newX)
          Sets the x coordinate.
 void setY(double newY)
          Sets the y coordinate.
 java.lang.String toString()
          Returns a string representation of this point.
 void translate(double dx, double dy)
          Translates this point by the coordinates of another.
 void translate(java.awt.Point p)
          Translates this point by the coordinates of another.
 void translate(Point p)
          Translates this point by the coordinates of another.
 void writeXML(XMLWriter out)
          Writes this point as an XML tag.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
Warning: though public, treat as read-only. When writing, make sure to use setter method so observers are notified.


y

public double y
Warning: though public, treat as read-only. When writing, make sure to use setter method so observers are notified.

Constructor Detail

Point

public Point()
Constructor.


Point

public Point(java.awt.Point p)
Constructor.


Point

public Point(Point p)
Constructor.


Point

public Point(double x,
             double y)
Constructor.

Parameters:
x - a double
y - a double
Method Detail

getX

public double getX()
Returns the x coordinate.

Returns:
the doubleing-point x coordinate

setX

public void setX(double newX)
Sets the x coordinate.

Parameters:
newX - the new x coordinate

getY

public double getY()
Returns the y coordinate.

Returns:
the doubleing-point y coordinate

setY

public void setY(double newY)
Sets the y coordinate.

Parameters:
newY - the new y coordinate

translate

public void translate(java.awt.Point p)
Translates this point by the coordinates of another.


translate

public void translate(Point p)
Translates this point by the coordinates of another.


translate

public void translate(double dx,
                      double dy)
Translates this point by the coordinates of another.


distanceTo

public double distanceTo(Point p)
Returns the distance from this point to another.

Parameters:
p - the other point
Returns:
the distance between the two points

toString

public java.lang.String toString()
Returns a string representation of this point.

Overrides:
toString in class java.lang.Object
Returns:
a string representing this point

writeXML

public void writeXML(XMLWriter out)
Writes this point as an XML tag.

Specified by:
writeXML in interface Writeable
Parameters:
out - a writer that knows how to write XML