edu.neu.ccs.gui
Class AutomaticShape

java.lang.Object
  |
  +--edu.neu.ccs.gui.BaseShape
        |
        +--edu.neu.ccs.gui.AutomaticShape
All Implemented Interfaces:
Shape, SupportsPropertyChange

public class AutomaticShape
extends BaseShape

Class AutomaticShape implements a BaseShape in which the tangent array is always computed from the vertex array automatically using a Tangent.Strategy object.

The default tangent strategy produces Bezier curves in which the first and second derivatives of the curve are continuous at each vertex. This strategy is described in the article:

Richard Rasala, Explicit Cubic Spline Interpolation Formulas, in Andrew S. Glassner, Graphics Gems, Academic Press, 1990, 579-584.

To define a shape in which the tangent array varies independently of the vertex array, use the class TweakableShape.

Since:
2.3
See Also:
Path, Tangent, TweakableShape

Field Summary
static String ADD_VERTEX
          Bound property name to add one vertex.
static String REMOVE_VERTEX
          Bound property name to remove one vertex.
static String SET_END_TANGENT
          Bound property name to set one end tangent.
static String SET_END_TANGENT_DATA
          Bound property name to set both end tangents.
static String SET_TANGENT_STRATEGY
          Bound property name to set the tangent strategy.
static String SET_VERTEX
          Bound property name to set one vertex.
static String SET_VERTEX_DATA
          Bound property name to set the vertex data.
 
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
AutomaticShape()
          The default constructor with an empty shape.
AutomaticShape(float[][] vertex)
          The constructor with the given vertex data.
AutomaticShape(float[][] vertex, float[][] endTangent)
          The constructor with the given vertex data and the given end tangent data.
AutomaticShape(float[][] vertex, float[][] endTangent, Tangent.Strategy tangentstrategy)
          The constructor with the given vertex data, the given end tangent data, and the given tangent strategy.
AutomaticShape(float[][] vertex, float[][] endTangent, Tangent.Strategy tangentstrategy, Path.Strategy pathstrategy)
          The constructor with the given vertex data, the given end tangent data, the given tangent strategy, and the given path strategy.
AutomaticShape(float[][] vertex, float[][] endTangent, Tangent.Strategy tangentstrategy, Path.Strategy pathstrategy, ClosureMode closuremode)
          The constructor with the given vertex data, the given end tangent data, the given tangent strategy, the given path strategy, and the given closure mode.
AutomaticShape(float[][] vertex, float[][] endTangent, Tangent.Strategy tangentstrategy, Path.Strategy pathstrategy, ClosureMode closuremode, WindingRule windingrule)
          The constructor with the given vertex data, the given end tangent data, the given tangent strategy, the given path strategy, the given closure mode, and the given winding rule.
 
Method Summary
 void addVertex(int index, float[] point)
          Add a new vertex at the given index with the given point.
 void addVertex(int index, float x, float y)
          Add a new vertex at the given index with the given point coordinates.
 float[][] getEndTangentData()
          Returns a copy of the endTangent data.
 Tangent.Strategy getTangentStrategy()
          Returns the tangent strategy.
protected  void makeAutomaticPath()
          Make the path for this AutomaticShape taking into account the vertex and end tangent arrays and the closure mode.
 void removeVertex(int index)
          Remove the vertex at the given index.
 void setEndTangent(int index, float[] delta)
          Sets the end tangent at the given index (0, 1) to the given delta and makes a new path.
 void setEndTangent(int index, float dx, float dy)
          Sets the end tangent at the given index (0, 1) to the given delta coordinates dx, dy and makes a new path.
 void setEndTangentData(float[][] endTangent)
          Sets the end tangent data of the shape using a 2-by-2 array of single precision numbers and makes a new path.
 void setTangentStrategy(Tangent.Strategy tangentstrategy)
          Sets the tangent strategy of the shape 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.
 
Methods inherited from class edu.neu.ccs.gui.BaseShape
addForwardingListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListeners, addPropertyChangeListeners, contains, contains, contains, contains, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBezierTangentSegmentData, getBounds, getBounds2D, getClosedBezierFrameData, getClosureMode, getCubicCurvePoint, getForwardingListener, getMergedVertexTangentData, getOpenBezierFrameData, getPath, getPathIterator, getPathIterator, getPathStrategy, getPolygonPoint, getPropertyChangeListeners, getPropertyChangeListeners, getTangentData, getVertexData, getWindingRule, hasListeners, intersects, intersects, length, makeBezierTangentSegments, makeClosedBezierFrame, makeOpenBezierFrame, makePath, makePolygonDots, removeAndAddForwardingListener, removeForwardingListener, removePropertyChangeListener, removePropertyChangeListener, removeShapeData, setClosureMode, setPathStrategy, setWindingRule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SET_VERTEX_DATA

public static final String SET_VERTEX_DATA
Bound property name to set the vertex data.

See Also:
Constant Field Values

SET_VERTEX

public static final String SET_VERTEX
Bound property name to set one vertex.

See Also:
Constant Field Values

ADD_VERTEX

public static final String ADD_VERTEX
Bound property name to add one vertex.

See Also:
Constant Field Values

REMOVE_VERTEX

public static final String REMOVE_VERTEX
Bound property name to remove one vertex.

See Also:
Constant Field Values

SET_TANGENT_STRATEGY

public static final String SET_TANGENT_STRATEGY
Bound property name to set the tangent strategy.

See Also:
Constant Field Values

SET_END_TANGENT_DATA

public static final String SET_END_TANGENT_DATA
Bound property name to set both end tangents.

See Also:
Constant Field Values

SET_END_TANGENT

public static final String SET_END_TANGENT
Bound property name to set one end tangent.

See Also:
Constant Field Values
Constructor Detail

AutomaticShape

public AutomaticShape()

The default constructor with an empty shape.

The default settings are as follows:

See Also:
AutomaticShape(float[][]), AutomaticShape(float[][], float[][]), AutomaticShape(float[][], float[][], Tangent.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode, WindingRule), setVertexData(float[][]), setEndTangentData(float[][])

AutomaticShape

public AutomaticShape(float[][] vertex)

The constructor with the given vertex data.

Precondition:

Parameters:
vertex - the vertex data
See Also:
AutomaticShape(), AutomaticShape(float[][], float[][]), AutomaticShape(float[][], float[][], Tangent.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode, WindingRule), setVertexData(float[][]), setEndTangentData(float[][])

AutomaticShape

public AutomaticShape(float[][] vertex,
                      float[][] endTangent)

The constructor with the given vertex data and the given end tangent data.

Precondition 1:

Precondition 2:

Parameters:
vertex - the vertex data
endTangent - the end tangent data
See Also:
AutomaticShape(), AutomaticShape(float[][]), AutomaticShape(float[][], float[][], Tangent.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode, WindingRule), setVertexData(float[][]), setEndTangentData(float[][])

AutomaticShape

public AutomaticShape(float[][] vertex,
                      float[][] endTangent,
                      Tangent.Strategy tangentstrategy)

The constructor with the given vertex data, the given end tangent data, and the given tangent strategy.

Precondition 1:

Precondition 2:

Parameters:
vertex - the vertex data
endTangent - the end tangent data
tangentstrategy - the tangent strategy
See Also:
AutomaticShape(), AutomaticShape(float[][]), AutomaticShape(float[][], float[][]), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode, WindingRule), setVertexData(float[][]), setEndTangentData(float[][])

AutomaticShape

public AutomaticShape(float[][] vertex,
                      float[][] endTangent,
                      Tangent.Strategy tangentstrategy,
                      Path.Strategy pathstrategy)

The constructor with the given vertex data, the given end tangent data, the given tangent strategy, and the given path strategy.

Precondition 1:

Precondition 2:

Parameters:
vertex - the vertex data
endTangent - the end tangent data
tangentstrategy - the tangent strategy
pathstrategy - the path strategy
See Also:
AutomaticShape(), AutomaticShape(float[][]), AutomaticShape(float[][], float[][]), AutomaticShape(float[][], float[][], Tangent.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode, WindingRule), setVertexData(float[][]), setEndTangentData(float[][])

AutomaticShape

public AutomaticShape(float[][] vertex,
                      float[][] endTangent,
                      Tangent.Strategy tangentstrategy,
                      Path.Strategy pathstrategy,
                      ClosureMode closuremode)

The constructor with the given vertex data, the given end tangent data, the given tangent strategy, the given path strategy, and the given closure mode.

Precondition 1:

Precondition 2:

Parameters:
vertex - the vertex data
endTangent - the end tangent data
tangentstrategy - the tangent strategy
pathstrategy - the path strategy
closuremode - the closure mode
See Also:
AutomaticShape(), AutomaticShape(), AutomaticShape(float[][]), AutomaticShape(float[][], float[][]), AutomaticShape(float[][], float[][], Tangent.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode, WindingRule), setVertexData(float[][]), setEndTangentData(float[][])

AutomaticShape

public AutomaticShape(float[][] vertex,
                      float[][] endTangent,
                      Tangent.Strategy tangentstrategy,
                      Path.Strategy pathstrategy,
                      ClosureMode closuremode,
                      WindingRule windingrule)

The constructor with the given vertex data, the given end tangent data, the given tangent strategy, the given path strategy, the given closure mode, and the given winding rule.

Precondition 1:

Precondition 2:

Parameters:
vertex - the vertex data
endTangent - the end tangent data
tangentstrategy - the tangent strategy
pathstrategy - the path strategy
closuremode - the closure mode
windingrule - the winding rule
See Also:
AutomaticShape(), AutomaticShape(float[][]), AutomaticShape(float[][], float[][]), AutomaticShape(float[][], float[][], Tangent.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy), AutomaticShape(float[][], float[][], Tangent.Strategy, Path.Strategy, ClosureMode), setVertexData(float[][]), setEndTangentData(float[][])
Method Detail

setVertexData

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.

Sets the tangents to be used when the shape is displayed as a curve.

Precondition:

Does nothing if the precondition fails.

Fires property change: SET_VERTEX_DATA.

Parameters:
vertex - the vertex data to set
See Also:
setVertex(int, float, float), setVertex(int, float[])

setVertex

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, length()).

Sets the tangents to be used when the shape is displayed as a curve.

Fires property change: SET_VERTEX.

Parameters:
index - the vertex index
x - the new x-coordinate for the vertex
y - the new y-coordinate for the vertex
See Also:
setVertexData(float[][]), setVertex(int, float[])

setVertex

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, length()).

Does nothing if point is not float[2].

Sets the tangents to be used when the shape is displayed as a curve.

Fires property change: SET_VERTEX.

Parameters:
index - the vertex index
point - the new point for the vertex at the given index
See Also:
setVertexData(float[][]), setVertex(int, float, float)

addVertex

public final void addVertex(int index,
                            float x,
                            float y)

Add a new vertex at the given index with the given point coordinates.

Does nothing if the index is not in [0, length()].

If index is 0, the insertion is at the front.

If index is length(), the insertion is at the end.

Sets the tangents to be used when the shape is displayed as a curve.

Fires property change: ADD_VERTEX.

Parameters:
index - the vertex index
x - the x-coordinate for the new vertex to add
y - the y-coordinate for the new vertex to add
See Also:
addVertex(int, float[]), removeVertex(int)

addVertex

public final void addVertex(int index,
                            float[] point)

Add a new vertex at the given index with the given point.

Does nothing if the index is not in [0, length()] or point is not float[2].

If index is 0, the insertion is at the front.

If index is length(), the insertion is at the end.

Sets the tangents to be used when the shape is displayed as a curve.

Fires property change: ADD_VERTEX.

Parameters:
index - the vertex index
point - the new vertex to add
See Also:
addVertex(int, float, float), removeVertex(int)

removeVertex

public final void removeVertex(int index)

Remove the vertex at the given index.

Does nothing if the index is not in [0, length()).

Sets the tangents to be used when the shape is displayed as a curve.

Fires property change: REMOVE_VERTEX.

Parameters:
index - the vertex index
See Also:
addVertex(int, float[]), addVertex(int, float, float)

setEndTangentData

public final void setEndTangentData(float[][] endTangent)

Sets the end tangent data of the shape using a 2-by-2 array of single precision numbers and makes a new path.

Sets the tangents to be used when the shape is displayed as a curve.

Precondition:

Does nothing if the precondition fails.

Fires property change: SET_END_TANGENT_DATA.

Parameters:
endTangent - the endTangent data to set
See Also:
getEndTangentData(), setEndTangent(int, float, float), setEndTangent(int, float[])

getEndTangentData

public final float[][] getEndTangentData()

Returns a copy of the endTangent data.

The returned value will either be null or have the form float[2][2].

Returns:
a copy of the endTangent data
See Also:
setEndTangentData(float[][]), setEndTangent(int, float, float), setEndTangent(int, float[])

setEndTangent

public final void setEndTangent(int index,
                                float dx,
                                float dy)

Sets the end tangent at the given index (0, 1) to the given delta coordinates dx, dy and makes a new path.

Does nothing if the index is not in [0, 1].

If the current end tangent array is null, then this array will be set to new float[2][2] before setting the delta value.

Sets the tangents to be used when the shape is displayed as a curve.

Fires property change: SET_END_TANGENT.

Parameters:
index - the end tangent index
dx - the new x-coordinate for the end tangent
dy - the new y-coordinate for the end tangent
See Also:
setEndTangentData(float[][]), getEndTangentData(), setEndTangent(int, float[])

setEndTangent

public final void setEndTangent(int index,
                                float[] delta)

Sets the end tangent at the given index (0, 1) to the given delta and makes a new path.

Does nothing if the index is not in [0, 1].

Does nothing if delta is not float[2].

If the current end tangent array is null, then this array will be set to new float[2][2] before setting the delta value.

Sets the tangents to be used when the shape is displayed as a curve.

Fires property change: SET_END_TANGENT.

Parameters:
index - the vertex index
delta - the new delta for the vertex at the given index
See Also:
setEndTangentData(float[][]), getEndTangentData(), setEndTangent(int, float, float)

setTangentStrategy

public final void setTangentStrategy(Tangent.Strategy tangentstrategy)

Sets the tangent strategy of the shape and makes a new path.

Does nothing if its parameter is null.

Also sets the tangents to be used when the shape is displayed as a curve.

Fires property change: SET_TANGENT_STRATEGY.

See Also:
getTangentStrategy()

getTangentStrategy

public final Tangent.Strategy getTangentStrategy()
Returns the tangent strategy.

Returns:
the tangent strategy
See Also:
setTangentStrategy(Tangent.Strategy)

makeAutomaticPath

protected final void makeAutomaticPath()
Make the path for this AutomaticShape taking into account the vertex and end tangent arrays and the closure mode.