public static SketchDocument importSVG(URL url) throws Exception { SketchDocument sdoc = importSVG(url.openStream()); // sdoc.setFile(file); sdoc.setTitle(url.getPath() + ""); sdoc.setCurrentPage(0); sdoc.setDirty(false); return sdoc; }
public static SketchDocument importSVG(File file) throws Exception { SketchDocument sdoc = importSVG(new FileInputStream(file)); // sdoc.setFile(file); sdoc.setTitle(file.getName() + ""); sdoc.setCurrentPage(0); sdoc.setDirty(false); return sdoc; }
private void load(File file) throws Exception { if (file.getName().toLowerCase().endsWith(".svg")) { SketchDocument doc = importSVG(file); if (doc.isPresentation()) { context.getMain().setupNewDoc(new PresoModeHelper(context.getMain()), doc); } else { context.getMain().setupNewDoc(new VectorModeHelper(context.getMain()), doc); } return; } StandardDialog.showError( "Could not open file " + file.getName() + ".\nUnknown format. Sorry. :("); }
private static SketchDocument importSVG(InputStream stream) throws Exception { SketchDocument sdoc = new SketchDocument(); sdoc.removePage(sdoc.getCurrentPage()); SketchDocument.SketchPage page = sdoc.addPage(); u.p("parsing"); Doc doc = XMLParser.parse(stream); u.p("parsed"); Elem svg = doc.xpathElement("/svg"); for (Elem n : svg.xpath("./*")) { u.p("node = " + n + " " + n.name()); SNode node = loadNode(n); if (node != null) page.add(node); } return sdoc; }