|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.geom.RectangularShape
java.awt.geom.Rectangle2D
java.awt.geom.Rectangle2D.Double
edu.neu.ccs.XRect
Class XRect extends Rectangle2D.Double in
order to provide a much shorter name that does not explicitly refer to
an inner class, to add error checking that prevents the width and
height from being set to negative values,
and to support Stringable.
| Nested Class Summary |
| Nested classes inherited from class java.awt.geom.Rectangle2D |
Rectangle2D.Double, Rectangle2D.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". |
private static String[] |
XYRS
The data array with names "xc", "yc", "r", "s". |
private static String[] |
XYWH
The data array with names "x", "y", "w", "h". |
| Fields inherited from class java.awt.geom.Rectangle2D.Double |
height, width, x, y |
| Fields inherited from class java.awt.geom.Rectangle2D |
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP |
| 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 | |
XRect()
Constructs a new XRect initialized to location (0, 0)
and size (0, 0). |
|
XRect(double r,
double s)
Constructs a new XRect initialized to center (0, 0)
and with the given radii: r = half-width and s = half-height. |
|
XRect(double x,
double y,
double w,
double h)
Constructs and initializes a XRect from the specified
double coordinates. |
|
XRect(Rectangle2D rect)
Constructs and initializes a XRect from the specified
Rectangle2D object. |
|
| 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. |
XRect |
createIntersectionRect(Rectangle2D rect)
Mimics the inherited method createIntersection
but makes the return type XRect. |
XRect |
createUnionRect(Rectangle2D rect)
Mimics the inherited method createUnion
but makes the return type XRect. |
void |
fromStringData(String data)
Defines the data state for this XRect object
from a String representation of the data state. |
void |
move(double dx,
double dy)
Moves the rectangle by a translation using the data in the point specified by coordinates. |
void |
move(Point2D p)
Moves the rectangle 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 |
setFrame(double x,
double y,
double w,
double h)
Overrides the corresponding inherited method to use the method setXYWH. |
void |
setFrame(Point2D point,
Dimension2D dimension)
Overrides the corresponding inherited method to use the method setXYWH. |
void |
setFrame(Rectangle2D rect)
Overrides the corresponding inherited method to use the method setXYWH. |
void |
setRect(double x,
double y,
double w,
double h)
Overrides the corresponding inherited method to use the method setXYWH. |
void |
setRect(Rectangle2D rect)
Overrides the corresponding inherited method to use the method setXYWH. |
void |
setX1Y1X2Y2(double x1,
double y1,
double x2,
double y2)
Sets the parameters of the XRect with error checking
using the coordinates of any pair of opposite corners. |
void |
setXYRS(double x,
double y,
double r,
double s)
Sets the parameters of the XRect with error checking
using the center (x,y) and the inner radii: r = half-width and
s = half-height. |
void |
setXYWH(double x,
double y,
double w,
double h)
Sets the parameters of the XRect with error checking. |
String |
toString()
Returns a human readable String representing
the data state of this XRect as an annotated
string. |
String |
toStringAsX1Y1X2Y2()
Returns a human readable String representing
the data state of this XRect as an annotated
string. |
String |
toStringAsXYRS()
Returns a human readable String representing
the data state of this XRect as an annotated
string. |
String |
toStringData()
Returns a human readable String representing
the data state of this XRect as a simple
string. |
| Methods inherited from class java.awt.geom.Rectangle2D.Double |
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode |
| Methods inherited from class java.awt.geom.Rectangle2D |
add, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, union |
| Methods inherited from class java.awt.geom.RectangularShape |
clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
private static String[] BLANK
private static String[] XYWH
private static String[] XYRS
private static String[] X1Y1X2Y2
public static final String standardMessage
protected SwingPropertyChangeSupport changeAdapter
| Constructor Detail |
public XRect()
XRect initialized to location (0, 0)
and size (0, 0).
public XRect(double x,
double y,
double w,
double h)
XRect from the specified
double coordinates. Calls setXYWH.
x - the proposed top-left x-coordinatey - the proposed top-left y-coordinatew - the proposed widthh - the proposed heightpublic XRect(Rectangle2D rect)
Constructs and initializes a XRect from the specified
Rectangle2D object. Calls setXYWH.
Initializes to location (0, 0) and size (0, 0) if the given rect
is null.
rect - the Rectangle2D object to copy
public XRect(double r,
double s)
Constructs a new XRect initialized to center (0, 0)
and with the given radii: r = half-width and s = half-height.
Calls setXYRS
r - the proposed x-radius or half-widths - the proposed y-radius or half-height| Method Detail |
public String toString()
Returns a human readable String representing
the data state of this XRect as an annotated
string.
XRect[x=...;y=...;w=...;h=...]
where the dots stand for the x,y corner data and the w,h dimension data.
public String toStringAsXYRS()
Returns a human readable String representing
the data state of this XRect as an annotated
string.
XRect[xc=...;yc=...;r=...;s=...]
where the dots stand for the xc,yc center data and the r,s radius data.
public String toStringAsX1Y1X2Y2()
Returns a human readable String representing
the data state of this XRect as an annotated
string.
XRect[x1=...;y1=...;x2=...;y2=...]
where the dots stand for the x1,y1,x2,y2 corner data.
public String toStringData()
Returns a human readable String representing
the data state of this XRect as a simple
string.
[...;...;...;...]
where the dots stand for the x,y corner data and the w,h dimension data.
toStringData in interface StringableStringable.fromStringData(String)
public void fromStringData(String data)
throws ParseException
Defines the data state for this XRect 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 setXYWH(double x,
double y,
double w,
double h)
Sets the parameters of the XRect with error checking.
If the width w is negative, then w is replaced by its absolute value and then x is replaced by (x - w).
If the height h is negative, then h is replaced by its absolute value and then y is replaced by (y - h).
This method guarantees that the internal width and height are always greater than or equal to zero.
Fires property change VALUE.
x - the proposed top-left x-coordinatey - the proposed top-left y-coordinatew - the proposed widthh - the proposed height
public void setXYRS(double x,
double y,
double r,
double s)
Sets the parameters of the XRect with error checking
using the center (x,y) and the inner radii: r = half-width and
s = half-height.
If the radius r is negative, then r is replaced by its absolute value.
If the radius s is negative, then s is replaced by its absolute value.
This method guarantees that the internal width and height are always greater than or equal to zero.
Fires property change VALUE.
x - the proposed center x-coordinatey - the proposed center y-coordinater - the proposed x-radius or half-widths - the proposed y-radius or half-height
public void setX1Y1X2Y2(double x1,
double y1,
double x2,
double y2)
Sets the parameters of the XRect with error checking
using the coordinates of any pair of opposite corners.
Fires property change VALUE.
x1 - the x-coordinate of one cornery1 - the y-coordinate of one cornerx2 - the x-coordinate of the opposite cornery2 - the y-coordinate of the opposite corner
public void setFrame(double x,
double y,
double w,
double h)
Overrides the corresponding inherited method to use the method
setXYWH.
Fires property change VALUE.
x - the proposed top-left x-coordinatey - the proposed top-left y-coordinatew - the proposed widthh - the proposed heightpublic void setFrame(Rectangle2D rect)
Overrides the corresponding inherited method to use the method
setXYWH.
Does nothing if the given rect is null.
Fires property change VALUE.
rect - the Rectangle2D object to copy
public void setFrame(Point2D point,
Dimension2D dimension)
Overrides the corresponding inherited method to use the method
setXYWH.
Does nothing if the given point or dimension is null.
Fires property change VALUE.
point - the top-left cornerdimension - the dimension with the width and height
public void setRect(double x,
double y,
double w,
double h)
Overrides the corresponding inherited method to use the method
setXYWH.
Fires property change VALUE.
x - the proposed top-left x-coordinatey - the proposed top-left y-coordinatew - the proposed widthh - the proposed heightpublic void setRect(Rectangle2D rect)
Overrides the corresponding inherited method to use the method
setXYWH.
Does nothing if the given rect is null.
Fires property change VALUE.
rect - the Rectangle2D object to copy
public void move(double dx,
double dy)
Moves the rectangle by a translation using the data in the point specified by coordinates.
dx - the x-coordinate of the translationdy - the y-coordinate of the translationpublic void move(Point2D p)
Moves the rectangle by a translation using the data in the point.
p - the translation vectorpublic XRect createIntersectionRect(Rectangle2D rect)
Mimics the inherited method createIntersection
but makes the return type XRect.
rect - the rectangle to intersect with this rectangle
public XRect createUnionRect(Rectangle2D rect)
Mimics the inherited method createUnion
but makes the return type XRect.
rect - the rectangle to union with this rectangle
public 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 deregistered
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||