public static Rectangle2D getAnchor(Graphics2D graphics, Rectangle2D anchor) { if(graphics == null) { return anchor; } AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM); if(tx != null && !tx.isIdentity() && tx.createTransformedShape(anchor) != null) { anchor = tx.createTransformedShape(anchor).getBounds2D(); } return anchor; }
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); }
AffineTransform tx = graphics == null ? null : (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM); if (tx == null) { tx = new AffineTransform(); final Rectangle2D anchorO = tx.createTransformedShape(shapeAnchor).getBounds2D(); final AffineTransform txs2 = new AffineTransform(); anchorT = txs2.createTransformedShape(shapeAnchor).getBounds2D(); final AffineTransform txs2 = new AffineTransform(); txs2.translate(centerX, centerY); txs2.translate(-centerX, -centerY); normalizedShape = txs2.createTransformedShape(shapeAnchor).getBounds2D(); final java.awt.Shape anc = tx.createTransformedShape(normalizedShape); return (anc != null) ? anc.getBounds2D() : normalizedShape;
protected Collection<Outline> computeOutlines(Graphics2D graphics) { List<Outline> lst = new ArrayList<>(); FreeformShape<?,?> fsh = (FreeformShape<?, ?>) getShape(); Path2D sh = fsh.getPath(); AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM); if (tx == null) { tx = new AffineTransform(); } java.awt.Shape canvasShape = tx.createTransformedShape(sh); FillStyle fs = fsh.getFillStyle(); StrokeStyle ss = fsh.getStrokeStyle(); Path path = new Path(fs != null, ss != null); lst.add(new Outline(canvasShape, path)); return lst; }
public Rectangle2D getForElement(N node, Point p) { Shape shape = (Shape) rc.getNodeShapeFunction().apply(node); // Point2D p = (Point2D) layoutModel.apply(node); log.trace("node is at {}", p); float x = (float) p.x; float y = (float) p.y; AffineTransform xform = AffineTransform.getTranslateInstance(x, y); return xform.createTransformedShape(shape).getBounds2D(); }
flipAT = new AffineTransform(); flipAT.translate(0, pdPage.getBBox().getHeight()); flipAT.scale(1, -1); rotateAT = new AffineTransform(); int rotation = pdPage.getRotation(); if (rotation != 0) transAT = AffineTransform.getTranslateInstance(-cropBox.getLowerLeftX(), cropBox.getLowerLeftY()); s = flipAT.createTransformedShape(s); s = rotateAT.createTransformedShape(s); g2d.setColor(Color.green); g2d.draw(s);
private BufferedImage adjustImage(BufferedImage gray) throws IOException { AffineTransform at = new AffineTransform(xform); Matrix m = new Matrix(at); at.scale(1.0 / Math.abs(m.getScalingFactorX()), 1.0 / Math.abs(m.getScalingFactorY())); Rectangle originalBounds = new Rectangle(gray.getWidth(), gray.getHeight()); Rectangle2D transformedBounds = at.createTransformedShape(originalBounds).getBounds2D(); at.preConcatenate(AffineTransform.getTranslateInstance(-transformedBounds.getMinX(), -transformedBounds.getMinY())); int width = (int) Math.ceil(transformedBounds.getWidth()); int height = (int) Math.ceil(transformedBounds.getHeight()); BufferedImage transformedGray = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY); Graphics2D g2 = (Graphics2D) transformedGray.getGraphics(); g2.drawImage(gray, at, null); g2.dispose(); return transformedGray; }
AffineTransform at = new AffineTransform(); java.awt.Shape tailShape = null; Path p = null; p = new Path(); tailShape = new Ellipse2D.Double(0, 0, lineWidth * scaleX, lineWidth * scaleY); bounds = tailShape.getBounds2D(); at.translate(x2 - bounds.getWidth() / 2, y2 - bounds.getHeight() / 2); at.rotate(alpha, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2); tailShape = at.createTransformedShape(tailShape);
AffineTransform at = new AffineTransform(); at.translate(anchor.getX(), anchor.getY()); at.scale(scaleX, scaleY); java.awt.Shape canvasShape = at.createTransformedShape(gp);
public ShapeStroke(Shape shape, float width, float advance, float phase) { this.advance = advance; this.phase = phase; Rectangle2D bounds = shape.getBounds2D(); double scale = width / bounds.getHeight(); t.setToScale(scale, scale); t.translate(-bounds.getCenterX(), -bounds.getCenterY()); this.theShape = t.createTransformedShape(shape); }
Point2D p = gv.getGlyphPosition(i); double theta = (double) i / (double) (length - 1) * Math.PI / 4; AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY()); at.rotate(theta); Shape glyph = gv.getGlyphOutline(i); Shape transformedGlyph = at.createTransformedShape(glyph); g2.fill(transformedGlyph);
public Rectangle2D getForElement(N node, Point p) { Shape shape = (Shape) rc.getNodeShapeFunction().apply(node); // Point2D p = (Point2D) layoutModel.apply(node); log.trace("node is at {}", p); float x = (float) p.x; float y = (float) p.y; AffineTransform xform = AffineTransform.getTranslateInstance(x, y); return xform.createTransformedShape(shape).getBounds2D(); }
public static void drawEllipse( EllipseRotated_F64 ellipse , double scale , Graphics2D g2 ) { AffineTransform rotate = new AffineTransform(); rotate.rotate(ellipse.phi); double w = scale*ellipse.a*2; double h = scale*ellipse.b*2; Shape shape = rotate.createTransformedShape(new Ellipse2D.Double(-w/2,-h/2,w,h)); shape = AffineTransform.getTranslateInstance(scale*ellipse.center.x,scale*ellipse.center.y).createTransformedShape(shape); g2.draw(shape); }
Rectangle2D bounds = at.createTransformedShape(unitRect).getBounds2D(); BufferedImage renderedPaint = new BufferedImage((int) Math.ceil(bounds.getWidth()), g = (Graphics2D) renderedMask.getGraphics(); g.translate(-bounds.getMinX(), -bounds.getMinY()); AffineTransform imageTransform = new AffineTransform(at); imageTransform.scale(1.0 / mask.getWidth(), -1.0 / mask.getHeight()); imageTransform.translate(0, -mask.getHeight()); AffineTransform.getTranslateInstance(bounds.getMinX(), bounds.getMinY()), null);
AffineTransform at = new AffineTransform(); java.awt.Shape headShape = null; Path p = null; p = new Path(); headShape = new Ellipse2D.Double(0, 0, lineWidth * scaleX, lineWidth * scaleY); bounds = headShape.getBounds2D(); at.translate(x1 - bounds.getWidth() / 2, y1 - bounds.getHeight() / 2); at.rotate(alpha, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2); headShape = at.createTransformedShape(headShape);
final AffineTransform at = new AffineTransform(); at.scale(1./Units.EMU_PER_POINT, 1./Units.EMU_PER_POINT); at.translate(-xfrm2d.getCenterX(), -xfrm2d.getCenterY()); return new Path2D.Double(at.createTransformedShape(path));
/** * Builds a new transformed icon * * @param icon The icon to be rescaled * @param transformation The icon transformation */ public TransformedIcon(Icon icon, AffineTransform at) { this.icon = icon; this.at = at; Rectangle2D bounds = new Rectangle2D.Double(0, 0, icon.getIconWidth(), icon.getIconHeight()); bounds = at.createTransformedShape(bounds).getBounds2D(); this.width = (int) Math.round(bounds.getWidth()); this.height = (int) Math.round(bounds.getHeight()); }
int spaceX = sz - r.width; int spaceY = sz - r.height; AffineTransform trans = AffineTransform.getTranslateInstance( -r.x + (spaceX / 2), -r.y + (spaceY / 2)); System.out.println("Box2D " + trans); Shape shapeCentered = trans.createTransformedShape(shape1);
public Rectangle2D getForElement(N node) { Shape shape = new Rectangle2D.Double(); Point p = (Point) visualizationModel.getLayoutModel().apply(node); float x = (float) p.x; float y = (float) p.y; AffineTransform xform = AffineTransform.getTranslateInstance(x, y); Rectangle2D xfs = xform.createTransformedShape(shape).getBounds2D(); log.trace("node {} with shape bounds {} is at {}", node, xfs, p); return xfs; }
public static void drawEllipse( EllipseRotated_F64 ellipse , double scale , Graphics2D g2 ) { AffineTransform rotate = new AffineTransform(); rotate.rotate(ellipse.phi); double w = scale*ellipse.a*2; double h = scale*ellipse.b*2; Shape shape = rotate.createTransformedShape(new Ellipse2D.Double(-w/2,-h/2,w,h)); shape = AffineTransform.getTranslateInstance(scale*ellipse.center.x,scale*ellipse.center.y).createTransformedShape(shape); g2.draw(shape); }