|
||||||||||
| 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
edu.neu.ccs.XSquare
Class XSquare extends XRect
but requires that its location be specifed by its center
and its size be specified by the radius of the inscribed
circle. The side of the square is twice this radius and
is the value returned by either getWidth or
getHeight.
The design of this class makes it similar to the class
Circle.
Inherited methods that would permit the caller to make the width and height have different values are overridden to do nothing.
| 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. |
private double |
r
The radius. |
static String |
standardMessage
The standard error message for fromStringData. |
private static String[] |
XYR
The data array with names "xc", "yc", "r". |
| Fields inherited from class edu.neu.ccs.XRect |
|
| 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 | |
XSquare()
Constructs a new XSquare initialized to center (0, 0)
and radius 0. |
|
XSquare(double r)
Constructs a new XSquare initialized to center (0, 0)
and with the given inner radius: r = half-width. |
|
XSquare(double x,
double y,
double r)
Constructs and initializes a XSquare from the specified
double coordinates. |
|
XSquare(XSquare square)
Constructs and initializes a XSquare from the specified
XSquare 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. |
void |
fromStringData(String data)
Defines the data state for this XSquare object
from a String representation of the data state. |
double |
getRadius()
Returns the radius. |
void |
move(double dx,
double dy)
Moves the square by a translation using the data in the point specified by coordinates. |
void |
move(Point2D p)
Moves the square 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 |
setSquare(XSquare square)
Uses the data from the given square to set the parameters of this square. |
void |
setXYR(double xc,
double yc,
double r)
Sets the parameters of the XSquare with error checking. |
void |
setXYWH(double x,
double y,
double w,
double h)
Overrides the inherited method to do nothing since a square cannot have a distinct width and height. |
String |
toString()
Returns a human readable String representing
the data state of this XSquare as an annotated
string. |
String |
toStringData()
Returns a human readable String representing
the data state of this XSquare as a simple
string. |
| Methods inherited from class edu.neu.ccs.XRect |
createIntersectionRect, createUnionRect, setFrame, setFrame, setFrame, setRect, setRect, setX1Y1X2Y2, setXYRS, toStringAsX1Y1X2Y2, toStringAsXYRS |
| 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[] XYR
public static final String standardMessage
private double r
protected SwingPropertyChangeSupport changeAdapter
| Constructor Detail |
public XSquare()
XSquare initialized to center (0, 0)
and radius 0.
public XSquare(double x,
double y,
double r)
XSquare from the specified
double coordinates. Calls setXYR.
x - the proposed center x-coordinatey - the proposed center y-coordinater - the proposed inner radiuspublic XSquare(double r)
Constructs a new XSquare initialized to center (0, 0)
and with the given inner radius: r = half-width.
Calls setXYR
r - the proposed inner radius or half-widthpublic XSquare(XSquare square)
Constructs and initializes a XSquare from the specified
XSquare object. Calls setXYR indirectly.
Initializes to center (0, 0) and inner radius 0 if the given square
is null.
square - the XSquare object to copy| Method Detail |
public String toString()
Returns a human readable String representing
the data state of this XSquare as an annotated
string.
XSquare[xc=...;yc=...;r=...]
where the dots stand for the xc,yc center data and the radius r.
toString in class XRectpublic String toStringData()
Returns a human readable String representing
the data state of this XSquare as a simple
string.
[...;...;...]
where the dots stand for the xc,yc center data and the radius r.
toStringData in interface StringabletoStringData in class XRect
public void fromStringData(String data)
throws ParseException
Defines the data state for this XSquare object
from a String representation of the data state.
Fires property change VALUE.
fromStringData in interface StringablefromStringData in class XRectdata - String representation of the data state
ParseException - if the data is malformed
public void setXYR(double xc,
double yc,
double r)
Sets the parameters of the XSquare with error checking.
If the radius r is negative, it is replaced by its absolute value.
The square is then set up as a rectangle with center location xc,yc and common width and height equal to 2*r.
Fires property change VALUE.
xc - the proposed center x-coordinateyc - the proposed center y-coordinater - the proposed inner radiuspublic void setSquare(XSquare square)
Uses the data from the given square to set the parameters of this square.
Does nothing if the given square is null.
Fires property change VALUE.
square - the XSquare object to copypublic double getRadius()
public void setXYWH(double x,
double y,
double w,
double h)
Overrides the inherited method to do nothing since a square cannot have a distinct width and height.
The fact that this method does nothing implies that the following methods
inherited from XRect and other base classes also do nothing.
setXYRSsetX1Y1X2Y2setRectsetFramesetFrameFromCentersetFrameFromDiagonal
setXYWH in class XRectx - the proposed top-left x-coordinatey - the proposed top-left y-coordinatew - the proposed widthh - the proposed height
public void move(double dx,
double dy)
Moves the square by a translation using the data in the point specified by coordinates.
move in class XRectdx - the x-coordinate of the translationdy - the y-coordinate of the translationpublic void move(Point2D p)
Moves the square by a translation using the data in the point.
move in class XRectp - the translation vectorpublic void addPropertyChangeListener(PropertyChangeListener listener)
addPropertyChangeListener in class XRectlistener - the listener to be registered
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
addPropertyChangeListener in class XRectpropertyName - the name of the desired propertylistener - the listener to be registeredpublic void removePropertyChangeListener(PropertyChangeListener listener)
removePropertyChangeListener in class XRectlistener - the listener to be deregistered
public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
removePropertyChangeListener in class XRectpropertyName - 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 | |||||||||