|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.geom.Point2D
java.awt.geom.Point2D.Double
edu.neu.ccs.XPoint2D
Class XPoint2D extends Point2D.Double in
order to provide a much shorter name that does not explicitly refer
to an inner class and to support Stringable.
As of 2.5.0, added the isFinite methods.
| Nested Class Summary |
| Nested classes inherited from class java.awt.geom.Point2D |
Point2D.Double, Point2D.Float |
| Field Summary | |
static String[] |
BLANK
The data array with blank names "", "". |
protected SwingPropertyChangeSupport |
changeAdapter
Helper object for property change API. |
static String |
standardMessage
The standard error message for fromStringData. |
static String[] |
XY
The data array with names "x", "y". |
| Fields inherited from class java.awt.geom.Point2D.Double |
x, y |
| Fields inherited from interface edu.neu.ccs.util.JPTConstants |
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE |
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Constructor Summary | |
XPoint2D()
Constructs a default XPoint2D. |
|
XPoint2D(double[] data)
Constructs an XPoint2D using the pair of values
in the given array of double which must be of
size 2. |
|
XPoint2D(double x,
double y)
Constructs an XPoint2D using the given
x,y double values. |
|
XPoint2D(float[] data)
Constructs an XPoint2D using the pair of values
in the given array of float which must be of
size 2. |
|
XPoint2D(Point2D p)
Constructs an XPoint2D using a copy of
the data in the given Point2D. |
|
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 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). |
static double |
angleInDegrees(Point2D p,
Point2D q)
Computes the angle in degrees from the point p to the point q. |
double |
angleInRadians()
Computes the angle in radians 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). |
static double |
angleInRadians(Point2D p,
Point2D q)
Computes the angle in radians from the point p to the point q. |
void |
fromStringData(String data)
Defines the data state for this XPoint2D object
from a String representation of the data state. |
boolean |
isFinite()
Returns true if both coordinates of this XPoint2D are finite and false otherwise. |
static boolean |
isFinite(Point2D p)
Returns true if both coordinates of the given Point2D are finite and false otherwise. |
void |
move(double dx,
double dy)
Moves the point by a translation using the data in the point specified by coordinates. |
void |
move(Point2D p)
Moves the point by a translation using the data in the point. |
double |
radius()
Computes the distance of the point to the origin, that is sqrt(x*x+y*y). |
double |
radiusSq()
Computes the distance squared of the point to the origin, that is, x*x+y*y. |
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 |
setLocation(double[] data)
Sets this point using the pair of values in the given array of double which must be of size 2. |
void |
setLocation(double x,
double y)
Sets this point to the given x,y values. |
void |
setLocation(float[] data)
Sets this point using the pair of values in the given array of float which must be of size 2. |
void |
setLocation(Point2D p)
Sets this point to the value of the given point. |
void |
setValue(double[] data)
Sets this point using the pair of values in the given array of double which must be of size 2. |
void |
setValue(double x,
double y)
Sets this point to the given x,y values. |
void |
setValue(float[] data)
Sets this point using the pair of values in the given array of float which must be of size 2. |
void |
setValue(Point2D p)
Sets this point to the value of the given point. |
double[] |
toDoubleArray()
Returns the x,y data in an array of double
of size 2. |
float[] |
toFloatArray()
Returns the x,y data in an array of float
of size 2. |
String |
toString()
Returns a human readable String representing
the data state of this XPoint2D as an annotated
string. |
String |
toStringData()
Returns a human readable String representing
the data state of this XPoint2D as a simple
string. |
| Methods inherited from class java.awt.geom.Point2D.Double |
getX, getY |
| Methods inherited from class java.awt.geom.Point2D |
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, equals, hashCode |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final String[] BLANK
public static final String[] XY
public static final String standardMessage
protected SwingPropertyChangeSupport changeAdapter
| Constructor Detail |
public XPoint2D()
XPoint2D.
public XPoint2D(double x,
double y)
XPoint2D using the given
x,y double values.
x - the x-coordinate of the pointy - the y-coordinate of the pointpublic XPoint2D(Point2D p)
Constructs an XPoint2D using a copy of
the data in the given Point2D.
If the given point is null,
then initializes this point to 0,0.
p - the existing point whose data will be copiedpublic XPoint2D(double[] data)
XPoint2D using the pair of values
in the given array of double which must be of
size 2.
If the given array is null or not of size 2,
then initializes this point to 0,0.
data - the array of size 2 with the x,y datapublic XPoint2D(float[] data)
XPoint2D using the pair of values
in the given array of float which must be of
size 2.
If the given array is null or not of size 2,
then initializes this point to 0,0.
data - the array of size 2 with the x,y data
public XPoint2D(String data)
throws ParseException
XPoint2D object from
a String representation of the data state.
data - String representation of the data state
ParseException - if the data is malformed| Method Detail |
public String toString()
Returns a human readable String representing
the data state of this XPoint2D as an annotated
string.
XPoint2D[x=...;y=...]
where the dots stand for the x,y coordinate data.
public String toStringData()
Returns a human readable String representing
the data state of this XPoint2D as a simple
string.
[...;...]
where the dots stand for the x,y coordinate data.
toStringData in interface StringableStringable.fromStringData(String)
public void fromStringData(String data)
throws ParseException
Defines the data state for this XPoint2D object
from a String representation of the data state.
Fires property change VALUE.
fromStringData in interface Stringabledata - String representation of the data state
ParseException - if the data is malformedStringable.toStringData()
public void setValue(double x,
double y)
Sets this point to the given x,y values.
Fires property change VALUE.
x - the x-coordinate of the pointy - the y-coordinate of the pointpublic void setValue(Point2D p)
Sets this point to the value of the given point.
If the given point is null, then does nothing.
Fires property change VALUE.
p - the existing point whose data will be copiedpublic void setValue(double[] data)
Sets this point using the pair of values in the given array
of double which must be of size 2.
If the given array is null or not of size 2,
then does nothing.
Fires property change VALUE.
data - the array of size 2 with the x,y datapublic void setValue(float[] data)
Sets this point using the pair of values in the given array
of float which must be of size 2.
If the given array is null or not of size 2,
then does nothing.
Fires property change VALUE.
data - the array of size 2 with the x,y data
public void setLocation(double x,
double y)
Sets this point to the given x,y values.
Fires property change VALUE.
Equivalent to setValue.
x - the x-coordinatey - the y-coordinatepublic void setLocation(Point2D p)
Sets this point to the value of the given point.
If the given point is null, then does nothing.
Fires property change VALUE.
p - the existing point whose data will be copiedpublic void setLocation(double[] data)
Sets this point using the pair of values in the given array
of double which must be of size 2.
If the given array is null or not of size 2,
then does nothing.
Fires property change VALUE.
data - the array of size 2 with the x,y datapublic void setLocation(float[] data)
Sets this point using the pair of values in the given array
of float which must be of size 2.
If the given array is null or not of size 2,
then does nothing.
Fires property change VALUE.
data - the array of size 2 with the x,y data
public void move(double dx,
double dy)
Moves the point by a translation using the data in the point specified by coordinates.
Fires property change VALUE.
dx - the x-coordinate of the translationdy - the y-coordinate of the translationpublic void move(Point2D p)
Moves the point by a translation using the data in the point.
If the given point is null, then does nothing.
Fires property change VALUE.
p - the translation vectorpublic double[] toDoubleArray()
Returns the x,y data in an array of double
of size 2.
public float[] toFloatArray()
Returns the x,y data in an array of float
of size 2.
public double radius()
sqrt(x*x+y*y).
public double radiusSq()
x*x+y*y.
public double angleInRadians()
public static double angleInRadians(Point2D p,
Point2D q)
p - point to start angle measurementq - point to finish angle measurement
public static double angleInRadians(double x1,
double y1,
double x2,
double y2)
x1 - x-coordinate of point to start angle measurementy1 - y-coordinate of point to start angle measurementx2 - x-coordinate of point to finish angle measurementy2 - y-coordinate of point to finish angle measurementpublic double angleInDegrees()
public static double angleInDegrees(Point2D p,
Point2D q)
p - point to start angle measurementq - point to finish angle measurement
public static double angleInDegrees(double x1,
double y1,
double x2,
double y2)
x1 - x-coordinate of point to start angle measurementy1 - y-coordinate of point to start angle measurementx2 - x-coordinate of point to finish angle measurementy2 - y-coordinate of point to finish angle measurementpublic void addPropertyChangeListener(PropertyChangeListener listener)
listener - the listener to be registered
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
propertyName - the name of the desired propertylistener - the listener to be registeredpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener - the listener to be deregistered
public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
propertyName - the name of the desired propertylistener - the listener to be deregisteredpublic boolean isFinite()
public static boolean isFinite(Point2D p)
Returns true if both coordinates of the given Point2D are finite and false otherwise.
In particular, returns false if the given Point2D is
null.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||