Search in sources :

Example 1 with PathHandler

use of org.apache.batik.parser.PathHandler in project chordatlas by twak.

the class Extruder method readPath.

private void readPath(String name) {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {
        // Using factory get an instance of document builder
        DocumentBuilder db = dbf.newDocumentBuilder();
        // parse using builder to get DOM representation of the XML file
        Document dom = db.parse(name);
        NodeList paths = dom.getElementsByTagName("path");
        PathParser pathParser = new PathParser();
        PathHandler pathHandler = new MyPathHandler();
        pathParser.setPathHandler(pathHandler);
        for (int i = 0; i < paths.getLength(); i++) {
            pathParser.parse(paths.item(i).getAttributes().getNamedItem("d").getTextContent());
        }
        for (Point2d pt : path) {
            System.out.println(pt);
        }
    } catch (Throwable pce) {
        pce.printStackTrace();
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) PathParser(org.apache.batik.parser.PathParser) Point2d(javax.vecmath.Point2d) NodeList(org.w3c.dom.NodeList) PathHandler(org.apache.batik.parser.PathHandler) Document(org.w3c.dom.Document)

Aggregations

Point2d (javax.vecmath.Point2d)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 PathHandler (org.apache.batik.parser.PathHandler)1 PathParser (org.apache.batik.parser.PathParser)1 Document (org.w3c.dom.Document)1 NodeList (org.w3c.dom.NodeList)1