private boolean hasPoints() { return !mPath.getPathIterator(null).isDone(); }
@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; }
@Implementation protected void offset(float dx, float dy) { GeneralPath newPath = new GeneralPath(); PathIterator iterator = mPath.getPathIterator(new AffineTransform(0, 0, dx, 0, 0, dy)); newPath.append(iterator, false /*connect*/); mPath = newPath; }
@Implementation(minSdk = LOLLIPOP) protected float[] approximate(float acceptableError) { PathIterator iterator = mPath.getPathIterator(null, acceptableError);
@Implementation protected void __constructor__(Path path, boolean forceClosed) { if (path != null) { ShadowPath shadowPath = (ShadowPath) Shadow.extract(path); mOriginalPathIterator = new CachedPathIteratorFactory(shadowPath.getJavaShape().getPathIterator(null)); } }
@Implementation protected void transform(Matrix matrix, Path dst) { ShadowMatrix shadowMatrix = extract(matrix); if (shadowMatrix.hasPerspective()) { Log.w(TAG, "android.graphics.Path#transform() only supports affine transformations."); } GeneralPath newPath = new GeneralPath(); PathIterator iterator = mPath.getPathIterator(shadowMatrix.getAffineTransform()); newPath.append(iterator, false /*connect*/); if (dst != null) { ShadowPath shadowPath = extract(dst); shadowPath.mPath = newPath; } else { mPath = newPath; } }
private static void addPath(Path destPath, Path srcPath, AffineTransform transform) { if (destPath == null) { return; } if (srcPath == null) { return; } ShadowPath shadowDestPath = extract(destPath); ShadowPath shadowSrcPath = extract(srcPath); if (transform != null) { shadowDestPath.mPath.append(shadowSrcPath.mPath.getPathIterator(transform), false); } else { shadowDestPath.mPath.append(shadowSrcPath.mPath, false); } }
static void assertPathEquals(final Path2D expectedPath, final Path2D actualPath) { PathIterator expectedIterator = expectedPath.getPathIterator(null); PathIterator actualIterator = actualPath.getPathIterator(null); float[] expectedCoords = new float[6]; float[] actualCoords = new float[6]; while(!actualIterator.isDone()) { int expectedType = expectedIterator.currentSegment(expectedCoords); int actualType = actualIterator.currentSegment(actualCoords); assertEquals(expectedType, actualType); assertArrayEquals(expectedCoords, actualCoords, 0); actualIterator.next(); expectedIterator.next(); } } }
@Override public PathIterator getPathIterator(AffineTransform at, double flatness) { return path.getPathIterator(at, flatness); }
@Override public PathIterator getPathIterator(AffineTransform at) { return path.getPathIterator(at); }
@Override public PathIterator getPathIterator(AffineTransform at) { return path.getPathIterator(at); }
@Override public PathIterator getPathIterator(AffineTransform at, double flatness) { return path.getPathIterator(at, flatness); }
private boolean hasPoints() { return !mPath.getPathIterator(null).isDone(); }
public static List<Point2D> getPoints(final Path2D path) { final PathIterator pi = path.getPathIterator(null); final double[] coordinates = new double[22]; final List<Point2D> points = new ArrayList<>(); while (!pi.isDone()) { pi.next(); pi.currentSegment(coordinates); final Point2D currentPoint = new Point2D.Double(coordinates[0], coordinates[1]); points.add(currentPoint); } return points; }
@Override protected SVGPath doBackward(Path2D b) { return SVGPath.create(b.getPathIterator(null)); } }
@Override public List<Point2> getPolygonPoints() { if (shape == null) return Collections.emptyList(); return getLinearPathPoints(shape, shape.getPathIterator(null, 0.5)); }
@Implementation protected void offset(float dx, float dy) { GeneralPath newPath = new GeneralPath(); PathIterator iterator = mPath.getPathIterator(new AffineTransform(0, 0, dx, 0, 0, dy)); newPath.append(iterator, false /*connect*/); mPath = newPath; }
@Override public PathIterator getPathIterator(AffineTransform at) { if (at != null) { setAffineTransform(at); } return getFullPathShape().getPathIterator(at); }
@Override public PathIterator getPathIterator(AffineTransform at, double flatness) { if (at != null) { setAffineTransform(at); } return getFullPathShape().getPathIterator(at, flatness); }
@Implementation protected void __constructor__(Path path, boolean forceClosed) { if (path != null) { ShadowPath shadowPath = (ShadowPath) Shadow.extract(path); mOriginalPathIterator = new CachedPathIteratorFactory(shadowPath.getJavaShape().getPathIterator(null)); } }