Examples of AFPPaintingState


Examples of org.apache.fop.afp.AFPPaintingState

    public void handleImage(RenderingContext context, Image image, Rectangle pos)
            throws IOException {
        AFPRenderingContext afpContext = (AFPRenderingContext)context;

        AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)createDataObjectInfo();
        AFPPaintingState paintingState = afpContext.getPaintingState();

        // set resource information
        setResourceInformation(imageObjectInfo,
                image.getInfo().getOriginalURI(),
                afpContext.getForeignAttributes());
View Full Code Here

Examples of org.apache.fop.afp.AFPPaintingState

    public boolean isCompatible(RenderingContext targetContext, Image image) {
        if (!(targetContext instanceof AFPRenderingContext)) {
            return false; //AFP-specific image handler
        }
        AFPRenderingContext context = (AFPRenderingContext)targetContext;
        AFPPaintingState paintingState = context.getPaintingState();
        if (!paintingState.canEmbedJpeg()) {
            return false;
        }
        if (paintingState.getBitsPerPixel() < 8) {
            return false; //This would stand in the way of dithering and cause exceptions
        }
        if (image == null) {
            return true; //Don't know the image format, yet
        }
        if (image instanceof ImageRawJPEG) {
            ImageRawJPEG jpeg = (ImageRawJPEG)image;
            ColorSpace cs = jpeg.getColorSpace();
            switch (cs.getType()) {
            case ColorSpace.TYPE_GRAY:
            case ColorSpace.TYPE_RGB:
                //ok
                break;
            case ColorSpace.TYPE_CMYK:
                if (!paintingState.isCMYKImagesSupported()) {
                    return false; //CMYK is disabled
                    //Note: you may need to disable this image handler through configuration
                    //if you want to paint a CMYK JPEG on 24bit and less configurations.
                }
                break;
View Full Code Here

Examples of org.apache.fop.afp.AFPPaintingState

    public void handleImage(RenderingContext context, Image image, Rectangle pos)
            throws IOException {
        AFPRenderingContext afpContext = (AFPRenderingContext)context;

        AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)createDataObjectInfo();
        AFPPaintingState paintingState = afpContext.getPaintingState();

        // set resource information
        setResourceInformation(imageObjectInfo,
                image.getInfo().getOriginalURI(),
                afpContext.getForeignAttributes());
View Full Code Here

Examples of org.apache.fop.afp.AFPPaintingState

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

        // Create a new AFPGraphics2D
        AFPPaintingState paintingState = afpContext.getPaintingState();
        final boolean textAsShapes = paintingState.isStrokeGOCAText();
        AFPGraphics2D g2d = new AFPGraphics2D(
                textAsShapes,
                afpContext.getPaintingState(),
                afpContext.getResourceManager(),
                resourceInfo,
                (textAsShapes ? null : afpContext.getFontInfo()));
        g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

        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);

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

Examples of org.apache.fop.afp.AFPPaintingState

        // Create a new AFPGraphics2D
        final boolean textAsShapes = afpInfo.strokeText();
        AFPGraphics2D g2d = afpInfo.createGraphics2D(textAsShapes);

        AFPPaintingState paintingState = g2d.getPaintingState();
        paintingState.setImageUri(uri);

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

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

        // 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

        AFPObjectAreaInfo objectAreaInfo
            = createObjectAreaInfo(paintingState, x, y, width, height, resolution);

        // Create AFPGraphicsObjectInfo
        AFPResourceInfo resourceInfo = afpInfo.getResourceInfo();
        AFPGraphicsObjectInfo graphicsObjectInfo = createGraphicsObjectInfo(
                paintingState, painter, userAgent, resourceInfo, g2d);
        graphicsObjectInfo.setObjectAreaInfo(objectAreaInfo);

        // Create the GOCA GraphicsObject in the DataStream
        AFPResourceManager resourceManager = afpInfo.getResourceManager();
        resourceManager.createObject(graphicsObjectInfo);

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

Examples of org.apache.fop.afp.AFPPaintingState

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

        // set object area info
        //AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
        AFPPaintingState paintingState = afpContext.getPaintingState();
        int resolution = paintingState.getResolution();
        AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
        objectAreaInfo.setResolution(resolution);

        // Image content
        ImageRawStream imageStream = (ImageRawStream)image;
View Full Code Here

Examples of org.apache.fop.afp.AFPPaintingState

    /**
     * Default constructor.
     */
    public AFPDocumentHandler() {
        this.resourceManager = new AFPResourceManager();
        this.paintingState = new AFPPaintingState();
        this.unitConv = paintingState.getUnitConverter();
    }
View Full Code Here

Examples of org.apache.fop.afp.AFPPaintingState

                                throws FOPException {
        super.processNode(elementName, locator, attlist, propertyList);
        AFPPageOverlay pageOverlay = getPageSetupAttachment();
        if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(elementName)) {
            // convert user specific units to mpts and set the coordinates for the page overlay
            AFPPaintingState paintingState = new AFPPaintingState();
            AFPUnitConverter unitConverter = new AFPUnitConverter(paintingState);
            int x = (int)unitConverter.mpt2units(UnitConv.convert(attlist.getValue(ATT_X)));
            int y = (int)unitConverter.mpt2units(UnitConv.convert(attlist.getValue(ATT_Y)));
            pageOverlay.setX(x);
            pageOverlay.setY(y);
View Full Code Here

Examples of org.apache.fop.afp.AFPPaintingState

            = (AFPRendererContext)rendererImageInfo.getRendererContext();
        AFPInfo afpInfo = rendererContext.getInfo();

        setDefaultResourceLevel(imageObjectInfo, afpInfo.getResourceManager());

        AFPPaintingState paintingState = afpInfo.getPaintingState();
        ImageRendered imageRendered = (ImageRendered) rendererImageInfo.img;
        Dimension targetSize = new Dimension(afpInfo.getWidth(), afpInfo.getHeight());

        updateDataObjectInfo(imageObjectInfo, paintingState, imageRendered, targetSize);
        return imageObjectInfo;
View Full Code Here

Examples of org.apache.fop.afp.AFPPaintingState

        // Create a new AFPGraphics2D
        final boolean textAsShapes = afpInfo.strokeText();
        AFPGraphics2D g2d = afpInfo.createGraphics2D(textAsShapes);

        AFPPaintingState paintingState = g2d.getPaintingState();
        paintingState.setImageUri(uri);

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

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

        // 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

        AFPObjectAreaInfo objectAreaInfo
            = createObjectAreaInfo(paintingState, x, y, width, height, resolution);

        // Create AFPGraphicsObjectInfo
        AFPResourceInfo resourceInfo = afpInfo.getResourceInfo();
        AFPGraphicsObjectInfo graphicsObjectInfo = createGraphicsObjectInfo(
                paintingState, painter, userAgent, resourceInfo, g2d);
        graphicsObjectInfo.setObjectAreaInfo(objectAreaInfo);

        // Create the GOCA GraphicsObject in the DataStream
        AFPResourceManager resourceManager = afpInfo.getResourceManager();
        resourceManager.createObject(graphicsObjectInfo);

        paintingState.restore(); // resume
    }
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.