Class SimplifiedPathIterator

  • All Implemented Interfaces:
    PathIterator


    public class SimplifiedPathIterator
    extends Object
    implements PathIterator
    This filters a PathIterator and makes sure that each curve is of the smallest possible degree.

    In addition to being more efficient, this can avoid divide-by-zero errors for some operations.

    • Constructor Detail

      • SimplifiedPathIterator

        public SimplifiedPathIterator(PathIterator i)
        Creates a new SimplifiedPathIterator that filters the argument.
        Parameters:
        i -
    • Method Detail

      • collinear

        public static boolean collinear(double x1,
                                        double y1,
                                        double x2,
                                        double y2,
                                        double x3,
                                        double y3)
        Returns true if all 3 points are on the same line. This checks to see if:
        x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)<TOL*TOL
        Parameters:
        x1 - the x-coordinate of point #1
        y1 - the y-coordinate of point #1
        x2 - the x-coordinate of point #2
        y2 - the y-coordinate of point #2
        x3 - the x-coordinate of point #3
        y3 - the y-coordinate of point #3
        Returns:
        true if all 3 points are on the same line.
      • simplify

        public static int simplify(int type,
                                   float lastX,
                                   float lastY,
                                   float[] data)
        This possibly reduces the degree of a segment, if possible.
        Parameters:
        type - the current expected type of the segment data
        lastX - the previous X value from which this segment begins
        lastY - the previous Y value from which this segment begins
        data - the data of the current segment.
        Returns:
        the new segment type, or the original type argument if nothing was modified.
      • simplify

        public static int simplify(int type,
                                   double lastX,
                                   double lastY,
                                   double[] data)
        This possibly reduces the degree of a segment, if possible.
        Parameters:
        type - the current expected type of the segment data
        lastX - the previous X value from which this segment begins
        lastY - the previous Y value from which this segment begins
        data - the data of the current segment.
        Returns:
        the new segment type, or the original type argument if nothing was modified.
      • currentSegment

        public int currentSegment(double[] f)
      • currentSegment

        public int currentSegment(float[] f)
      • getWindingRule

        public int getWindingRule()
      • isDone

        public boolean isDone()
      • next

        public void next()