Package org.apache.batik.gvt

Examples of org.apache.batik.gvt.ImageNode


     * @param ctx the bridge context to use
     * @param e the element that describes the graphics node to build
     * @return a graphics node that represents the specified element
     */
    public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
        ImageNode imageNode = (ImageNode)super.createGraphicsNode(ctx, e);
        if (imageNode == null) {
            return null;
        }

        hitCheckChildren = false;
        GraphicsNode node = buildImageGraphicsNode(ctx,e);

        if (node == null) {
            String uriStr = XLinkSupport.getXLinkHref(e);
            throw new BridgeException(e, ERR_URI_IMAGE_INVALID,
                                      new Object[] {uriStr});
        }

        imageNode.setImage(node);
        imageNode.setHitCheckChildren(hitCheckChildren);

        // 'image-rendering' and 'color-rendering'
        RenderingHints hints = CSSUtilities.convertImageRendering(e, null);
        hints = CSSUtilities.convertColorRendering(e, hints);
        if (hints != null) {
            imageNode.setRenderingHints(hints);
        }

        return imageNode;
    }
View Full Code Here


    /**
     * Creates an <tt>ImageNode</tt>.
     */
    protected GraphicsNode instantiateGraphicsNode() {
        return new ImageNode();
    }
View Full Code Here

        if (!ctx.isInteractive())
            return;

        // Bind the nodes for interactive and dynamic
        // HACK due to the way images are represented in GVT
        ImageNode imgNode = (ImageNode)node;
        ctx.bind(e, node);

        if (ctx.isDynamic()) {
            // Only do this for dynamic not interactive.
            this.e = e;
View Full Code Here

        if (inode == null) {
            String uriStr = XLinkSupport.getXLinkHref(e);
            throw new BridgeException(e, ERR_URI_IMAGE_INVALID,
                                      new Object[] {uriStr});
        }
        ImageNode imgNode = (ImageNode)node;
        //HACK : see 'initializeDynamicSupport'
        if (!(imgNode.getImage() instanceof RasterImageNode)) {
            //it was an svg file referenced
            //dispose it
            if ( oldSVGDoc != null ){
                disposeTree(oldSVGDoc);
            }
        }
        imgNode.setImage(inode);
    }
View Full Code Here

     * @param ctx the bridge context to use
     * @param e the element that describes the graphics node to build
     * @return a graphics node that represents the specified element
     */
    public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
        ImageNode imageNode = (ImageNode)super.createGraphicsNode(ctx, e);
        if (imageNode == null) {
            return null;
        }

        associateSVGContext(ctx, e, imageNode);

        hitCheckChildren = false;
        GraphicsNode node = buildImageGraphicsNode(ctx,e);

        if (node == null) {
            SVGImageElement ie = (SVGImageElement) e;
            String uriStr = ie.getHref().getAnimVal();
            throw new BridgeException(ctx, e, ERR_URI_IMAGE_INVALID,
                                      new Object[] {uriStr});
        }

        imageNode.setImage(node);
        imageNode.setHitCheckChildren(hitCheckChildren);

        // 'image-rendering' and 'color-rendering'
        RenderingHints hints = null;
        hints = CSSUtilities.convertImageRendering(e, hints);
        hints = CSSUtilities.convertColorRendering(e, hints);
        if (hints != null)
            imageNode.setRenderingHints(hints);

        return imageNode;
    }
View Full Code Here

    /**
     * Creates an <tt>ImageNode</tt>.
     */
    protected GraphicsNode instantiateGraphicsNode() {
        return new ImageNode();
    }
View Full Code Here

                    updateImageBounds();
                    return;
                } else if (ln.equals(SVG_WIDTH_ATTRIBUTE)
                        || ln.equals(SVG_HEIGHT_ATTRIBUTE)) {
                    SVGImageElement ie = (SVGImageElement) e;
                    ImageNode imageNode = (ImageNode) node;
                    AbstractSVGAnimatedLength _attr;
                    if (ln.charAt(0) == 'w') {
                        _attr = (AbstractSVGAnimatedLength) ie.getWidth();
                    } else {
                        _attr = (AbstractSVGAnimatedLength) ie.getHeight();
                    }
                    float val = _attr.getCheckedValue();
                    if (val == 0 || imageNode.getImage() instanceof ShapeNode) {
                        rebuildImageNode();
                    } else {
                        updateImageBounds();
                    }
                    return;
View Full Code Here

        subCtx = null;

        //update of the reference of the image.
        GraphicsNode inode = buildImageGraphicsNode(ctx,e);

        ImageNode imgNode = (ImageNode)node;
        imgNode.setImage(inode);

        if (inode == null) {
            SVGImageElement ie = (SVGImageElement) e;
            String uriStr = ie.getHref().getAnimVal();
            throw new BridgeException(ctx, e, ERR_URI_IMAGE_INVALID,
View Full Code Here

        }
        if (node == null) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("image.xlinkHref.badImageType", null));
        }
        ImageNode imgNode = ctx.getGVTFactory().createImageNode();
        imgNode.setImage(node);
        // initialize the transform
        AffineTransform at =
            SVGUtilities.convertAffineTransform(element,
                                                ATTR_TRANSFORM,
                                                ctx.getParserFactory());
        imgNode.setTransform(at);
        // bind it as soon as it's available...
        ctx.bind(element, imgNode);

        return imgNode;
    }
View Full Code Here

     * @param e the element that describes the graphics node to build
     * @return a graphics node that represents the specified element
     */
    public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {

        ImageNode imageNode = (ImageNode)super.createGraphicsNode(ctx, e);

        // 'xlink:href' attribute - required
        String uriStr = XLinkSupport.getXLinkHref(e);
        if (uriStr.length() == 0) {
            throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
                                      new Object[] {"xlink:href"});
        }
        if (uriStr.indexOf('#') != -1) {
            throw new BridgeException(e, ERR_ATTRIBUTE_VALUE_MALFORMED,
                                      new Object[] {"xlink:href", uriStr});
        }
        GraphicsNode node = null;
        // try to load the image as an svg document
        SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();
        URL baseURL = ((SVGOMDocument)svgDoc).getURLObject();
        ParsedURL purl = new ParsedURL(baseURL, uriStr);

        // try to load an SVG document
        DocumentLoader loader = ctx.getDocumentLoader();
        URIResolver resolver = new URIResolver(svgDoc, loader);
        try {
            Node n = resolver.getNode(purl.toString(), e);
            if (n.getNodeType() == n.DOCUMENT_NODE) {
                SVGDocument imgDocument = (SVGDocument)n;
                node = createSVGImageNode(ctx, e, imgDocument);
            }
        } catch (BridgeException ex) {
            throw ex;
        } catch (Exception ex) {
            /* Nothing to do */
        }

        if (node == null) {
            // try to load the image as a raster image (JPG or PNG)
            node = createRasterImageNode(ctx, e, purl);
        }

        if (node == null) {
            throw new BridgeException(e, ERR_URI_IMAGE_INVALID,
                                      new Object[] {uriStr});
        }

        // 'image-rendering' and 'color-rendering'
        Map imageHints = CSSUtilities.convertImageRendering(e);
        Map colorHints = CSSUtilities.convertColorRendering(e);
        if (imageHints != null || colorHints != null) {
            RenderingHints hints;
            if (imageHints == null) {
                hints = new RenderingHints(colorHints);
            } else if (colorHints == null) {
                hints = new RenderingHints(imageHints);
            } else {
                hints = new RenderingHints(imageHints);
                hints.putAll(colorHints);
            }
            node.setRenderingHints(hints);
        }

        imageNode.setImage(node);
        return imageNode;
    }
View Full Code Here

TOP

Related Classes of org.apache.batik.gvt.ImageNode

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.