|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.gui.BaseShape
edu.neu.ccs.gui.TweakableShape
Class TweakableShape implements a BaseShape
in which the vertex array and the tangent array may be changed
independently of one another.
The derived class TweakableCurve was introduced in
2.4.0 to fix the path strategy to be Path.BEZIER_CUBIC
since that is the most common case.
To define a shape in which the tangent array is computed from the
vertex array automatically, use the class AutomaticShape.
The internal tangent array will be maintained as non-null
by creating an array of zero tangents if needed.
| Field Summary | |
static String |
ADD_VERTEX_TANGENT
Bound property name to add one or more vertex-tangent pairs. |
static String |
REMOVE_VERTEX_TANGENT
Bound property name to remove one or more vertex-tangent pairs. |
static String |
SET_TANGENT
Bound property name to set one or more tangents. |
static String |
SET_VERTEX
Bound property name to set one or more vertices. |
static String |
SET_VERTEX_TANGENT
Bound property name to set one or more vertex-tangent pairs. |
| Fields inherited from class edu.neu.ccs.gui.BaseShape |
REMOVE_SHAPE_DATA, SET_CLOSURE_MODE, SET_PATH_STRATEGY, SET_WINDING_RULE, tangent, vertex |
| Constructor Summary | |
TweakableShape()
The default constructor with an empty shape. |
|
TweakableShape(float[][] vertex)
The constructor with the given vertex data. |
|
TweakableShape(float[][] vertex,
float[][] tangent)
The constructor with the given vertex and tangent data. |
|
TweakableShape(float[][] vertex,
float[][] tangent,
Path.Strategy pathstrategy)
The constructor with the given vertex and tangent data and the given path strategy. |
|
TweakableShape(float[][] vertex,
float[][] tangent,
Path.Strategy pathstrategy,
ClosureMode closuremode)
The constructor with the given vertex and tangent data, the given path strategy, and the given closure mode. |
|
TweakableShape(float[][] vertex,
float[][] tangent,
Path.Strategy pathstrategy,
ClosureMode closuremode,
WindingRule windingrule)
The constructor with the given vertex and tangent data, the given path strategy, the given closure mode, and the given winding rule. |
|
| Method Summary | |
void |
addVertexTangent(int index,
float[] array)
Adds a new vertex and tangent at the given index with the given array of point and displacement coordinates and makes a new path. |
void |
addVertexTangent(int index,
float[] point,
float[] delta)
Adds a new vertex and tangent at the given index using the given point and delta arrays and makes a new path. |
void |
addVertexTangent(int index,
float x,
float y,
float dx,
float dy)
Adds a new vertex and tangent at the given index with the given point and displacement coordinates x, y, dx, dy. |
void |
addVerticesTangents(int index,
float[][] array)
Adds a new sequence of vertices and tangents at the given index extracting data from the given array of type float[K][4] and then makes a new path. |
void |
addVerticesTangents(int index,
float[][] points,
float[][] deltas)
Adds a new sequence of vertices and tangents at the given index using copies of the given points and deltas and then makes a new path. |
void |
appendVertexTangent(float[] array)
Appends a new vertex and tangent with the given array of point and displacement coordinates and makes a new path. |
void |
appendVertexTangent(float[] point,
float[] delta)
Appends a new vertex and tangent using the given point and delta arrays and makes a new path. |
void |
appendVertexTangent(float x,
float y,
float dx,
float dy)
Appends a new vertex and tangent with the given point and displacement coordinates x, y, dx, dy. |
void |
appendVerticesTangents(float[][] array)
Appends a new sequence of vertices and tangents extracting data from the given array of type float[K][4] and then makes a new path. |
void |
appendVerticesTangents(float[][] points,
float[][] deltas)
Appends a new sequence of vertices and tangents using copies of the given points and deltas and then makes a new path. |
float[][] |
removeAllVerticesTangents()
Removes all vertices and tangents, makes a new path, and returns an array float[N][4] with the
vertices and tangents that were removed. |
float[] |
removeVertexTangent(int index)
Removes the vertex/tangent at the given index, makes a new path, and returns an array with the data from the removed vertex/tangent as x, y, dx, dy. |
float[][] |
removeVerticesTangents(int m,
int n)
Removes the vertices and tangents starting at the given index m inclusive and ending at the given index n exclusive, makes a new path, and returns an array float[K][4]
with the vertices and tangents that were removed. |
void |
setTangent(int index,
float[] delta)
Sets the tangent at the given index to the given displacement and makes a new path. |
void |
setTangent(int index,
float dx,
float dy)
Sets the tangent at the given index to the given displacement coordinates and makes a new path. |
void |
setTangentData(float[][] tangent)
Sets the tangent data of the shape using a 2-dimensional array of single precision numbers and makes a new path. |
void |
setTangentViaControlA(int index,
float[] control)
Sets the tangent at the given index to using the given ahead control point and makes a new path. |
void |
setTangentViaControlA(int index,
float x,
float y)
Sets the tangent at the given index using the given coordinates for the ahead control point and makes a new path. |
void |
setTangentViaControlB(int index,
float[] control)
Sets the tangent at the given index to using the given behind control point and makes a new path. |
void |
setTangentViaControlB(int index,
float x,
float y)
Sets the tangent at the given index using the given coordinates for the behind control point and makes a new path. |
void |
setVertex(int index,
float[] point)
Sets the vertex at the given index to the given point and makes a new path. |
void |
setVertex(int index,
float x,
float y)
Sets the vertex at the given index to the given point coordinates and makes a new path. |
void |
setVertexData(float[][] vertex)
Sets the vertex data of the shape using a 2-dimensional array of single precision numbers and makes a new path. |
void |
setVertexTangent(int index,
float[] array)
Sets the vertex and tangent at the given index to the given array of point and displacement coordinates and makes a new path. |
void |
setVertexTangent(int index,
float[] point,
float[] delta)
Sets the vertex and tangent at the given index using the given point and delta arrays and makes a new path. |
void |
setVertexTangent(int index,
float x,
float y,
float dx,
float dy)
Sets the vertex and tangent at the given index to the given point and displacement coordinates and makes a new path. |
void |
setVertexTangentData(float[][] vertex_tangent)
Sets the vertex and tangent data of the shape using a 2-dimensional array of single precision numbers and makes a new path. |
void |
setVertexTangentData(float[][] vertex,
float[][] tangent)
Sets the vertex and tangent data of the shape using a pair of 2-dimensional arrays of single precision numbers 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_VERTEX
public static final String SET_TANGENT
public static final String SET_VERTEX_TANGENT
public static final String ADD_VERTEX_TANGENT
public static final String REMOVE_VERTEX_TANGENT
| Constructor Detail |
public TweakableShape()
The default constructor with an empty shape.
The default settings are as follows:
new float[0][2]new float[0][2]Path.BEZIER_CUBICClosureMode.CLOSEDWindingRule.WIND_NON_ZERO.
public TweakableShape(float[][] vertex)
The constructor with the given vertex data.
Preconditions:
null or
float[N][2] for some N.If the given vertex array is null then the
internal vertex and tangent arrays are set to
float[0][2].
Otherwise the vertex array will be cloned and an array of zero tangents will be constructed.
vertex - the vertex data
public TweakableShape(float[][] vertex,
float[][] tangent)
The constructor with the given vertex and tangent data.
Preconditions:
null or
float[N][2] for some N.null or
float[N][2] for the same N as in the vertex
array.If the given vertex array is null then the
given tangent array is ignored and the internal vertex and
tangent arrays are set to float[0][2].
Otherwise if the given tangent array is null
then the vertex array will be cloned and an array of zero
tangents will be constructed.
Otherwise both the vertex and tangent array should be
float[N][2] for the same N. These arrays will
be cloned to set the internal vertex and tangent data.
vertex - the vertex datatangent - the tangent data
public TweakableShape(float[][] vertex,
float[][] tangent,
Path.Strategy pathstrategy)
The constructor with the given vertex and tangent data and the given path strategy.
Preconditions:
null or
float[N][2] for some N.null or
float[N][2] for the same N as in the vertex
array.If the given vertex array is null then the
given tangent array is ignored and the internal vertex and
tangent arrays are set to float[0][2].
Otherwise if the given tangent array is null
then the vertex array will be cloned and an array of zero
tangents will be constructed.
Otherwise both the vertex and tangent array should be
float[N][2] for the same N. These arrays will
be cloned to set the internal vertex and tangent data.
vertex - the vertex datatangent - the tangent datapathstrategy - the path strategy
public TweakableShape(float[][] vertex,
float[][] tangent,
Path.Strategy pathstrategy,
ClosureMode closuremode)
The constructor with the given vertex and tangent data, the given path strategy, and the given closure mode.
Preconditions:
null or
float[N][2] for some N.null or
float[N][2] for the same N as in the vertex
array.If the given vertex array is null then the
given tangent array is ignored and the internal vertex and
tangent arrays are set to float[0][2].
Otherwise if the given tangent array is null
then the vertex array will be cloned and an array of zero
tangents will be constructed.
Otherwise both the vertex and tangent array should be
float[N][2] for the same N. These arrays will
be cloned to set the internal vertex and tangent data.
vertex - the vertex datatangent - the tangent datapathstrategy - the path strategyclosuremode - the closure mode
public TweakableShape(float[][] vertex,
float[][] tangent,
Path.Strategy pathstrategy,
ClosureMode closuremode,
WindingRule windingrule)
The constructor with the given vertex and tangent data, the given path strategy, the given closure mode, and the given winding rule.
Preconditions:
null or
float[N][2] for some N.null or
float[N][2] for the same N as in the vertex
array.If the given vertex array is null then the
given tangent array is ignored and the internal vertex and
tangent arrays are set to float[0][2].
Otherwise if the given tangent array is null
then the vertex array will be cloned and an array of zero
tangents will be constructed.
Otherwise both the vertex and tangent array should be
float[N][2] for the same N. These arrays will
be cloned to set the internal vertex and tangent data.
vertex - the vertex datatangent - the tangent datapathstrategy - the path strategyclosuremode - the closure modewindingrule - the winding rule| Method Detail |
public final void setVertexData(float[][] vertex)
Sets the vertex data of the shape using a 2-dimensional array of single precision numbers and makes a new path.
Does not change the current tangent data.
Preconditions:
null and has the form
float[N][2].float[N][2] for the same N.Does nothing if the preconditions fail.
Fires property change: SET_VERTEX.
vertex - the vertex datapublic final void setTangentData(float[][] tangent)
Sets the tangent data of the shape using a 2-dimensional array of single precision numbers and makes a new path.
Does not change the current vertex data.
Preconditions:
null or,
for some integer N, has the form
float[N][2].float[N][2] for the same N.If the given tangent array is null, then the
internal tangent array will be set to a new array of zeroes.
Does nothing if the preconditions fail.
Fires property change: SET_TANGENT.
tangent - the tangent data
public final void setVertexTangentData(float[][] vertex,
float[][] tangent)
Sets the vertex and tangent data of the shape using a pair of 2-dimensional arrays of single precision numbers and makes a new path.
Preconditions:
null or
float[N][2] for some N.null or
float[N][2] for the same N as in the vertex
array.If the given vertex array is null then the
given tangent array is ignored and the internal vertex and
tangent arrays are set to float[0][2].
Otherwise if the given tangent array is null
then the vertex array will be cloned and an array of zero
tangents will be constructed.
Otherwise both the vertex and tangent array should be
float[N][2] for the same N. These arrays will
be cloned to set the internal vertex and tangent data.
Does nothing if the preconditions fail.
Fires property change: SET_VERTEX_TANGENT.
vertex - the vertex datatangent - the tangent datapublic final void setVertexTangentData(float[][] vertex_tangent)
Sets the vertex and tangent data of the shape using a 2-dimensional array of single precision numbers and makes a new path.
Conceptually, each row of the array should contain 4 items (x, y, dx, dy).
Preconditions:
null or float[N][4] for
some N.If the given vertex_tangent array is null
then the internal vertex and tangent arrays are set to
float[0][2].
Does nothing if the preconditions fail.
Fires property change: SET_VERTEX_TANGENT.
vertex_tangent - the combined vertex and tangent data
public final void setVertex(int index,
float x,
float y)
Sets the vertex at the given index to the given point coordinates and makes a new path.
Does nothing if the index is not in [0, vertex.length).
Does not change the tangent data.
Fires property change: SET_VERTEX.
index - the vertex indexx - the new x-coordinate for the vertexy - the new y-coordinate for the vertex
public final void setVertex(int index,
float[] point)
Sets the vertex at the given index to the given point and makes a new path.
Does nothing if the index is not in [0, vertex.length).
Does nothing if point is not float[2].
Does not change the tangent data.
Fires property change: SET_VERTEX.
index - the vertex indexpoint - the new position for the vertex
public final void setTangent(int index,
float dx,
float dy)
Sets the tangent at the given index to the given displacement coordinates and makes a new path.
Does nothing if the index is not in [0, vertex.length).
Does not change the vertex data.
Fires property change: SET_TANGENT.
index - the tangent indexdx - the new x-coordinate for the displacementdy - the new y-coordinate for the displacement
public final void setTangent(int index,
float[] delta)
Sets the tangent at the given index to the given displacement and makes a new path.
Does nothing if the index is not in [0, vertex.length).
Does nothing if delta is not float[2].
Does not change the vertex data.
Fires property change: SET_TANGENT.
index - the tangent indexdelta - the new displacement for the tangent
public final void setTangentViaControlA(int index,
float x,
float y)
Sets the tangent at the given index using the given coordinates for the ahead control point and makes a new path.
Subtracts ((x,y) - vertex) at the given index to set the tangent coordinates.
Does nothing if the index is not in [0, vertex.length).
Does not change the vertex data.
Fires property change: SET_TANGENT.
index - the tangent indexx - the new x-coordinate for the ahead control pointy - the new y-coordinate for the ahead control point
public final void setTangentViaControlA(int index,
float[] control)
Sets the tangent at the given index to using the given ahead control point and makes a new path.
Subtracts (control - vertex) at the given index to set the tangent coordinates.
Does nothing if the index is not in [0, vertex.length).
Does nothing if control is not float[2].
Does not change the vertex data.
Fires property change: SET_TANGENT.
index - the tangent indexcontrol - the ahead control point
public final void setTangentViaControlB(int index,
float x,
float y)
Sets the tangent at the given index using the given coordinates for the behind control point and makes a new path.
Subtracts (vertex - (x,y)) at the given index to set the tangent coordinates.
Does nothing if the index is not in [0, vertex.length).
Does not change the vertex data.
Fires property change: SET_TANGENT.
index - the tangent indexx - the new x-coordinate for the behind control pointy - the new y-coordinate for the behind control point
public final void setTangentViaControlB(int index,
float[] control)
Sets the tangent at the given index to using the given behind control point and makes a new path.
Subtracts (vertex - control) at the given index to set the tangent coordinates.
Does nothing if the index is not in [0, vertex.length).
Does nothing if control is not float[2].
Does not change the vertex data.
Fires property change: SET_TANGENT.
index - the tangent indexcontrol - the behind control point
public final void setVertexTangent(int index,
float x,
float y,
float dx,
float dy)
Sets the vertex and tangent at the given index to the given point and displacement coordinates and makes a new path.
Does nothing if the index is not in [0, vertex.length).
Fires property change: SET_VERTEX_TANGENT.
index - the vertex/tangent indexx - the new x-coordinate for the vertexy - the new y-coordinate for the vertexdx - the new x-coordinate for the displacementdy - the new y-coordinate for the displacement
public final void setVertexTangent(int index,
float[] point,
float[] delta)
Sets the vertex and tangent at the given index using the given point and delta arrays and makes a new path.
Conceptually, the point array should contain 2 items (x, y) and the delta array 2 items (dx, dy).
Does nothing if the index is not in [0, vertex.length).
Does nothing if the arrays are not float[2].
Fires property change: SET_VERTEX_TANGENT.
index - the vertex/tangent indexpoint - the array with x, ydelta - the array with dx, dy
public final void setVertexTangent(int index,
float[] array)
Sets the vertex and tangent at the given index to the given array of point and displacement coordinates and makes a new path.
Conceptually, the array should contain 4 items (x, y, dx, dy).
Does nothing if the index is not in [0, vertex.length).
Does nothing if the array is not float[4].
Fires property change: SET_VERTEX_TANGENT.
index - the vertex/tangent indexarray - the array with x, y, dx, dy
public final void addVertexTangent(int index,
float x,
float y,
float dx,
float dy)
Adds a new vertex and tangent at the given index with the given point and displacement coordinates x, y, dx, dy.
If index is 0, the insertion is at the front.
If index is vertex.length, the insertion is at the end.
Forces the given index into the range:
0 <= index <= vertex.length
Fires property change: ADD_VERTEX_TANGENT.
index - the vertex/tangent indexx - the x-coordinate for the vertexy - the y-coordinate for the vertexdx - the x-coordinate for the tangentdy - the y-coordinate for the tangent
public final void addVertexTangent(int index,
float[] point,
float[] delta)
Adds a new vertex and tangent at the given index using the given point and delta arrays and makes a new path.
Conceptually, the point array should contain 2 items (x, y) and the delta array 2 items (dx, dy).
If index is 0, the insertion is at the front.
If index is vertex.length, the insertion is at the end.
Forces the given index into the range:
0 <= index <= vertex.length
Does nothing if the arrays are not float[2].
Fires property change: ADD_VERTEX_TANGENT.
index - the vertex/tangent indexpoint - the array with x, ydelta - the array with dx, dy
public final void addVertexTangent(int index,
float[] array)
Adds a new vertex and tangent at the given index with the given array of point and displacement coordinates and makes a new path.
Conceptually, the array should contain 4 items (x, y, dx, dy).
If index is 0, the insertion is at the front.
If index is vertex.length, the insertion is at the end.
Forces the given index into the range:
0 <= index <= vertex.length
Does nothing if array is not float[4].
Fires property change: ADD_VERTEX_TANGENT.
index - the vertex indexarray - the array with x, y, dx, dy
public final void addVerticesTangents(int index,
float[][] points,
float[][] deltas)
Adds a new sequence of vertices and tangents at the given index using copies of the given points and deltas and then makes a new path.
If index is 0, the insertion is at the front.
If index is vertex.length, the insertion is at the end.
Forces the given index into the range:
0 <= index <= vertex.length
Does nothing if the given arrays are null
or do not have the form float[K][2] for the
same K.
Fires property change: ADD_VERTEX_TANGENT.
index - the start indexpoints - the new vertices to adddeltas - the new tangents to add
public final void addVerticesTangents(int index,
float[][] array)
Adds a new sequence of vertices and tangents at the
given index extracting data from the given array of
type float[K][4] and then makes a new path.
Conceptually, the each row of the array should contain 4 items (x, y, dx, dy).
If index is 0, the insertion is at the front.
If index is vertex.length, the insertion is at the end.
Forces the given index into the range:
0 <= index <= vertex.length
Does nothing if the given array is null
or does not have the form float[K][4].
Fires property change: ADD_VERTEX_TANGENT.
index - the start indexarray - the new vertices and tangents to add
public final void appendVertexTangent(float x,
float y,
float dx,
float dy)
Appends a new vertex and tangent with the given point and displacement coordinates x, y, dx, dy.
Fires property change: ADD_VERTEX_TANGENT.
x - the x-coordinate for the vertexy - the y-coordinate for the vertexdx - the x-coordinate for the tangentdy - the y-coordinate for the tangent
public final void appendVertexTangent(float[] point,
float[] delta)
Appends a new vertex and tangent using the given point and delta arrays and makes a new path.
Conceptually, the point array should contain 2 items (x, y) and the delta array 2 items (dx, dy).
Does nothing if the arrays are not float[2].
Fires property change: ADD_VERTEX_TANGENT.
point - the array with x, ydelta - the array with dx, dypublic final void appendVertexTangent(float[] array)
Appends a new vertex and tangent with the given array of point and displacement coordinates and makes a new path.
Conceptually, the array should contain 4 items (x, y, dx, dy).
Does nothing if array is not float[4].
Fires property change: ADD_VERTEX_TANGENT.
array - the array with x, y, dx, dy
public final void appendVerticesTangents(float[][] points,
float[][] deltas)
Appends a new sequence of vertices and tangents using copies of the given points and deltas and then makes a new path.
Does nothing if the given arrays are null
or do not have the form float[K][2] for the
same K.
Fires property change: ADD_VERTEX_TANGENT.
points - the new vertices to appenddeltas - the new tangents to appendpublic final void appendVerticesTangents(float[][] array)
Appends a new sequence of vertices and tangents
extracting data from the given array of
type float[K][4] and then makes a new path.
Conceptually, the each row of the array should contain 4 items (x, y, dx, dy).
Does nothing if the given array is null
or does not have the form float[K][4].
Fires property change: ADD_VERTEX_TANGENT.
array - the new vertices and tangents to appendpublic final float[] removeVertexTangent(int index)
Removes the vertex/tangent at the given index, makes a new path, and returns an array with the data from the removed vertex/tangent as x, y, dx, dy.
If the index is not in [0, vertex.length) then removes
nothing and returns null.
Fires property change: REMOVE_VERTEX_TANGENT.
index - the vertex index
public final float[][] removeVerticesTangents(int m,
int n)
Removes the vertices and tangents starting at the given
index m inclusive and ending at the given index n exclusive,
makes a new path, and returns an array float[K][4]
with the vertices and tangents that were removed.
Conceptually, the each row of the array returned should contain 4 items (x, y, dx, dy).
Forces m and n into range if needed.
Returns an array of length 0 if no nodes are removed.
Fires property change: REMOVE_VERTEX_TANGENT.
m - the starting index inclusiven - the ending index exclusivepublic final float[][] removeAllVerticesTangents()
Removes all vertices and tangents, makes a new path,
and returns an array float[N][4] with the
vertices and tangents that were removed.
Conceptually, the each row of the array returned should contain 4 items (x, y, dx, dy).
Fires property change: REMOVE_VERTEX_TANGENT.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||