title: iterate through each point on a line/path in java
body: <p>I'm new to using iterators and was wondering how one would iterate through each point on a line segment (Line2D.Double, to be precise) -- I need to check to see if each point on the line fulfills certain requirements.</p>
  
  <p>Also, given a path object (like GeneralPath), how would you do the same thing (iterate through each point on the outline of the shape)?</p>
  
  <p>Ideally I'd like something like this (with either a line or a path):</p>
  
  <pre><code>Line2D line = new Line2D.Double(p1,p2);
  for (Point2D point : line)
  {
     point.callSomeMethod();
  }
  </code></pre>