Package org.apache.batik.util

Examples of org.apache.batik.util.ParsedURL


                    burl = new URL(durl, href);
                } catch (Exception ex) {
                }
                CSSEngine e = doc.getCSSEngine();
                styleSheet = e.parseStyleSheet
                    (new InputSource(new ParsedURL(durl, href).toString()),
                     burl,
                     media);
                styleSheet.setAlternate("yes".equals(alternate));
                styleSheet.setTitle(title);
            }
View Full Code Here


            /* Nothing to do */
        }

        if (node == null) {
            String baseURI = XMLBaseSupport.getCascadedXMLBase(e);
            ParsedURL purl;
            if (baseURI == null)
                purl = new ParsedURL(uriStr);
            else
                purl = new ParsedURL(baseURI, uriStr);

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

View Full Code Here

        public void actionPerformed(ActionEvent e) {
            if (svgDocument == null) {
                return;
            }

            final ParsedURL u
                = new ParsedURL(((SVGOMDocument)svgDocument).getURLObject());

            final JFrame fr = new JFrame(u.toString());
            fr.setSize(resources.getInteger("ViewSource.width"),
                       resources.getInteger("ViewSource.height"));
            final JTextArea ta  = new JTextArea();
            ta.setLineWrap(true);
            ta.setFont(new Font("monospaced", Font.PLAIN, 12));

            JScrollPane scroll = new JScrollPane();
            scroll.getViewport().add(ta);
            scroll.setVerticalScrollBarPolicy
                (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            fr.getContentPane().add(scroll, BorderLayout.CENTER);

            new Thread() {
                public void run() {
                    char [] buffer = new char[4096];

                    try {
                        Document  doc = new PlainDocument();

                        InputStream is
                            = u.openStream(MimeTypeConstants.MIME_TYPES_SVG);

                        Reader in = XMLUtilities.createXMLDocumentReader(is);
                        int len;
                        while ((len=in.read(buffer, 0, buffer.length)) != -1) {
                            doc.insertString(doc.getLength(),
View Full Code Here

                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,
                                          new Object[] {uriStr});

            Iterator iter = refs.iterator();
            while (iter.hasNext()) {
                if (purl.equals(iter.next()))
                    throw new BridgeException
                        (e, ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES,
                         new Object[] {uriStr});
            }

            try {
                URIResolver resolver = new URIResolver(svgDoc, loader);
                e = resolver.getElement(purl.toString(), e);
                refs.add(purl);
            } catch(IOException ex) {
                throw new BridgeException(e, ERR_URI_IO,
                                          new Object[] {uriStr});
            }
View Full Code Here

            Thread t = new Thread() {
                    public void run() {
                        try {
                            URL burl;
                            burl = ((SVGOMDocument)document).getURLObject();
                            final ParsedURL purl = new ParsedURL(burl, uri);
                            String e = EncodingUtilities.javaEncoding(enc);
                            e = (e == null) ? enc : e;
                            Reader r =
                                new InputStreamReader(purl.openStream(), e);
                            r = new BufferedReader(r);
                            final StringWriter sw = new StringWriter();
                            int read;
                            char[] buf = new char[4096];
                            while ((read = r.read(buf, 0, buf.length)) != -1) {
                                sw.write(buf, 0, read);
                            }

                            updateRunnableQueue.invokeLater(new Runnable() {
                                    public void run() {
                                        try {
                                            h.getURLDone(true,
                                                         purl.getContentType(),
                                                         sw.toString());
                                        } catch (Exception e){
                                            if (userAgent != null) {
                                                userAgent.displayError(e);
                                            }
View Full Code Here

            if (uri.length() == 0) {
                return null; // no xlink:href found, exit
            }
            // check if there is circular dependencies
            SVGOMDocument doc = (SVGOMDocument)paintElement.getOwnerDocument();
            ParsedURL purl = new ParsedURL(doc.getURL(), uri);
            if (!purl.complete())
                throw new BridgeException(paintElement,
                                          ERR_URI_MALFORMED,
                                          new Object[] {uri});

            if (contains(refs, purl)) {
View Full Code Here

        Attr xmlBase = localRefElement.getAttributeNodeNS
            (XML_NAMESPACE_URI, "xml:base");
        if (xmlBase != null) {
            // We have a current base so merge it with our new base and
            // set the result...
            ParsedURL purl = new ParsedURL(uri, xmlBase.getNodeValue());
            uri = purl.toString();
        }
        localRefElement.setAttributeNS(XML_NAMESPACE_URI,
                                       "xml:base",
                                       uri);
View Full Code Here

            throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
                                      new Object[] {"xlink:href"});
        }

        String baseURI = XMLBaseSupport.getCascadedXMLBase(e);
        ParsedURL purl;
        if (baseURI == null) purl = new ParsedURL(uriStr);
        else                 purl = new ParsedURL(baseURI, uriStr);

        dims.add(d);
        uris.add(purl);
    }
View Full Code Here

                    }

                    if (st != null) {
                        if (svgDocument != null) {
                            SVGOMDocument doc = (SVGOMDocument)svgDocument;
                            ParsedURL docPURL
                                = new ParsedURL(svgDocument.getURL());
                            ParsedURL purl = new ParsedURL(docPURL, st);
                            String fi = svgCanvas.getFragmentIdentifier();
                            fi = (fi == null) ? "" : fi;
                            if (docPURL.equals(purl) && t.equals(fi)) {
                                return;
                            }
View Full Code Here

     * Called when a link was activated.
     */
    public void linkActivated(LinkActivationEvent e) {
        String s = e.getReferencedURI();
        if (svgDocument != null) {
            ParsedURL docURL = new ParsedURL(svgDocument.getURL());
            ParsedURL url    = new ParsedURL(docURL, s);
            if (!url.sameFile(docURL)) {
                return;
            }

            if (s.indexOf("#") != -1) {
                localHistory.update(s);
View Full Code Here

TOP

Related Classes of org.apache.batik.util.ParsedURL

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.