|
||||||||||
| 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.Ellipse2D
java.awt.geom.Ellipse2D.Double
edu.neu.ccs.XOval
edu.neu.ccs.XCircle
Class XCircle extends XOval
but requires that its location be specifed by its center
and its size be specified by its radius. The diameter
of the circle is twice the radius and is the value
returned by either getWidth or
getHeight.
The design of this class makes it similar to the class
Square.
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.Ellipse2D |
Ellipse2D.Double, Ellipse2D.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.XOval |
|
| Fields inherited from class java.awt.geom.Ellipse2D.Double |
height, width, 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 | |
XCircle()
Constructs a new XCircle initialized to center (0, 0)
and radius 0. |
|
XCircle(double r)
Constructs a new XCircle initialized to center (0, 0)
and with the given radius r. |
|
XCircle(double x,
double y,
double r)
Constructs and initializes a XCircle from the specified
double coordinates. |
|
XCircle(XCircle circle)
Constructs and initializes a XCircle from the specified
XCircle 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 XCircle object
from a String representation of the data state. |
double |
getRadius()
Returns the radius. |
void |
move(double dx,
double dy)
Moves the circle by a translation using the data in the point specified by coordinates. |
void |
move(Point2D p)
Moves the circle 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 |
setCircle(XCircle circle)
Uses the data from the given circle to set the parameters of this circle. |
void |
setXYR(double xc,
double yc,
double r)
Sets the parameters of the XCircle with error checking. |
void |
setXYWH(double x,
double y,
double w,
double h)
Overrides the inherited method to do nothing since a circle cannot have a distinct width and height. |
String |
toString()
Returns a human readable String representing
the data state of this XCircle as an annotated
string. |
String |
toStringData()
Returns a human readable String representing
the data state of this XCircle as a simple
string. |
| Methods inherited from class edu.neu.ccs.XOval |
setFrame, setFrame, setFrame, setOval, setX1Y1X2Y2, setXYRS, toStringAsX1Y1X2Y2, toStringAsXYRS |
| Methods inherited from class java.awt.geom.Ellipse2D.Double |
getBounds2D, getHeight, getWidth, getX, getY, isEmpty |
| Methods inherited from class java.awt.geom.Ellipse2D |
contains, contains, getPathIterator, intersects |
| Methods inherited from class java.awt.geom.RectangularShape |
clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, getPathIterator, intersects, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, 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 XCircle()
XCircle initialized to center (0, 0)
and radius 0.
public XCircle(double x,
double y,
double r)
XCircle from the specified
double coordinates. Calls setXYR.
x - the proposed center x-coordinatey - the proposed center y-coordinater - the proposed radiuspublic XCircle(double r)
Constructs a new XCircle initialized to center (0, 0)
and with the given radius r. Calls setXYR
r - the proposed radiuspublic XCircle(XCircle circle)
Constructs and initializes a XCircle from the specified
XCircle object. Calls setXYR.
Initializes to center (0, 0) and radius 0 if the given circle
is null.
circle - the XCircle object to copy| Method Detail |
public String toString()
Returns a human readable String representing
the data state of this XCircle as an annotated
string.
XCircle[xc=...;yc=...;r=...]
where the dots stand for the xc,yc center data and the radius r.
toString in class XOvalpublic String toStringData()
Returns a human readable String representing
the data state of this XCircle as a simple
string.
[...;...;...]
where the dots stand for the xc,yc center data and the radius r.
toStringData in interface StringabletoStringData in class XOval
public void fromStringData(String data)
throws ParseException
Defines the data state for this XCircle object
from a String representation of the data state.
Fires property change VALUE.
fromStringData in interface StringablefromStringData in class XOvaldata - 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 XCircle with error checking.
If the radius r is negative, it is replaced by its absolute value.
The circle is then set up as an oval 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 radiuspublic void setCircle(XCircle circle)
Uses the data from the given circle to set the parameters of this circle.
Does nothing if the given circle is null.
Fires property change VALUE.
circle - the XCircle 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 circle cannot have a distinct width and height.
The fact that this method does nothing implies that the following methods
inherited from XOval and other base classes also do nothing.
setXYRSsetX1Y1X2Y2setFramesetFrameFromCentersetFrameFromDiagonal
setXYWH in class XOvalx - the proposed top-left x-coordinate of the framey - the proposed top-left y-coordinate of the framew - the proposed width of the frameh - the proposed height of the frame
public void move(double dx,
double dy)
Moves the circle by a translation using the data in the point specified by coordinates.
move in class XOvaldx - the x-coordinate of the translationdy - the y-coordinate of the translationpublic void move(Point2D p)
Moves the circle by a translation using the data in the point.
move in class XOvalp - the translation vectorpublic void addPropertyChangeListener(PropertyChangeListener listener)
addPropertyChangeListener in class XOvallistener - the listener to be registered
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
addPropertyChangeListener in class XOvalpropertyName - the name of the desired propertylistener - the listener to be registeredpublic void removePropertyChangeListener(PropertyChangeListener listener)
removePropertyChangeListener in class XOvallistener - the listener to be deregistered
public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
removePropertyChangeListener in class XOvalpropertyName - 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 | |||||||||