Class AbstractSplinePathBuilder<T extends SplinePath2D>
- Direct Known Subclasses:
BasicSplinePathBuilder
,SplinePathBuilder
This class is not public. Its documentation is inherited by its superclasses, which is why there are javadoc comments. The class hierarchy is somewhat unusual because AbstractSplinePathBuilder's two subclassses differ in the type of the objects they create, and those objects are created and initialized the same way.
Note: this class is declared to be public even though no classes outside this package create subclasses of it. The reason is that scripting languages (both ESP and Nashorn) will generate errors if the class is not public due to the behavior of the Java reflection API. In particular, if this class is not public, those scripting-language implementations cannot find public methods such constantWIND_NON_ZERO() when given an instance of a subclass.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bzdev.scripting.ScriptingContext
ScriptingContext.BindingSwapper
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor.protected
Constructor given a parent. -
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(List<SplinePathBuilder.CPoint> cpoints) Add segments from a list to a path.void
append
(SplinePathBuilder.CPoint cpoint) Add a control point or operation to a path.void
append
(SplinePathBuilder.CPoint[] cpoints) Add segments to a path.void
Configure a spline-path builder using a scripting language, using a default winding rule.void
Configure a spline-path builder using a scripting language, specifying a winding rule.Get the enum constantSplinePathBuilder.CPointType.CLOSE
.Get the enum constantSplinePathBuilder.CPointType.CONTROL
.Get the enum constantSplinePathBuilder.CPointType.MOVE_TO
.Get the enum constantSplinePathBuilder.CPointType.SEG_END
.Get the enum constantSplinePathBuilder.CPointType.SPLINE
.Get the enum constantSplinePathBuilder.WindingRule.WIND_EVEN_ODD
.Get the enum constantSplinePathBuilder.WindingRule.WIND_NON_ZERO
.final SplinePathBuilder.CPoint
Create aSplinePathBuilder.CPoint
whose type isSplinePathBuilder.CPointType.CLOSE
.final SplinePathBuilder.CPoint
createCPointControl
(double x, double y) Create aSplinePathBuilder.CPoint
whose type isSplinePathBuilder.CPointType.CONTROL
.final SplinePathBuilder.CPoint
createCPointMoveTo
(double x, double y) Create aSplinePathBuilder.CPoint
whose type isSplinePathBuilder.CPointType.MOVE_TO
.final SplinePathBuilder.CPoint
createCPointSegEnd
(double x, double y) Create aSplinePathBuilder.CPoint
whose type isSplinePathBuilder.CPointType.SEG_END
.final SplinePathBuilder.CPoint
createCPointSpline
(double x, double y) Create aSplinePathBuilder.CPoint
whose type isSplinePathBuilder.CPointType.SPLINE
.getCPoints
(boolean reversed, AffineTransform af) Get the control points for this spline-path builder.double
Get the numerical limit for equality tests.getPath()
Get the path that was build.void
initPath()
Initialize the path with a default winding rule.void
initPath
(SplinePathBuilder.CPoint[] cpoints) Initialize a path using a default winding rule and an array of control points.void
initPath
(SplinePathBuilder.WindingRule windingRule) Initialize the path given a winding rule.void
initPath
(SplinePathBuilder.WindingRule windingRule, SplinePathBuilder.CPoint[] cpoints) Initialize the path given a winding rule and control points.static void
modifyCPoints
(List<SplinePathBuilder.CPoint> list, boolean reversed, AffineTransform af) Modify a list of control points for this spline-path builder.static void
modifyCPoints
(SplinePathBuilder.CPoint[] array, boolean reversed, AffineTransform af) Modify an array of control points for this spline-path builder.void
setNumericalLimit
(double value) Set the numerical limit for equality tests.Methods inherited from class org.bzdev.scripting.ScriptingContext
callScriptFunction, callScriptFunction, callScriptMethod, callScriptMethod, containsScriptObject, createBindings, createBindingSwapper, createScriptEngine, doGetDefaultBindings, doGetScriptEngine, doGetScriptLanguage, doScriptPrivileged, evalScript, evalScript, evalScript, evalScript, getErrorWriter, getNames, getReader, getScriptLanguage, getScriptObject, getWriter, hasScriptEngine, invokePrivateFunction, invokePrivateFunction, putScriptObject, setErrorWriter, setReader, setWriter, usingGraalVM
-
Constructor Details
-
AbstractSplinePathBuilder
protected AbstractSplinePathBuilder()Constructor. -
AbstractSplinePathBuilder
Constructor given a parent.- Parameters:
parent
- the parant scripting context.
-
-
Method Details
-
getPath
Get the path that was build.- Returns:
- the path
-
constantWIND_NON_ZERO
Get the enum constantSplinePathBuilder.WindingRule.WIND_NON_ZERO
.This is a convenience method used for scripting.
- Returns:
- the enum constant
-
constantWIND_EVEN_ODD
Get the enum constantSplinePathBuilder.WindingRule.WIND_EVEN_ODD
.This is a convenience method used for scripting.
- Returns:
- the enum constant
-
configure
Configure a spline-path builder using a scripting language, using a default winding rule.- Parameters:
spec
- a scripting-language object describing the configuration- Throws:
UnsupportedOperationException
- this object does not support scriptingIllegalArgumentException
- an error occurred while processing the specification or winding rule.
-
configure
public void configure(Object windingRule, Object spec) throws UnsupportedOperationException, IllegalArgumentException Configure a spline-path builder using a scripting language, specifying a winding rule.- Parameters:
windingRule
- the winding rulespec
- a scripting-language object describing the configuration- Throws:
UnsupportedOperationException
- this object does not support scriptingIllegalArgumentException
- an error occurred while processing the specification or winding rule.
-
initPath
public void initPath()Initialize the path with a default winding rule. Also create a new path. -
initPath
Initialize the path given a winding rule. Also create a new path.- Parameters:
windingRule
- WindingRule.WIND_EVEN_ODD or WindingRule.WIND_NON_ZERO.
-
initPath
Initialize a path using a default winding rule and an array of control points.- Parameters:
cpoints
- the control points along the segments in order of occurrence.
-
initPath
Initialize the path given a winding rule and control points.- Parameters:
windingRule
- WindingRule.WIND_EVEN_ODD or WindingRule.WIND_NON_ZERO.cpoints
- the control points along the segments in order of occurrence.
-
getCPoints
Get the control points for this spline-path builder. If the array that is returned describes a path that is closed, reversing the list elements may result in a different starting point: the exception, where the starting point does not change, occurs when the initial element in the list has a type ofSplinePathBuilder.CPointType.MOVE_TO
.For a path to be reversed, each element whose type is
SplinePathBuilder.CPointType.CLOSE
must be followed by an element whoseSplinePathBuilder.CPointType.MOVE_TO
orSplinePathBuilder.CPointType.MOVE_TO_NEXT
unless it is the last element added to a path builder.- Parameters:
reversed
- true if the path represented by the control points should be reversed; false otherwiseaf
- an affine transform to apply to the control points; null for the identity transform- Returns:
- the control points, possibly modified by the arguments
- Throws:
IllegalStateException
- the control points are not in an allowed order
-
modifyCPoints
public static void modifyCPoints(List<SplinePathBuilder.CPoint> list, boolean reversed, AffineTransform af) throws UnsupportedOperationException, IllegalArgumentException Modify a list of control points for this spline-path builder. If the array describes a path that is closed, reversing the list elements may result in a different starting point: the exception, where the starting point does not change, occurs when the initial element in the list has a type ofSplinePathBuilder.CPointType.MOVE_TO
.For a list to be reversed, each element whose type is
SplinePathBuilder.CPointType.CLOSE
must be followed by an element whoseSplinePathBuilder.CPointType.MOVE_TO
orSplinePathBuilder.CPointType.MOVE_TO_NEXT
.- Parameters:
list
- the list to modifyreversed
- true if the path represented by the control points should be reversed; false otherwiseaf
- an affine transform to apply to the control points; null for the identity transform- Throws:
UnsupportedOperationException
- the list does not allow items to be added or removed.IllegalArgumentException
- the control-point list does not have its points in an allowed order
-
modifyCPoints
public static void modifyCPoints(SplinePathBuilder.CPoint[] array, boolean reversed, AffineTransform af) throws IllegalArgumentException Modify an array of control points for this spline-path builder. If the array describes a path that is closed, reversing the array elements may result in a different starting point: the exception, where the starting point does not change, occurs when the initial element in the list has a type ofSplinePathBuilder.CPointType.MOVE_TO
.For a list to be reversed, each element whose type is
SplinePathBuilder.CPointType.CLOSE
must be followed by an element whoseSplinePathBuilder.CPointType.MOVE_TO
orSplinePathBuilder.CPointType.MOVE_TO_NEXT
.- Parameters:
array
- the control point sequence to modifyreversed
- true if the path represented by the control points should be reversed; false otherwiseaf
- an affine transform to apply to the control points; null for the identity transform- Throws:
IllegalArgumentException
- the control-point array does not have its points in an allowed order
-
append
Add a control point or operation to a path. Segments can also be added by calling getPath() and using the methods specific to SplinePath2D.- Parameters:
cpoint
- the control point .
-
append
Add segments to a path. Segments can also be added by calling getPath() and using the methods specific to SplinePath2D.- Parameters:
cpoints
- the control points along the segments in order of occurrence.
-
append
Add segments from a list to a path. Segments can also be added by calling getPath() and using the methods specific to SplinePath2D.- Parameters:
cpoints
- the control points along the segments in order of occurrence.
-
setNumericalLimit
public void setNumericalLimit(double value) Set the numerical limit for equality tests. For a sequence of spline points, the maximum deviation of the x and y coordinates from the point specified in the last MOVE_TO operation is computed. If the deviation from the last MOVE_TO coordinates of the x or y value of the spline point provided before a CLOSE is less than the maximum deviation multiplied by the numerical limit, the two points are assumed to be identical.- Parameters:
value
- the numerical limit, which must be non-negative
-
getNumericalLimit
public double getNumericalLimit()Get the numerical limit for equality tests. For a sequence of spline points, the maximum deviation of the x and y coordinates from the point specified in the last MOVE_TO operation is computed. If the deviation from the last MOVE_TO coordinates of the x or y value of the spline point provided before a CLOSE is less than the maximum deviation multiplied by the numerical limit, the two points are assumed to be identical.- Returns:
- the numerical limit
- See Also:
-
constantCLOSE
Get the enum constantSplinePathBuilder.CPointType.CLOSE
.This is a convenience method used for scripting. It is not final because adding a final declaration confuses the Nashorn javascript engine.
- Returns:
- the enum constant
-
createCPointClose
Create aSplinePathBuilder.CPoint
whose type isSplinePathBuilder.CPointType.CLOSE
.This is a convenience method used for scripting.
- Returns:
- the
SplinePathBuilder.CPoint
-
constantMOVE_TO
Get the enum constantSplinePathBuilder.CPointType.MOVE_TO
.This is a convenience method used for scripting. It is not final because adding a final declaration confuses the Nashorn javascript engine.
- Returns:
- the enum constant
-
createCPointMoveTo
Create aSplinePathBuilder.CPoint
whose type isSplinePathBuilder.CPointType.MOVE_TO
.This is a convenience method used for scripting.
- Parameters:
x
- the X coordinatey
- the Y coordinate- Returns:
- the
SplinePathBuilder.CPoint
-
constantSEG_END
Get the enum constantSplinePathBuilder.CPointType.SEG_END
.This is a convenience method used for scripting. It is not final because adding a final declaration confuses the Nashorn javascript engine.
- Returns:
- the enum constant
-
createCPointSegEnd
Create aSplinePathBuilder.CPoint
whose type isSplinePathBuilder.CPointType.SEG_END
.This is a convenience method used for scripting.
- Parameters:
x
- the X coordinatey
- the Y coordinate- Returns:
- the
SplinePathBuilder.CPoint
-
constantCONTROL
Get the enum constantSplinePathBuilder.CPointType.CONTROL
.This is a convenience method used for scripting. It is not final because adding a final declaration confuses the Nashorn javascript engine.
- Returns:
- the enum constant
-
createCPointControl
Create aSplinePathBuilder.CPoint
whose type isSplinePathBuilder.CPointType.CONTROL
.This is a convenience method used for scripting.
- Parameters:
x
- the X coordinatey
- the Y coordinate- Returns:
- the
SplinePathBuilder.CPoint
-
constantSPLINE
Get the enum constantSplinePathBuilder.CPointType.SPLINE
.This is a convenience method used for scripting. It is not final because adding a final declaration confuses the Nashorn javascript engine.
- Returns:
- the enum constant
-
createCPointSpline
Create aSplinePathBuilder.CPoint
whose type isSplinePathBuilder.CPointType.SPLINE
.This is a convenience method used for scripting.
- Parameters:
x
- the X coordinatey
- the Y coordinate- Returns:
- the
SplinePathBuilder.CPoint
-