0

I am having trouble with a fairly simple task, as the title says, i want to iterate over all points contained in a Line2D.Double. I tried googling, but couldn't really find anything. I am guessing it has something to do with the PathIterators?

Thank you in advance for your tips

Simon Eismann
  • 273
  • 1
  • 5
  • 17

1 Answers1

1

A Line2D.Double only has 2 points P1 and P2, the start and end of a straight line. You can get them with getP1() and getP2().

Do you actually want to iterate over a Path2D.Double? If so you would iterate over a path like this:

    PathIterator pathIter = path.getPathIterator(null);
    while(!pathIter.isDone()) {
        final double[] segment = new double[6];
        pathIter.currentSegment(segment);
        //do something with segment
        pathIter.next();
    }
bhspencer
  • 13,086
  • 5
  • 35
  • 44