- All Implemented Interfaces:
PathIterator
AffineTransform
), All the control points, including
the end points, of a segment must be separated from each other by
no more than the flatness parameter.
The iterator has a recursion limit (the default value is 10) to prevent the number of segments from becoming excessively large. Incrementing the recursion limit by 1 can double the number of segments from that returned by the previous limit.
A transform can be provided in the constructors
FlatteningPathIterator2D(PathIterator,Transform2D,double)
,
FlatteningPathIterator2D(PathIterator,Transform2D,double,int)
.
FlatteningPathIterator2D(PathIterator,AffineTransform,double)
,
and
FlatteningPathIterator2D(PathIterator,AffineTransform,double,int)
.
The transform will be applied after the path is flattened, and
will be applied only to the control points. Because of this, the
path should be flattened sufficiently so that the transform can
be approximated by an affine transform over the convex hull for
the flattened path's control points. While the transform is applied
after the path is flattened, the flatness test uses transformed
values of the control points.
This class does not modify segment types, unlike
FlatteningPathIterator
which turns quadratic
and cubic segments into straight lines. Not modifying segment types
is useful when applying a transform that is not an affine transform.
-
Field Summary
Fields inherited from interface java.awt.geom.PathIterator
SEG_CLOSE, SEG_CUBICTO, SEG_LINETO, SEG_MOVETO, SEG_QUADTO, WIND_EVEN_ODD, WIND_NON_ZERO
-
Constructor Summary
ConstructorsConstructorDescriptionFlatteningPathIterator2D
(int type, double x0, double y0, double[] coords, double flatness, int limit) Constructor give a type and a double-precision coordinate array.FlatteningPathIterator2D
(int type, double x0, double y0, double[] coords, AffineTransform transform, double flatness, int limit) Constructor give a type and double-precision coordinate array, with a transform that is an AffineTransform.FlatteningPathIterator2D
(int type, double x0, double y0, double[] coords, Transform2D transform, double flatness, int limit) Constructor give a type, a double-precision coordinate array, and a transform.FlatteningPathIterator2D
(int type, float x0, float y0, float[] coords, double flatness, int limit) Constructor given a type and a single-precision coordinate array.FlatteningPathIterator2D
(int type, float x0, float y0, float[] coords, AffineTransform transform, double flatness, int limit) Constructor give a type and single-precision coordinate array, with a transform that is an AffineTransform.FlatteningPathIterator2D
(int type, float x0, float y0, float[] coords, Transform2D transform, double flatness, int limit) Constructor given a type, single-precision coordinate array and a transform.FlatteningPathIterator2D
(PathIterator src, double flatness) Constructor.FlatteningPathIterator2D
(PathIterator src, double flatness, int limit) Constructor with a recursion limit.FlatteningPathIterator2D
(PathIterator src, AffineTransform transform, double flatness) Constructor given an affine transform.FlatteningPathIterator2D
(PathIterator src, AffineTransform transform, double flatness, int limit) Constructor given an affine transform and a recursion limit.FlatteningPathIterator2D
(PathIterator src, Transform2D transform, double flatness) Constructor given a general transform.FlatteningPathIterator2D
(PathIterator src, Transform2D transform, double flatness, int limit) Constructor with a general transform and a recursion limit. -
Method Summary
Modifier and TypeMethodDescriptionint
currentSegment
(double[] coords) int
currentSegment
(float[] coords) double
Get the flatness parameter.int
Get the recursion limit.int
boolean
isDone()
void
next()
-
Constructor Details
-
FlatteningPathIterator2D
Constructor. The default recursion limit is 10.- Parameters:
src
- a path iterator to flattenflatness
- the flatness constraint- Throws:
IllegalArgumentException
-
FlatteningPathIterator2D
public FlatteningPathIterator2D(PathIterator src, Transform2D transform, double flatness) throws IllegalArgumentException Constructor given a general transform. The transform is not constrained to be an affine transform. The default recursion limit is 10.- Parameters:
src
- a path iterator to flattentransform
- the transform to applyflatness
- the flatness constraint- Throws:
IllegalArgumentException
-
FlatteningPathIterator2D
public FlatteningPathIterator2D(PathIterator src, AffineTransform transform, double flatness) throws IllegalArgumentException Constructor given an affine transform. The transform is not constrained to be an affine transform. The default recursion limit is 10.- Parameters:
src
- a path iterator to flattentransform
- the transform to applyflatness
- the flatness constraint- Throws:
IllegalArgumentException
-
FlatteningPathIterator2D
public FlatteningPathIterator2D(PathIterator src, double flatness, int limit) throws IllegalArgumentException Constructor with a recursion limit. Both the flatness and the limit must be non-negative.- Parameters:
src
- a path iterator to flattenflatness
- the flatness constraintlimit
- the recursion limit- Throws:
IllegalArgumentException
-
FlatteningPathIterator2D
public FlatteningPathIterator2D(int type, double x0, double y0, double[] coords, double flatness, int limit) Constructor give a type and a double-precision coordinate array. Both the flatness and the limit must be non-negative. The transform is not constrained to be an affine transform. If the segment type is PathIterator.SEG_MOVETO, the arguments x0 and y0 are ignored.- Parameters:
type
- the type of a segment (PathIterator.SEG_MOVETO
,PathIterator.SEG_LINETO
,PathIterator.SEG_QUADTO
,PathIterator.SEG_CUBICTO
)x0
- the starting X coordinate for the segmenty0
- the starting Y coordinate for the segment,coords
- the coordinates for the segment as returned bycurrentSegment(double[])
flatness
- the flatness constraintlimit
- the recursion limit
-
FlatteningPathIterator2D
public FlatteningPathIterator2D(int type, float x0, float y0, float[] coords, double flatness, int limit) Constructor given a type and a single-precision coordinate array. Both the flatness and the limit must be non-negative. The transform is not constrained to be an affine transform.- Parameters:
type
- the type of a segment (PathIterator.SEG_MOVETO
,PathIterator.SEG_LINETO
,PathIterator.SEG_QUADTO
,PathIterator.SEG_CUBICTO
)x0
- the starting X coordinate for the segmenty0
- the starting Y coordinate for the segment,coords
- the coordinates for the segment as returned bycurrentSegment(double[])
flatness
- the flatness constraintlimit
- the recursion limit
-
FlatteningPathIterator2D
public FlatteningPathIterator2D(PathIterator src, Transform2D transform, double flatness, int limit) throws IllegalArgumentException Constructor with a general transform and a recursion limit. Both the flatness and the limit must be non-negative. The transform is not constrained to be an affine transform.- Parameters:
src
- a path iterator to flattentransform
- a transform to applyflatness
- the flatness constraintlimit
- the recursion limit- Throws:
IllegalArgumentException
-
FlatteningPathIterator2D
public FlatteningPathIterator2D(int type, double x0, double y0, double[] coords, Transform2D transform, double flatness, int limit) Constructor give a type, a double-precision coordinate array, and a transform. Both the flatness and the limit must be non-negative. The transform is not constrained to be an affine transform.- Parameters:
type
- the type of a segment (PathIterator.SEG_MOVETO
,PathIterator.SEG_LINETO
,PathIterator.SEG_QUADTO
,PathIterator.SEG_CUBICTO
)x0
- the starting X coordinate for the segmenty0
- the starting Y coordinate for the segment,coords
- the coordinates for the segment as returned bycurrentSegment(double[])
transform
- a transform to applyflatness
- the flatness constraintlimit
- the recursion limit
-
FlatteningPathIterator2D
public FlatteningPathIterator2D(int type, float x0, float y0, float[] coords, Transform2D transform, double flatness, int limit) Constructor given a type, single-precision coordinate array and a transform. Both the flatness and the limit must be non-negative. The transform is not constrained to be an affine transform.- Parameters:
type
- the type of a segment (PathIterator.SEG_MOVETO
,PathIterator.SEG_LINETO
,PathIterator.SEG_QUADTO
,PathIterator.SEG_CUBICTO
)x0
- the starting X coordinate for the segmenty0
- the starting Y coordinate for the segment,coords
- the coordinates for the segment as returned bycurrentSegment(double[])
transform
- a transform to applyflatness
- the flatness constraintlimit
- the recursion limit
-
FlatteningPathIterator2D
public FlatteningPathIterator2D(PathIterator src, AffineTransform transform, double flatness, int limit) throws IllegalArgumentException Constructor given an affine transform and a recursion limit. Both the flatness and the limit must be non-negative. The transform is not constrained to be an affine transform.- Parameters:
src
- a path iterator to flattentransform
- a transform to applyflatness
- the flatness constraintlimit
- the recursion limit- Throws:
IllegalArgumentException
-
FlatteningPathIterator2D
public FlatteningPathIterator2D(int type, double x0, double y0, double[] coords, AffineTransform transform, double flatness, int limit) Constructor give a type and double-precision coordinate array, with a transform that is an AffineTransform. Both the flatness and the limit must be non-negative. The transform is not constrained to be an affine transform.- Parameters:
type
- the type of a segment (PathIterator.SEG_MOVETO
,PathIterator.SEG_LINETO
,PathIterator.SEG_QUADTO
,PathIterator.SEG_CUBICTO
)x0
- the starting X coordinate for the segmenty0
- the starting Y coordinate for the segment,coords
- the coordinates for the segment as returned bycurrentSegment(double[])
transform
- a transform to applyflatness
- the flatness constraintlimit
- the recursion limit
-
FlatteningPathIterator2D
public FlatteningPathIterator2D(int type, float x0, float y0, float[] coords, AffineTransform transform, double flatness, int limit) Constructor give a type and single-precision coordinate array, with a transform that is an AffineTransform. Both the flatness and the limit must be non-negative. The transform is not constrained to be an affine transform.- Parameters:
type
- the type of a segment (PathIterator.SEG_MOVETO
,PathIterator.SEG_LINETO
,PathIterator.SEG_QUADTO
,PathIterator.SEG_CUBICTO
)x0
- the starting X coordinate for the segmenty0
- the starting Y coordinate for the segment,coords
- the coordinates for the segment as returned bycurrentSegment(double[])
transform
- a transform to applyflatness
- the flatness constraintlimit
- the recursion limit
-
-
Method Details
-
getFlatness
public double getFlatness()Get the flatness parameter.- Returns:
- the flatness parameter
-
getRecursionLimit
public int getRecursionLimit()Get the recursion limit.- Returns:
- the recursion limit
-
currentSegment
public int currentSegment(double[] coords) - Specified by:
currentSegment
in interfacePathIterator
-
currentSegment
public int currentSegment(float[] coords) - Specified by:
currentSegment
in interfacePathIterator
-
isDone
public boolean isDone()- Specified by:
isDone
in interfacePathIterator
-
next
public void next()- Specified by:
next
in interfacePathIterator
-
getWindingRule
public int getWindingRule()- Specified by:
getWindingRule
in interfacePathIterator
-