public static void render( Graphics2D gc, GraphicsNode svgGraphicsNode, Dimension2D svgGraphicsSize, int centerX, int centerY, int width, int height, double angleRadians ) { double scaleX = width / svgGraphicsSize.getWidth(); double scaleY = height / svgGraphicsSize.getHeight(); AffineTransform affineTransform = new AffineTransform(); if ( centerX != 0 || centerY != 0 ) { affineTransform.translate( centerX, centerY ); } affineTransform.scale( scaleX, scaleY ); if ( angleRadians != 0 ) { affineTransform.rotate( angleRadians ); } affineTransform.translate( -svgGraphicsSize.getWidth() / 2, -svgGraphicsSize.getHeight() / 2 ); svgGraphicsNode.setTransform( affineTransform ); svgGraphicsNode.paint( gc ); } }
public void paint(Graphics2D g, int width, int height, int x, int y) { // saves the old transform; AffineTransform oldTransform = g.getTransform(); try { if (oldTransform == null) oldTransform = new AffineTransform(); AffineTransform transform = new AffineTransform(oldTransform); // adds scaling to the transform so that we respect the declared size transform.translate(x, y); transform.scale(width / bounds.getWidth(), height / bounds.getHeight()); g.setTransform(transform); node.paint(g); } finally { g.setTransform(oldTransform); } } }
public RenderableSVG(Document doc) { this.node = getGraphicNode(doc); this.bounds = getSvgDocBounds(doc); if (bounds == null) bounds = node.getBounds(); }
cgn.setViewingTransform(Px); curTxf = new AffineTransform(); ImageRendererFactory rendFactory = new ConcreteImageRendererFactory(); ImageRenderer renderer = rendFactory.createStaticImageRenderer(); renderer.updateOffScreen(w, h); renderer.setTransform(curTxf); renderer.setTree(this.root); this.root = null; // We're done with it... renderer.repaint(curTxf.createInverse().createTransformedShape(raoi)); BufferedImage rend = renderer.getOffScreen();
private Shape getShape(GraphicsNode node) { if (!node.isVisible()) { return null; result = ((ShapeNode) node).getShape(); } else if (node instanceof CompositeGraphicsNode) { CompositeGraphicsNode composite = (CompositeGraphicsNode) node; for (Object object : composite.getChildren()) { Shape subShape = getShape((GraphicsNode) object); if (subShape != null) { AffineTransform transform = node.getTransform(); if (result != null && transform != null && !transform.isIdentity()) { result = new TransformedShape(result, transform);
/** * Returns the bounds of the area painted by this shape painter */ public Rectangle2D getPaintedBounds2D(){ if (markerGroup == null) { buildMarkerGroup(); } return markerGroup.getPrimitiveBounds(); }
/** * Returns the area painted by this shape painter. */ public Shape getPaintedArea(){ if (markerGroup == null) { buildMarkerGroup(); } return markerGroup.getOutline(); }
/** * Returns the GraphicsNode containing point p if this node or one of its * children is sensitive to mouse events at p. * * @param p the specified Point2D in the user space */ public GraphicsNode nodeHitAt(Point2D p) { if (hitCheckChildren) return super.nodeHitAt(p); return (contains(p) ? this : null); }
/** * Returns true if pt is in the area painted by this shape painter */ public boolean inPaintedArea(Point2D pt){ if (markerGroup == null) { buildMarkerGroup(); } GraphicsNode gn = markerGroup.nodeHitAt(pt); return (gn != null); }
/** * Returns the global transformation matrix from the current * element to the root. */ public AffineTransform getGlobalTransform() { return node.getGlobalTransform(); }
/** * Creates a <code>ShapeNode</code>. */ protected GraphicsNode instantiateGraphicsNode() { return new ShapeNode(); }
@Override public void render(Graphics2D graphics2D) { /* * Do the real paint */ PDFTranscoder.this.root.paint(graphics2D); } });
/** * Returns the bounds of the area painted by this shape painter */ public Rectangle2D getPaintedBounds2D(){ if (markerGroup == null) { buildMarkerGroup(); } return markerGroup.getPrimitiveBounds(); }
/** * Returns the area painted by this shape painter. */ public Shape getPaintedArea(){ if (markerGroup == null) { buildMarkerGroup(); } return markerGroup.getOutline(); }
/** * Returns the GraphicsNode containing point p if this node or one of its * children is sensitive to mouse events at p. * * @param p the specified Point2D in the user space */ public GraphicsNode nodeHitAt(Point2D p) { if (hitCheckChildren) return super.nodeHitAt(p); return (contains(p) ? this : null); }
/** * Returns true if pt is in the area painted by this shape painter */ public boolean inPaintedArea(Point2D pt){ if (markerGroup == null) { buildMarkerGroup(); } GraphicsNode gn = markerGroup.nodeHitAt(pt); return (gn != null); }
/** * Returns the bounds of the area painted by this shape painter */ public Rectangle2D getPaintedBounds2D(){ if (markerGroup == null) { buildMarkerGroup(); } return markerGroup.getPrimitiveBounds(); }
/** * Returns the area painted by this shape painter. */ public Shape getPaintedArea(){ if (markerGroup == null) { buildMarkerGroup(); } return markerGroup.getOutline(); }
/** * Returns the GraphicsNode containing point p if this node or one of its * children is sensitive to mouse events at p. * * @param p the specified Point2D in the user space */ public GraphicsNode nodeHitAt(Point2D p) { if (hitCheckChildren) return super.nodeHitAt(p); return (contains(p) ? this : null); }
/** * Returns true if pt is in the area painted by this shape painter */ public boolean inPaintedArea(Point2D pt){ if (markerGroup == null) { buildMarkerGroup(); } GraphicsNode gn = markerGroup.nodeHitAt(pt); return (gn != null); }