Exemplo n.º 1
0
 public void parseChildren(Element e) {
   try {
     NodeList nl = e.getChildNodes();
     for (int i = 0; i < nl.getLength(); i++) {
       // parse Elements only
       if ((nl.item(i).getNodeType() == Node.ELEMENT_NODE)) {
         Element elm = (Element) nl.item(i);
         String tag = elm.getTagName();
         if (tag.equals("canvas")) {
           parseChildren(elm);
         } else if (tag.equals("label")) {
           parseLabel(elm);
         } else if (tag.equals("textfield")) {
           parseTextField(elm);
         } else if (tag.equals("button")) {
           parseButton(elm);
         } else if (tag.equals("textarea")) {
           parseTextArea(elm);
         } else if (tag.equals("progressbar")) {
           parseProgressBar(elm);
         }
       }
     }
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
Exemplo n.º 2
0
 public void parseBorder(JComponent c, Element elm) {
   if (elm.getTagName().equals("border")) {
     String type = elm.getAttribute("type");
     if (type.equals("empty")) {
       c.setBorder(new EmptyBorder(2, 2, 2, 2));
     } else if (type.equals("titled")) {
       String title = elm.getAttribute("title");
       c.setBorder(new TitledBorder(title));
     } else if (type.equals("beveled")) {
       int btype = Integer.parseInt(elm.getAttribute("bevel"));
       c.setBorder(new BevelBorder(btype));
     }
   } else {
     NodeList nl = elm.getElementsByTagName("border");
     for (int n = 0; n < nl.getLength(); n++) {
       parseBorder(c, (Element) nl.item(n));
     }
   }
 }
Exemplo n.º 3
0
 public SpazPosition parseSpazPosition(Element elm) {
   if (elm.getTagName().equals("position")) {
     SpazPosition lp = new SpazPosition();
     double left_rel = Double.parseDouble(elm.getAttribute("left_rel"));
     double right_rel = Double.parseDouble(elm.getAttribute("right_rel"));
     double top_rel = Double.parseDouble(elm.getAttribute("top_rel"));
     double bottom_rel = Double.parseDouble(elm.getAttribute("bottom_rel"));
     int left_abs = Integer.parseInt(elm.getAttribute("left_abs"));
     int right_abs = Integer.parseInt(elm.getAttribute("right_abs"));
     int top_abs = Integer.parseInt(elm.getAttribute("top_abs"));
     int bottom_abs = Integer.parseInt(elm.getAttribute("bottom_abs"));
     lp.setHPos(left_rel, left_abs, right_rel, right_abs);
     lp.setVPos(top_rel, top_abs, bottom_rel, bottom_abs);
     return lp;
   } else {
     NodeList nl = elm.getElementsByTagName("position");
     for (int n = 0; n < nl.getLength(); n++) {
       SpazPosition lp = parseSpazPosition((Element) (nl.item(n)));
       return lp;
     }
   }
   return null;
 }