Thanks a lot! This was the information that I missed.

All the best,

Pim

--
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

   Pim van Nierop

   Center for Neurogenomics and Cognitive Research
   Faculty of Earth and Life Sciences
   Vrije Universiteit
   Amsterdam
   Email    pim.van.nie...@cncr.vu.nl
   Tel.     +31 (0)20 5987114
   Fax.     +31 (0)20 5987112

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

________________________________
From: Thomas DeWeese [thomas.dewe...@gmail.com]
Sent: 24 November 2012 13:14
To: batik-users@xmlgraphics.apache.org
Subject: Re: Problem using path objects (SVGOMPathElement) parsed from svg file

Hi Nierop,

   I'm fairly sure that the problem is that you haven't booted the SVG DOM.  
Please see the following link for information on how to do that:

http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom

On Thu, Nov 22, 2012 at 3:04 AM, Nierop, P. van 
<p.van.nie...@vu.nl<mailto:p.van.nie...@vu.nl>> wrote:
My next goal is to read in this svg file and generate a object representation 
of the path element (try to make it a valid SVGOMPathElement instance) This is 
the java code with which I try to read the svg:

import java.io.File;
import java.io.IOException;
import java.net.URI;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.dom.svg.SVGOMPathElement;
import org.apache.batik.util.XMLResourceDescriptor;
import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGDocument;

public class TestSVGDomParser {

    public static void main(String[] args) throws IOException {

        URI fileURI = new File("basedrawing.svg").toURI();

        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
        SVGDocument doc = (SVGDocument) f.createDocument( fileURI.toString() );

        // try to get a path using the unique identifier
        Element e = doc.getElementById("test");

        // cast to path
        SVGOMPathElement path = (SVGOMPathElement) e;

        // works fine
        System.out.println( path.getAttribute("d") );

        // does not work, throws a null pointer exception
        System.out.println( path.getTotalLength() );
    }

}
The problem I think is that the cast of the e (instance of Element) to path 
(instance of SVGOMPathElement) does not trigger the internal interpretation of 
the 'd' attribute. I conclude from this that I do not follow the proper 
procedures to build the object representation of the svg document.

Could someone advise me on how to proceed?

Thanks in advance,

Pim


--
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

   Pim van Nierop

   Center for Neurogenomics and Cognitive Research
   Faculty of Earth and Life Sciences
   Vrije Universiteit
   Amsterdam
   Email    pim.van.nie...@cncr.vu.nl<mailto:pim.van.nie...@cncr.vu.nl>
   Tel.     +31 (0)20 5987114<tel:%2B31%20%280%2920%205987114>
   Fax.     +31 (0)20 5987112<tel:%2B31%20%280%2920%205987112>

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-


Reply via email to