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); } }
@Implementation(minSdk = LOLLIPOP) protected void addRoundRect( float left, float top, float right, float bottom, float[] radii, Path.Direction dir) { if (radii.length < 8) { throw new ArrayIndexOutOfBoundsException("radii[] needs 8 values"); } isSimplePath = false; float[] cornerDimensions = new float[radii.length]; for (int i = 0; i < radii.length; i++) { cornerDimensions[i] = 2 * radii[i]; } mPath.append( new RoundRectangle(left, top, right - left, bottom - top, cornerDimensions), false); }
@Implementation(minSdk = LOLLIPOP) protected void addArc( float left, float top, float right, float bottom, float startAngle, float sweepAngle) { mPath.append( new Arc2D.Float( left, top, right - left, bottom - top, -startAngle, -sweepAngle, Arc2D.OPEN), false); }
@Implementation(minSdk = LOLLIPOP) protected void addRoundRect( float left, float top, float right, float bottom, float rx, float ry, Path.Direction dir) { mPath.append( new RoundRectangle2D.Float(left, top, right - left, bottom - top, rx * 2, ry * 2), false); }
@Implementation(minSdk = LOLLIPOP) protected void addOval(float left, float top, float right, float bottom, Path.Direction dir) { mPath.append(new Ellipse2D.Float(left, top, right - left, bottom - top), false); }
@Implementation protected void addCircle(float x, float y, float radius, Path.Direction dir) { mPath.append(new Ellipse2D.Float(x - radius, y - radius, radius * 2, radius * 2), false); }
@Implementation protected void set(Path src) { mPath.reset(); ShadowPath shadowSrc = extract(src); setFillType(shadowSrc.mFillType); mPath.append(shadowSrc.mPath, false /*connect*/); }
@Implementation(minSdk = LOLLIPOP) protected void arcTo( float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean forceMoveTo) { isSimplePath = false; Arc2D arc = new Arc2D.Float( left, top, right - left, bottom - top, -startAngle, -sweepAngle, Arc2D.OPEN); mPath.append(arc, true /*connect*/); resetLastPointFromPath(); }
/** * {@inheritDoc} */ @Override public void rect(final double x, final double y, final double w, final double h) { final Path2D subPath = getCurrentSubPath(); if (subPath != null) { final Point2D p = transformation_.transform(new Point2D.Double(x, y), null); final Rectangle2D rect = new Rectangle2D.Double(p.getX(), p.getY(), w, h); subPath.append(rect, false); } }
public void addShape(Color col, Shape shape) { if (col != null) { if (!areas.containsKey(col)) { areas.put(col, new Path2D.Double()); } areas.get(col).append(shape.getPathIterator(null), false); } }
/** * Generates a full round rectangle that is made of bounds and border * @param bounds Dimmensions of the rect * @param border The border specs * @param inside true if you want the inner bounds of borders * @return A Path that is all sides of the round rectangle */ public static Path2D generateBorderBounds(Rectangle bounds, BorderPropertySet border, boolean inside) { Path2D path = generateBorderShape(bounds, TOP, border, false, inside ? 1 : 0, 1); path.append(generateBorderShape(bounds, RIGHT, border, false, inside ? 1 : 0, 1), true); path.append(generateBorderShape(bounds, BOTTOM, border, false, inside ? 1 : 0, 1), true); path.append(generateBorderShape(bounds, LEFT, border, false, inside ? 1 : 0, 1), true); return path; }
/** * Append the given point to the given path. */ private static void addPoint(final Path2D addTo, final double x, final double y) { addTo.append(new Ellipse2D.Double(x - POINT_RADIUS, y - POINT_RADIUS, 2*POINT_RADIUS, 2*POINT_RADIUS), false); }
Path2D path = new Path2D.Double(); AffineTransform at = new AffineTransform(); path.moveTo(p1p2a.x, p1p2a.y); path.lineTo(p1p2b.x, p1p2b.y); path.append(c1.getPathIterator(at), true); path.lineTo(p2p3b.x, p2p3b.y); path.append(c2.getPathIterator(at), true); path.lineTo(p3p1b.x, p3p1b.y); path.append(c3.getPathIterator(at), true); path.closePath(); g.fill(path);
private void addToZone(Shape diamond, Path2D[] zones, int z) { if (zones[z] == null) { zones[z] = new Path2D.Double(); } zones[z].append(diamond.getPathIterator(null), false); }
private Path2D getFullPathShape() { Path2D pathShape = new Path2D.Double(Path2D.WIND_NON_ZERO); for (BasicShape item : shapeList) { Shape realShape = item.getRealShape(); if (realShape != null) { pathShape.append(realShape, false); } } return pathShape; }
@Implementation(minSdk = LOLLIPOP) protected void addRoundRect( float left, float top, float right, float bottom, float rx, float ry, Path.Direction dir) { mPath.append( new RoundRectangle2D.Float(left, top, right - left, bottom - top, rx * 2, ry * 2), false); }
@Implementation(minSdk = LOLLIPOP) protected void addArc( float left, float top, float right, float bottom, float startAngle, float sweepAngle) { mPath.append( new Arc2D.Float( left, top, right - left, bottom - top, -startAngle, -sweepAngle, Arc2D.OPEN), false); }
@Implementation protected void addCircle(float x, float y, float radius, Path.Direction dir) { mPath.append(new Ellipse2D.Float(x - radius, y - radius, radius * 2, radius * 2), false); }
@Implementation protected void set(Path src) { mPath.reset(); ShadowPath shadowSrc = extract(src); setFillType(shadowSrc.mFillType); mPath.append(shadowSrc.mPath, false /*connect*/); }
/** * Calculate the convex hull of multiple shapes. * * @param shapes Java 2D shapes * @return the convex hull */ public static ConvexHull ofShapes(final List<Shape> shapes) { final Path2D combined = new Path2D.Double(); for (Shape shape : shapes) combined.append(shape, false); return new ConvexHull(shapeOf(grahamScan(pointsOf(combined)))); }