Exemple #1
0
 public void parseAttributes(Element elm, JComponent comp) {
   String enabled = elm.getAttribute("enabled");
   if (enabled != null) {
     comp.setEnabled(!enabled.equals("false"));
   }
   String id = elm.getAttribute("id");
   if (id.length() > 0) {
     components.put(id, comp);
     comp.setName(id);
   }
   String tooltip = elm.getAttribute("tooltip");
   if (tooltip.length() > 0) {
     comp.setToolTipText(tooltip);
   }
 }
Exemple #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));
     }
   }
 }
Exemple #3
0
 public void parseButton(Element elm) {
   JButton btn = new JButton();
   String title = elm.getAttribute("title");
   if (title != null) {
     btn.setText(title);
   }
   SpazPosition lp = parseSpazPosition(elm);
   if (lp == null) {
     return;
   }
   this.add(btn, lp);
   parseBorder(btn, elm);
   parseAttributes(elm, btn);
   String action = elm.getAttribute("action");
   if (action.length() > 0) {
     actions.put(btn, action);
     btn.addActionListener(this);
   }
 }
Exemple #4
0
 public void parseLabel(Element elm) {
   JLabel label = new JLabel();
   String title = elm.getAttribute("title");
   if (title != null) {
     label.setText(title);
   }
   SpazPosition lp = parseSpazPosition(elm);
   if (lp == null) {
     return;
   }
   this.add(label, lp);
   parseBorder(label, elm);
   parseAttributes(elm, label);
 }
Exemple #5
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;
 }