edu.neu.ccs.gui
Class AutomaticCurve

java.lang.Object
  extended byedu.neu.ccs.gui.BaseShape
      extended byedu.neu.ccs.gui.BaseVertexShape
          extended byedu.neu.ccs.gui.AutomaticShape
              extended byedu.neu.ccs.gui.AutomaticCurve
All Implemented Interfaces:
Shape, SupportsPropertyChange

public class AutomaticCurve
extends AutomaticShape

Class AutomaticCurve extends AutomaticShape and fixes the Path.Strategy to be Path.BEZIER_CUBIC.

The class provides a wealth of constructors so that the user can supply precisely the data that is needed and avoid having to specify default data. Let us explain in detail how this will work.

The five possible constructor parameters in order are:

The following preconditions must hold for the vertex and end tangent arrays when supplied:

Preconditions:

If the given vertex array is null then the internal vertex array is set to float[0][2].

If the given end tangent array is null then an open curve is rendered with the same end tangents as are computed automatically for the corresponding closed curve.

The default constructor has no parameters. In all other constructors, the vertex must be supplied to define the vertex points that the curve must pass through in sequential order.

The caller may supply any subset of the remaining parameters but whatever parameters are supplied must be in the order listed above. Since the types of the last four parameters are distinct, Java will be able to determine the particular constructor being called.

Let us now discuss the last four parameters but for explanatory reasons not in the order in which they must be supplied.

The closure mode determines whether the path will be closed or open and is either ClosureMode.CLOSED or ClosureMode.OPEN.

The tangent strategy excapsulates a pair of algorithms that compute the tangents which are used in turn to compute the Bezier control points for the cubic arches. One algorithm of the pair should compute the tangents for a CLOSED curve using just the vertex information and the other algorithm should compute the tangents for an OPEN curve using both the vertex and end tangent information. The Tangent.Strategy interface discusses the contract for both algorithms in detail. In particular, one requirement is that if the end tangent array is null then the tangents for an OPEN curve should be computed by the algorithm for a CLOSED curve. This has effect that the shape of a curve does not change if it is changed from OPEN to CLOSED or vice versa. On the other hand, if this is not a concern, then providing an end tangent array allows the user more control of the shape of an OPEN curve.

The class Tangent defines two families of tangent strategies that are parametrized to permit variation. The default strategy used in this class is: Tangent.bezierStrategy(). Since a tangent strategy is defined by an an interface, the user may also define and implement additional strategies.

The following conventions apply to the relationship between the end tangent array, the closure mode, and the default settings:

The winding rule determines which of two mathematical algorithms built into Java are used to fill regions: WindingRule.WIND_NON_ZERO or WindingRule.WIND_EVEN_ODD. There are valid arguments to choose either algorithm as the default but we have chosen WIND_NON_ZERO as the default.

Since the constructor parameters have been extensively discussed in this introduction, the comments in the actual constructors will be very brief.

Since:
2.4.0
Version:
2.4.0

Field Summary
 
Fields inherited from class edu.neu.ccs.gui.AutomaticShape
SET_END_TANGENT, SET_TANGENT_STRATEGY
 
Fields inherited from class edu.neu.ccs.gui.BaseVertexShape
ADD_VERTEX, REMOVE_VERTEX, SET_VERTEX
 
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
AutomaticCurve()
          The default constructor.
AutomaticCurve(float[][] vertex)
          The constructor with the given vertex data.
AutomaticCurve(float[][] vertex, ClosureMode closuremode)
          The constructor with the given vertex data and the given closure mode.
AutomaticCurve(float[][] vertex, ClosureMode closuremode, WindingRule windingrule)
          The constructor with the given vertex data, the given closure mode, and the given winding rule.
AutomaticCurve(float[][] vertex, float[][] endTangent)
          The constructor with the given vertex data and the given end tangent data.
AutomaticCurve(float[][] vertex, float[][] endTangent, ClosureMode closuremode)
          The constructor with the given vertex data, the given end tangent data, and the given closure mode.
AutomaticCurve(float[][] vertex, float[][] endTangent, ClosureMode closuremode, WindingRule windingrule)
          The constructor with the given vertex data, the given end tangent data, the given closure mode, and the given winding rule.
AutomaticCurve(float[][] vertex, float[][] endTangent, Tangent.Strategy tangentstrategy)
          The constructor with the given vertex data, the given end tangent data, and the given tangent strategy.
AutomaticCurve(float[][] vertex, float[][] endTangent, Tangent.Strategy tangentstrategy, ClosureMode closuremode)
          The constructor with the given vertex data, the given end tangent data, the given tangent strategy, and the given closure mode.
AutomaticCurve(float[][] vertex, float[][] endTangent, Tangent.Strategy tangentstrategy, ClosureMode closuremode, WindingRule windingrule)
          The constructor with the given vertex data, the given end tangent data, the given tangent strategy, the given closure mode, the given winding rule.
AutomaticCurve(float[][] vertex, float[][] endTangent, Tangent.Strategy tangentstrategy, WindingRule windingrule)
          The constructor with the given vertex data, the given end tangent data, the given tangent strategy, and the given winding rule.
AutomaticCurve(float[][] vertex, float[][] endTangent, WindingRule windingrule)
          The constructor with the given vertex data, the given end tangent data, and the given winding rule.
AutomaticCurve(float[][] vertex, Tangent.Strategy tangentstrategy)
          The constructor with the given vertex data and the given tangent strategy.
AutomaticCurve(float[][] vertex, Tangent.Strategy tangentstrategy, ClosureMode closuremode)
          The constructor with the given vertex data, the given tangent strategy, and the given closure mode.
AutomaticCurve(float[][] vertex, Tangent.Strategy tangentstrategy, ClosureMode closuremode, WindingRule windingrule)
          The constructor with the given vertex data, the given tangent strategy, the given closure mode, and the given winding rule.
AutomaticCurve(float[][] vertex, Tangent.Strategy tangentstrategy, WindingRule windingrule)
          The constructor with the given vertex data, the given tangent strategy, and the given winding rule.
AutomaticCurve(float[][] vertex, WindingRule windingrule)
          The constructor with the given vertex data and the given winding rule.
 
Method Summary
 void setPathStrategy(Path.Strategy pathstrategy)
          Since the Path.Strategy of this class is fixed to be Path.BEZIER_CUBIC, this method overrides the inherited method to do nothing.
 
Methods inherited from class edu.neu.ccs.gui.AutomaticShape
findEndTangentControl, findEndTangentControl, getEndTangent, getEndTangentControl, getEndTangentControlData, getEndTangentData, getEndTX, getEndTY, getTangentStrategy, isEndTangentNull, makeEndTangentControlDots, makePath, setEndTangent, setEndTangent, setEndTangentData, setEndTangentViaControl, setEndTangentViaControl, setTangentStrategy
 
Methods inherited from class edu.neu.ccs.gui.BaseVertexShape
addVertex, addVertex, addVertices, appendVertex, appendVertex, appendVertices, removeAllVertices, removeVertex, removeVertices, setVertex, setVertex, setVertexData
 
Methods inherited from class edu.neu.ccs.gui.BaseShape
addForwardingListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListeners, addPropertyChangeListeners, bezierTangentSegmentPoints, closedBezierControlPoints, closedBezierFramePoints, contains, contains, contains, contains, findControlA, findControlA, findControlB, findControlB, findVertex, findVertex, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAX, getAY, getBezierTangentSegmentData, getBounds, getBounds2D, getBX, getBY, getClosedBezierControlData, getClosedBezierFrameData, getClosureMode, getControlA, getControlB, getCubicCurvePoint, getForwardingListener, getOpenBezierControlData, getOpenBezierFrameData, getPath, getPathIterator, getPathIterator, getPathStrategy, getPolygonPoint, getPropertyChangeListeners, getPropertyChangeListeners, getTangent, getTangentData, getTransformedShape, getTransformedShape, getTX, getTY, getVertex, getVertexData, getVertexTangent, getVertexTangentData, getVX, getVY, getWindingRule, hasListeners, intersects, intersects, isTangentNull, length, makeBezierTangentSegments, makeClosedBezierFrame, makeClosedControlDots, makeClosedPolygon, makeOpenBezierFrame, makeOpenControlDots, makeOpenPolygon, makePolygonDots, openBezierControlPoints, openBezierFramePoints, removeAndAddForwardingListener, removeForwardingListener, removePropertyChangeListener, removePropertyChangeListener, removeShapeData, setClosureMode, setWindingRule, setWindingRule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutomaticCurve

public AutomaticCurve()

The default constructor.


AutomaticCurve

public AutomaticCurve(float[][] vertex)

The constructor with the given vertex data.

Parameters:
vertex - the vertex data

AutomaticCurve

public AutomaticCurve(float[][] vertex,
                      WindingRule windingrule)

The constructor with the given vertex data and the given winding rule.

Parameters:
vertex - the vertex data
windingrule - the winding rule

AutomaticCurve

public AutomaticCurve(float[][] vertex,
                      ClosureMode closuremode)

The constructor with the given vertex data and the given closure mode.

Parameters:
vertex - the vertex data
closuremode - the closure mode

AutomaticCurve

public AutomaticCurve(float[][] vertex,
                      ClosureMode closuremode,
                      WindingRule windingrule)

The constructor with the given vertex data, the given closure mode, and the given winding rule.

Parameters:
vertex - the vertex data
closuremode - the closure mode
windingrule - the winding rule

AutomaticCurve

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

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

Parameters:
vertex - the vertex data
tangentstrategy - the tangent strategy

AutomaticCurve

public AutomaticCurve(float[][] vertex,
                      Tangent.Strategy tangentstrategy,
                      WindingRule windingrule)

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

Parameters:
vertex - the vertex data
tangentstrategy - the tangent strategy
windingrule - the winding rule

AutomaticCurve

public AutomaticCurve(float[][] vertex,
                      Tangent.Strategy tangentstrategy,
                      ClosureMode closuremode)

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

Parameters:
vertex - the vertex data
tangentstrategy - the tangent strategy
closuremode - the closure mode

AutomaticCurve

public AutomaticCurve(float[][] vertex,
                      Tangent.Strategy tangentstrategy,
                      ClosureMode closuremode,
                      WindingRule windingrule)

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

Parameters:
vertex - the vertex data
tangentstrategy - the tangent strategy
closuremode - the closure mode
windingrule - the winding rule

AutomaticCurve

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

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

Parameters:
vertex - the vertex data
endTangent - the end tangent data

AutomaticCurve

public AutomaticCurve(float[][] vertex,
                      float[][] endTangent,
                      WindingRule windingrule)

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

Parameters:
vertex - the vertex data
endTangent - the end tangent data
windingrule - the winding rule

AutomaticCurve

public AutomaticCurve(float[][] vertex,
                      float[][] endTangent,
                      ClosureMode closuremode)

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

Parameters:
vertex - the vertex data
endTangent - the end tangent data
closuremode - the closure mode

AutomaticCurve

public AutomaticCurve(float[][] vertex,
                      float[][] endTangent,
                      ClosureMode closuremode,
                      WindingRule windingrule)

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

Parameters:
vertex - the vertex data
endTangent - the end tangent data
closuremode - the closure mode
windingrule - the winding rule

AutomaticCurve

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

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

Parameters:
vertex - the vertex data
endTangent - the end tangent data
tangentstrategy - the tangent strategy

AutomaticCurve

public AutomaticCurve(float[][] vertex,
                      float[][] endTangent,
                      Tangent.Strategy tangentstrategy,
                      WindingRule windingrule)

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

Parameters:
vertex - the vertex data
endTangent - the end tangent data
tangentstrategy - the tangent strategy
windingrule - the winding rule

AutomaticCurve

public AutomaticCurve(float[][] vertex,
                      float[][] endTangent,
                      Tangent.Strategy tangentstrategy,
                      ClosureMode closuremode)

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

Parameters:
vertex - the vertex data
endTangent - the end tangent data
tangentstrategy - the tangent strategy
closuremode - the closure mode

AutomaticCurve

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

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

Parameters:
vertex - the vertex data
endTangent - the end tangent data
tangentstrategy - the tangent strategy
closuremode - the closure mode
windingrule - the winding rule
Method Detail

setPathStrategy

public final void setPathStrategy(Path.Strategy pathstrategy)

Since the Path.Strategy of this class is fixed to be Path.BEZIER_CUBIC, this method overrides the inherited method to do nothing.

Overrides:
setPathStrategy in class BaseShape
Parameters:
pathstrategy - the path strategy to set