Package org.apache.fop.render.RendererContext

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


        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


     * @throws IOException In case of an I/O error while painting the image
     */
    protected void renderSVGDocument(final RendererContext context,
            final Document doc) throws IOException {
        updateRendererContext(context);
        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

        transform.translate(fx, fy);
        gen.getCurrentState().concatMatrix(transform);
        if (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 GVT tree
        final GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, clonedDoc);

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

        //Let the painter paint the SVG on the Graphics2D instance
        Graphics2DAdapter g2dAdapter = rendererContext.getRenderer().getGraphics2DAdapter();

        //Paint the image
        final int x = wrappedContext.getCurrentXPosition();
        final int y = wrappedContext.getCurrentYPosition();
        final int width = wrappedContext.getWidth();
        final int height = wrappedContext.getHeight();
        g2dAdapter.paintImage(painter, rendererContext, x, y, width, height);
    }
View Full Code Here

        //Fallback solution: Paint to a BufferedImage
        if (afpInfo.paintAsBitmap()) {

            // paint image
            RendererContextWrapper rendererContextWrapper
                = RendererContext.wrapRendererContext(rendererContext);
            float targetResolution = rendererContext.getUserAgent().getTargetResolution();
            int resolution = Math.round(targetResolution);
            boolean colorImages = afpInfo.isColorSupported();
            BufferedImage bufferedImage = paintToBufferedImage(
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

        transform.translate(fx, fy);
        gen.getCurrentState().concatMatrix(transform);
        if (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 = PDFFactory.DEFAULT_PDF_RESOLUTION
                            / context.getUserAgent().getTargetResolution();
            graphics.drawImage(bi, new AffineTransform(scale, 0, 0, scale, 0, 0), null);
View Full Code Here

        //Build the GVT tree
        final GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, clonedDoc);

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

        //Let the painter paint the SVG on the Graphics2D instance
        Graphics2DAdapter g2dAdapter = rendererContext.getRenderer().getGraphics2DAdapter();

        //Paint the image
        final int x = wrappedContext.getCurrentXPosition();
        final int y = wrappedContext.getCurrentYPosition();
        final int width = wrappedContext.getWidth();
        final int height = wrappedContext.getHeight();
        g2dAdapter.paintImage(painter, rendererContext, x, y, width, height);
    }
View Full Code Here

        //Fallback solution: Paint to a BufferedImage
        if (afpInfo.paintAsBitmap()) {

            // paint image
            RendererContextWrapper rendererContextWrapper
                = RendererContext.wrapRendererContext(rendererContext);
            float targetResolution = rendererContext.getUserAgent().getTargetResolution();
            int resolution = Math.round(targetResolution);
            boolean colorImages = afpInfo.isColorSupported();
            BufferedImage bufferedImage = paintToBufferedImage(
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.