public void draw(Graphics2D g2d, double x, double y) { final GeneralPath p = new GeneralPath(); for (CubicCurve2D.Double bez : beziers) { bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2, y + bez.ctrly2, x + bez.x2, y + bez.y2); p.append(bez, true); } g2d.draw(p); }
final public GeneralPath asGeneralPath() { final GeneralPath generalPath = new GeneralPath(); for (LineSegmentInt seg : segments()) { generalPath.append(seg, false); } return generalPath; }
private void appendAndRotate(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg, final Shape shape) { final AffineTransform at = AffineTransform.getTranslateInstance(point.x, point.y); final double theta = seg.getAngle(); at.rotate(theta); final Shape r = at.createTransformedShape(shape); generalPath.append(r, false); }
@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; }
t.setToTranslation(x, y); t.rotate(angle); result.append(t.createTransformedShape(theShape), false); next += advance;
@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; } }
t.rotate(angle); t.translate(-px - advance, -py + height * factor / 2.0f); result.append(t.createTransformedShape(glyph), false); next += (advance + nextAdvance) * factor; currentChar++;
arc.getCenterY()); final Shape s = t.createTransformedShape(arc); path.append(s, true);
void endRing() { ringPath.closePath(); if (polygonPath == null) { polygonPath = ringPath; } else { polygonPath.append(ringPath, false); } ringPath = null; }
public static void drawPoints(Graphics2D g, Iterable<Point> points) { GeneralPath onCurves = new GeneralPath(); GeneralPath offCurves = new GeneralPath(); for (Point point : points) { Shape s = new Ellipse2D.Double(point.x - HALF_POINT_SIZE, point.y - HALF_POINT_SIZE, POINT_SIZE, POINT_SIZE); if (point.isOnCurve()) { onCurves.append(s, false); } else { offCurves.append(s, false); } } g.setColor(Color.BLUE); g.fill(onCurves); g.setColor(Color.RED); g.fill(offCurves); }
/** * Creates a new polygon {@link Shape}. * * @param shellVertices the vertices of the shell * @param holeVerticesCollection a collection of Coordinate[] for each hole */ public PolygonShape(Coordinate[] shellVertices, Collection holeVerticesCollection) { polygonPath = toPath(shellVertices); for (Iterator i = holeVerticesCollection.iterator(); i.hasNext();) { Coordinate[] holeVertices = (Coordinate[]) i.next(); polygonPath.append(toPath(holeVertices), false); } }
public static Shape getDonutSliceShape( Rectangle2D pieBounds, double thickness, double start, double extent) { thickness = thickness / 2; GeneralPath generalPath = new GeneralPath(); GeneralPath dummy = new GeneralPath(); // used to find arc endpoints double x = pieBounds.getX(); double y = pieBounds.getY(); double width = pieBounds.getWidth(); double height = pieBounds.getHeight(); Shape outer = new Arc2D.Double(x, y, width, height, start, extent, Arc2D.OPEN); double wt = width * thickness; double ht = height * thickness; Shape inner = new Arc2D.Double( x + wt, y + ht, width - 2 * wt, height - 2 * ht, start + extent, -extent, Arc2D.OPEN); generalPath.append(outer, false); dummy.append( new Arc2D.Double( x + wt, y + ht, width - 2 * wt, height - 2 * ht, start, extent, Arc2D.OPEN), false); Point2D point = dummy.getCurrentPoint(); if (point != null) { generalPath.lineTo(point.getX(), point.getY()); } generalPath.append(inner, false); dummy.append(new Arc2D.Double(x, y, width, height, start + extent, -extent, Arc2D.OPEN), false); point = dummy.getCurrentPoint(); generalPath.lineTo(point.getX(), point.getY()); return generalPath; }
private GeneralPath toShape(MultiLineString mls) { GeneralPath path = new GeneralPath(); for (int i = 0; i < mls.getNumGeometries(); i++) { LineString lineString = (LineString) mls.getGeometryN(i); path.append(toShape(lineString), false); } return path; }
mTransform.setToTranslation(x, y); result.append(mTransform.createTransformedShape(mShapes[currentShape]), false); next += 1; currentShape++;
/** * End buffering the text clipping path, if any. */ private void endTextClip() { PDGraphicsState state = getGraphicsState(); RenderingMode renderingMode = state.getTextState().getRenderingMode(); // apply the buffered clip as one area if (renderingMode.isClip() && !textClippings.isEmpty()) { // PDFBOX-4150: this is much faster than using textClippingArea.add(new Area(glyph)) // https://stackoverflow.com/questions/21519007/fast-union-of-shapes-in-java GeneralPath path = new GeneralPath(); for (Shape shape : textClippings) { path.append(shape, false); } state.intersectClippingPath(path); textClippings = new ArrayList<>(); // PDFBOX-3681: lastClip needs to be reset, because after intersection it is still the same // object, thus setClip() would believe that it is cached. lastClip = null; } }
private GeneralPath getPathB() { GeneralPath path = new GeneralPath(I_SHAPE); GeneralPath bow = getPathPBow(); bow.transform(AffineTransform.getTranslateInstance(15, 20)); path.append(bow, false); return path; }
private GeneralPath toShape(MultiLineString mls) { GeneralPath path = new GeneralPath(); for (int i = 0; i < mls.getNumGeometries(); i++) { LineString lineString = (LineString) mls.getGeometryN(i); path.append(toShape(lineString), false); } return path; }