Examples of AFPGraphicsObjectInfo


Examples of org.apache.fop.afp.AFPGraphicsObjectInfo

        BatikImageFlavors.SVG_DOM
    };

    /** {@inheritDoc} */
    protected AFPDataObjectInfo createDataObjectInfo() {
        return new AFPGraphicsObjectInfo();
    }
View Full Code Here

Examples of org.apache.fop.afp.AFPGraphicsObjectInfo

                throws IOException {
        AFPRenderingContext afpContext = (AFPRenderingContext)context;
        ImageXMLDOM imageSVG = (ImageXMLDOM)image;
        FOUserAgent userAgent = afpContext.getUserAgent();

        AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)createDataObjectInfo();
        AFPResourceInfo resourceInfo = graphicsObjectInfo.getResourceInfo();
        setDefaultToInlineResourceLevel(graphicsObjectInfo);

        // Create a new AFPGraphics2D
        final boolean textAsShapes = false; //afpInfo.strokeText(); //TODO make configurable
        AFPGraphics2D g2d = new AFPGraphics2D(
                textAsShapes,
                afpContext.getPaintingState(),
                afpContext.getResourceManager(),
                resourceInfo,
                afpContext.getFontInfo());
        g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

        AFPPaintingState paintingState = g2d.getPaintingState();
        paintingState.setImageUri(image.getInfo().getOriginalURI());

        // Create an AFPBridgeContext
        BridgeContext bridgeContext = AFPSVGHandler.createBridgeContext(userAgent, g2d);

        // Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
        // to it.
        Document clonedDoc = BatikUtil.cloneSVGDocument(imageSVG.getDocument());

        // Build the SVG DOM and provide the painter with it
        GraphicsNode root;
        try {
            GVTBuilder builder = new GVTBuilder();
            root = builder.build(bridgeContext, clonedDoc);
        } catch (Exception e) {
            SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
                    context.getUserAgent().getEventBroadcaster());
            eventProducer.svgNotBuilt(this, e, image.getInfo().getOriginalURI());
            return;
        }

        // Image positioning
        AFPObjectAreaInfo objectAreaInfo = AFPImageHandler.createObjectAreaInfo(paintingState, pos);
        graphicsObjectInfo.setObjectAreaInfo(objectAreaInfo);

        paintingState.save(); // save
        AffineTransform placement = new AffineTransform();
        placement.translate(pos.x, pos.y);
        paintingState.concatenate(placement);

        //Set up painter and target
        graphicsObjectInfo.setGraphics2D(g2d);
        // Create Graphics2DImagePainter
        Dimension imageSize = image.getSize().getDimensionMpt();
        Graphics2DImagePainter painter = new Graphics2DImagePainterImpl(
                root, bridgeContext, imageSize);
        graphicsObjectInfo.setPainter(painter);

        // Create the GOCA GraphicsObject in the DataStream
        AFPResourceManager resourceManager = afpContext.getResourceManager();
        resourceManager.createObject(graphicsObjectInfo);
View Full Code Here

Examples of org.apache.fop.afp.AFPGraphicsObjectInfo

            // draw image
            AffineTransform at = paintingState.getData().getTransform();
            at.translate(x, y);
            g2d.drawImage(bufferedImage, at, null);
        } else {
            AFPGraphicsObjectInfo graphicsObjectInfo = new AFPGraphicsObjectInfo();
            graphicsObjectInfo.setPainter(painter);
            graphicsObjectInfo.setGraphics2D(g2d);

            // get the 'width' and 'height' attributes of the SVG document
            Dimension imageSize = painter.getImageSize();
            float imw = (float)imageSize.getWidth() / 1000f;
            float imh = (float)imageSize.getHeight() / 1000f;

            Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
            graphicsObjectInfo.setArea(area);
            AFPResourceManager resourceManager = afpInfo.getResourceManager();
            resourceManager.createObject(graphicsObjectInfo);
        }

        paintingState.restore();
View Full Code Here

Examples of org.apache.fop.afp.AFPGraphicsObjectInfo

            AFPPaintingState paintingState = afpInfo.getPaintingState();
            AFPGraphics2DAdapter g2dAdapter = new AFPGraphics2DAdapter(paintingState);
            g2dAdapter.paintImage(painter, rendererContext, x, y, width, height);
            return null;
        } else {
            AFPGraphicsObjectInfo graphicsObjectInfo
                = (AFPGraphicsObjectInfo)super.generateDataObjectInfo(rendererImageInfo);

            setDefaultResourceLevel(graphicsObjectInfo, afpInfo.getResourceManager());

            // set mime type (unsupported by MOD:CA registry)
            graphicsObjectInfo.setMimeType(MimeConstants.MIME_AFP_GOCA);

            // set g2d
            boolean textAsShapes = false;
            AFPGraphics2D g2d = afpInfo.createGraphics2D(textAsShapes);

            graphicsObjectInfo.setGraphics2D(g2d);

            // set painter
            graphicsObjectInfo.setPainter(painter);

            return graphicsObjectInfo;
        }
    }
View Full Code Here

Examples of org.apache.fop.afp.AFPGraphicsObjectInfo

        return FLAVORS;
    }

    /** {@inheritDoc} */
    protected AFPDataObjectInfo createDataObjectInfo() {
        return new AFPGraphicsObjectInfo();
    }
View Full Code Here

Examples of org.apache.fop.afp.AFPGraphicsObjectInfo

    /** {@inheritDoc} */
    public void handleImage(RenderingContext context, Image image, Rectangle pos)
            throws IOException {
        AFPRenderingContext afpContext = (AFPRenderingContext)context;

        AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)createDataObjectInfo();

        // set resource information
        setResourceInformation(graphicsObjectInfo,
                image.getInfo().getOriginalURI(),
                afpContext.getForeignAttributes());

        // Positioning
        graphicsObjectInfo.setObjectAreaInfo(
                createObjectAreaInfo(afpContext.getPaintingState(), pos));

        setDefaultResourceLevel(graphicsObjectInfo, afpContext.getResourceManager());

        AFPPaintingState paintingState = afpContext.getPaintingState();
        paintingState.save(); // save
        AffineTransform placement = new AffineTransform();
        placement.translate(pos.x, pos.y);
        paintingState.concatenate(placement);

        // Image content
        ImageGraphics2D imageG2D = (ImageGraphics2D)image;
        boolean textAsShapes = false; //TODO Make configurable
        AFPGraphics2D g2d = new AFPGraphics2D(
                textAsShapes,
                afpContext.getPaintingState(),
                afpContext.getResourceManager(),
                graphicsObjectInfo.getResourceInfo(),
                afpContext.getFontInfo());
        g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

        graphicsObjectInfo.setGraphics2D(g2d);
        graphicsObjectInfo.setPainter(imageG2D.getGraphics2DImagePainter());

        // Create image
        afpContext.getResourceManager().createObject(graphicsObjectInfo);

        paintingState.restore(); // resume
View Full Code Here

Examples of org.apache.fop.afp.AFPGraphicsObjectInfo

    }

    /** {@inheritDoc} */
    @Override
    protected AFPDataObjectInfo createDataObjectInfo() {
        return new AFPGraphicsObjectInfo();
    }
View Full Code Here

Examples of org.apache.fop.afp.AFPGraphicsObjectInfo

    /** {@inheritDoc} */
    public void handleImage(RenderingContext context, Image image, Rectangle pos)
            throws IOException {
        AFPRenderingContext afpContext = (AFPRenderingContext)context;

        AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)createDataObjectInfo();

        // set resource information
        setResourceInformation(graphicsObjectInfo,
                image.getInfo().getOriginalURI(),
                afpContext.getForeignAttributes());

        // Positioning
        graphicsObjectInfo.setObjectAreaInfo(
                createObjectAreaInfo(afpContext.getPaintingState(), pos));

        setDefaultResourceLevel(graphicsObjectInfo, afpContext.getResourceManager());

        AFPPaintingState paintingState = afpContext.getPaintingState();
        paintingState.save(); // save
        AffineTransform placement = new AffineTransform();
        placement.translate(pos.x, pos.y);
        paintingState.concatenate(placement);

        // Image content
        ImageGraphics2D imageG2D = (ImageGraphics2D)image;
        final boolean textAsShapes = paintingState.isStrokeGOCAText();
        AFPGraphics2D g2d = new AFPGraphics2D(
                textAsShapes,
                afpContext.getPaintingState(),
                afpContext.getResourceManager(),
                graphicsObjectInfo.getResourceInfo(),
                (textAsShapes ? null : afpContext.getFontInfo()));
        g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

        graphicsObjectInfo.setGraphics2D(g2d);
        graphicsObjectInfo.setPainter(imageG2D.getGraphics2DImagePainter());

        // Create image
        afpContext.getResourceManager().createObject(graphicsObjectInfo);

        paintingState.restore(); // resume
View Full Code Here

Examples of org.apache.fop.afp.AFPGraphicsObjectInfo

            // draw image
            AffineTransform at = paintingState.getData().getTransform();
            at.translate(x, y);
            g2d.drawImage(bufferedImage, at, null);
        } else {
            AFPGraphicsObjectInfo graphicsObjectInfo = new AFPGraphicsObjectInfo();
            graphicsObjectInfo.setPainter(painter);
            graphicsObjectInfo.setGraphics2D(g2d);

            // get the 'width' and 'height' attributes of the SVG document
            Dimension imageSize = painter.getImageSize();
            float imw = (float)imageSize.getWidth() / 1000f;
            float imh = (float)imageSize.getHeight() / 1000f;

            Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
            graphicsObjectInfo.setArea(area);
            AFPResourceManager resourceManager = afpInfo.getResourceManager();
            resourceManager.createObject(graphicsObjectInfo);
        }

        paintingState.restore();
View Full Code Here

Examples of org.apache.fop.afp.AFPGraphicsObjectInfo

        BatikImageFlavors.SVG_DOM
    };

    /** @return a new AFP data object info instance */
    protected AFPDataObjectInfo createDataObjectInfo() {
        return new AFPGraphicsObjectInfo();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.