Package org.w3c.dom.svg

Examples of org.w3c.dom.svg.SVGDocument


            }
            String uriStr = XLinkSupport.getXLinkHref(e);
            if (uriStr.length() == 0) { // exit if no more xlink:href
                return "";
            }
            SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();
            String baseURI = ((SVGOMDocument)svgDoc).getURL();

            ParsedURL purl = new ParsedURL(baseURI, uriStr);
            if (!purl.complete())
                throw new BridgeException(e, ERR_URI_MALFORMED,
View Full Code Here


    public Document loadDocument(String uri) throws IOException {
        Document ret = checkCache(uri);
        if (ret != null)
            return ret;

        SVGDocument document = documentFactory.createSVGDocument(uri);

        DocumentDescriptor desc = documentFactory.getDocumentDescriptor();
        DocumentState state = new DocumentState(uri, document, desc);
        synchronized (cacheMap) {
            cacheMap.put(uri, state);
View Full Code Here

        throws IOException {
        Document ret = checkCache(uri);
        if (ret != null)
            return ret;

        SVGDocument document = documentFactory.createSVGDocument(uri, is);

        DocumentDescriptor desc = documentFactory.getDocumentDescriptor();
        DocumentState state = new DocumentState(uri, document, desc);
        synchronized (cacheMap) {
            cacheMap.put(uri, state);
View Full Code Here

     * Returns the error message according to the error code and parameters.
     */
    public String getMessage() {
        String uri;
        String lname = "<Unknown Element>";
        SVGDocument doc = null;
        if (e != null) {
            doc = (SVGDocument)e.getOwnerDocument();
            lname = e.getLocalName();
        }
        if (doc == nulluri = "<Unknown Document>";
        else              uri = doc.getURL();
        Object [] fullparams = new Object[params.length+3];
        fullparams[0] = uri;
        fullparams[1] = new Integer(line);
        fullparams[2] = lname;
        for (int i=0; i < params.length; ++i) {
View Full Code Here

    /**
     * Updates the thumbnail component rendering transform.
     */
    protected void updateThumbnailRenderingTransform() {
        SVGDocument svgDocument = svgCanvas.getSVGDocument();
        if (svgDocument != null) {
            SVGSVGElement elt = svgDocument.getRootElement();
            Dimension dim = svgThumbnailCanvas.getSize();

            String viewBox = elt.getAttributeNS
                (null, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE);

View Full Code Here

        String uriStr = purl.toString();
        Dimension cursorSize = null;

        // Try to load as an SVG Document
        DocumentLoader loader = ctx.getDocumentLoader();
        SVGDocument svgDoc = (SVGDocument)cursorElement.getOwnerDocument();
        URIResolver resolver = new URIResolver(svgDoc, loader);
        try {
            Element rootElement = null;
            Node n = resolver.getNode(uriStr, cursorElement);
            if (n.getNodeType() == Node.DOCUMENT_NODE) {
                SVGDocument doc = (SVGDocument)n;
                // FIXX: really should be subCtx here.
                ctx.initializeDocument(doc);
                rootElement = doc.getRootElement();
            } else {
                throw new BridgeException
                    (cursorElement, ERR_URI_IMAGE_INVALID,
                     new Object[] {uriStr});
            }
View Full Code Here

        // In some cases we converted document fragments which didn't
        // have a parent SVG element, this check makes sure only the
        // real root of the SVG Document tries to do negotiation with
        // the UA.
        SVGDocument doc = (SVGDocument)e.getOwnerDocument();
        boolean isOutermost = (doc.getRootElement() == e);
        float x = 0;
        float y = 0;
        // x and y have no meaning on the outermost 'svg' element
        if (!isOutermost) {
            // 'x' attribute - default is 0
View Full Code Here

        if (attrName.equals(SVG_WIDTH_ATTRIBUTE) ||
            attrName.equals(SVG_HEIGHT_ATTRIBUTE) ) {
            rebuild = true;
        } else if (attrName.equals(SVG_X_ATTRIBUTE) ||
                   attrName.equals(SVG_Y_ATTRIBUTE)) {
            SVGDocument doc = (SVGDocument)e.getOwnerDocument();
            boolean isOutermost = (doc.getRootElement() == e);
            if (!isOutermost) {
                // X & Y are ignored on outermost SVG.
                float x = 0;
                float y = 0;
                UnitProcessor.Context uctx;
                uctx = UnitProcessor.createContext(ctx, e);
                // 'x' attribute - default is 0
                String s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
                if (s.length() != 0) {
                    x = UnitProcessor.svgHorizontalCoordinateToUserSpace
                        (s, SVG_X_ATTRIBUTE, uctx);
                }
                // 'y' attribute - default is 0
                s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
                if (s.length() != 0) {
                    y = UnitProcessor.svgVerticalCoordinateToUserSpace
                        (s, SVG_Y_ATTRIBUTE, uctx);
                }

                AffineTransform positionTransform =
                    AffineTransform.getTranslateInstance(x, y);
                CanvasGraphicsNode cgn;
                cgn = (CanvasGraphicsNode)node;

                cgn.setPositionTransform(positionTransform);
            }
        } else if (attrName.equals(SVG_VIEW_BOX_ATTRIBUTE) ||
                   attrName.equals(SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE)) {
            SVGDocument doc = (SVGDocument)e.getOwnerDocument();
            boolean isOutermost = (doc.getRootElement() == e);

            String s;
            UnitProcessor.Context uctx;
            uctx = UnitProcessor.createContext(ctx, e);
            // X & Y are ignored on outermost SVG.
View Full Code Here

    protected GVTFontFamily getFontFamily(BridgeContext ctx,
                                          ParsedURL purl) {
        String purlStr = purl.toString();

        Element e = getBaseElement(ctx);
        SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();
        String docURL = svgDoc.getURL();
        ParsedURL pDocURL = null;
        if (docURL != null)
            pDocURL = new ParsedURL(docURL);

        // try to load an SVG document
        String baseURI = XMLBaseSupport.getCascadedXMLBase(e);
        purl = new ParsedURL(baseURI, purlStr);
        UserAgent userAgent = ctx.getUserAgent();

        try {
            userAgent.checkLoadExternalResource(purl, pDocURL);
        } catch (SecurityException ex) {
            // Can't load font - Security violation.
            // We should not throw the error that is for certain, just
            // move down the font list, but do we display the error or not???
            // I'll vote yes just because it is a security exception (other
            // exceptions like font not available etc I would skip).
            userAgent.displayError(ex);
            return null;
        }

        if (purl.getRef() != null) {
            // Reference must be to a SVGFont.
            Element ref = ctx.getReferencedElement(e, purlStr);
            if (!ref.getNamespaceURI().equals(SVG_NAMESPACE_URI) ||
                !ref.getLocalName().equals(SVG_FONT_TAG)) {
                return null;
            }

            SVGDocument doc  = (SVGDocument)e.getOwnerDocument();
            SVGDocument rdoc = (SVGDocument)ref.getOwnerDocument();

            Element fontElt = ref;
            if (doc != rdoc) {
                fontElt = (Element)doc.importNode(ref, true);
                String base = XMLBaseSupport.getCascadedXMLBase(ref);
View Full Code Here

    /**
     * Default implementation uses the root element of the document
     * associated with BridgeContext.  This is useful for CSS case.
     */
    protected Element getBaseElement(BridgeContext ctx) {
        SVGDocument d = (SVGDocument)ctx.getDocument();
        return d.getRootElement();
    }
View Full Code Here

TOP

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

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.