Package org.apache.xmlgraphics.image.loader

Examples of org.apache.xmlgraphics.image.loader.ImageManager


    /** {@inheritDoc} */
    public void drawImage(String uri, Rectangle rect) throws IFException {
        try {
            establish(MODE_NORMAL);

            ImageManager manager = getUserAgent().getFactory().getImageManager();
            ImageInfo info = null;
            try {
                ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
                info = manager.getImageInfo(uri, sessionContext);

                String mime = info.getMimeType();
                Map foreignAttributes = getContext().getForeignAttributes();
                String conversionMode = (String)foreignAttributes.get(
                        ImageHandlerUtil.CONVERSION_MODE);
View Full Code Here


        }
        int width = (int)pos.getWidth();
        int height = (int)pos.getHeight();
        Rectangle targetRect = new Rectangle(x, y, width, height);

        ImageManager manager = getUserAgent().getFactory().getImageManager();
        ImageInfo info = null;
        try {
            ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
            info = manager.getImageInfo(uri, sessionContext);

            PSRenderingContext renderingContext = new PSRenderingContext(
                    getUserAgent(), gen, getFontInfo());

            if (!isOptimizeResources()
                    || PSImageUtils.isImageInlined(info, renderingContext)) {
                if (log.isDebugEnabled()) {
                    log.debug("Image " + info + " is inlined");
                }

                //Determine supported flavors
                ImageFlavor[] flavors;
                ImageHandlerRegistry imageHandlerRegistry
                    = userAgent.getFactory().getImageHandlerRegistry();
                flavors = imageHandlerRegistry.getSupportedFlavors(renderingContext);

                //Only now fully load/prepare the image
                Map hints = ImageUtil.getDefaultHints(sessionContext);
                org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
                        info, flavors, hints, sessionContext);

                //Get handler for image
                ImageHandler basicHandler = imageHandlerRegistry.getHandler(renderingContext, img);
View Full Code Here

    private void generateFormForImage(PSGenerator gen, PSImageFormResource form)
                throws IOException {
        final String uri = form.getImageURI();

        ImageManager manager = userAgent.getFactory().getImageManager();
        ImageInfo info = null;
        try {
            ImageSessionContext sessionContext = userAgent.getImageSessionContext();
            info = manager.getImageInfo(uri, sessionContext);

            //Create a rendering context for form creation
            PSRenderingContext formContext = new PSRenderingContext(
                    userAgent, gen, fontInfo, true);

            ImageFlavor[] flavors;
            ImageHandlerRegistry imageHandlerRegistry
                = userAgent.getFactory().getImageHandlerRegistry();
            flavors = imageHandlerRegistry.getSupportedFlavors(formContext);

            Map hints = ImageUtil.getDefaultHints(sessionContext);
            org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
                    info, flavors, hints, sessionContext);

            ImageHandler basicHandler = imageHandlerRegistry.getHandler(formContext, img);
            if (basicHandler == null) {
                throw new UnsupportedOperationException(
View Full Code Here

                super.setFontBaseURL(getFOURIResolver().checkBaseURL(fontBase));
            }

        };
        this.colorSpaceCache = new ColorSpaceCache(foURIResolver);
        this.imageManager = new ImageManager(this);
        this.rendererFactory = new RendererFactory();
        this.xmlHandlers = new XMLHandlerRegistry();
        this.imageHandlers = new ImageHandlerRegistry();
        this.ignoredNamespaces = new java.util.HashSet();
    }
View Full Code Here

            pxToMillimeter = (float)(UnitConv.IN2MM / ptm.doubleValue());
        }
        UserAgent ua = createBatikUserAgent(pxToMillimeter);
        GVTBuilder builder = new GVTBuilder();

        final ImageManager imageManager = (ImageManager)hints.get(
                ImageProcessingHints.IMAGE_MANAGER);
        final ImageSessionContext sessionContext = (ImageSessionContext)hints.get(
                ImageProcessingHints.IMAGE_SESSION_CONTEXT);

        boolean useEnhancedBridgeContext = (imageManager != null && sessionContext != null);
View Full Code Here

    /** {@inheritDoc} */
    public void activateLayout() {
        initialize();

        FOUserAgent userAgent = pageSeq.getUserAgent();
        ImageManager imageManager = userAgent.getFactory().getImageManager();

        String uri = URISpecification.getURL(getExternalDocument().getSrc());
        Integer firstPageIndex = ImageUtil.getPageIndexFromURI(uri);
        boolean hasPageIndex = (firstPageIndex != null);

        try {
            ImageInfo info = imageManager.getImageInfo(uri, userAgent.getImageSessionContext());

            Object moreImages = info.getCustomObjects().get(ImageInfo.HAS_MORE_IMAGES);
            boolean hasMoreImages = moreImages != null && !Boolean.FALSE.equals(moreImages);

            Dimension intrinsicSize = info.getSize().getDimensionMpt();
            ImageLayout layout = new ImageLayout(getExternalDocument(), this, intrinsicSize);

            PageSequence pageSequence = new PageSequence(null);
            transferExtensions(pageSequence);
            areaTreeHandler.getAreaTreeModel().startPageSequence(pageSequence);
            if (log.isDebugEnabled()) {
                log.debug("Starting layout");
            }

            makePageForImage(info, layout);

            if (!hasPageIndex && hasMoreImages) {
                if (log.isTraceEnabled()) {
                    log.trace("Starting multi-page processing...");
                }
                URI originalURI;
                try {
                    originalURI = new URI(URISpecification.escapeURI(uri));
                    int pageIndex = 1;
                    while (hasMoreImages) {
                        URI tempURI = new URI(originalURI.getScheme(),
                                originalURI.getSchemeSpecificPart(),
                                "page=" + Integer.toString(pageIndex + 1));
                        if (log.isTraceEnabled()) {
                            log.trace("Subimage: " + tempURI.toASCIIString());
                        }
                        ImageInfo subinfo = imageManager.getImageInfo(
                                tempURI.toASCIIString(), userAgent.getImageSessionContext());

                        moreImages = subinfo.getCustomObjects().get(ImageInfo.HAS_MORE_IMAGES);
                        hasMoreImages = moreImages != null && !Boolean.FALSE.equals(moreImages);

View Full Code Here

                super.setFontBaseURL(getFOURIResolver().checkBaseURL(fontBase));
            }

        };
        this.colorSpaceCache = new ColorSpaceCache(foURIResolver);
        this.imageManager = new ImageManager(this);
        this.rendererFactory = new RendererFactory();
        this.xmlHandlers = new XMLHandlerRegistry();
        this.imageHandlers = new ImageHandlerRegistry();
        this.ignoredNamespaces = new java.util.HashSet<String>();
    }
View Full Code Here

        when(mockFOUserAgent.getFactory()).thenReturn(mockFopFactory);
    }

    private static void mockGetImageManager(FopFactory mockFopFactory) {
        try {
            ImageManager mockImageManager = mock(ImageManager.class);
            when(mockImageManager.getImageInfo(anyString(), any(ImageSessionContext.class)))
                    .thenReturn(null);
            when(mockFopFactory.getImageManager()).thenReturn(mockImageManager);
        } catch (ImageException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
View Full Code Here

    /** {@inheritDoc} */
    public void drawImage(String uri, Rectangle rect) throws IFException {
        try {
            establish(MODE_NORMAL);

            ImageManager manager = getUserAgent().getFactory().getImageManager();
            ImageInfo info = null;
            try {
                ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
                info = manager.getImageInfo(uri, sessionContext);

                String mime = info.getMimeType();
                Map foreignAttributes = getContext().getForeignAttributes();
                String conversionMode = (String)foreignAttributes.get(
                        ImageHandlerUtil.CONVERSION_MODE);
View Full Code Here

        final ImageContext imageContext = new ImageContext() {
            public float getSourceResolution() {
                return UnitConv.IN2MM / userAgent.getPixelUnitToMillimeter();
            }
        };
        this.imageManager = new ImageManager(imageContext);
        this.imageSessionContext = new AbstractImageSessionContext() {

            public ImageContext getParentContext() {
                return imageContext;
            }
View Full Code Here

TOP

Related Classes of org.apache.xmlgraphics.image.loader.ImageManager

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.