Package com.joshondesign.xml

Examples of com.joshondesign.xml.Elem


        rect.setFillPaint(grad);
        rect.setStrokeWidth(0);
        page.clear();
        page.add(rect);
        Doc xdoc = saveAndReadback(doc);
        Elem e = xdoc.xpath("/svg/linearGradient/stop").iterator().next();
        assertTrue("0.0".equals(e.attr("offset")));
    }
View Full Code Here


        page.clear();
        page.add(rect);
        Doc xdoc = saveAndReadback(doc);
        Iterator<? extends Elem> it = xdoc.xpath("/svg/linearGradient/stop").iterator();
        it.next();
        Elem e = it.next();
        assertTrue("0.5".equals(e.attr("offset")));
    }
View Full Code Here

        String type = doc.xpathString("/sketchy/info/@type");
        if("presentation".equals(type)) {
            sdoc.setPresentation(true);
        }

        Elem info = doc.xpathElement("/sketchy/info");
        if(info != null) {
            loadBooleanAttribute(info,sdoc,"gridActive");
            loadBooleanAttribute(info,sdoc,"pagesVisible");
            if(info.hasAttr("backgroundFill")) {
                sdoc.setBackgroundFill(loadFillPaint(info, "backgroundFill", zipFile));
            }
            for(Elem element : info.xpath("property")) {
                sdoc.setStringProperty(
                        element.attr("name"),
                        element.attr("value"));
            }
View Full Code Here

            GradientFill fill = new GradientFill(start,end,angle,true);
            return fill;
        }
        */
        if("linearGradient".equals(e.attr(attName))) {
            Elem egrad = e.xpath("linearGradient").iterator().next();
            LinearGradientFill fill = new LinearGradientFill()
                    .setStartX(Double.parseDouble(egrad.attr("startX")))
                    .setStartY(Double.parseDouble(egrad.attr("startY")))
                    .setEndX(Double.parseDouble(egrad.attr("endX")))
                    .setEndY(Double.parseDouble(egrad.attr("endY")))
                    ;
            if(egrad.hasAttr("startXSnapped")) fill.setStartXSnapped(LinearGradientFill.Snap.valueOf(egrad.attr("startXSnapped")));
            if(egrad.hasAttr("startYSnapped"))fill.setStartYSnapped(LinearGradientFill.Snap.valueOf(egrad.attr("startYSnapped")));
            if(egrad.hasAttr("endXSnapped"))fill.setEndXSnapped(LinearGradientFill.Snap.valueOf(egrad.attr("endXSnapped")));
            if(egrad.hasAttr("endYSnapped"))fill.setEndYSnapped(LinearGradientFill.Snap.valueOf(egrad.attr("endYSnapped")));
            for(Elem stop : egrad.xpath("stop")) {
                fill.addStop(
                        Double.parseDouble(stop.attr("position")),
                        new FlatColor(stop.attr("color"))
                        );
            }
            return fill;
        }
        if("radialGradient".equals(e.attr(attName))) {
            Elem egrad = e.xpath("radialGradient").iterator().next();
            RadialGradientFill fill = new RadialGradientFill()
                    .setCenterX(Double.parseDouble(egrad.attr("centerX")))
                    .setCenterY(Double.parseDouble(egrad.attr("centerY")))
                    .setRadius(Double.parseDouble(egrad.attr("radius")))
                    ;
            for(Elem stop : egrad.xpath("stop")) {
                fill.addStop(
                        Double.parseDouble(stop.attr("position")),
                        new FlatColor(stop.attr("color"))
                        );
            }
            return fill;
        }
        if("patternPaint".equals(e.attr(attName))) {
            Elem pp = e.xpath("patternPaint").iterator().next();
            PatternPaint pat = null;
            u.p("using url " + pp.attr("relativeURL"));

            try {
                u.p("loading an image from a file");
                String path = pp.attr("relativeURL");
                String fullpath = "resources/"+path;
                u.p("path = " + path);
                u.p("fullpath = " + fullpath);

                String zfname = zipFile.getName();
                u.p("name = " + zfname);
                String pth = zfname.substring(
                                zfname.lastIndexOf(File.separator)+1,
                                zfname.lastIndexOf(".")
                            )+"/"+fullpath;
                u.p("pth = " + pth);
                ZipEntry entry = zipFile.getEntry(pth);
                u.p("entry = " + entry);
                BufferedImage img = ImageIO.read(zipFile.getInputStream(entry));
                pat = PatternPaint
                    .create(img,path)
                    .deriveNewStart(new Point2D.Double(
                            Double.parseDouble(pp.attr("startX")),
                            Double.parseDouble(pp.attr("startY"))))
                    .deriveNewEnd(new Point2D.Double(
                            Double.parseDouble(pp.attr("endX")),
                            Double.parseDouble(pp.attr("endY"))));
            } catch (IOException e1) {
                e1.printStackTrace();
            }
            return pat;
        }
View Full Code Here

        return node;
    }

    private static void loadShadow(Elem e, SShape shape) throws XPathExpressionException {
        if(e.xpath("shadow").iterator().hasNext()) {
            Elem shadow = e.xpath("shadow").iterator().next();
            shape.setShadow(new DropShadow()
                    .setColor(new FlatColor(shadow.attr("color")))
                    .setBlurRadius(Integer.parseInt(shadow.attr("radius")))
                    .setOpacity(Double.parseDouble(shadow.attr("opacity")))
                    .setXOffset(Double.parseDouble(shadow.attr("xOffset")))
                    .setYOffset(Double.parseDouble(shadow.attr("yOffset")))
                    );
        }
    }
View Full Code Here

        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;
View Full Code Here

            }
            for(File xml : new File(basedir,"hardware/boards/").listFiles()) {
                Util.p("parsing: " + xml.getCanonicalPath());
                try {
                    Doc doc = XMLParser.parse(xml);
                    Elem e = doc.xpathElement("/board");
                    Device d = new Device();
                    d.name = e.attr("name");
                    d.protocol = e.attr("protocol");
                    d.maximum_size = Integer.parseInt(e.attr("maximum-size"));
                    d.upload_speed = Integer.parseInt(e.attr("upload-speed"));
                    d.low_fuses = parseHex(e.attr("low-fuses"));
                    d.high_fuses = parseHex(e.attr("high-fuses"));
                    d.extended_fuses = parseHex(e.attr("extended-fuses"));
                    d.path = e.attr("path");
                    d.file = e.attr("file");
                    d.unlock_bits = parseHex(e.attr("unlock-bits"));
                    d.lock_bits = parseHex(e.attr("lock-bits"));
                    d.mcu = e.attr("mcu");
                    d.f_cpu = e.attr("f-cpu");
                    d.core = e.attr("core");
                    d.variant = e.attr("variant");
                    devices.add(d);
                } catch (Exception ex) {
                    Logger.getLogger(Global.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
View Full Code Here

    }

    private Example parseExample(File file) {
        try {
            Doc doc = XMLParser.parse(file);
            Elem e = doc.xpathElement("/example");
            Example ex = new Example();
            ex.name = e.attr("name");
            for(Elem k : e.xpath("keyword")) {
                ex.keywords.add(k.text().toLowerCase());
                //Util.p("added keyword: " + k.text().toLowerCase());
            }
            ex.description = e.xpathString("description/text()");
            ex.directory = file.getParentFile();
            //Util.p("parsed example: " + ex.name);
            return ex;
        } catch (Exception ex) {
            Logger.getLogger(Global.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

TOP

Related Classes of com.joshondesign.xml.Elem

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.