java.awt.geom

Class FlatteningPathIterator

public class FlatteningPathIterator extends Object implements PathIterator

A PathIterator for approximating curved path segments by sequences of straight lines. Instances of this class will only return segments of type {@link PathIterator#SEG_MOVETO}, {@link PathIterator#SEG_LINETO}, and {@link PathIterator#SEG_CLOSE}.

The accuracy of the approximation is determined by two parameters:

Memory Efficiency: The memory consumption grows linearly with the recursion limit. Neither the flatness parameter nor the number of segments in the flattened path will affect the memory consumption.

Thread Safety: Multiple threads can safely work on separate instances of this class. However, multiple threads should not concurrently access the same instance, as no synchronization is performed.

Since: 1.2

See Also: Implementation Note

Constructor Summary
FlatteningPathIterator(PathIterator src, double flatness)
Constructs a new PathIterator for approximating an input PathIterator with straight lines.
FlatteningPathIterator(PathIterator src, double flatness, int limit)
Constructs a new PathIterator for approximating an input PathIterator with straight lines.
Method Summary
intcurrentSegment(double[] coords)
intcurrentSegment(float[] coords)
doublegetFlatness()
Returns the maximally acceptable flatness.
intgetRecursionLimit()
Returns the maximum number of recursive curve subdivisions.
intgetWindingRule()
booleanisDone()
voidnext()

Constructor Detail

FlatteningPathIterator

public FlatteningPathIterator(PathIterator src, double flatness)
Constructs a new PathIterator for approximating an input PathIterator with straight lines. The approximation works by recursive subdivisons, until the specified flatness threshold is not exceeded.

There will not be more than 10 nested recursion steps, which means that a single SEG_QUADTO or SEG_CUBICTO segment is approximated by at most 210 = 1024 straight lines.

FlatteningPathIterator

public FlatteningPathIterator(PathIterator src, double flatness, int limit)
Constructs a new PathIterator for approximating an input PathIterator with straight lines. The approximation works by recursive subdivisons, until the specified flatness threshold is not exceeded. Additionally, the number of recursions is also bound by the specified recursion limit.

Method Detail

currentSegment

public int currentSegment(double[] coords)

currentSegment

public int currentSegment(float[] coords)

getFlatness

public double getFlatness()
Returns the maximally acceptable flatness.

See Also: getFlatness getFlatness

getRecursionLimit

public int getRecursionLimit()
Returns the maximum number of recursive curve subdivisions.

getWindingRule

public int getWindingRule()

isDone

public boolean isDone()

next

public void next()