static class Path{ int type; float[] coords; } public static GeneralPath reversePath(PathIterator itr) Stack pathStack = new Stack(); while(!itr.isDone()){ float coords[] = new float[6]; Path path = new Path(); path.type = itr.currentSegment(coords); path.coords = coords; pathStack.push(path); itr.next(); } Path prePath = null; GeneralPath newShapePath = new GeneralPath(); while(!pathStack.isEmpty()){ Path path = (Path)pathStack.pop(); if(prePath == null){ Point2D.Float point = coords2Point(path.coords,path.type); if(point == null) continue; else newShapePath.moveTo(point.x,point.y); } else{ int type = prePath.type; Point2D.Float currentPoint = coords2Point(path.coords,path.type); switch(type){ case PathIterator.SEG_MOVETO: newShapePath.moveTo(currentPoint.x,currentPoint.y); break; case PathIterator.SEG_LINETO: newShapePath.lineTo(currentPoint.x,currentPoint.y); break; case PathIterator.SEG_QUADTO: newShapePath.quadTo(prePath.coords[0],prePath.coords[1],currentPoint.x,currentPoint.y); break; case PathIterator.SEG_CUBICTO: newShapePath.curveTo(prePath.coords[2],prePath.coords[3],prePath.coords[0],prePath.coords[1],currentPoint.x,currentPoint.y); break; } } prePath = path; } return newShapePath; } public static Point2D.Float coords2Point(float[] coords,int type){ switch(type){ case PathIterator.SEG_MOVETO: case PathIterator.SEG_LINETO: return new Point2D.Float(coords[0],coords[1]); case PathIterator.SEG_QUADTO: return new Point2D.Float(coords[2],coords[3]); case PathIterator.SEG_CUBICTO: return new Point2D.Float(coords[4],coords[5]); case PathIterator.SEG_CLOSE: default: return null; } }