public Shape createStrokedShape (Shape shape) { GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0;
new FlatteningPathIterator(shape.getPathIterator(g.getTransform()), 1); float[] floats = new float[6]; fpi.currentSegment(floats); float last_x = floats[0]; float last_y = floats[1]; while (! fpi.isDone()) fpi.currentSegment(floats); int distance = (int) Math.sqrt( (floats[0] - last_x) * (floats[0] - last_x) fpi.next();
public static Polygon getPolygonOutline(BufferedImage image) { Area a = getOutline(image, new Color(0, 0, 0, 0), false, 10); // 10 or whatever color tolerance you want Polygon p = new Polygon(); FlatteningPathIterator fpi = new FlatteningPathIterator(a.getPathIterator(null), 0.1); // 0.1 or how sloppy you want it double[] pts = new double[6]; while (!fpi.isDone()) { switch (fpi.currentSegment(pts)) { case FlatteningPathIterator.SEG_MOVETO: case FlatteningPathIterator.SEG_LINETO: p.addPoint((int) pts[0], (int) pts[1]); break; } fpi.next(); } return p; }
final double inset = 4; FlatteningPathIterator i = new FlatteningPathIterator(iterator, flateness); while(!i.isDone()) { switch(i.currentSegment(coord)) { case FlatteningPathIterator.SEG_MOVETO: oldx = coord[0]; break; i.next();
public Shape createStrokedShape (Shape shape) { GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0;
public void drawCircle(int x, int y, int w, int h) { int index = preview.getCurrentSlice(); Ellipse2D e = new Ellipse2D.Float(x, y, w, h); float[] v = new float[6]; boolean finished = false; ImageProcessor ip = stack.getProcessor(index); for(int z = 0; !finished; z++) { ip = ip.convertToRGB(); ip.setValue(color); ip.setLineWidth(linewidth); FlatteningPathIterator it = new FlatteningPathIterator( e.getPathIterator(null), 1); it.currentSegment(v); ip.moveTo((int)v[0], (int)v[1]); it.next(); for(int i = 0; i < z; i++) { it.currentSegment(v); ip.lineTo((int)v[0], (int)v[1]); it.next(); finished = it.isDone(); } if(!stack.addSlice(index + z, ip)) break; } }
public float measurePathLength(Shape shape) { PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0;
int index=0; public PaintPanel(Shape s) { iter=new FlatteningPathIterator(s.getPathIterator(new AffineTransform()), 1); points=new ArrayList<Point>(); float[] coords=new float[6]; while (!iter.isDone()) { iter.currentSegment(coords); int x=(int)coords[0]; int y=(int)coords[1]; points.add(new Point(x,y)); iter.next();
public Shape createStrokedShape(Shape shape) { GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0;
sspi.setPathIterator(pi, currentX, currentY); FlatteningPathIterator fpi = new FlatteningPathIterator(sspi, 0.01f); while (!fpi.isDone()) { segType = fpi.currentSegment(seg); if (segType == PathIterator.SEG_LINETO) { pathLength += Point2D.distance(currentX, currentY, index++; fpi.next();
public Shape createStrokedShape (Shape shape) { GeneralPath result = new GeneralPath(); shape = new BasicStroke(getWidth(), BasicStroke.CAP_SQUARE, getJoin()).createStrokedShape(shape); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0;
sspi.setPathIterator(pi, currentX, currentY); FlatteningPathIterator fpi = new FlatteningPathIterator(sspi, 0.01f); while (!fpi.isDone()) { segType = fpi.currentSegment(seg); if (segType == PathIterator.SEG_LINETO) { pathLength += Point2D.distance(currentX, currentY, index++; fpi.next();
public Shape createStrokedShape (Shape shape) { GeneralPath result = new GeneralPath(); shape = new BasicStroke(getWidth(), BasicStroke.CAP_SQUARE, getJoin()).createStrokedShape(shape); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0;
sspi.setPathIterator(pi, currentX, currentY); FlatteningPathIterator fpi = new FlatteningPathIterator(sspi, 0.01f); while (!fpi.isDone()) { segType = fpi.currentSegment(seg); if (segType == PathIterator.SEG_LINETO) { pathLength += Point2D.distance(currentX, currentY, index++; fpi.next();
PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0;
FlatteningPathIterator f = new FlatteningPathIterator(pathIt,0.1); float[] oldPts = null; Collection curveSegments = new Vector(); while ( !f.isDone() ) { float[] pts = new float[6]; int segType = f.currentSegment(pts); if (segType == PathIterator.SEG_MOVETO || segType == PathIterator.SEG_LINETO) { f.next();
public Shape createStrokedShape(Shape shape) { GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0;
@Override public final PathIterator getPathIterator(AffineTransform at, double flatness) { return new FlatteningPathIterator(this.path.getPathIterator(at), flatness); }
@Override public final PathIterator getPathIterator(AffineTransform at, double flatness) { return new FlatteningPathIterator(this.path.getPathIterator(at), flatness); }
/** * {@inheritDoc} */ @Override public PathIterator getPathIterator(AffineTransform at, double flatness) { return new FlatteningPathIterator(getPathIterator(at), flatness); }