Class DecimatedPathIterator
java.lang.Object
org.apache.sis.internal.feature.j2d.DecimatedPathIterator
- All Implemented Interfaces:
PathIterator
A path iterator with applies on-the-fly decimation for faster drawing.
The decimation algorithm is based on a simple distance calculation on
each axis (this is not a Douglas-Peucker algorithm).
- Since:
- 1.2
- Version:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate double
Previous coordinates, or NaN if none.private double
Previous coordinates, or NaN if none.private final PathIterator
The source of line segments.private final double
The desired resolution on each axis.private final double
The desired resolution on each axis.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
ConstructorsConstructorDescriptionDecimatedPathIterator
(PathIterator source, double xRes, double yRes) Creates a new iterator. -
Method Summary
Modifier and TypeMethodDescriptionint
currentSegment
(double[] coords) Returns the coordinates and type of the current path segment in the iteration.int
currentSegment
(float[] coords) Returns the coordinates and type of the current path segment in the iteration.int
Returns the winding rule for determining the interior of the path.private boolean
include
(double x, double y) Returns whether the given point should be returned in aPathIterator.SEG_LINETO
segment.boolean
isDone()
Returnstrue
if iteration is finished.void
next()
Moves the iterator to the next segment.
-
Field Details
-
source
The source of line segments. -
xRes
private final double xResThe desired resolution on each axis. -
yRes
private final double yResThe desired resolution on each axis. -
px
private double pxPrevious coordinates, or NaN if none. -
py
private double pyPrevious coordinates, or NaN if none.
-
-
Constructor Details
-
DecimatedPathIterator
DecimatedPathIterator(PathIterator source, double xRes, double yRes) Creates a new iterator.
-
-
Method Details
-
next
public void next()Moves the iterator to the next segment.- Specified by:
next
in interfacePathIterator
-
isDone
public boolean isDone()Returnstrue
if iteration is finished.- Specified by:
isDone
in interfacePathIterator
-
getWindingRule
public int getWindingRule()Returns the winding rule for determining the interior of the path.- Specified by:
getWindingRule
in interfacePathIterator
-
currentSegment
public int currentSegment(double[] coords) Returns the coordinates and type of the current path segment in the iteration. This method has a fallback for quadratic and cubic curves, but this fallback is not very good. This iterator should be used for flat shapes only.- Specified by:
currentSegment
in interfacePathIterator
- Parameters:
coords
- an array where to store the data returned from this method.- Returns:
- the path-segment type of the current path segment.
-
currentSegment
public int currentSegment(float[] coords) Returns the coordinates and type of the current path segment in the iteration. This is a copy ofcurrentSegment(double[])
with only the type changed.- Specified by:
currentSegment
in interfacePathIterator
- Parameters:
coords
- an array where to store the data returned from this method.- Returns:
- the path-segment type of the current path segment.
-
include
private boolean include(double x, double y) Returns whether the given point should be returned in aPathIterator.SEG_LINETO
segment.
-