|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.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:
BaseVertexShapePolygonShapePolygonDotsShapeAutomaticShapeAutomaticCurveTweakableShapeTweakableCurveClass BaseShape may not be instantiated directly since it
does not have a public constructor.
In 2.4.0, the restriction that the internal vertex and tangent array must be
non-null and of form float[N][2] for the same N was
weakened to permit the tangent array to be null. It is
still the case that the vertex array must be non-null and of form
float[N][2] and that if the tangent array is non-null
then it must have the same form. The relaxation was introduced to support
the derived classes whose Path.Strategy does not use tangents and
for which creation of a tangent array is unnecessary.
If the internal tangent array is null and a tangent is requested
by some method then it is treated as [0;0].
| Field Summary | |
private PropertyChangeSupport |
changeAdapter
The main listener for this BaseShape object
to implement the interface SupportsPropertyChange. |
private ClosureMode |
closuremode
The ClosureMode: OPEN or CLOSED. |
private PropertyChangeForwardingListener |
forwardingListener
The forwarding listener for this BaseShape object
to implement the interface SupportsPropertyChange. |
private GeneralPath |
path
The GeneralPath used to implement the Shape. |
private Path.Strategy |
pathstrategy
The Path.Strategy. |
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. |
private WindingRule |
windingrule
The WindingRule: WIND_NON_ZERO or WIND_EVEN_ODD. |
| Constructor Summary | |
protected |
BaseShape()
The protected default constructor. |
| 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. |
static float[][] |
bezierTangentSegmentPoints(float[][] vertex,
float[][] tangent)
Static method that returns a float array that contains the Bezier tangent segments for the given vertex and tangent arrays. |
static float[][] |
closedBezierControlPoints(float[][] vertex,
float[][] tangent)
Static method that returns a float array that contains the Bezier control points for the closed curve with the given vertex and tangent arrays. |
static float[][] |
closedBezierFramePoints(float[][] vertex,
float[][] tangent)
Static method that returns a float array that contains the points on the closed Bezier frame for the given vertex and tangent arrays. |
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. |
int |
findControlA(double x,
double y,
double epsilon)
Returns the index of the first ahead control point that is within epsilon of (x,y) relative to the metric Metric.MAX;
returns -1 if no such ahead control point exists. |
int |
findControlA(double x,
double y,
double epsilon,
Metric metric)
Returns the index of the first ahead control point that is within epsilon of (x,y) relative to the given metric; returns -1 if no such ahead control point exists. |
int |
findControlB(double x,
double y,
double epsilon)
Returns the index of the first behind control point that is within epsilon of (x,y) relative to the metric Metric.MAX;
returns -1 if no such behind control point exists. |
int |
findControlB(double x,
double y,
double epsilon,
Metric metric)
Returns the index of the first behind control point that is within epsilon of (x,y) relative to the given metric; returns -1 if no such behind control point exists. |
int |
findVertex(double x,
double y,
double epsilon)
Returns the index of the first vertex that is within epsilon of (x,y) relative to the metric Metric.MAX;
returns -1 if no such vertex exists. |
int |
findVertex(double x,
double y,
double epsilon,
Metric metric)
Returns the index of the first vertex that is within epsilon of (x,y) relative to the given metric; returns -1 if no such vertex exists. |
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 |
getAX(int index)
Returns the x-coordinate of the Bezier control point that is ahead of the vertex at the given index. |
float |
getAY(int index)
Returns the y-coordinate of the Bezier control point that is ahead of the vertex at the given index. |
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 |
getBX(int index)
Returns the x-coordinate of the Bezier control point that is behind the vertex at the given index. |
float |
getBY(int index)
Returns the y-coordinate of the Bezier control point that is behind the vertex at the given index. |
float[][] |
getClosedBezierControlData()
Returns the closed Bezier control points corresponding to the vertex and tangent data. |
float[][] |
getClosedBezierFrameData()
Returns the closed Bezier frame data corresponding to the vertex and tangent data. |
ClosureMode |
getClosureMode()
Get the closure mode. |
float[] |
getControlA(int index)
Returns a copy of the Bezier control point that is ahead of the vertex at the given index. |
float[] |
getControlB(int index)
Returns a copy of the Bezier control point that is behind the vertex at the given index. |
float[] |
getCubicCurvePoint(float t)
Returns an array float[2] with the coordinates of a
point on the closed 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[][] |
getOpenBezierControlData()
Returns the open Bezier control points corresponding to 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 based on the vertex data, tangent data, path
strategy, closure mode, and winding rule. |
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 closed 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[] |
getTangent(int index)
Returns a copy of the tangent at the given index. |
float[][] |
getTangentData()
Returns a copy of the tangent data. |
Shape |
getTransformedShape(AffineTransform at)
Returns a new Shape obtained from this object by
using the path iterator corresponding to the given transform. |
Shape |
getTransformedShape(AffineTransform at,
double flatness)
Returns a new Shape obtained from this object by
using the path iterator corresponding to the given transform
and flatness. |
float |
getTX(int index)
Returns the x-coordinate of the tangent data if the given index is in bounds or 0 if the index is out of bounds or if the tangent data is null. |
float |
getTY(int index)
Returns the y-coordinate of the tangent data if the given index is in bounds or 0 if the index is out of bounds or if the tangent data is null. |
float[] |
getVertex(int index)
Returns a copy of the vertex at the given index. |
float[][] |
getVertexData()
Returns a copy of the vertex data. |
float[] |
getVertexTangent(int index)
Returns a copy of the combined vertex and tangent data at the given index. |
float[][] |
getVertexTangentData()
Returns a copy of the vertex and tangent data. |
float |
getVX(int index)
Returns the x-coordinate of the vertex data if the given index is in bounds or 0 if the index is out of bounds. |
float |
getVY(int index)
Returns the y-coordinate of the vertex data if the given index is in bounds or 0 if the index is out of bounds. |
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. |
boolean |
isTangentNull()
Returns true if the internal tangent data is null. |
int |
length()
Returns the length N of the vertex data; if the tangent data is non- null then this data has the same length. |
TweakableShape |
makeBezierTangentSegments()
Returns a new TweakableShape
whose vertex and tangent data is a copy of the corresponding
vertex and tangent data of this shape,
whose Path.Strategy is
Path.BEZIER_TANGENT_SEGMENTS,
and whose winding rule is the same as this shape. |
PolygonShape |
makeClosedBezierFrame()
Returns a new closed PolygonShape
whose vertex data is the closed Bezier frame corresponding
to the vertex and tangent data of this shape
and whose winding rule is the same as this shape. |
PolygonDotsShape |
makeClosedControlDots()
Returns a new PolygonDotsShape
whose vertex data is the closed Bezier control point list
corresponding to the vertex and tangent data of this shape. |
PolygonShape |
makeClosedPolygon()
Returns a new closed PolygonShape
whose vertex data is a copy of the vertex data of this shape. |
PolygonShape |
makeOpenBezierFrame()
Returns a new open PolygonShape
whose vertex data is the open Bezier frame corresponding
to the vertex and tangent data of this shape
and whose winding rule is the same as this shape. |
PolygonDotsShape |
makeOpenControlDots()
Returns a new PolygonDotsShape
whose vertex data is the open Bezier control point list
corresponding to the vertex and tangent data of this shape. |
PolygonShape |
makeOpenPolygon()
Returns a new open PolygonShape
whose vertex data is a copy of the vertex data of this shape. |
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. |
PolygonDotsShape |
makePolygonDots()
Returns a new PolygonDotsShape
whose vertex data is a copy of the vertex data of this shape. |
static float[][] |
openBezierControlPoints(float[][] vertex,
float[][] tangent)
Static method that returns a float array that contains the Bezier control points for the open curve with the given vertex and tangent arrays. |
static float[][] |
openBezierFramePoints(float[][] vertex,
float[][] tangent)
Static method that returns a float array that contains the points on the open Bezier frame for the given vertex and tangent arrays. |
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(int rule)
Sets the winding rule via an int 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].
The initial default is new float[0][2].
protected float[][] tangent
The tangent data of the shape.
Derived classes must ensure that this member data is either
null or that it has the form
float[N][2] for the same N as in the vertex array.
The requirement on the tangent array to permit null
was introduced in 2.4.0.
The initial default is null.
private GeneralPath path
GeneralPath used to implement the Shape.
private Path.Strategy pathstrategy
The Path.Strategy.
The initial default is Path.POLYGON.
private ClosureMode closuremode
The ClosureMode: OPEN or CLOSED.
The initial default is ClosureMode.CLOSED.
private WindingRule windingrule
The WindingRule: WIND_NON_ZERO or WIND_EVEN_ODD.
The initial default is WindingRule.WIND_NON_ZERO.
private final PropertyChangeSupport changeAdapter
The main listener for this BaseShape object
to implement the interface SupportsPropertyChange.
Note: In this implementation, PropertyChangeSupport
is used rather than SwingPropertyChangeSupport to
ensure thread safety.
private final PropertyChangeForwardingListener forwardingListener
The forwarding listener for this BaseShape object
to implement the interface SupportsPropertyChange.
| Constructor Detail |
protected BaseShape()
The protected default constructor.
The default settings are as follows:
new float[0][2]nullPath.POLYGONClosureMode.CLOSEDWindingRule.WIND_NON_ZERO.
| Method Detail |
public final int length()
null then this data has the same length.
public final boolean isTangentNull()
null.
public final float getVX(int index)
index - the index of the vertexpublic final float getVY(int index)
index - the index of the vertexpublic final float[] getVertex(int index)
Returns a copy of the vertex at the given index.
More precisely, returns:
new float[] { getVX(index), getVY(index) }
In particular, returns [0;0] if the given
index is out of bounds.
public final float getTX(int index)
null.
index - the index of the tangentpublic final float getTY(int index)
null.
index - the index of the tangentpublic final float[] getTangent(int index)
Returns a copy of the tangent at the given index.
More precisely, returns:
new float[] { getTX(index), getTY(index) }
In particular, returns [0;0] if the given
index is out of bounds or if the tangent data is
null.
public final float getAX(int index)
Returns the x-coordinate of the Bezier control point that is ahead of the vertex at the given index.
Specifically, returns:
getVX(index) + getTX(index)
index - the index of the ahead control pointpublic final float getAY(int index)
Returns the y-coordinate of the Bezier control point that is ahead of the vertex at the given index.
Specifically, returns:
getVY(index) + getTY(index)
index - the index of the ahead control pointpublic final float[] getControlA(int index)
Returns a copy of the Bezier control point that is ahead of the vertex at the given index.
Specifically, returns:
new float[] { getAX(index), getAY(index) }
index - the index of the ahead control pointpublic final float getBX(int index)
Returns the x-coordinate of the Bezier control point that is behind the vertex at the given index.
Specifically, returns:
getVX(index) - getTX(index)
index - the index of the behind control pointpublic final float getBY(int index)
Returns the y-coordinate of the Bezier control point that is behind the vertex at the given index.
Specifically, returns:
getVY(index) - getTY(index)
index - the index of the behind control pointpublic final float[] getControlB(int index)
Returns a copy of the Bezier control point that is behind the vertex at the given index.
Specifically, returns:
new float[] { getBX(index), getBY(index) }
index - the index of the behind control pointpublic final float[] getVertexTangent(int index)
Returns a copy of the combined vertex and tangent data at the given index.
More precisely, returns:
new float[] { getVX(index), getVY(index), getTX(index), getTY(index) }
In particular, returns [0;0] if the given
index is out of bounds.
public final float[][] getVertexData()
Returns a copy of the vertex data.
The returned array will have the form float[N][2]
where N is the length.
The row at index i will contain:
getVertex(i)
public final float[][] getTangentData()
Returns a copy of the tangent data.
The returned array will have the form float[N][2]
where N is the length even if the internal tangent
array is null.
The row at index i will contain:
getTangent(i)
Use the method isTangentNull() to test
if the internal tangent array is null.
public final float[][] getVertexTangentData()
Returns a copy of the vertex and tangent data.
The returned array will have the form float[N][4]
where N is the length.
The row at index i will contain:
getVertexTangent(i)
public final float[] getPolygonPoint(float t)
Returns an array float[2] with the coordinates of a
point on the closed 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 [0;0].
If N == 1 or
if N > 1 and
either t <= 0
or t >= N,
return getVertex(0).
Otherwise, let t = a + f
where a is an integer and
0 <= f < 1.
Let b = a+1 modulo N.
Then, return the linear interpolation between the points
getVertex(a) and getVertex(b)
corresponding to the parameter f.
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 closed 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 [0;0].
If N == 1 or
if N > 1 and
either t <= 0
or t >= N,
return getVertex(0).
Otherwise, let t = a + f
where a is an integer and
0 <= f < 1.
Let b = a+1 modulo N.
Then, return the Bezier cubic point corresponding to the parameter
f and the 4 Bezier control points given below.
getVertex(a)getVertex(a) + getTangent(a), that is,
getControlA(a)getVertex(b) - getTangent(b), that is,
getControlB(b)getVertex(b)
t - the parameter that determines the point
public final int findVertex(double x,
double y,
double epsilon)
Returns the index of the first vertex
that is within epsilon of (x,y)
relative to the metric Metric.MAX;
returns -1 if no such vertex exists.
The intended use of this method is to locate a vertex using an approximate mouse position.
x - the x-coordinate of the search pointy - the y-coordinate of the search pointepsilon - the measure of closeness
public final int findVertex(double x,
double y,
double epsilon,
Metric metric)
Returns the index of the first vertex that is within epsilon of (x,y) relative to the given metric; returns -1 if no such vertex exists.
If the given metric is null
then Metric.MAX is used.
The intended use of this method is to locate a vertex using an approximate mouse position.
x - the x-coordinate of the search pointy - the y-coordinate of the search pointepsilon - the measure of closenessmetric - the metric to do the distance computation
public final int findControlA(double x,
double y,
double epsilon)
Returns the index of the first ahead control point
that is within epsilon of (x,y)
relative to the metric Metric.MAX;
returns -1 if no such ahead control point exists.
The intended use of this method is to locate an ahead control point using an approximate mouse position.
x - the x-coordinate of the search pointy - the y-coordinate of the search pointepsilon - the measure of closeness
public final int findControlA(double x,
double y,
double epsilon,
Metric metric)
Returns the index of the first ahead control point that is within epsilon of (x,y) relative to the given metric; returns -1 if no such ahead control point exists.
If the given metric is null
then Metric.MAX is used.
The intended use of this method is to locate an ahead control point using an approximate mouse position.
x - the x-coordinate of the search pointy - the y-coordinate of the search pointepsilon - the measure of closenessmetric - the metric to do the distance computation
public final int findControlB(double x,
double y,
double epsilon)
Returns the index of the first behind control point
that is within epsilon of (x,y)
relative to the metric Metric.MAX;
returns -1 if no such behind control point exists.
The intended use of this method is to locate a behind control point using an approximate mouse position.
x - the x-coordinate of the search pointy - the y-coordinate of the search pointepsilon - the measure of closeness
public final int findControlB(double x,
double y,
double epsilon,
Metric metric)
Returns the index of the first behind control point that is within epsilon of (x,y) relative to the given metric; returns -1 if no such behind control point exists.
If the given metric is null
then Metric.MAX is used.
The intended use of this method is to locate a behind control point using an approximate mouse position.
x - the x-coordinate of the search pointy - the y-coordinate of the search pointepsilon - the measure of closenessmetric - the metric to do the distance computationpublic 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.
This method may be overridden in a derived class but only if the following contract is observed:
super.setPathStrategy in
all of its constructors to select a specific strategy that
will be the same for all objects and remain fixed.setPathStrategy does nothing.This contract permits the definition of derived classes that are
intended to support a specific 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 void setWindingRule(int rule)
Sets the winding rule via an int and makes a new path.
GeneralPath.WIND_NON_ZERO corresponds
to WindingRule.WIND_NON_ZERO.
GeneralPath.WIND_EVEN_ODD corresponds
to WindingRule.WIND_EVEN_ODD.
Ignores an invalid parameter.
Fires property change: SET_WINDING_RULE.
rule - the winding rule as an intpublic final WindingRule getWindingRule()
public final void removeShapeData()
Removes all vertex and tangent data and makes a new path.
Fires property change: REMOVE_SHAPE_DATA.
public final GeneralPath getPath()
Returns a copy of the GeneralPath that defines this
Shape based on the vertex data, tangent data, path
strategy, closure mode, and winding rule.
Specifically, calls pathstrategy.makePath using the
current path strategy and passing the current vertex data, tangent
data, closure mode, and winding rule.
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.
May be overridden in a derived class if some settings such as the tangent data must be computed before the path is constructed and set.
To assist in a possible override, we reveal additional detail about the implementation.
BaseShape maintains a private member path of
type GeneralPath. The implementation of this method is:
path = getPath();
An override method should make any necessary changes to the vertex data, tangent data, closure mode, and winding rule, and then call:
super.makePath();
Normally, an override method will change only the tangent data.
An override method may not directly access the path member
variable since it is private.
public final PolygonShape makeClosedPolygon()
PolygonShape
whose vertex data is a copy of the vertex data of this shape.
public final PolygonShape makeOpenPolygon()
PolygonShape
whose vertex data is a copy of the vertex data of this shape.
public final PolygonDotsShape makePolygonDots()
PolygonDotsShape
whose vertex data is a copy of the vertex data of this shape.
public final PolygonShape makeClosedBezierFrame()
PolygonShape
whose vertex data is the closed Bezier frame corresponding
to the vertex and tangent data of this shape
and whose winding rule is the same as this shape.
public final PolygonShape makeOpenBezierFrame()
PolygonShape
whose vertex data is the open Bezier frame corresponding
to the vertex and tangent data of this shape
and whose winding rule is the same as this shape.
public final PolygonDotsShape makeClosedControlDots()
PolygonDotsShape
whose vertex data is the closed Bezier control point list
corresponding to the vertex and tangent data of this shape.
public final PolygonDotsShape makeOpenControlDots()
PolygonDotsShape
whose vertex data is the open Bezier control point list
corresponding to the vertex and tangent data of this shape.
public final TweakableShape makeBezierTangentSegments()
TweakableShape
whose vertex and tangent data is a copy of the corresponding
vertex and tangent data of this shape,
whose Path.Strategy is
Path.BEZIER_TANGENT_SEGMENTS,
and whose winding rule is the same as this shape.
public final float[][] getClosedBezierFrameData()
Returns the closed Bezier frame data corresponding to the vertex and tangent data.
If N is length of the vertex data
then the returned array will have the form
float[3*N][2].
If the internal tangent array is null then it
is treated as an array of zeroes.
For each index i less than N
with j=(i+1)%N,
this method places the following three points into successive
cells in the result array:
getVertex(i)
getControlA(i)
getControlB(j)
public final float[][] getOpenBezierFrameData()
Returns the open Bezier frame data corresponding to the vertex and tangent data.
If N is length of the vertex data
then the returned array will have the form
float[3*N-2][2] if N is positive and
float[0][2] if N is zero.
If the internal tangent array is null then it
is treated as an array of zeroes.
For each index i less than (N-1)
with j=(i+1),
this method places the following three points into successive
cells in the result array:
getVertex(i)
getControlA(i)
getControlB(j)
The last point placed into the array is:
getVertex(N-1)
public final float[][] getClosedBezierControlData()
Returns the closed Bezier control points corresponding to the vertex and tangent data.
If N is length of the vertex data
then the returned array will have the form
float[2*N][2].
If the internal tangent array is null then it
is treated as an array of zeroes.
For each index i less than N
with j=(i+1)%N,
this method places the following two points into successive
cells in the result array:
getControlA(i)
getControlB(j)
public final float[][] getOpenBezierControlData()
Returns the open Bezier control points corresponding to the vertex and tangent data.
If N is length of the vertex data
then the returned array will have the form
float[2*N-2][2] if N is greater than 1 and
float[0][2] if N is 0 or 1.
If the internal tangent array is null then it
is treated as an array of zeroes.
For each index i less than (N-1)
with j=(i+1),
this method places the following two points into successive
cells in the result array:
getControlA(i)
getControlB(j)
public final float[][] getBezierTangentSegmentData()
Returns the Bezier tangent segment data corresponding to the vertex and tangent data.
If N is length of the vertex data
then the returned array will have the form
float[2*N][2].
If the internal tangent array is null then it
is treated as an array of zeroes.
For each index i less than N,
this method places the following two points into successive
cells in the result array:
getControlB(i)
getControlA(i)
public static float[][] closedBezierFramePoints(float[][] vertex,
float[][] tangent)
Static method that returns a float array that contains the points on the closed Bezier frame for the given vertex and tangent arrays.
Precondition: For some integer N:
float[N][2]float[N][2] or nullIf the precondition holds, a new BaseShape is
constructed and this method then returns the result of
getClosedBezierFrameData on that shape.
If the precondition fails, then float[0][2] is returned.
vertex - the array of vertex informationtangent - the array of tangent information
public static float[][] openBezierFramePoints(float[][] vertex,
float[][] tangent)
Static method that returns a float array that contains the points on the open Bezier frame for the given vertex and tangent arrays.
Precondition: For some integer N:
float[N][2]float[N][2] or nullIf the precondition holds, a new BaseShape is
constructed and this method then returns the result of
getOpenBezierFrameData on that shape.
If the precondition fails, then float[0][2] is returned.
vertex - the array of vertex informationtangent - the array of tangent information
public static float[][] closedBezierControlPoints(float[][] vertex,
float[][] tangent)
Static method that returns a float array that contains the Bezier control points for the closed curve with the given vertex and tangent arrays.
Precondition: For some integer N:
float[N][2]float[N][2] or nullIf the precondition holds, a new BaseShape is
constructed and this method then returns the result of
getClosedBezierControlData on that shape.
If the precondition fails, then float[0][2] is returned.
vertex - the array of vertex informationtangent - the array of tangent information
public static float[][] openBezierControlPoints(float[][] vertex,
float[][] tangent)
Static method that returns a float array that contains the Bezier control points for the open curve with the given vertex and tangent arrays.
Precondition: For some integer N:
float[N][2]float[N][2] or nullIf the precondition holds, a new BaseShape is
constructed and this method then returns the result of
getOpenBezierControlData on that shape.
If the precondition fails, then float[0][2] is returned.
vertex - the array of vertex informationtangent - the array of tangent information
public static float[][] bezierTangentSegmentPoints(float[][] vertex,
float[][] tangent)
Static method that returns a float array that contains the Bezier tangent segments for the given vertex and tangent arrays.
Precondition: For some integer N:
float[N][2]float[N][2] or nullIf the precondition holds, a new BaseShape is
constructed and this method then returns the result of
getBezierTangentSegmentData on that shape.
If the precondition fails, then float[0][2] is returned.
vertex - the array of vertex informationtangent - the array of tangent information
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 transform to apply to the path
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 transform to apply to the pathflatness - the flatness to use to simplify the pathpublic final Shape getTransformedShape(AffineTransform at)
Returns a new Shape obtained from this object by
using the path iterator corresponding to the given transform.
at - the transform to apply to the path
public final Shape getTransformedShape(AffineTransform at,
double flatness)
Returns a new Shape obtained from this object by
using the path iterator corresponding to the given transform
and flatness.
at - the transform to apply to the pathflatness - the flatness to use to simplify the pathpublic 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 | |||||||||