edu.neu.ccs
Class XLine2D

java.lang.Object
  extended byjava.awt.geom.Line2D
      extended byjava.awt.geom.Line2D.Double
          extended byedu.neu.ccs.XLine2D
All Implemented Interfaces:
Cloneable, JPTConstants, Serializable, Shape, Stringable, SwingConstants

public final class XLine2D
extends Line2D.Double
implements Serializable, Stringable, JPTConstants

Class XLine2D extends Line2D.Double in order to provide a much shorter name that does not explicitly refer to an inner class and to support Stringable.

Since:
2.4.0
Version:
2.4.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.geom.Line2D
Line2D.Double, Line2D.Float
 
Field Summary
private 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.
private static String[] X1Y1X2Y2
          The data array with names "x1", "y1", "x2", "y2".
 
Fields inherited from class java.awt.geom.Line2D.Double
x1, x2, y1, y2
 
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
XLine2D()
          Constructs a default XLine2D.
XLine2D(double x1, double y1, double x2, double y2)
          Constructs an XLine2D using the given double values.
XLine2D(Line2D line)
          Constructs an XLine2D using the given Line2D value.
XLine2D(Point2D p1, Point2D p2)
          Constructs an XLine2D using the given Point2D values.
XLine2D(String data)
          Constructs an XLine2D 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 of the line from the positive x-axis.
 double angleInRadians()
          Computes the angle in radians of the line from the positive x-axis.
 void fromStringData(String data)
          Defines the data state for this XLine2D object from a String representation of the data state.
 double length()
          Computes the length of the line, that is, the distance from x1,y1 to x2,y2.
 double lengthSq()
          Computes the length squared of the line, that is, the distance squared from x1,y1 to x2,y2.
 void move(double dx, double dy)
          Moves the line by a translation using the data in the point specified by coordinates.
 void move(Point2D p)
          Moves the line by a translation using the data in the point.
 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 setLine(double x1, double y1, double x2, double y2)
          Sets this line to the given values.
 void setLine(Line2D line)
          Sets this line to the given value.
 void setLine(Point2D p1, Point2D p2)
          Sets this line to the given values.
 void setValue(double x1, double y1, double x2, double y2)
          Sets this line to the given values.
 void setValue(Line2D line)
          Sets this line to the given value.
 void setValue(Point2D p1, Point2D p2)
          Sets this line to the given values.
 String toString()
          Returns a human readable String representing the data state of this XLine2D as an annotated string.
 String toStringData()
          Returns a human readable String representing the data state of this XLine2D as a simple string.
 
Methods inherited from class java.awt.geom.Line2D.Double
getBounds2D, getP1, getP2, getX1, getX2, getY1, getY2
 
Methods inherited from class java.awt.geom.Line2D
clone, contains, contains, contains, contains, getBounds, getPathIterator, getPathIterator, intersects, intersects, intersectsLine, intersectsLine, linesIntersect, ptLineDist, ptLineDist, ptLineDist, ptLineDistSq, ptLineDistSq, ptLineDistSq, ptSegDist, ptSegDist, ptSegDist, ptSegDistSq, ptSegDistSq, ptSegDistSq, relativeCCW, relativeCCW, relativeCCW
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BLANK

private static String[] BLANK
The data array with blank names "", "", "", "".


X1Y1X2Y2

private static String[] X1Y1X2Y2
The data array with names "x1", "y1", "x2", "y2".


standardMessage

public static final String standardMessage
The standard error message for fromStringData.

See Also:
Constant Field Values

changeAdapter

protected SwingPropertyChangeSupport changeAdapter
Helper object for property change API.

Constructor Detail

XLine2D

public XLine2D()
Constructs a default XLine2D.


XLine2D

public XLine2D(Line2D line)
Constructs an XLine2D using the given Line2D value.

Parameters:
line - the line to be copied

XLine2D

public XLine2D(Point2D p1,
               Point2D p2)
Constructs an XLine2D using the given Point2D values.

Parameters:
p1 - point 1
p2 - point 2

XLine2D

public XLine2D(double x1,
               double y1,
               double x2,
               double y2)
Constructs an XLine2D using the given double values.

Parameters:
x1 - the x-coordinate of point 1
y1 - the y-coordinate of point 1
x2 - the x-coordinate of point 2
y2 - the y-coordinate of point 2

XLine2D

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

Parameters:
data - String representation of the data state
Throws:
ParseException - if the data is malformed
Method Detail

toString

public String toString()

Returns a human readable String representing the data state of this XLine2D as an annotated string.

XLine2D[x1=...;y1=...;x2=...;y2=...]

where the dots stand for the x1,y1,x2,y2 coordinate data.


toStringData

public String toStringData()

Returns a human readable String representing the data state of this XLine2D as a simple string.

[...;...;...;...]

where the dots stand for the x1,y1,x2,y2 coordinate data.

Specified by:
toStringData in interface Stringable
See Also:
Stringable.fromStringData(String)

fromStringData

public void fromStringData(String data)
                    throws ParseException

Defines the data state for this XLine2D object from a String representation of the data state.

Fires property change VALUE.

Specified by:
fromStringData in interface Stringable
Parameters:
data - String representation of the data state
Throws:
ParseException - if the data is malformed
See Also:
Stringable.toStringData()

setValue

public void setValue(Line2D line)

Sets this line to the given value.

Fires property change VALUE.

Parameters:
line - the line to copy

setValue

public void setValue(Point2D p1,
                     Point2D p2)

Sets this line to the given values.

Fires property change VALUE.

Parameters:
p1 - point 1
p2 - point 2

setValue

public void setValue(double x1,
                     double y1,
                     double x2,
                     double y2)

Sets this line to the given values.

Fires property change VALUE.

Parameters:
x1 - the x-coordinate of point 1
y1 - the y-coordinate of point 1
x2 - the x-coordinate of point 2
y2 - the y-coordinate of point 2

setLine

public void setLine(Line2D line)

Sets this line to the given value.

Fires property change VALUE.

Parameters:
line - the line to copy

setLine

public void setLine(Point2D p1,
                    Point2D p2)

Sets this line to the given values.

Fires property change VALUE.

Parameters:
p1 - point 1
p2 - point 2

setLine

public void setLine(double x1,
                    double y1,
                    double x2,
                    double y2)

Sets this line to the given values.

Fires property change VALUE.

Parameters:
x1 - the x-coordinate of point 1
y1 - the y-coordinate of point 1
x2 - the x-coordinate of point 2
y2 - the y-coordinate of point 2

move

public void move(double dx,
                 double dy)

Moves the line by a translation using the data in the point specified by coordinates.

Parameters:
dx - the x-coordinate of the translation
dy - the y-coordinate of the translation

move

public void move(Point2D p)

Moves the line by a translation using the data in the point.

Parameters:
p - the translation vector

length

public double length()
Computes the length of the line, that is, the distance from x1,y1 to x2,y2.


lengthSq

public double lengthSq()
Computes the length squared of the line, that is, the distance squared from x1,y1 to x2,y2.


angleInRadians

public double angleInRadians()
Computes the angle in radians of the line from the positive x-axis.


angleInDegrees

public double angleInDegrees()
Computes the angle in degrees of the line from the positive x-axis.


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