public static int count(Shape source) { int result = 0; final PathIterator path = source.getPathIterator(null); while (path.isDone() == false) { result++; path.next(); } return result; }
private static List<Integer> getClosings(PathIterator path) { final List<Integer> result = new ArrayList<Integer>(); int current = 0; final double coord[] = new double[6]; while (path.isDone() == false) { final int code = path.currentSegment(coord); if (code == PathIterator.SEG_CLOSE) { result.add(current); } current++; path.next(); } return result; }
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; float next = 0; int phase = 0; while (!it.isDone()) { type = it.currentSegment(points); switch (type) { case PathIterator.SEG_MOVETO: break; it.next();
/** * Moves the iterator to the next segment of the path forwards along the primary direction of * traversal as long as there are more points in that direction. */ public void next() { // try to move the current iterator forward if (!currentIterator.isDone()) { currentIterator.next(); } // if the iterator is finished, let's move to the next one (and if // the next one, should the next one be empty) while (currentIterator.isDone() && !done) { if (currentGeom < (gc.getNumGeometries() - 1)) { currentGeom++; currentIterator = getIterator(gc.getGeometryN(currentGeom)); } else { done = true; } } } }
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; float next = 0; int phase = 0; while (!it.isDone()) { type = it.currentSegment(points); switch (type) { case PathIterator.SEG_MOVETO: break; it.next();
/** * Returns the estimated length of a flat path. If the passed path is not flat (i.e. contains a * segment that is not {@link PathIterator#SEG_CLOSE}, {@link PathIterator#SEG_MOVETO} or {@link * PathIterator#SEG_LINETO} this method will fail. */ private static float getFlatPathLength(PathIterator iterator) { float segment[] = new float[6]; float totalLength = 0; float[] previousPoint = new float[2]; boolean isFirstPoint = true; while (!iterator.isDone()) { int type = iterator.currentSegment(segment); assert type == PathIterator.SEG_LINETO || type == PathIterator.SEG_CLOSE || type == PathIterator.SEG_MOVETO; // MoveTo shouldn't affect the length if (!isFirstPoint && type != PathIterator.SEG_MOVETO) { totalLength += (float) Point2D.distance(previousPoint[0], previousPoint[1], segment[0], segment[1]); } else { isFirstPoint = false; } previousPoint[0] = segment[0]; previousPoint[1] = segment[1]; iterator.next(); } return totalLength; }
public void next() { currentPathIterator.next(); if (currentPathIterator.isDone() && !shapeIterator.hasNext()) { done = true; return; } if (currentPathIterator.isDone()) { currentPathIterator = ((Shape) shapeIterator.next()).getPathIterator(affineTransform); } }
public float measurePathLength(Shape shape) { PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0; float total = 0; while (!it.isDone()) { type = it.currentSegment(points); switch (type) { case PathIterator.SEG_MOVETO: break; it.next();
@Implementation protected boolean isEmpty() { if (!mCachedIsEmpty) { return false; } float[] coords = new float[6]; mCachedIsEmpty = Boolean.TRUE; for (PathIterator it = mPath.getPathIterator(null); !it.isDone(); it.next()) { int type = it.currentSegment(coords); // if (type != PathIterator.SEG_MOVETO) { // Once we know that the path is not empty, we do not need to check again unless // Path#reset is called. mCachedIsEmpty = false; return false; // } } return true; }
public static int count(Shape source) { int result = 0; final PathIterator path = source.getPathIterator(null); while (path.isDone() == false) { result++; path.next(); } return result; }
PathIterator it = shape.getPathIterator(null); double[] coords = new double[6]; double[] pos = new double[2]; Line2D.Double l = new Line2D.Double(); while (!it.isDone()) { int type = it.currentSegment(coords); switch (type) { case PathIterator.SEG_MOVETO: it.next();
ArrayList<Point2D.Float> points = new ArrayList<Point2D.Float>(); Point2D.Float previousPoint = null; while (!iterator.isDone()) { int type = iterator.currentSegment(segment); Point2D.Float currentPoint = new Point2D.Float(segment[0], segment[1]); iterator.next();
public void next() { currentPathIterator.next(); if (currentPathIterator.isDone() && !shapeIterator.hasNext()) { done = true; return; } if (currentPathIterator.isDone()) { currentPathIterator = ((Shape) shapeIterator.next()).getPathIterator(affineTransform); } }
public String getCharDesc(char c) { final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext()); final Shape sh = t.getOutline(null); final double current[] = new double[6]; final PathIterator it = sh.getPathIterator(null); int sum = 0; final StringBuilder result = new StringBuilder(); while (it.isDone() == false) { final double oldX = current[0]; final double oldY = current[1]; final int nb = it.currentSegment(current); sum += nb; result.append(getType(nb, oldX, oldY, current[0], current[1])); it.next(); } return result.toString(); }
+ getColorName(color) + "] "); final double coord[] = new double[6]; while (path.isDone() == false) { final int code = path.currentSegment(coord); if (code == PathIterator.SEG_MOVETO) { sb.append(couple(coord[0] + x, coord[1] + y)); path.next();
public void next() { currentPathIterator.next(); if (currentPathIterator.isDone() && !shapeIterator.hasNext()) { done = true; return; } if (currentPathIterator.isDone()) { currentPathIterator = ((Shape) shapeIterator.next()).getPathIterator(affineTransform); } }
public String getCharDescVerbose(char c) { final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext()); final Shape sh = t.getOutline(null); final double current[] = new double[6]; final PathIterator it = sh.getPathIterator(null); int sum = 0; final StringBuilder result = new StringBuilder(); while (it.isDone() == false) { final double oldX = current[0]; final double oldY = current[1]; final int nb = it.currentSegment(current); sum += nb; result.append(getType(nb, oldX, oldY, current[0], current[1])); appendValue(result, current); it.next(); } return result.toString(); }
final double[] vals = new double[6]; while (!pi.isDone()) { Arrays.fill(vals, 0); int type = pi.currentSegment(vals); pi.next(); if (connect && numVals != 0) { if (type == PathIterator.SEG_MOVETO) { } else { if (pi.isDone()) { break; // Nothing interesting type = pi.currentSegment(vals); pi.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; float next = phase; while (!it.isDone()) { type = it.currentSegment(points); switch (type) { case PathIterator.SEG_MOVETO: break; it.next();
ArrayList<float[]> pointsArray = new ArrayList<>(); float[] points = new float[6]; while (!iterator.isDone()) { int type = iterator.currentSegment(points); int nPoints = getNumberOfPoints(type) * 2; // 2 coordinates per point System.arraycopy(points, 0, itemPoints, 0, nPoints); pointsArray.add(itemPoints); iterator.next();