public void assignPointAndType() { currentPolygon = multiPolygon.getPolygon(polygonNum); if (index == 0) { currentPoint = currentPolygon.getPoint(0); type = PathIterator.SEG_MOVETO; } else if (index == currentPolygon.points.size()) { type = PathIterator.SEG_CLOSE; } else { currentPoint = currentPolygon.getPoint(index); type = PathIterator.SEG_LINETO; } }
public static void main(String[] args) { ga_Polygon poly1 = ga_Polygon.createRegularPolygon(10, 100); ga_Polygon poly2 = ga_Polygon.createRegularPolygon(10, 50); poly1.translate(10, 10); poly2.translate(10, 10); ga_PolygonMultiAwt multiPoly = new ga_PolygonMultiAwt(poly1, poly2); Shape shape = ga_PolygonConverterAwt.makePath2DFrom(multiPoly); { System.out.println("For shape:"); PathIterator pathIterator = shape.getPathIterator(null); float[] coords = new float[6]; while (pathIterator.isDone() == false) { int type = pathIterator.currentSegment(coords); if (type == PathIterator.SEG_MOVETO) { System.out.println(": SEG_MOVETO, " + coords[0] + ", " + coords[1]); pathIterator.next(); } else if (type == PathIterator.SEG_LINETO) { System.out.println(": SEG_LINETO, " + coords[0] + ", " + coords[1]); pathIterator.next(); } else if (type == PathIterator.SEG_CLOSE) { System.out.println(": SEG_CLOSE, " + coords[0] + ", " + coords[1]); pathIterator.next(); } } } { System.out.println("For multiPoly:"); PathIterator pathIterator = multiPoly.getPathIterator(null); float[] coords = new float[6]; while (pathIterator.isDone() == false) { int type = pathIterator.currentSegment(coords); if (type == PathIterator.SEG_MOVETO) { System.out.println(": SEG_MOVETO, " + coords[0] + ", " + coords[1]); pathIterator.next(); } else if (type == PathIterator.SEG_LINETO) { System.out.println(": SEG_LINETO, " + coords[0] + ", " + coords[1]); pathIterator.next(); } else if (type == PathIterator.SEG_CLOSE) { System.out.println(": SEG_CLOSE, " + coords[0] + ", " + coords[1]); pathIterator.next(); } } } }
PolygonMultiIterator(ga_PolygonMulti kPolygon, AffineTransform at) { this.multiPolygon = kPolygon; this.affine = at; currentPolygon = multiPolygon.getPolygon(polygonNum); currentPoint = currentPolygon.getPoint(0); }