edu.neu.ccs
Class XPoint2D

java.lang.Object
  |
  +--java.awt.geom.Point2D
        |
        +--java.awt.geom.Point2D.Double
              |
              +--edu.neu.ccs.XPoint2D
All Implemented Interfaces:
Cloneable, Serializable, Stringable

public final class XPoint2D
extends Point2D.Double
implements Cloneable, Serializable, Stringable

Data model representing a point in graphics, containing a double x coordinate and a double y coordinate.

Since:
1.1
See Also:
Serialized Form

Field Summary
protected  SwingPropertyChangeSupport changeAdapter
          Helper object for property change API.
protected static String X_PROPERTY
          Bound property name for the x property.
protected static String Y_PROPERTY
          Bound property name for the y property.
 
Fields inherited from class java.awt.geom.Point2D.Double
x, y
 
Constructor Summary
XPoint2D()
          Constructs a wrapper for the default Point2D.Double value.
XPoint2D(double x, double y)
          Constructs a wrapper for the given double values.
XPoint2D(Point2D p)
          Constructs a wrapper for the given Point2D value.
XPoint2D(String data)
          Constructs an XPoint2D object from a String representation of the data state.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Registers the given object to listen for property change events generated by this object.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Registers the given object to listen for property change events generated by this object with the given property name.
 double angleInDegrees()
          Computes the angle in degrees measured counter-clockwise from the positive x-axis.
static double angleInDegrees(double x1, double y1, double x2, double y2)
          Computes the angle in degrees from the the point (x1,y1) to the point (x2,y2) measured counter-clockwise.
static double angleInDegrees(Point2D p, Point2D q)
          Computes the angle in degrees from the point p to the point q measured counter-clockwise.
 double angleInRadians()
          Computes the angle in radians measured counter-clockwise from the positive x-axis.
static double angleInRadians(double x1, double y1, double x2, double y2)
          Computes the angle in radians from the the point (x1,y1) to the point (x2,y2) measured counter-clockwise.
static double angleInRadians(Point2D p, Point2D q)
          Computes the angle in radians from the point p to the point q measured counter-clockwise.
static String[] decodeIntoPair(String data)
          Decode a pair of numeric strings encoded using a standard codec or encoded using the format [x;y] or the format (x,y).
 void fromStringData(String data)
          Extracts the data state for this XPoint2D object from a String representation of the data state.
 double radius()
          Computes the distance of the point to the origin.
 double radiusSq()
          Computes the distance squared of the point to the origin.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Deregisters the given object from listening for property change events generated by this object.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Deregisters the given object from listening for property change events generated by this object with the given property name.
 void setValue(double newX, double newY)
          Sets the values wrapped by this object to the given values.
 void setValue(Point2D p)
          Sets the value wrapped by this object to the given value.
 String toString()
          Returns a human readable String representing the data state of this XPoint2D as [x;y].
 String toStringData()
          Returns a String representation of the data state for this XPoint2D object.
 
Methods inherited from class java.awt.geom.Point2D.Double
getX, getY, setLocation
 
Methods inherited from class java.awt.geom.Point2D
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, equals, hashCode, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

X_PROPERTY

protected static final String X_PROPERTY
Bound property name for the x property.

See Also:
Constant Field Values

Y_PROPERTY

protected static final String Y_PROPERTY
Bound property name for the y property.

See Also:
Constant Field Values

changeAdapter

protected SwingPropertyChangeSupport changeAdapter
Helper object for property change API.

Constructor Detail

XPoint2D

public XPoint2D()
Constructs a wrapper for the default Point2D.Double value.

See Also:
XPoint2D(Point2D), XPoint2D(double, double), XPoint2D(String)

XPoint2D

public XPoint2D(Point2D p)
Constructs a wrapper for the given Point2D value.

Parameters:
p - the value to be wrapped
See Also:
XPoint2D(), XPoint2D(double, double), XPoint2D(String), setValue(Point2D)

XPoint2D

public XPoint2D(double x,
                double y)
Constructs a wrapper for the given double values.

Parameters:
x - the x value to be wrapped
y - the y value to be wrapped
See Also:
XPoint2D(), XPoint2D(Point2D), XPoint2D(String), setValue(double, double)

XPoint2D

public XPoint2D(String data)
         throws ParseException
Constructs an XPoint2D object from a String representation of the data state.

Parameters:
data - String representation of the desired value
Throws:
ParseException - if the data is malformed
See Also:
XPoint2D(), XPoint2D(double, double), XPoint2D(Point2D), toStringData(), fromStringData(String), toString()
Method Detail

toStringData

public String toStringData()
Returns a String representation of the data state for this XPoint2D object.

Specified by:
toStringData in interface Stringable
See Also:
XPoint2D(String), fromStringData(String), toString()

fromStringData

public void fromStringData(String data)
                    throws ParseException
Extracts the data state for this XPoint2D object from a String representation of the data state.

Specified by:
fromStringData in interface Stringable
Parameters:
data - String representation of the desired value
Throws:
ParseException - if the data is malformed
See Also:
XPoint2D(String), toStringData(), toString(), decodeIntoPair(String), setValue(double, double)

toString

public String toString()
Returns a human readable String representing the data state of this XPoint2D as [x;y].

Overrides:
toString in class Point2D.Double
See Also:
XPoint2D(String), toStringData(), fromStringData(String)

decodeIntoPair

public static String[] decodeIntoPair(String data)
                               throws ParseException
Decode a pair of numeric strings encoded using a standard codec or encoded using the format [x;y] or the format (x,y).

Parameters:
data - the String to decode into a String pair
ParseException
See Also:
fromStringData(String)

setValue

public void setValue(Point2D p)
Sets the value wrapped by this object to the given value.

Parameters:
p - the value to be wrapped
See Also:
setValue(double, double)

setValue

public void setValue(double newX,
                     double newY)
Sets the values wrapped by this object to the given values.

Parameters:
newX - the x coordinate
newY - the y coordinate
See Also:
setValue(Point2D)

radius

public double radius()
Computes the distance of the point to the origin.

See Also:
radiusSq()

radiusSq

public double radiusSq()
Computes the distance squared of the point to the origin.

See Also:
radius()

angleInRadians

public double angleInRadians()
Computes the angle in radians measured counter-clockwise from the positive x-axis.

See Also:
angleInDegrees()

angleInDegrees

public double angleInDegrees()
Computes the angle in degrees measured counter-clockwise from the positive x-axis.

See Also:
angleInRadians()

angleInRadians

public static double angleInRadians(Point2D p,
                                    Point2D q)
Computes the angle in radians from the point p to the point q measured counter-clockwise.

Parameters:
p - point to start angle measurement
q - point to finish angle measurement
See Also:
angleInRadians(double, double, double, double), angleInDegrees(Point2D, Point2D)

angleInRadians

public static double angleInRadians(double x1,
                                    double y1,
                                    double x2,
                                    double y2)
Computes the angle in radians from the the point (x1,y1) to the point (x2,y2) measured counter-clockwise.

Parameters:
x1 - x-coordinate of point to start angle measurement
y1 - y-coordinate of point to start angle measurement
x2 - x-coordinate of point to finish angle measurement
y2 - y-coordinate of point to finish angle measurement
See Also:
angleInRadians(Point2D, Point2D), angleInDegrees(double, double, double, double)

angleInDegrees

public static double angleInDegrees(Point2D p,
                                    Point2D q)
Computes the angle in degrees from the point p to the point q measured counter-clockwise.

Parameters:
p - point to start angle measurement
q - point to finish angle measurement
See Also:
angleInDegrees(double, double, double, double), angleInRadians(Point2D, Point2D)

angleInDegrees

public static double angleInDegrees(double x1,
                                    double y1,
                                    double x2,
                                    double y2)
Computes the angle in degrees from the the point (x1,y1) to the point (x2,y2) measured counter-clockwise.

Parameters:
x1 - x-coordinate of point to start angle measurement
y1 - y-coordinate of point to start angle measurement
x2 - x-coordinate of point to finish angle measurement
y2 - y-coordinate of point to finish angle measurement
See Also:
angleInDegrees(Point2D, Point2D), angleInRadians(double, double, double, double)

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Registers the given object to listen for property change events generated by this object.

Parameters:
listener - the listener to be registered

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Registers the given object to listen for property change events generated by this object with the given property name.

Parameters:
propertyName - the name of the desired property
listener - the listener to be registered

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Deregisters the given object from listening for property change events generated by this object.

Parameters:
listener - the listener to be deregistered

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Deregisters the given object from listening for property change events generated by this object with the given property name.

Parameters:
propertyName - the name of the desired property
listener - the listener to be deregistered