Package org.apache.fop.render.RendererContext

Examples of org.apache.fop.render.RendererContext.RendererContextWrapper


        // Build the SVG DOM and provide the painter with it
        GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, clonedDoc);

        // Create Graphics2DImagePainter
        final RendererContextWrapper wrappedContext
            = RendererContext.wrapRendererContext(rendererContext);
        Dimension imageSize = getImageSize(wrappedContext);
        Graphics2DImagePainter painter
            = createGraphics2DImagePainter(bridgeContext, root, imageSize);

        // Create AFPObjectAreaInfo
        RendererContextWrapper rctx = RendererContext.wrapRendererContext(rendererContext);
        int x = rctx.getCurrentXPosition();
        int y = rctx.getCurrentYPosition();
        int width = afpInfo.getWidth();
        int height = afpInfo.getHeight();
        int resolution = afpInfo.getResolution();

        paintingState.save(); // save
View Full Code Here


     * @param doc the SVG document
     * @throws IOException In case of an I/O error while painting the image
     */
    protected void renderSVGDocument(final RendererContext context,
            final Document doc) throws IOException {
        final RendererContextWrapper wrappedContext = RendererContext.wrapRendererContext(context);
        int x = wrappedContext.getCurrentXPosition();
        int y = wrappedContext.getCurrentYPosition();

        //Prepare
        SVGUserAgent ua = new SVGUserAgent(
                context.getUserAgent().getSourcePixelUnitToMillimeter(),
                new AffineTransform());
        GVTBuilder builder = new GVTBuilder();
        final BridgeContext ctx = new BridgeContext(ua);

        //Build the GVT tree
        final GraphicsNode root;
        try {
            root = builder.build(ctx, doc);
        } catch (Exception e) {
            log.error("SVG graphic could not be built: " + e.getMessage(), e);
            return;
        }

        //Create the painter
        Graphics2DImagePainter painter = new Graphics2DImagePainter() {

            public void paint(Graphics2D g2d, Rectangle2D area) {
                // If no viewbox is defined in the svg file, a viewbox of 100x100 is
                // assumed, as defined in SVGUserAgent.getViewportSize()
                float iw = (float) ctx.getDocumentSize().getWidth();
                float ih = (float) ctx.getDocumentSize().getHeight();
                float w = (float) area.getWidth();
                float h = (float) area.getHeight();
                g2d.scale(w / iw, h / ih);

                root.paint(g2d);
            }

            public Dimension getImageSize() {
                return new Dimension(wrappedContext.getWidth(), wrappedContext.getHeight());
            }

        };

        //Let the painter paint the SVG on the Graphics2D instance
        Graphics2DAdapter adapter = context.getRenderer().getGraphics2DAdapter();
        adapter.paintImage(painter, context,
                x, y, wrappedContext.getWidth(), wrappedContext.getHeight());
    }
View Full Code Here

        graphics.setOutputStream(pdfInfo.outputStream);

        if (pdfInfo.paintAsBitmap) {
            //Fallback solution: Paint to a BufferedImage
            int resolution = (int)Math.round(context.getUserAgent().getTargetResolution());
            RendererContextWrapper ctx = RendererContext.wrapRendererContext(context);
            BufferedImage bi = paintToBufferedImage(painter, ctx, resolution, false, false);

            float scale = PDFRenderer.NORMAL_PDF_RESOLUTION
                            / context.getUserAgent().getTargetResolution();
            graphics.drawImage(bi, new AffineTransform(scale, 0, 0, scale, 0, 0), null);
View Full Code Here

        // Build the SVG DOM and provide the painter with it
        GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, clonedDoc);

        // Create Graphics2DImagePainter
        final RendererContextWrapper wrappedContext
            = RendererContext.wrapRendererContext(rendererContext);
        Dimension imageSize = getImageSize(wrappedContext);
        Graphics2DImagePainter painter
            = createGraphics2DImagePainter(bridgeContext, root, imageSize);

        // Create AFPObjectAreaInfo
        RendererContextWrapper rctx = RendererContext.wrapRendererContext(rendererContext);
        int x = rctx.getCurrentXPosition();
        int y = rctx.getCurrentYPosition();
        int width = afpInfo.getWidth();
        int height = afpInfo.getHeight();
        int resolution = afpInfo.getResolution();

        paintingState.save(); // save
View Full Code Here

TOP

Related Classes of org.apache.fop.render.RendererContext.RendererContextWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.