Package org.apache.batik.dom.svg

Examples of org.apache.batik.dom.svg.SAXSVGDocumentFactory


    }

    private static SVGElement parseSvg(final InputStream inputStream)
            throws IOException {
        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
        SVGDocument document = (SVGDocument) f.createDocument("", inputStream);
        return (SVGElement) document.getDocumentElement();
    }
View Full Code Here


        // El synchronized es por si acaso.

        urlStr = urlStr.trim();

        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
        URL baseURL = applet.getDocumentBase();
        URL url = buildURL(baseURL,urlStr);

        System.out.println("Loading:" + url.toString()); // Para que el programador detecte errores tontos en la formación de la URL

        SVGOMDocument doc;

        try
        {
            URLConnection urlCon = url.openConnection();

            urlCon.setUseCaches(false);
            urlCon.setRequestProperty("User-Agent", ParsedURL.getGlobalUserAgent()); // "Batik/development.build"
            urlCon.setRequestProperty("Cache-Control","no-store,max-age=0,no-cache");
            urlCon.setRequestProperty("Expires", "0");
            urlCon.setRequestProperty("Pragma", "no-cache");

            if ((cookie != null) && cookie.length() > 0)
                urlCon.setRequestProperty("Cookie",cookie);

            InputStream stream = urlCon.getInputStream();
            doc = (SVGOMDocument)f.createDocument(url.toString(),stream);
            stream.close();
        }
        catch(IOException ex)
        {
            ex.printStackTrace();
View Full Code Here

        // El synchronized es por si acaso.

        urlStr = urlStr.trim();

        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
        URL baseURL = applet.getDocumentBase();
        URL url = buildURL(baseURL,urlStr);

        System.out.println("Loading:" + url.toString()); // Para que el programador detecte errores tontos en la formación de la URL

        SVGOMDocument doc;

        try
        {
            URLConnection urlCon = url.openConnection();

            urlCon.setUseCaches(false);
            urlCon.setRequestProperty("User-Agent", ParsedURL.getGlobalUserAgent()); // "Batik/development.build"
            urlCon.setRequestProperty("Cache-Control","no-store,max-age=0,no-cache");
            urlCon.setRequestProperty("Expires", "0");
            urlCon.setRequestProperty("Pragma", "no-cache");

            if ((cookie != null) && cookie.length() > 0)
                urlCon.setRequestProperty("Cookie",cookie);

            InputStream stream = urlCon.getInputStream();
            doc = (SVGOMDocument)f.createDocument(url.toString(),stream);
            stream.close();
        }
        catch(IOException ex)
        {
            ex.printStackTrace();
View Full Code Here

        getContentPane().add(canvas);

        try {
            // Parse the barChart.svg file into a Document.
            String parser = XMLResourceDescriptor.getXMLParserClassName();
            SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
            URL url = new URL(getCodeBase(), "barChart.svg");
            doc = f.createDocument(url.toString());

            svg = doc.getDocumentElement();

            // Change the document viewBox.
            svg.setAttributeNS(null, "viewBox", "40 95 370 265");
View Full Code Here

                info.mimeType = getMimeType();
                info.str = SVGDOMImplementation.SVG_NAMESPACE_URI;

                length = fis.available();
                fis.mark(length + 1);
                SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(
                        XMLImage.getParserName());
                SVGDocument doc = (SVGDocument) factory.createSVGDocument(uri, fis);
                info.data = doc;

                Element e = doc.getRootElement();
                String s;
                SVGUserAgent userAg = new SVGUserAgent(pixelUnitToMM,
View Full Code Here

     * @param domImpl the DOM Implementation (not used)
     * @param parserClassname the XML parser classname
     */
    protected DocumentFactory createDocumentFactory(DOMImplementation domImpl,
                                                    String parserClassname) {
        return new SAXSVGDocumentFactory(parserClassname);
    }
View Full Code Here

     * Constructs a new <tt>DocumentLoader</tt> with the specified XML parser.
     * @param userAgent the user agent to use
     */
    public DocumentLoader(UserAgent userAgent) {
        this.userAgent = userAgent;
        documentFactory = new SAXSVGDocumentFactory
            (userAgent.getXMLParserClassName(), true);
  documentFactory.setValidating(userAgent.isXMLParserValidating());
    }
View Full Code Here

         * org.apache.batik.script.Window#parseXML(String,Document)}.
         */
        public Node parseXML(String text, Document doc) {
            // System.out.println("Text: " + text);
            // Try and parse it as an SVGDocument
            SAXSVGDocumentFactory df = new SAXSVGDocumentFactory
                (XMLResourceDescriptor.getXMLParserClassName());
            URL urlObj = null;
            if ((doc != null) && (doc instanceof SVGOMDocument))
                urlObj = ((SVGOMDocument)doc).getURLObject();
            if (urlObj == null) {
                urlObj = ((SVGOMDocument)bridgeContext.getDocument()).
                    getURLObject();
            }
            String uri = (urlObj==null)?"":urlObj.toString();
            try {
                Document d = df.createDocument(uri, new StringReader(text));
                if (doc == null)
                    return d;

                Node result = doc.createDocumentFragment();
                result.appendChild(doc.importNode(d.getDocumentElement(),
                                                  true));
                return result;
            } catch (Exception ex) {
                /* nothing  */
            }
           
            if ((doc != null) && (doc instanceof SVGOMDocument)) {
                // Try and parse with an 'svg' element wrapper - for
                // things like '<rect ../>' - ensure that rect ends up
                // in SVG namespace - xlink namespace is declared etc...

                // Only do this when generating a doc fragment, since
                // a 'rect' element can not be root of SVG Document
                // (only an svg element can be).
                StringBuffer sb = new StringBuffer(FRAGMENT_PREFIX.length() +
                                                   text.length() +
                                                   FRAGMENT_SUFFIX.length());
                sb.append(FRAGMENT_PREFIX);
                sb.append(text);
                sb.append(FRAGMENT_SUFFIX);
                String newText = sb.toString();
                try {
                    Document d = df.createDocument
                        (uri, new StringReader(newText));
                    // No document given so make doc fragment from our
                    // new Document.
                    if (doc == null) doc = d;
                    for (Node n = d.getDocumentElement().getFirstChild();
View Full Code Here

            assertTrue(t.passed);
        }
        // Document
        {
            String parser = XMLResourceDescriptor.getXMLParserClassName();
            SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
            Document doc = f.createDocument(TEST_URI);       
            TranscoderInput ti = new TranscoderInput(doc);
            ti.setURI(TEST_URI);
            t = new TestTranscoder();
            t.transcode(ti, out);
            assertTrue(t.passed);
        }

        // Generic Document
        {
            String parser = XMLResourceDescriptor.getXMLParserClassName();
            DOMImplementation impl =
                GenericDOMImplementation.getDOMImplementation();
            SAXDocumentFactory f = new SAXDocumentFactory(impl, parser);
            Document doc = f.createDocument(TEST_URI);
            TranscoderInput ti = new TranscoderInput(doc);
            ti.setURI(TEST_URI);
            t = new TestTranscoder();
            t.transcode(ti, out);
            assertTrue(t.passed);
View Full Code Here

       
        String docString = stringWriter.toString();
        System.err.println(">>>>>>>>>>> Document content \n\n" + docString + "\n\n<<<<<<<<<<<<<<<<");

        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
        doc = f.createDocument("http://xml.apache.org/batik/foo.svg",
                               new StringReader(stringWriter.toString()));

        text = doc.getElementById("myText");
        cdata = (CDATASection)text.getFirstChild();
        if (cdata.getData().equals(unescapedContent)) {
View Full Code Here

TOP

Related Classes of org.apache.batik.dom.svg.SAXSVGDocumentFactory

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.