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 doublePrevious coordinates, or NaN if none.private doublePrevious coordinates, or NaN if none.private final PathIteratorThe source of line segments.private final doubleThe desired resolution on each axis.private final doubleThe 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 TypeMethodDescriptionintcurrentSegment(double[] coords) Returns the coordinates and type of the current path segment in the iteration.intcurrentSegment(float[] coords) Returns the coordinates and type of the current path segment in the iteration.intReturns the winding rule for determining the interior of the path.private booleaninclude(double x, double y) Returns whether the given point should be returned in aPathIterator.SEG_LINETOsegment.booleanisDone()Returnstrueif iteration is finished.voidnext()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:
nextin interfacePathIterator
-
isDone
public boolean isDone()Returnstrueif iteration is finished.- Specified by:
isDonein interfacePathIterator
-
getWindingRule
public int getWindingRule()Returns the winding rule for determining the interior of the path.- Specified by:
getWindingRulein 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:
currentSegmentin 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:
currentSegmentin 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_LINETOsegment.
-