GeneralPath out = new GeneralPath(); return out;
FlatteningPathIterator flat = new FlatteningPathIterator(pi, Math.sqrt(width / 3));   double[] coords = new double[2];   double x, y, x0, y0; x = x0 = y = y0 = 0;   boolean pathOpen = false; boolean dashOn = true; boolean offsetting = (phase != 0);   double distance = 0; int dashIndex = 0;   GeneralPath output = new GeneralPath(); Segment[] p;   while (! flat.isDone()) { switch (flat.currentSegment(coords)) { case PathIterator.SEG_MOVETO: x0 = x = coords[0]; y0 = y = coords[1];  if (pathOpen) { capEnds(); convertPath(output, start); start = end = null; pathOpen = false; }  break;  case PathIterator.SEG_LINETO: boolean segmentConsumed = false;  while (! segmentConsumed) {  double segLength = Math.sqrt((x - coords[0]) * (x - coords[0]) + (y - coords[1]) * (y - coords[1])); boolean spanBoundary = true; double[] segmentEnd = null;   if ((offsetting && distance + segLength <= phase) || distance + segLength <= dash[dashIndex]) { spanBoundary = false; }    else { segmentEnd = (double[]) coords.clone();    double reqLength; if (offsetting) reqLength = phase - distance; else reqLength = dash[dashIndex] - distance;  coords[0] = x + ((coords[0] - x) * reqLength / segLength); coords[1] = y + ((coords[1] - y) * reqLength / segLength); }  if (offsetting || ! dashOn) {   x0 = x = coords[0]; y0 = y = coords[1];  if (pathOpen) { capEnds(); convertPath(output, start); start = end = null; pathOpen = false; } } else {  p = (new LineSegment(x, y, coords[0], coords[1])).getDisplacedSegments(width / 2.0);  if (! pathOpen) { start = p[0]; end = p[1]; pathOpen = true; } else addSegments(p);  x = coords[0]; y = coords[1]; }    if (! spanBoundary) { distance += segLength; segmentConsumed = true; } else { if (offsetting) offsetting = false; dashOn = ! dashOn; distance = 0; coords = segmentEnd;  if (dashIndex + 1 == dash.length) dashIndex = 0; else dashIndex++;    } } break;   } flat.next(); }  if (pathOpen) { capEnds(); convertPath(output, start); } return output;
  private Shape dashedStroke(PathIterator pi)  {    GeneralPath out = new GeneralPath();    return out;  }