edu.neu.ccs
Class XRoundSquare

java.lang.Object
  extended byjava.awt.geom.RectangularShape
      extended byjava.awt.geom.RoundRectangle2D
          extended byjava.awt.geom.RoundRectangle2D.Double
              extended byedu.neu.ccs.XRoundRect
                  extended byedu.neu.ccs.XRoundSquare
All Implemented Interfaces:
Cloneable, JPTConstants, Serializable, Shape, Stringable, SwingConstants

public class XRoundSquare
extends XRoundRect
implements Serializable, Stringable, JPTConstants

Class XRoundSquare extends XRoundRect but requires that its location be specifed by its center, its size by an object radius, and its arc size by a common arc radius. The side of the roundsquare is twice the object radius and is the value returned by either getWidth or getHeight.

Inherited methods that would permit the caller to make the width and height have different values are overridden to do nothing.

Since:
2.4.0
Version:
2.4.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.geom.RoundRectangle2D
RoundRectangle2D.Double, RoundRectangle2D.Float
 
Field Summary
private  double arcr
          The arc radius.
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[] XYRArc
          The data array with names "xc", "yc", "r", "arcr".
 
Fields inherited from class edu.neu.ccs.XRoundRect
 
Fields inherited from class java.awt.geom.RoundRectangle2D.Double
archeight, arcwidth, 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
XRoundSquare()
          Constructs a new XRoundSquare initialized to center (0, 0), inner radius 0, and arc radius 0.
XRoundSquare(double r, double arcr)
          Constructs a new XRoundSquare initialized to center (0, 0) and with the given inner radius r and arc radius arcr.
XRoundSquare(double xc, double yc, double r, double arcr)
          Constructs and initializes an XRoundSquare from the specified double coordinates.
XRoundSquare(XRoundSquare roundsquare)
          Constructs and initializes an XRoundSquare from the specified XRoundSquare 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 XRoundSquare object from a String representation of the data state.
 double getArcRadius()
          Returns the arc radius.
 double getRadius()
          Returns the radius.
 void move(double dx, double dy)
          Moves the round square by a translation using the data in the point specified by coordinates.
 void move(Point2D p)
          Moves the round 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 setRoundSquare(XRoundSquare roundsquare)
          Uses the data from the given roundsquare to set the parameters of this roundsquare.
 void setXYRArc(double xc, double yc, double r, double arcr)
          Sets the parameters of the XRoundSquare with error checking.
 void setXYWHArcs(double x, double y, double w, double h, double arcw, double arch)
          Overrides the inherited method to do nothing since a roundsquare cannot have a distinct width and height or a distinct arc width and arc height.
 String toString()
          Returns a human readable String representing the data state of this XRoundSquare as an annotated string.
 String toStringData()
          Returns a human readable String representing the data state of this XRoundSquare as a simple string.
 
Methods inherited from class edu.neu.ccs.XRoundRect
setFrame, setFrame, setFrame, setRect, setRect, setRoundRect, setRoundRect, setX1Y1X2Y2, setXYRS, setXYRSArcs, setXYWH, toStringAsXYRSArcs
 
Methods inherited from class java.awt.geom.RoundRectangle2D.Double
getArcHeight, getArcWidth, getBounds2D, getHeight, getWidth, getX, getY, isEmpty
 
Methods inherited from class java.awt.geom.RoundRectangle2D
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

BLANK

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


XYRArc

private static String[] XYRArc
The data array with names "xc", "yc", "r", "arcr".


standardMessage

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

See Also:
Constant Field Values

r

private double r
The radius.


arcr

private double arcr
The arc radius.


changeAdapter

protected SwingPropertyChangeSupport changeAdapter
Helper object for property change API.

Constructor Detail

XRoundSquare

public XRoundSquare()
Constructs a new XRoundSquare initialized to center (0, 0), inner radius 0, and arc radius 0.


XRoundSquare

public XRoundSquare(double xc,
                    double yc,
                    double r,
                    double arcr)
Constructs and initializes an XRoundSquare from the specified double coordinates. Calls setXYRArc.

Parameters:
xc - the proposed center x-coordinate
yc - the proposed center y-coordinate
r - the proposed inner radius
arcr - the proposed arc radius

XRoundSquare

public XRoundSquare(double r,
                    double arcr)

Constructs a new XRoundSquare initialized to center (0, 0) and with the given inner radius r and arc radius arcr. Calls setXYRArc

Parameters:
r - the proposed inner radius
arcr - the proposed arc radius

XRoundSquare

public XRoundSquare(XRoundSquare roundsquare)

Constructs and initializes an XRoundSquare from the specified XRoundSquare object. Calls setXYRArc indirectly.

Initializes to center (0, 0), inner radius 0, and arc radius 0 if the given roundsquare is null.

Parameters:
roundsquare - the XRoundSquare object to copy
Method Detail

toString

public String toString()

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

XRoundSquare[xc=...;yc=...;r=...;arcr=...]

where the dots stand for the center data xc,yc, the inner radius r, and the arc radius arcr.

Overrides:
toString in class XRoundRect

toStringData

public String toStringData()

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

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

where the dots stand for the center data xc,yc, the inner radius r, and the arc radius arcr.

Specified by:
toStringData in interface Stringable
Overrides:
toStringData in class XRoundRect

fromStringData

public void fromStringData(String data)
                    throws ParseException

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

Fires property change VALUE.

Specified by:
fromStringData in interface Stringable
Overrides:
fromStringData in class XRoundRect
Parameters:
data - String representation of the data state
Throws:
ParseException - if the data is malformed

setXYRArc

public void setXYRArc(double xc,
                      double yc,
                      double r,
                      double arcr)

Sets the parameters of the XRoundSquare with error checking.

If the inner radius r is negative, it is replaced by its absolute value.

If the arc radius arcr is negative, it is replaced by its absolute value.

The arc radius is forced to be less than or equal to the inner radius.

The roundsquare is then set up as a round rectangle with center location xc,yc, common inner radius r, and common arc radius arcr.

Fires property change VALUE.

Parameters:
xc - the proposed center x-coordinate
yc - the proposed center y-coordinate
r - the proposed inner radius
arcr - the proposed arc radius

setRoundSquare

public void setRoundSquare(XRoundSquare roundsquare)

Uses the data from the given roundsquare to set the parameters of this roundsquare.

Does nothing if the given roundsquare is null.

Fires property change VALUE.

Parameters:
roundsquare - the XRoundSquare object to copy

getRadius

public double getRadius()
Returns the radius.


getArcRadius

public double getArcRadius()
Returns the arc radius.


setXYWHArcs

public void setXYWHArcs(double x,
                        double y,
                        double w,
                        double h,
                        double arcw,
                        double arch)

Overrides the inherited method to do nothing since a roundsquare cannot have a distinct width and height or a distinct arc width and arc height.

The fact that this method does nothing implies that the following methods inherited from XRoundRect and other base classes also do nothing.

Overrides:
setXYWHArcs in class XRoundRect
Parameters:
x - the proposed top-left x-coordinate
y - the proposed top-left y-coordinate
w - the proposed width
h - the proposed height
arcw - the proposed arc width
arch - the proposed arc height

move

public void move(double dx,
                 double dy)

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

Overrides:
move in class XRoundRect
Parameters:
dx - the x-coordinate of the translation
dy - the y-coordinate of the translation

move

public void move(Point2D p)

Moves the round square by a translation using the data in the point.

Overrides:
move in class XRoundRect
Parameters:
p - the translation vector

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Registers the given object to listen for property change events generated by this object.

Overrides:
addPropertyChangeListener in class XRoundRect
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.

Overrides:
addPropertyChangeListener in class XRoundRect
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.

Overrides:
removePropertyChangeListener in class XRoundRect
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.

Overrides:
removePropertyChangeListener in class XRoundRect
Parameters:
propertyName - the name of the desired property
listener - the listener to be deregistered