Java examples for 2D Graphics:Path
get Path From Index
//package com.java2s; import java.awt.geom.PathIterator; import java.awt.geom.GeneralPath; public class Main { public static GeneralPath getPathFromIndex(int point, GeneralPath path) { GeneralPath newPath = new GeneralPath(GeneralPath.WIND_EVEN_ODD); double x1 = 0, y1 = 0, x2 = 0, y2 = 0; int index = 0; double seg[] = new double[6]; boolean gotThere = false; for (PathIterator i = path.getPathIterator(null); !i.isDone(); i .next()) {/* w w w .j av a2s.c om*/ int segType = i.currentSegment(seg); if (gotThere) { newPath.lineTo((int) seg[0], (int) seg[1]); } else { if (point == index) { newPath.moveTo((int) seg[0], (int) seg[1]); gotThere = true; } } index++; } return newPath; } }