Package org.w3c.dom.svg

Examples of org.w3c.dom.svg.SVGSVGElement


    protected static GraphicsNode createSVGImageNode(BridgeContext ctx,
                                                     Element element,
                                                     SVGDocument imgDocument) {

        // viewport is automatically created by the svg element of the image
        SVGSVGElement svgElement = imgDocument.getRootElement();
        CompositeGraphicsNode result = new CompositeGraphicsNode();
        CSSStyleDeclaration decl = CSSUtilities.getComputedStyle(element);
        UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, element);

        Rectangle2D r
            = CSSUtilities.convertEnableBackground(element, uctx);
        if (r != null) {
            result.setBackgroundEnable(r);
        }

        Rectangle2D bounds = getImageBounds(ctx, element);
        svgElement.setAttributeNS(null, SVG_WIDTH_ATTRIBUTE,
                                  String.valueOf(bounds.getWidth()));
        svgElement.setAttributeNS(null, SVG_HEIGHT_ATTRIBUTE,
                                  String.valueOf(bounds.getHeight()));

        AffineTransform at
            = ViewBox.getPreserveAspectRatioTransform(svgElement,
                                                      (float)bounds.getWidth(),
View Full Code Here


        if (!(document instanceof SVGOMDocument)) {
            throw new TranscoderException(
                Messages.formatMessage("notsvg", null));
        }
        SVGDocument svgDoc = (SVGDocument)document;
        SVGSVGElement root = svgDoc.getRootElement();
        // initialize the SVG document with the appropriate context
        String parserClassname = (String)hints.get(KEY_XML_PARSER_CLASSNAME);
        DefaultSVGContext svgCtx = new DefaultSVGContext();
        svgCtx.setPixelToMM(userAgent.getPixelToMM());
        ((SVGOMDocument)document).setSVGContext(svgCtx);
View Full Code Here

    /**
     * Returns the viewport width used to compute units.
     */
    public float getViewportWidth() {
        SVGSVGElement svg = element.getOwnerSVGElement();
        if (svg == null) {
            return (float)context.getViewportWidth(element);
        }
        String s = svg.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
        LengthParser p = new LengthParser();
        UnitProcessor.UnitResolver ur = new UnitProcessor.UnitResolver();
        p.setLengthHandler(ur);
        p.parse(new StringReader(s));
        return UnitProcessor.svgToUserSpace(ur.unit,
View Full Code Here

    /**
     * Returns the viewport height used to compute units.
     */
    public float getViewportHeight() {
        SVGSVGElement svg = element.getOwnerSVGElement();
        if (svg == null) {
            return (float)context.getViewportHeight(element);
        }
        String s = svg.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
        LengthParser p = new LengthParser();
        UnitProcessor.UnitResolver ur = new UnitProcessor.UnitResolver();
        p.setLengthHandler(ur);
        p.parse(new StringReader(s));
        return UnitProcessor.svgToUserSpace(ur.unit,
View Full Code Here

            target = (EventTarget)element;
        } catch (ClassCastException e) {
            // will not work on this one!
            return;
        }
        SVGSVGElement svgElement = (SVGSVGElement)element.getOwnerSVGElement();
        if (svgElement == null) {
            if (element.getLocalName().equals(SVG_SVG_TAG)) {
                svgElement = (SVGSVGElement)element;
            } else {
                // something goes wrong => disable scripting
                return;
            }
        }
        String language = svgElement.getContentScriptType();
        Interpreter interpret = null;
        String script = null;
        // <!> TODO we need to memo listeners to be able to remove
        // them later when deconnecting the bridge binding...
        if (element.getLocalName().equals(SVG_SVG_TAG)) {
View Full Code Here

    /**
     * <b>DOM</b>: Implements {@link org.w3c.dom.svg.SVGDocument#getTitle()}.
     */
    public String getTitle() {
        String result = "";
        SVGSVGElement elt = getRootElement();
        boolean preserve = false;
        for (Node n = elt.getFirstChild(); n != null; n = n.getNextSibling()) {
            if (n.getNodeType() == Node.ELEMENT_NODE) {
                String name = (n.getPrefix() == null)
                    ? n.getNodeName()
                    : n.getLocalName();
                if (name.equals("title")) {
View Full Code Here

        if (getNamespace().equals(ns)) {
            if (!(doc instanceof SVGDocument)) {
                DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
                doc = DOMUtilities.deepCloneDocument(doc, impl);
            }
            SVGSVGElement svg = ((SVGDocument) doc).getRootElement();
            SVGDocument targetDoc = (SVGDocument)context.getProperty(SVG_DOCUMENT);
            SVGElement currentPageG = (SVGElement)context.getProperty(SVG_PAGE_G);
            Element view = targetDoc.createElementNS(getNamespace(), "svg");
            Node newsvg = targetDoc.importNode(svg, true);
            //view.setAttributeNS(null, "viewBox", "0 0 ");
View Full Code Here

        if (getNamespace().equals(ns)) {
            if (!(doc instanceof SVGDocument)) {
                DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
                doc = DOMUtilities.deepCloneDocument(doc, impl);
            }
            SVGSVGElement svg = ((SVGDocument) doc).getRootElement();
            SVGDocument targetDoc = (SVGDocument)context.getProperty(SVG_DOCUMENT);
            SVGElement currentPageG = (SVGElement)context.getProperty(SVG_PAGE_G);
            Element view = targetDoc.createElementNS(getNamespace(), "svg");
            Node newsvg = targetDoc.importNode(svg, true);
            //view.setAttributeNS(null, "viewBox", "0 0 ");
View Full Code Here

            // transform so that the coordinates (0,0) is from the top left
            // and positive is down and to the right. (0,0) is where the
            // viewBox puts it.
            gen.concatMatrix(sx, 0, 0, sy, xOffset / 1000f, yOffset / 1000f);

            SVGSVGElement svg = ((SVGDocument)doc).getRootElement();
            AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg,
                    psInfo.getWidth() / 1000f, psInfo.getHeight() / 1000f);
            /*
            if (!at.isIdentity()) {
                double[] vals = new double[6];
View Full Code Here

        if (hints.containsKey(KEY_HEIGHT))
            height = ((Float)hints.get(KEY_HEIGHT)).floatValue();


        SVGOMDocument svgDoc = (SVGOMDocument)document;
        SVGSVGElement root = svgDoc.getRootElement();
        ctx = createBridgeContext(svgDoc);

        // build the GVT tree
        builder = new GVTBuilder();
        // flag that indicates if the document is dynamic
        boolean isDynamic =
            hints.containsKey(KEY_EXECUTE_ONLOAD) &&
             ((Boolean)hints.get(KEY_EXECUTE_ONLOAD)).booleanValue();

        GraphicsNode gvtRoot;
        try {
            if (isDynamic)
                ctx.setDynamicState(BridgeContext.DYNAMIC);

            gvtRoot = builder.build(ctx, svgDoc);

            // dispatch an 'onload' event if needed
            if (ctx.isDynamic()) {
                BaseScriptingEnvironment se;
                se = new BaseScriptingEnvironment(ctx);
                se.loadScripts();
                se.dispatchSVGLoadEvent();
                if (hints.containsKey(KEY_SNAPSHOT_TIME)) {
                    float t =
                        ((Float) hints.get(KEY_SNAPSHOT_TIME)).floatValue();
                    ctx.getAnimationEngine().setCurrentTime(t);
                } else if (ctx.isSVG12()) {
                    float t = SVGUtilities.convertSnapshotTime(root, null);
                    ctx.getAnimationEngine().setCurrentTime(t);
                }
            }
        } catch (BridgeException ex) {
            ex.printStackTrace();
            throw new TranscoderException(ex);
        }

        // get the 'width' and 'height' attributes of the SVG document
        float docWidth = (float)ctx.getDocumentSize().getWidth();
        float docHeight = (float)ctx.getDocumentSize().getHeight();

        setImageSize(docWidth, docHeight);

        // compute the preserveAspectRatio matrix
        AffineTransform Px;

        // take the AOI into account if any
        if (hints.containsKey(KEY_AOI)) {
            Rectangle2D aoi = (Rectangle2D)hints.get(KEY_AOI);
            // transform the AOI into the image's coordinate system
            Px = new AffineTransform();
            double sx = width / aoi.getWidth();
            double sy = height / aoi.getHeight();
            double scale = Math.min(sx,sy);
            Px.scale(scale, scale);
            double tx = -aoi.getX() + (width/scale - aoi.getWidth())/2;
            double ty = -aoi.getY() + (height/scale -aoi.getHeight())/2;
            Px.translate(tx, ty);
            // take the AOI transformation matrix into account
            // we apply first the preserveAspectRatio matrix
            curAOI = aoi;
        } else {
            String ref = new ParsedURL(uri).getRef();

            // XXX Update this to use the animated value of 'viewBox' and
            //     'preserveAspectRatio'.
            String viewBox = root.getAttributeNS
                (null, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE);

            if ((ref != null) && (ref.length() != 0)) {
                Px = ViewBox.getViewTransform(ref, root, width, height, ctx);
            } else if ((viewBox != null) && (viewBox.length() != 0)) {
                String aspectRatio = root.getAttributeNS
                    (null, SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE);
                Px = ViewBox.getPreserveAspectRatioTransform
                    (root, viewBox, aspectRatio, width, height, ctx);
            } else {
                // no viewBox has been specified, create a scale transform
View Full Code Here

TOP

Related Classes of org.w3c.dom.svg.SVGSVGElement

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.