|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--edu.neu.ccs.gui.BaseShape
Class BaseShape encapsulates a Shape defined
using vertex and tangent data.
Specifically, BaseShape encapsulates:
A BaseShape is parametrized by three additional settings:
Path.Strategy settingClosureMode settingWindingRule settingClass BaseShape contains the common code and data for the
derived classes AutomaticShape and TweakableShape.
Class BaseShape may not be instantiated directly since it
does not have a public constructor.
| Field Summary | |
static String |
REMOVE_SHAPE_DATA
Bound property name to clear/remove all vertex and tangent data. |
static String |
SET_CLOSURE_MODE
Bound property name for set closure mode. |
static String |
SET_PATH_STRATEGY
Bound property name for set path strategy. |
static String |
SET_WINDING_RULE
Bound property name for set winding rule. |
protected float[][] |
tangent
The tangent data of the shape. |
protected float[][] |
vertex
The vertex data of the shape. |
| Constructor Summary | |
protected |
BaseShape()
The default constructor with an empty shape. |
| Method Summary | |
void |
addForwardingListener(Object object)
Add the forwarding listener as a property change listener for the given object if the object supports property change. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list for a
specific property. |
void |
addPropertyChangeListeners(PropertyChangeListener[] listeners)
Add all items in the given PropertyChangeListener array
to the listener list. |
void |
addPropertyChangeListeners(String propertyName,
PropertyChangeListener[] listeners)
Add all items in the given PropertyChangeListener array
to the listener list for a specific property. |
boolean |
contains(double x,
double y)
Tests if the specified coordinates are inside the boundary of the Shape. |
boolean |
contains(double x,
double y,
double w,
double h)
Tests if the interior of the Shape entirely contains the specified rectangular area. |
boolean |
contains(Point2D p)
Tests if a specified Point2D is inside the boundary of the Shape. |
boolean |
contains(Rectangle2D r)
Tests if the interior of the Shape entirely contains the specified rectangular area. |
void |
firePropertyChange(PropertyChangeEvent evt)
Fire an existing PropertyChangeEvent to any registered
listeners. |
void |
firePropertyChange(String propertyName,
boolean oldValue,
boolean newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
byte oldValue,
byte newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
char oldValue,
char newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
double oldValue,
double newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
float oldValue,
float newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
int oldValue,
int newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
long oldValue,
long newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Report a bound property update to any registered listeners. |
void |
firePropertyChange(String propertyName,
short oldValue,
short newValue)
Report a bound property update to any registered listeners. |
float[][] |
getBezierTangentSegmentData()
Returns the Bezier tangent segment data corresponding to the vertex and tangent data. |
Rectangle |
getBounds()
Returns an integer Rectangle that completely encloses the Shape. |
Rectangle2D |
getBounds2D()
Returns a high precision and more accurate bounding box of the Shape than the getBounds method. |
float[][] |
getClosedBezierFrameData()
Returns the closed Bezier frame data corresponding to the vertex and tangent data. |
ClosureMode |
getClosureMode()
Get the closure mode. |
float[] |
getCubicCurvePoint(float t)
Returns an array float[2] with the coordinates of
a point on the cubic curve determined by the internal vertex and
tangent data and the float parameter t. |
PropertyChangeForwardingListener |
getForwardingListener()
Returns the PropertyChangeForwardingListener that
will forward the property change events it receives to this object. |
float[][] |
getMergedVertexTangentData()
Returns the deep merge of the vertex and tangent data. |
float[][] |
getOpenBezierFrameData()
Returns the open Bezier frame data corresponding to the vertex and tangent data. |
GeneralPath |
getPath()
Returns a copy of the GeneralPath that defines this
Shape. |
PathIterator |
getPathIterator(AffineTransform at)
Returns an iterator object that iterates along the Shape boundary and provides access to the geometry of the Shape outline. |
PathIterator |
getPathIterator(AffineTransform at,
double flatness)
Returns an iterator object that iterates along the Shape boundary and provides access to a flattened view of the Shape outline geometry. |
Path.Strategy |
getPathStrategy()
Get the PathStrategy. |
float[] |
getPolygonPoint(float t)
Returns an array float[2] with the coordinates of
a point on the polygon determined by the internal vertex data and
the float parameter t. |
PropertyChangeListener[] |
getPropertyChangeListeners()
Returns an array of all listeners that were added to this object. |
PropertyChangeListener[] |
getPropertyChangeListeners(String propertyName)
Returns an array of all listeners that were added to this object and associated with the named property. |
float[][] |
getTangentData()
Returns a copy of the tangent data. |
float[][] |
getVertexData()
Returns a copy of the vertex data. |
WindingRule |
getWindingRule()
Get the winding rule. |
boolean |
hasListeners(String propertyName)
Check if there are any listeners for a specific property. |
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if the interior of the Shape intersects the interior of a specified rectangular area. |
boolean |
intersects(Rectangle2D r)
Tests if the interior of the Shape intersects the interior of a specified rectangular area. |
int |
length()
Returns the common length N of the vertex and tangent data. |
TweakableShape |
makeBezierTangentSegments()
Returns an open TweakableShape whose vertex and tangent
data is a copy of the corresponding vertex and tangent data of this
shape and whose Path.Strategy is
Path.BEZIER_TANGENT_SEGMENTS. |
TweakableShape |
makeClosedBezierFrame()
Returns a closed TweakableShape whose vertex data is the
closed Bezier frame corresponding to the vertex and tangent data of
this shape, whose tangent data is zero, and whose
Path.Strategy is Path.POLYGON. |
TweakableShape |
makeOpenBezierFrame()
Returns an open TweakableShape whose vertex data is the
open Bezier frame corresponding to the vertex and tangent data of
this shape, whose tangent data is zero, and whose
Path.Strategy is Path.POLYGON. |
protected void |
makePath()
Make the path for the shape using the internal vertex and tangent data and the path strategy, closure mode, and winding rule settings. |
TweakableShape |
makePolygonDots()
Returns an open TweakableShape whose vertex data is a copy
of the vertex data of this shape, whose tangent data is zero, and whose
Path.Strategy is Path.POLYGON_DOTS. |
void |
removeAndAddForwardingListener(Object oldobject,
Object newobject)
Remove the forwarding listener as a property change listener for the old object if the old object supports property change and add the forwarding listener as a property change listener for the new object if the new object supports property change. |
void |
removeForwardingListener(Object object)
Remove the forwarding listener as a property change listener for the given object if the object supports property change. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property. |
void |
removeShapeData()
Removes all vertex and tangent data and makes a new path. |
void |
setClosureMode(ClosureMode closuremode)
Sets the closure mode and makes a new path. |
void |
setPathStrategy(Path.Strategy pathstrategy)
Sets the path strategy and makes a new path. |
void |
setWindingRule(WindingRule windingrule)
Sets the winding rule and makes a new path. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String SET_PATH_STRATEGY
public static final String SET_CLOSURE_MODE
public static final String SET_WINDING_RULE
public static final String REMOVE_SHAPE_DATA
protected float[][] vertex
The vertex data of the shape.
Derived classes must ensure that this member data is not
null and that it has the form float[N][2].
protected float[][] tangent
The tangent data of the shape.
Derived classes must ensure that this member data is not
null and that it has the form float[N][2]
for the same N as in the vertex array.
| Constructor Detail |
protected BaseShape()
The default constructor with an empty shape.
The default settings are as follows:
new float[0][2]new float[0][2]Path.POLYGONClosureMode.CLOSEDWindingRule.WIND_NON_ZERO.
| Method Detail |
public final TweakableShape makePolygonDots()
TweakableShape whose vertex data is a copy
of the vertex data of this shape, whose tangent data is zero, and whose
Path.Strategy is Path.POLYGON_DOTS.
public final TweakableShape makeClosedBezierFrame()
TweakableShape whose vertex data is the
closed Bezier frame corresponding to the vertex and tangent data of
this shape, whose tangent data is zero, and whose
Path.Strategy is Path.POLYGON.
public final TweakableShape makeOpenBezierFrame()
TweakableShape whose vertex data is the
open Bezier frame corresponding to the vertex and tangent data of
this shape, whose tangent data is zero, and whose
Path.Strategy is Path.POLYGON.
public final TweakableShape makeBezierTangentSegments()
TweakableShape whose vertex and tangent
data is a copy of the corresponding vertex and tangent data of this
shape and whose Path.Strategy is
Path.BEZIER_TANGENT_SEGMENTS.
public final int length()
public final float[][] getVertexData()
Returns a copy of the vertex data.
The returned array will have the form float[N][2].
getTangentData(),
getClosedBezierFrameData(),
getOpenBezierFrameData(),
getBezierTangentSegmentData(),
getMergedVertexTangentData()public final float[][] getTangentData()
Returns a copy of the tangent data.
The returned array will have the form float[N][2] for the same N as in the vertex data.
getVertexData(),
getClosedBezierFrameData(),
getOpenBezierFrameData(),
getBezierTangentSegmentData(),
getMergedVertexTangentData()public final float[] getPolygonPoint(float t)
Returns an array float[2] with the coordinates of
a point on the polygon determined by the internal vertex data and
the float parameter t.
Let N denote the length of the vertex data array.
If N == 0, return new float[2].
If N == 1 or if N > 1 and
either t <= 0 or t >= N,
return a copy of vertex[0].
Otherwise, let t = a + f where a is an
integer and 0 <= f < 1. Let b = a+1
modulo N. Then, return the point:
(1 - f) * vertex[a] + f * vertex[b]
t - the parameter that determines the pointpublic final float[] getCubicCurvePoint(float t)
Returns an array float[2] with the coordinates of
a point on the cubic curve determined by the internal vertex and
tangent data and the float parameter t.
Let N denote the length of the vertex data array.
If N == 0, return new float[2].
If N == 1 or if N > 1 and
either t <= 0 or t >= N,
return a copy of vertex[0].
Otherwise, let t = a + f where a is an
integer and 0 <= f < 1. Let b = a+1
modulo N. Then, return the point corresponding to the
parameter f and the 4 Bezier control points given below.
vertex[a]vertex[a] + tangent[a]vertex[b] - tangent[b]vertex[b]
t - the parameter that determines the pointpublic final float[][] getClosedBezierFrameData()
Returns the closed Bezier frame data corresponding to the vertex and tangent data.
If N is the common length of the vertex and tangent data then the returned array will have the form float[3*N][2].
getVertexData(),
getTangentData(),
getOpenBezierFrameData(),
getBezierTangentSegmentData(),
getMergedVertexTangentData(),
Path.closedBezierFrame(float[][], float[][])public final float[][] getOpenBezierFrameData()
Returns the open Bezier frame data corresponding to the vertex and tangent data.
If N is the common length of the vertex and tangent data then if N is non-zero the returned array will have the form float[3*N-2][2] otherwise the returned array will have the form float[0][2].
getVertexData(),
getTangentData(),
getClosedBezierFrameData(),
getBezierTangentSegmentData(),
getMergedVertexTangentData(),
Path.openBezierFrame(float[][], float[][])public final float[][] getBezierTangentSegmentData()
Returns the Bezier tangent segment data corresponding to the vertex and tangent data.
If N is the common length of the vertex and tangent data then the returned array will have the form float[2*N][2].
getVertexData(),
getTangentData(),
getClosedBezierFrameData(),
getOpenBezierFrameData(),
getMergedVertexTangentData(),
Path.bezierTangentSegments(float[][], float[][])public final float[][] getMergedVertexTangentData()
Returns the deep merge of the vertex and tangent data.
If N is the common length of the vertex and tangent data then the returned array will have the form float[N][4].
getVertexData(),
getTangentData(),
getClosedBezierFrameData(),
getOpenBezierFrameData(),
getBezierTangentSegmentData()public final void removeShapeData()
Removes all vertex and tangent data and makes a new path.
Fires property change: REMOVE_SHAPE_DATA.
public final void setPathStrategy(Path.Strategy pathstrategy)
Sets the path strategy and makes a new path.
Does nothing if its parameter is null.
Fires property change: SET_PATH_STRATEGY.
pathstrategy - the path strategy to setpublic final Path.Strategy getPathStrategy()
public final void setClosureMode(ClosureMode closuremode)
Sets the closure mode and makes a new path.
Does nothing if its parameter is null.
Fires property change: SET_CLOSURE_MODE.
closuremode - the closure mode to setpublic final ClosureMode getClosureMode()
public final void setWindingRule(WindingRule windingrule)
Sets the winding rule and makes a new path.
Does nothing if its parameter is null.
Fires property change: SET_WINDING_RULE.
windingrule - the winding rule to setpublic final WindingRule getWindingRule()
public final GeneralPath getPath()
GeneralPath that defines this
Shape.
protected final void makePath()
public final boolean contains(double x,
double y)
contains in interface Shapex - the x-coordinate of the position testedy - the y-coordinate of the position testedpublic final boolean contains(Point2D p)
contains in interface Shapep - the position tested
public final boolean contains(double x,
double y,
double w,
double h)
Tests if the interior of the Shape entirely contains the specified rectangular area. All coordinates that lie inside the rectangular area must lie within the Shape for the entire rectangular area to be considered contained within the Shape.
This method might conservatively return false when:
This means that this method might return false even though the Shape contains the rectangular area. The Area class can be used to perform more accurate computations of geometric intersection for any Shape object if a more precise answer is required.
contains in interface Shapex - the x-coordinate of the rectangle's topleft cornery - the y-coordinate of the rectangle's topleft cornerw - the rectangle's widthh - the rectangle's heightpublic final boolean contains(Rectangle2D r)
Tests if the interior of the Shape entirely contains the specified rectangular area. All coordinates that lie inside the rectangular area must lie within the Shape for the entire rectangular area to be considered contained within the Shape.
This method might conservatively return false when:
This means that this method might return false even though the Shape contains the rectangular area. The Area class can be used to perform more accurate computations of geometric intersection for any Shape object if a more precise answer is required.
contains in interface Shaper - the rectangle
public final boolean intersects(double x,
double y,
double w,
double h)
Tests if the interior of the Shape intersects the interior of a specified rectangular area. The rectangular area is considered to intersect the Shape if any point is contained in both the interior of the Shape and the specified rectangular area.
This method might conservatively return true when:
This means that this method might return true even though the rectangular area does not intersect the Shape. The Area class can be used to perform more accurate computations of geometric intersection for any Shape object if a more precise answer is required.
intersects in interface Shapex - the x-coordinate of the rectangle's topleft cornery - the y-coordinate of the rectangle's topleft cornerw - the rectangle's widthh - the rectangle's heightpublic final boolean intersects(Rectangle2D r)
Tests if the interior of the Shape intersects the interior of a specified rectangular area. The rectangular area is considered to intersect the Shape if any point is contained in both the interior of the Shape and the specified rectangular area.
This method might conservatively return true when:
This means that this method might return true even though the rectangular area does not intersect the Shape. The Area class can be used to perform more accurate computations of geometric intersection for any Shape object if a more precise answer is required.
intersects in interface Shaper - the rectanglepublic final Rectangle getBounds()
getBounds in interface Shapepublic final Rectangle2D getBounds2D()
getBounds2D in interface Shapepublic final PathIterator getPathIterator(AffineTransform at)
Returns an iterator object that iterates along the Shape boundary and provides access to the geometry of the Shape outline.
If an optional AffineTransform is specified, the coordinates returned in the iteration are transformed accordingly.
Each call to this method returns a fresh PathIterator object that traverses the geometry of the Shape object independently from any other PathIterator objects in use at the same time.
getPathIterator in interface Shapeat - the optional transform to apply to the PathIterator
public final PathIterator getPathIterator(AffineTransform at,
double flatness)
Returns an iterator object that iterates along the Shape boundary and provides access to a flattened view of the Shape outline geometry.
Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types are returned by the iterator.
If an optional AffineTransform is specified, the coordinates returned in the iteration are transformed accordingly.
The amount of subdivision of the curved segments is controlled by the flatness parameter, which specifies the maximum distance that any point on the unflattened transformed curve can deviate from the returned flattened path segments. Note that a limit on the accuracy of the flattened path might be silently imposed, causing very small flattening parameters to be treated as larger values. This limit, if there is one, is defined by the particular implementation that is used.
Each call to this method returns a fresh PathIterator object that traverses the Shape object geometry independently from any other PathIterator objects in use at the same time.
getPathIterator in interface Shapeat - the optional transform to apply to the PathIteratorflatness - the flatness to use to simplify the PathIteratorpublic final void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.
The listener is registered for all properties.
addPropertyChangeListener in interface SupportsPropertyChangelistener - the PropertyChangeListener to be added
public final void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list for a
specific property. The listener will be invoked only when a call on
firePropertyChange names that specific property.
addPropertyChangeListener in interface SupportsPropertyChangepropertyName - the name of the property to listen onlistener - the PropertyChangeListener to be addedpublic void addPropertyChangeListeners(PropertyChangeListener[] listeners)
Add all items in the given PropertyChangeListener array
to the listener list. These items are registered for all properties.
addPropertyChangeListeners in interface SupportsPropertyChangelisteners - the PropertyChangeListener array to be added
public void addPropertyChangeListeners(String propertyName,
PropertyChangeListener[] listeners)
Add all items in the given PropertyChangeListener array
to the listener list for a specific property. These items will be invoked
only when a call on firePropertyChange names that specific
property.
addPropertyChangeListeners in interface SupportsPropertyChangelisteners - the PropertyChangeListener array to be addedpublic final void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.
This removes a PropertyChangeListener that was registered
for all properties.
removePropertyChangeListener in interface SupportsPropertyChangelistener - the PropertyChangeListener to be removed
public final void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property.
removePropertyChangeListener in interface SupportsPropertyChangepropertyName - the name of the property that was listened onlistener - the PropertyChangeListener to be removedpublic final PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all listeners that were added to this object.
getPropertyChangeListeners in interface SupportsPropertyChangepublic final PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Returns an array of all listeners that were added to this object and associated with the named property.
getPropertyChangeListeners in interface SupportsPropertyChangepropertyName - the name of the property to seek
public final boolean hasListeners(String propertyName)
Check if there are any listeners for a specific property.
hasListeners in interface SupportsPropertyChangepropertyName - the name of the property to check
public final void firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal and non-null.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
boolean oldValue,
boolean newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
char oldValue,
char newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
byte oldValue,
byte newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
short oldValue,
short newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
int oldValue,
int newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
long oldValue,
long newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
float oldValue,
float newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the property
public final void firePropertyChange(String propertyName,
double oldValue,
double newValue)
Report a bound property update to any registered listeners. No event is fired if the old and new values are equal.
firePropertyChange in interface SupportsPropertyChangepropertyName - the programmatic name of the property that was changedoldValue - the old value of the propertynewValue - the new value of the propertypublic final void firePropertyChange(PropertyChangeEvent evt)
Fire an existing PropertyChangeEvent to any registered
listeners. No event is fired if the given event's old and new values
are equal and non-null.
firePropertyChange in interface SupportsPropertyChangeevt - the PropertyChangeEvent objectpublic final PropertyChangeForwardingListener getForwardingListener()
Returns the PropertyChangeForwardingListener that
will forward the property change events it receives to this object.
getForwardingListener in interface SupportsPropertyChangepublic final void addForwardingListener(Object object)
addForwardingListener in interface SupportsPropertyChangeobject - the object that should add the forwarding listenerpublic final void removeForwardingListener(Object object)
removeForwardingListener in interface SupportsPropertyChangeobject - the object that should remove the forwarding listener
public final void removeAndAddForwardingListener(Object oldobject,
Object newobject)
removeAndAddForwardingListener in interface SupportsPropertyChangeoldobject - the old object that should remove the forwarding listenernewobject - the new object that should add the forwarding listener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||