private static int lengthOfPath(Path2D.Float path){
  FlatteningPathIterator f=new FlatteningPathIterator(path.getPathIterator(null),1);
  double sum=0;
  float x1, x2, y1, y2;
  float[] coords=new float[6];
  f.currentSegment(coords);
  x1=coords[0];
  y1=coords[1];
  f.next();
  do {
    f.currentSegment(coords);
    f.next();
    x2=coords[0];
    y2=coords[1];
    sum+=Math.hypot(x2 - x1,y2 - y1);
    x1=x2;
    y1=y2;
  }
 while (!f.isDone());
  return (int)sum;
}

private static int lengthOfPath ( Path2D . Float path ) { FlatteningPathIterator f = new FlatteningPathIterator ( path . getPathIterator ( null ) , 1 ) ; double sum = 0 ; float x1 , x2 , y1 , y2 ; float [ ] coords = new float [ 6 ] ; f . currentSegment ( coords ) ; x1 = coords [ 0 ] ; y1 = coords [ 1 ] ; f . next ( ) ; do { f . currentSegment ( coords ) ; f . next ( ) ; x2 = coords [ 0 ] ; y2 = coords [ 1 ] ; sum += Math . hypot ( x2 - x1 , y2 - y1 ) ; x1 = x2 ; y1 = y2 ; } while ( ! f . isDone ( ) ) ; return ( int ) sum ; }
return the length of the given path
