}
return convertCoords(coords, coords.length);
}
if (shape instanceof Polygon2D) {
Polygon2D p = (Polygon2D) shape;
int n = p.getVertexCount();
coords = new double[n * 2];
for (int i = 0; i < n; i++) {
coords[i * 2] = p.getX(i);
coords[i * 2 + 1] = p.getY(i);
}
return convertCoords(coords, coords.length);
}
// For Path2D, the integer path type is inserted before the coordinates of each segment
if (shape instanceof Path2D) {
Path2D p = (Path2D) shape;
StringBuffer buf = new StringBuffer();
coords = new double[6];
PathIterator pathIter = p.getPathIterator(null);
while (!pathIter.isDone()) {
int subPathType = pathIter.currentSegment(coords);
buf.append(subPathType).append(" ");
if (subPathType == PathIterator.SEG_MOVETO || subPathType == PathIterator.SEG_LINETO) {
buf.append(convertCoords(coords, 2)).append(" ");