private static float getFlatPathLength(PathIterator iterator) {
    float segment[] = new float[6];
    float totalLength = 0;
    float[] previousPoint = new float[2];
    boolean isFirstPoint = true;

    while (!iterator.isDone()) {
      int type = iterator.currentSegment(segment);
      assert type == PathIterator.SEG_LINETO
          || type == PathIterator.SEG_CLOSE
          || type == PathIterator.SEG_MOVETO;

      // MoveTo shouldn't affect the length
      if (!isFirstPoint && type != PathIterator.SEG_MOVETO) {
        totalLength +=
            (float) Point2D.distance(previousPoint[0], previousPoint[1], segment[0], segment[1]);
      } else {
        isFirstPoint = false;
      }
      previousPoint[0] = segment[0];
      previousPoint[1] = segment[1];
      iterator.next();
    }

    return totalLength;
  }
private static float getFlatPathLength(PathIterator iterator) {
    float segment[] = new float[6];
    float totalLength = 0;
    float[] previousPoint = new float[2];
    boolean isFirstPoint = true;

    while (!iterator.isDone()) {
      int type = iterator.currentSegment(segment);
      assert type == PathIterator.SEG_LINETO
          || type == PathIterator.SEG_CLOSE
          || type == PathIterator.SEG_MOVETO;

      
      if (!isFirstPoint && type != PathIterator.SEG_MOVETO) {
        totalLength +=
            (float) Point2D.distance(previousPoint[0], previousPoint[1], segment[0], segment[1]);
      } else {
        isFirstPoint = false;
      }
      previousPoint[0] = segment[0];
      previousPoint[1] = segment[1];
      iterator.next();
    }

    return totalLength;
  }
private static float getFlatPathLength ( PathIterator iterator ) { float segment [ ] = new float [ 6 ] ; float totalLength = 0 ; float [ ] previousPoint = new float [ 2 ] ; boolean isFirstPoint = true ; while ( ! iterator . isDone ( ) ) { int type = iterator . currentSegment ( segment ) ; assert type == PathIterator . SEG_LINETO || type == PathIterator . SEG_CLOSE || type == PathIterator . SEG_MOVETO ; // MoveTo shouldn't affect the length if ( ! isFirstPoint && type != PathIterator . SEG_MOVETO ) { totalLength += ( float ) Point2D . distance ( previousPoint [ 0 ] , previousPoint [ 1 ] , segment [ 0 ] , segment [ 1 ] ) ; } else { isFirstPoint = false ; } previousPoint [ 0 ] = segment [ 0 ] ; previousPoint [ 1 ] = segment [ 1 ] ; iterator . next ( ) ; } return totalLength ; }
Returns the estimated length of a flat path. If the passed path is not flat (i.e. contains a
segment that is not {@link PathIterator#SEG_CLOSE}, {@link PathIterator#SEG_MOVETO} or {@link
PathIterator#SEG_LINETO} this method will fail.
Returns the estimated length of a flat path . If the passed path is not flat ( i . e . contains a segment that is not {