KeyFrame
Evaluator
for Shape
objects.
This Evaluator
can be used to morph between the geometries
of two relatively arbitrary shapes with the only restrictions being
that the two different numbers of subpaths or two shapes with
disparate winding rules may not blend together in a pleasing
manner.
The ShapeEvaluator will do the best job it can if the shapes do
not match in winding rule or number of subpaths, but the geometry
of the shapes may need to be adjusted by other means to make the
shapes more like each other for best aesthetic effect.
Note that the process of comparing two geometries and finding similar
structures between them to blend for the morphing operation can be
expensive.
Instances of ShapeEvaluator
will properly perform the necessary
geometric analysis of their arguments on every method call and attempt
to cache the information so that they can operate more quickly if called
multiple times in a row on the same pair of Shape
objects.
As a result attempting to mutate a Shape
object that is stored
in one of their keyframes may not have any effect if the associated
ShapeEvaluator
has already cached the geometry.
Also, it is advisable to use different instances of ShapeEvaluator
for every pair of keyframes being morphed so that the cached information
can be reused as much as possible.
An example of proper usage:
SGShape s = ...; Shape s0 = ...; Shape s1 = ...; Shape s2 = ...; KeyFrame k0 = KeyFrame.create(0.0f, s0, new ShapeEvaluator()); KeyFrame k1 = KeyFrame.create(0.6f, s1, new ShapeEvaluator()); KeyFrame k2 = KeyFrame.create(1.0f, s2, new ShapeEvaluator()); KeyFrames morphFrames = KeyFrames.create(s, "shape", k0, k1, k2); Clip.create(5000, 1, morphFrames).start();
Modifier and Type | Class and Description |
---|---|
private static class | |
private static class | |
private static class |
Modifier and Type | Field and Description |
---|---|
private ShapeEvaluator. | |
private ShapeEvaluator. | |
private Shape | |
private Shape |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public Shape | |
private Shape | |
private static float | |
private static float[] | |
private void | |
private static int |
geom0 | back to summary |
---|---|
private ShapeEvaluator. |
geom1 | back to summary |
---|---|
private ShapeEvaluator. |
savedv0 | back to summary |
---|---|
private Shape savedv0 |
savedv1 | back to summary |
---|---|
private Shape savedv1 |
ShapeEvaluator | back to summary |
---|---|
pack-priv ShapeEvaluator() |
evaluate | back to summary |
---|---|
public Shape evaluate(Shape v0, Shape v1, float fraction) |
getShape | back to summary |
---|---|
private Shape getShape(float fraction) |
interp | back to summary |
---|---|
private static float interp(float v0, float v1, float t) |
mergeTvals | back to summary |
---|---|
private static float[] mergeTvals(float[] tvals0, float[] tvals1) |
recalculate | back to summary |
---|---|
private void recalculate(Shape v0, Shape v1) |
sortTvals | back to summary |
---|---|
private static int sortTvals(float[] tvals0, float[] tvals1, float[] newtvals) |
Modifier and Type | Field and Description |
---|---|
pack-priv float[] | |
pack-priv static final float | |
pack-priv float[] | |
pack-priv int | |
pack-priv static final float | |
pack-priv int |
Modifier and Type | Method and Description |
---|---|
private void | |
private void | |
private void | |
public float | |
public int | |
public float[] | |
public int | |
public void |
bezierCoords | back to summary |
---|---|
pack-priv float[] bezierCoords |
MIN_LEN | back to summary |
---|---|
pack-priv static final float MIN_LEN |
myTvals | back to summary |
---|---|
pack-priv float[] myTvals |
numCoords | back to summary |
---|---|
pack-priv int numCoords |
THIRD | back to summary |
---|---|
pack-priv static final float THIRD |
windingrule | back to summary |
---|---|
pack-priv int windingrule |
Geometry | back to summary |
---|---|
public Geometry(Shape s) |
appendCubicTo | back to summary |
---|---|
private void appendCubicTo(float ctrlx1, float ctrly1, float ctrlx2, float ctrly2, float x1, float y1) |
appendLineTo | back to summary |
---|---|
private void appendLineTo(float x0, float y0, float x1, float y1) |
appendQuadTo | back to summary |
---|---|
private void appendQuadTo(float x0, float y0, float ctrlx, float ctrly, float x1, float y1) |
getCoord | back to summary |
---|---|
public float getCoord(int i) |
getNumCoords | back to summary |
---|---|
public int getNumCoords() |
getTvals | back to summary |
---|---|
public float[] getTvals() |
getWindingRule | back to summary |
---|---|
public int getWindingRule() |
setTvals | back to summary |
---|---|
public void setTvals(float[] newTvals) |
Modifier and Type | Field and Description |
---|---|
pack-priv BaseTransform | |
pack-priv int | |
pack-priv ShapeEvaluator. | |
pack-priv ShapeEvaluator. | |
pack-priv float |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public int | currentSegment(float[]
an array that holds the data returned from
this method coords)Implements com. Returns the coordinates and type of the current path segment in the iteration. |
public int | getWindingRule()
Implements com. Returns the winding rule for determining the interior of the path. |
public boolean | |
public void | next()
Implements com. Moves the iterator to the next segment of the path forwards along the primary direction of traversal as long as there are more points in that direction. |
at | back to summary |
---|---|
pack-priv BaseTransform at |
cindex | back to summary |
---|---|
pack-priv int cindex |
g0 | back to summary |
---|---|
pack-priv ShapeEvaluator. |
g1 | back to summary |
---|---|
pack-priv ShapeEvaluator. |
t | back to summary |
---|---|
pack-priv float t |
Iterator | back to summary |
---|---|
public Iterator(BaseTransform at, ShapeEvaluator. |
currentSegment | back to summary |
---|---|
public int currentSegment(float[] coords) Implements com. Doc from com. Returns the coordinates and type of the current path segment in the iteration. The return value is the path-segment type: SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE. A float array of length 6 must be passed in and can be used to store the coordinates of the point(s). Each point is stored as a pair of float x,y coordinates. SEG_MOVETO and SEG_LINETO types returns one point, SEG_QUADTO returns two points, SEG_CUBICTO returns 3 points and SEG_CLOSE does not return any points.
|
getWindingRule | back to summary |
---|---|
public int getWindingRule() Implements com. Doc from com. Returns the winding rule for determining the interior of the path.
|
isDone | back to summary |
---|---|
public boolean isDone() Implements com. Doc from com. Tests if the iteration is complete.
|
next | back to summary |
---|---|
public void next() Implements com. Doc from com. Moves the iterator to the next segment of the path forwards along the primary direction of traversal as long as there are more points in that direction.
|
Modifier and Type | Field and Description |
---|---|
pack-priv ShapeEvaluator. | |
pack-priv ShapeEvaluator. | |
pack-priv float |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public boolean | contains(float
the specified X coordinate to be tested x, float the specified Y coordinate to be tested y)Implements abstract com. Tests if the specified coordinates are inside the boundary of the
|
public boolean | contains(float
the X coordinate of the upper-left corner
of the specified rectangular area x, float the Y coordinate of the upper-left corner
of the specified rectangular area y, float the width of the specified rectangular area width, float the height of the specified rectangular area height)Implements abstract com. Tests if the interior of the |
public Shape | copy()
Implements abstract com. Returns a new copy of this |
public RectBounds | getBounds()
Implements abstract com. Note that there is no guarantee that the returned
|
public PathIterator | getPathIterator(BaseTransform
an optional at)BaseTransform to be applied to the
coordinates as they are returned in the iteration, or
null if untransformed coordinates are desiredImplements abstract com. Returns an iterator object that iterates along the
|
public PathIterator | getPathIterator(BaseTransform
an optional at, float BaseTransform to be applied to the
coordinates as they are returned in the iteration, or
null if untransformed coordinates are desiredthe maximum distance that the line segments used to
approximate the curved segments are allowed to deviate
from any point on the original curve flatness)Implements abstract com. Returns an iterator object that iterates along the |
public Rectangle | |
public boolean | intersects(float
the X coordinate of the upper-left corner
of the specified rectangular area x, float the Y coordinate of the upper-left corner
of the specified rectangular area y, float the width of the specified rectangular area w, float the height of the specified rectangular area h)Implements abstract com. Tests if the interior of the |
geom0 | back to summary |
---|---|
pack-priv ShapeEvaluator. |
geom1 | back to summary |
---|---|
pack-priv ShapeEvaluator. |
t | back to summary |
---|---|
pack-priv float t |
MorphedShape | back to summary |
---|---|
pack-priv MorphedShape(ShapeEvaluator. |
contains | back to summary |
---|---|
public boolean contains(float x, float y) Implements abstract com. Doc from com. Tests if the specified coordinates are inside the boundary of the
|
contains | back to summary |
---|---|
public boolean contains(float x, float y, float width, float height) Implements abstract com. Doc from com. Tests if the interior of the
The
Shapes this method might
return false even though the Shape contains
the rectangular area.
The Area class performs
more accurate geometric computations than most
Shape objects and therefore can be used if a more precise
answer is required.
|
copy | back to summary |
---|---|
public Shape copy() Implements abstract com. Doc from com. Returns a new copy of this |
getBounds | back to summary |
---|---|
public RectBounds getBounds() Implements abstract com. Doc from com. Note that there is no guarantee that the returned
|
getPathIterator | back to summary |
---|---|
public PathIterator getPathIterator(BaseTransform at) Implements abstract com. Doc from com. Returns an iterator object that iterates along the
Each call to this method returns a fresh
It is recommended, but not guaranteed, that objects
implementing the
|
getPathIterator | back to summary |
---|---|
public PathIterator getPathIterator(BaseTransform at, float flatness) Implements abstract com. Doc from com. Returns an iterator object that iterates along the Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types are returned by the iterator.
If an optional
The amount of subdivision of the curved segments is controlled
by the
Each call to this method returns a fresh
It is recommended, but not guaranteed, that objects
implementing the
|
getRectangle | back to summary |
---|---|
public Rectangle getRectangle() |
intersects | back to summary |
---|---|
public boolean intersects(float x, float y, float w, float h) Implements abstract com. Doc from com. Tests if the interior of the
The
Shapes this method might
return true even though the rectangular area does not
intersect the Shape .
The Area class performs
more accurate computations of geometric intersection than most
Shape objects and therefore can be used if a more precise
answer is required.
|