Class DecimatedPathIterator

java.lang.Object
org.apache.sis.internal.feature.j2d.DecimatedPathIterator
All Implemented Interfaces:
PathIterator

final class DecimatedPathIterator extends Object implements 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 Details

    • source

      private final PathIterator source
      The source of line segments.
    • xRes

      private final double xRes
      The desired resolution on each axis.
    • yRes

      private final double yRes
      The desired resolution on each axis.
    • px

      private double px
      Previous coordinates, or NaN if none.
    • py

      private double py
      Previous 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 interface PathIterator
    • isDone

      public boolean isDone()
      Returns true if iteration is finished.
      Specified by:
      isDone in interface PathIterator
    • getWindingRule

      public int getWindingRule()
      Returns the winding rule for determining the interior of the path.
      Specified by:
      getWindingRule in interface PathIterator
    • 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 interface PathIterator
      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 of currentSegment(double[]) with only the type changed.
      Specified by:
      currentSegment in interface PathIterator
      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 a PathIterator.SEG_LINETO segment.