public abstract class Curve extends Object
A Curve is an object that defines itself using mathematical equations and points of a control-path in a given dimension. Classes that extend Curve must define the appendTo method.
A Curve object can be appended to a MultiPath object which creates a series of points that represent the curve. Most curves in the com.graphbuilder.curve package extend the ParametricCurve class, with one exception being the Polyline class. The ParametricCurve class allows curves to use the BinaryCurveApproximationAlgorithm class to generate the points. The number of points created depends on the curve properties, the control points, the sample limit and the flatness. The flatness is the only parameter that is controlled by the multi-path. How the flatness and sample limit affect the number of points created is described in the BinaryCurveApproximationAlgorithm class.
The data representation of a point is a double array. The double array was chosen because it offers a high degree of precision. An array based representation supports n-dimensional curves, with index locations acting as dimensions.
The ControlPath stores com.graphbuilder.curve.Point objects. The reason the ControlPath stores Point objects and not double arrays is to provide one level of indirection. For example, suppose two different objects had a reference to the same double array. To change the dimension of the array, a new array has to be created. This would require updating the references in each of the objects to the new array. However, if a Point object stores the array, and the objects refer to the Point object, then only the reference to the array in the Point object needs to be updated. However, multi-paths do not store Point objects, but instead references to double arrays. There is no need for MultiPaths to reference Point objects because the points inside a multi-path are generated.
In many of the implementations, curve instances share static memory blocks which are used to store the results of computations. The reason this is done is to avoid using excessive memory. However, none of the methods in the curve package are synchronized. Thus, multiple threads should not be appending curves to multi-paths, otherwise the results of computations will be overwritten. These static memory blocks are stored as thread local variables and retrieved in the constructor with almost zero overhead, so thread safe parallel usage is possible as long as multiple threads do not share or reuse the same curve instance.
Modifier and Type | Field and Description |
---|---|
protected boolean |
connect |
protected ControlPath |
cp |
protected GroupIterator |
gi |
Constructor and Description |
---|
Curve(ControlPath cp,
GroupIterator gi)
Constructs a curve with the specified control-path and group-iterator.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
appendTo(MultiPath mp)
Appends a sequence of points defined by this curve to the multi-path.
|
boolean |
getConnect()
Connect is used in the appendTo method to determine if the first point appended should be of type
MOVE_TO or LINE_TO.
|
ControlPath |
getControlPath()
Returns the control-path this curve uses to define itself.
|
GroupIterator |
getGroupIterator()
Returns the group-iterator associated with this curve.
|
void |
resetMemory()
Resets the shared memory to the initial state.
|
void |
setConnect(boolean b)
Sets the value of the boolean connect flag.
|
void |
setControlPath(ControlPath cp)
Sets the control-path this curve uses to define itself.
|
void |
setGroupIterator(GroupIterator gi)
Sets the group-iterator this curve uses to define itself.
|
protected ControlPath cp
getControlPath()
protected GroupIterator gi
getGroupIterator()
protected boolean connect
getConnect()
public Curve(ControlPath cp, GroupIterator gi)
IllegalArgumentException
- If the control-path or group-iterator is null.public ControlPath getControlPath()
setControlPath(ControlPath)
,
ControlPath
public void setControlPath(ControlPath cp)
IllegalArgumentException
- If the control-path is null.getControlPath()
public GroupIterator getGroupIterator()
setGroupIterator(GroupIterator)
,
getControlPath()
public void setGroupIterator(GroupIterator gi)
getGroupIterator()
public boolean getConnect()
public void setConnect(boolean b)
getConnect()
public abstract void appendTo(MultiPath mp)
MultiPath
,
BinaryCurveApproximationAlgorithm
public void resetMemory()
Copyright © 2024. All rights reserved.