Interface Path2D<ST extends Shape2D<?,?,I,P,V,B>,IT extends Path2D<?,?,I,P,V,B>,I extends PathIterator2D<?>,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Shape2D<?,?,I,P,V,B>>
-
- Type Parameters:
ST
- is the type of the general implementation.IT
- is the type of the implementation of this shape.I
- is the type of the iterator used to obtain the elements of the path.P
- is the type of the points.V
- is the type of the vectors.B
- is the type of the bounding boxes.
- All Superinterfaces:
Cloneable
,JsonableObject
,Serializable
,Shape2D<ST,IT,I,P,V,B>
public interface Path2D<ST extends Shape2D<?,?,I,P,V,B>,IT extends Path2D<?,?,I,P,V,B>,I extends PathIterator2D<?>,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Shape2D<?,?,I,P,V,B>> extends Shape2D<ST,IT,I,P,V,B>
2D Path.- Since:
- 13.0
- Version:
- 17.0 2020-01-04 14:41:43
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathgeom
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Path2D.ArcType
Type of drawing to used when drawing an arc.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
arcTo(Point2D<?,?> ctrl, Point2D<?,?> to)
Adds a section of an shallow ellipse to the current path.void
arcTo(Point2D<?,?> ctrl, Point2D<?,?> to, double tfrom, double tto, Path2D.ArcType type)
Adds a section of an shallow ellipse to the current path.void
arcTo(Point2D<?,?> to, Vector2D<?,?> radii, double xAxisRotation, boolean largeArcFlag, boolean sweepFlag)
Adds a section of an shallow ellipse to the current path.void
closePath()
Closes the current subpath by drawing a straight line back to the coordinates of the lastmoveTo
.boolean
containsControlPoint(Point2D<?,?> point)
Replies if the given points exists in the coordinates of this path.void
curveTo(Point2D<?,?> ctrl1, Point2D<?,?> ctrl2, Point2D<?,?> to)
Adds a curved segment, defined by three new points, to the path by drawing a Bézier curve that intersects both the current coordinates and the specified coordinates(x3, y3)
, using the specified points(x1, y1)
and(x2, y2)
as Bézier control points.P
getCurrentPoint()
Replies the last point in the path.default double
getLength()
Replies the total length of the path.double
getLengthSquared()
Replies the total squared length of the path.int
getPathElementCount()
Replies the number of path elements in this path.PathElementType
getPathElementTypeAt(int index)
Replies the type of the path element at the given position in this path.I
getPathIterator(double flatness)
Replies an iterator on the path elements.P
getPointAt(int index)
Replies the point at the given index.PathWindingRule
getWindingRule()
Replies the winding rule for the path.boolean
isCurved()
Replies the path contains a curve..boolean
isMultiParts()
Replies the path has multiple parts, i.e. multipleMOVE_TO
are inside.boolean
isPolygon()
Replies the path is composed only by oneMOVE_TO
, a sequence ofLINE_TO
orQUAD_TO
orCURVE_TO
, orARC_TO
, and a singleCLOSE
primitives.boolean
isPolyline()
Replies the path is composed only by oneMOVE_TO
, and a sequence ofLINE_TO
primitives.void
lineTo(Point2D<?,?> to)
Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in double precision.void
moveTo(Point2D<?,?> position)
Adds a point to the path by moving to the specified coordinates specified in double precision.void
moveToIfFar(Point2D<?,?> position)
Adds a point to the path by moving to the specified coordinates specified in double precision.void
quadTo(Point2D<?,?> ctrl, Point2D<?,?> to)
Adds a curved segment, defined by two new points, to the path by drawing a Quadratic curve that intersects both the current coordinates and the specified coordinates(x2, y2)
, using the specified point(x1, y1)
as a quadratic parametric control point.void
removeLast()
Remove the last action.void
setLastPoint(Point2D<?,?> point)
Change the coordinates of the last inserted point.void
setWindingRule(PathWindingRule rule)
Set the winding rule for the path.int
size()
Replies the number of points in the path.B
toBoundingBoxWithCtrlPoints()
Replies the bounding box of all the points added in this path.void
toBoundingBoxWithCtrlPoints(B box)
Compute the bounding box of all the points added in this path.Collection<P>
toCollection()
Replies the collection that is contains all the points of the path.default double[]
toDoubleArray()
Replies the coordinates of this path in an array of double precision floating-point numbers.double[]
toDoubleArray(Transform2D transform)
Replies the coordinates of this path in an array of double precision floating-point numbers.default float[]
toFloatArray()
Replies the coordinates of this path in an array of single precision floating-point numbers.float[]
toFloatArray(Transform2D transform)
Replies the coordinates of this path in an array of single precision floating-point numbers.default int[]
toIntArray()
Replies the coordinates of this path in an array of integer numbers.int[]
toIntArray(Transform2D transform)
Replies the coordinates of this path in an array of integer numbers.default P[]
toPointArray()
Replies the points of this path in an array.P[]
toPointArray(Transform2D transform)
Replies the points of this path in an array.-
Methods inherited from interface org.arakhne.afc.vmutil.json.JsonableObject
toJson
-
Methods inherited from interface org.arakhne.afc.math.geometry.d2.Shape2D
clear, clone, contains, contains, createTransformedShape, equalsToPathIterator, equalsToShape, getClosestPointTo, getClosestPointTo, getDistance, getDistance, getDistanceL1, getDistanceLinf, getDistanceSquared, getDistanceSquared, getFarthestPointTo, getGeomFactory, getPathIterator, getPathIterator, intersects, isEmpty, operator_add, operator_and, operator_and, operator_minus, operator_multiply, operator_plus, operator_remove, operator_upTo, set, toBoundingBox, toBoundingBox, translate
-
-
-
-
Method Detail
-
getWindingRule
@Pure PathWindingRule getWindingRule()
Replies the winding rule for the path.- Returns:
- the winding rule for the path.
-
setWindingRule
void setWindingRule(PathWindingRule rule)
Set the winding rule for the path.- Parameters:
rule
- is the winding rule for the path.
-
isPolyline
@Pure boolean isPolyline()
Replies the path is composed only by oneMOVE_TO
, and a sequence ofLINE_TO
primitives.- Returns:
true
if the path does not contain curve primitives,false
otherwise.
-
isCurved
@Pure boolean isCurved()
Replies the path contains a curve..- Returns:
true
if the path does not contain curve primitives,false
otherwise.
-
isMultiParts
@Pure boolean isMultiParts()
Replies the path has multiple parts, i.e. multipleMOVE_TO
are inside. primitives.- Returns:
true
if the path has multiple move-to primitive,false
otherwise.
-
isPolygon
@Pure boolean isPolygon()
Replies the path is composed only by oneMOVE_TO
, a sequence ofLINE_TO
orQUAD_TO
orCURVE_TO
, orARC_TO
, and a singleCLOSE
primitives.- Returns:
true
if the path does not contain curve primitives,false
otherwise.
-
getPathIterator
@Pure I getPathIterator(double flatness)
Replies an iterator on the path elements.Only
PathElementType.MOVE_TO
,PathElementType.LINE_TO
, andPathElementType.CLOSE
types are returned by the iterator.The amount of subdivision of the curved segments is controlled by the flatness parameter, which specifies the maximum distance that any point on the unflattened transformed curve can deviate from the returned flattened path segments. Note that a limit on the accuracy of the flattened path might be silently imposed, causing very small flattening parameters to be treated as larger values. This limit, if there is one, is defined by the particular implementation that is used.
The iterator for this class is not multi-threaded safe.
- Parameters:
flatness
- is the maximum distance that the line segments used to approximate the curved segments are allowed to deviate from any point on the original curve.- Returns:
- an iterator on the path elements.
-
moveTo
void moveTo(Point2D<?,?> position)
Adds a point to the path by moving to the specified coordinates specified in double precision.- Parameters:
position
- the new position.
-
moveToIfFar
void moveToIfFar(Point2D<?,?> position)
Adds a point to the path by moving to the specified coordinates specified in double precision.- Parameters:
position
- the new position.
-
lineTo
void lineTo(Point2D<?,?> to)
Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in double precision.- Parameters:
to
- the end point
-
quadTo
void quadTo(Point2D<?,?> ctrl, Point2D<?,?> to)
Adds a curved segment, defined by two new points, to the path by drawing a Quadratic curve that intersects both the current coordinates and the specified coordinates(x2, y2)
, using the specified point(x1, y1)
as a quadratic parametric control point. All coordinates are specified in double precision.- Parameters:
ctrl
- the quadratic control pointto
- the final end point
-
curveTo
void curveTo(Point2D<?,?> ctrl1, Point2D<?,?> ctrl2, Point2D<?,?> to)
Adds a curved segment, defined by three new points, to the path by drawing a Bézier curve that intersects both the current coordinates and the specified coordinates(x3, y3)
, using the specified points(x1, y1)
and(x2, y2)
as Bézier control points. All coordinates are specified in double precision.- Parameters:
ctrl1
- the first Bézier control pointctrl2
- the second Bézier control pointto
- the final end point
-
arcTo
void arcTo(Point2D<?,?> ctrl, Point2D<?,?> to, double tfrom, double tto, Path2D.ArcType type)
Adds a section of an shallow ellipse to the current path. The ellipse from which a quadrant is taken is the ellipse that would be inscribed in a parallelogram defined by 3 points, The current point which is considered to be the midpoint of the edge leading into the corner of the ellipse where the ellipse grazes it,(ctrlx, ctrly)
which is considered to be the location of the corner of the parallelogram in which the ellipse is inscribed, and(tox, toy)
which is considered to be the midpoint of the edge leading away from the corner of the oval where the oval grazes it.Only the portion of the ellipse from
tfrom
totto
will be included where0f
represents the point where the ellipse grazes the leading edge,1f
represents the point where the oval grazes the trailing edge, and0.5f
represents the point on the oval closest to the control point. The two values must satisfy the relation(0 <= tfrom <= tto <= 1)
.If
tfrom
is not0f
then the caller would most likely want to use one of the arctype
values that inserts a segment leading to the initial point. An initialmoveTo(Point2D)
orlineTo(Point2D)
can be added to direct the path to the starting point of the ellipse section ifPath2D.ArcType.MOVE_THEN_ARC
orPath2D.ArcType.LINE_THEN_ARC
are specified by the type argument. ThelineTo
path segment will only be added if the current point is not already at the indicated location to avoid spurious empty line segments. The type can be specified asPath2D.ArcType.ARC_ONLY
if the current point on the path is known to be at the starting point of the ellipse section.- Parameters:
ctrl
- the control point, i.e. the corner of the parallelogram in which the ellipse is inscribed.to
- the target point.tfrom
- the fraction of the ellipse section where the curve should start.tto
- the fraction of the ellipse section where the curve should endtype
- the specification of what additional path segments should be appended to lead the current path to the starting point.
-
arcTo
default void arcTo(Point2D<?,?> ctrl, Point2D<?,?> to)
Adds a section of an shallow ellipse to the current path.This function is equivalent to:
this.arcTo(ctrl, to, 0.0, 1.0, ArcType.ARCONLY);
- Parameters:
ctrl
- the control point, i.e. the corner of the parallelogram in which the ellipse is inscribed.to
- the target point.
-
arcTo
void arcTo(Point2D<?,?> to, Vector2D<?,?> radii, double xAxisRotation, boolean largeArcFlag, boolean sweepFlag)
Adds a section of an shallow ellipse to the current path. The ellipse from which the portions are extracted follows the rules:- The ellipse will have its X axis tilted from horizontal by the
angle
xAxisRotation
specified in radians. - The ellipse will have the X and Y radii (viewed from its tilted
coordinate system) specified by
radiusx
andradiusy
unless that ellipse is too small to bridge the gap from the current point to the specified destination point in which case a larger ellipse with the same ratio of dimensions will be substituted instead. - The ellipse may slide perpendicular to the direction from the current point to the specified destination point so that it just touches the two points. The direction it slides (to the "left" or to the "right") will be chosen to meet the criteria specified by the two boolean flags as described below. Only one direction will allow the method to meet both criteria.
- If the
largeArcFlag
is true, then the ellipse will sweep the longer way around the ellipse that meets these criteria. - If the
sweepFlag
is true, then the ellipse will sweep clockwise around the ellipse that meets these criteria.
The method will do nothing if the destination point is the same as the current point. The method will draw a simple line segment to the destination point if either of the two radii are zero.
- Parameters:
to
- the target point.radii
- the X and Y radii of the tilted ellipse.xAxisRotation
- the angle of tilt of the ellipse.largeArcFlag
-true
iff the path will sweep the long way around the ellipse.sweepFlag
-true
iff the path will sweep clockwise around the ellipse.- See Also:
- "http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands"
- The ellipse will have its X axis tilted from horizontal by the
angle
-
closePath
void closePath()
Closes the current subpath by drawing a straight line back to the coordinates of the lastmoveTo
. If the path is already closed or if the previous coordinates are for amoveTo
then this method has no effect.
-
toBoundingBoxWithCtrlPoints
B toBoundingBoxWithCtrlPoints()
Replies the bounding box of all the points added in this path.The replied bounding box includes the (invisible) control points.
- Returns:
- the bounding box with the control points.
- See Also:
Shape2D.toBoundingBox()
-
toBoundingBoxWithCtrlPoints
void toBoundingBoxWithCtrlPoints(B box)
Compute the bounding box of all the points added in this path.The replied bounding box includes the (invisible) control points.
- Parameters:
box
- is the rectangle to set with the bounds.- See Also:
Shape2D.toBoundingBox()
-
toIntArray
@Pure default int[] toIntArray()
Replies the coordinates of this path in an array of integer numbers.- Returns:
- the coordinates.
-
toIntArray
@Pure int[] toIntArray(Transform2D transform)
Replies the coordinates of this path in an array of integer numbers.- Parameters:
transform
- is the transformation to apply to all the coordinates.- Returns:
- the coordinates.
-
toFloatArray
@Pure default float[] toFloatArray()
Replies the coordinates of this path in an array of single precision floating-point numbers.- Returns:
- the coordinates.
-
toFloatArray
@Pure float[] toFloatArray(Transform2D transform)
Replies the coordinates of this path in an array of single precision floating-point numbers.- Parameters:
transform
- is the transformation to apply to all the coordinates.- Returns:
- the coordinates.
-
toDoubleArray
@Pure default double[] toDoubleArray()
Replies the coordinates of this path in an array of double precision floating-point numbers.- Returns:
- the coordinates.
-
toDoubleArray
@Pure double[] toDoubleArray(Transform2D transform)
Replies the coordinates of this path in an array of double precision floating-point numbers.- Parameters:
transform
- is the transformation to apply to all the coordinates.- Returns:
- the coordinates.
-
toPointArray
@Pure default P[] toPointArray()
Replies the points of this path in an array.- Returns:
- the points.
-
toPointArray
@Pure P[] toPointArray(Transform2D transform)
Replies the points of this path in an array.- Parameters:
transform
- is the transformation to apply to all the points.- Returns:
- the points.
-
toCollection
@Pure Collection<P> toCollection()
Replies the collection that is contains all the points of the path.- Returns:
- the point collection.
-
getPointAt
@Pure P getPointAt(int index)
Replies the point at the given index. The index is in [0;size()
).- Parameters:
index
- the index.- Returns:
- the point at the given index.
-
getCurrentPoint
@Pure P getCurrentPoint()
Replies the last point in the path.- Returns:
- the last point.
-
size
@Pure int size()
Replies the number of points in the path.- Returns:
- the number of points in the path.
-
getPathElementCount
@Pure int getPathElementCount()
Replies the number of path elements in this path.- Returns:
- the number of path elements.
- See Also:
getPathElementTypeAt(int)
-
getPathElementTypeAt
@Pure PathElementType getPathElementTypeAt(int index)
Replies the type of the path element at the given position in this path.- Parameters:
index
- the index of the path element.- Returns:
- the type of the path element.
- See Also:
getPathElementCount()
-
getLength
@Pure default double getLength()
Replies the total length of the path.- Returns:
- the length of the path.
-
getLengthSquared
@Pure double getLengthSquared()
Replies the total squared length of the path.- Returns:
- the length of the path.
-
removeLast
void removeLast()
Remove the last action.
-
setLastPoint
void setLastPoint(Point2D<?,?> point)
Change the coordinates of the last inserted point.- Parameters:
point
- the point.
-
containsControlPoint
@Pure boolean containsControlPoint(Point2D<?,?> point)
Replies if the given points exists in the coordinates of this path.- Parameters:
point
- the point.- Returns:
true
if the point is a control point of the path.
-
-