コード例 #1
0
  protected void writeAttributes(DOMOutput out) throws IOException {
    Figure prototype = (Figure) out.getPrototype();

    boolean isElementOpen = false;
    for (Map.Entry<AttributeKey, Object> entry : attributes.entrySet()) {
      AttributeKey key = entry.getKey();
      if (forbiddenAttributes == null || !forbiddenAttributes.contains(key)) {
        Object prototypeValue = key.get(prototype);
        Object attributeValue = key.get(this);
        if (prototypeValue != attributeValue
            || (prototypeValue != null
                && attributeValue != null
                && !prototypeValue.equals(attributeValue))) {
          if (!isElementOpen) {
            out.openElement("a");
            isElementOpen = true;
          }
          out.openElement(key.getKey());
          out.writeObject(entry.getValue());
          out.closeElement();
        }
      }
    }
    if (isElementOpen) {
      out.closeElement();
    }
  }
コード例 #2
0
 @Override
 public void write(DOMOutput out) throws IOException {
   super.write(out);
   out.openElement("locator");
   out.writeObject(locator);
   out.closeElement();
 }
コード例 #3
0
ファイル: BezierFigure.java プロジェクト: ilyessou/jhotdraw
 protected void writePoints(DOMOutput out) throws IOException {
   out.openElement("points");
   if (isClosed()) {
     out.addAttribute("closed", true);
   }
   for (int i = 0, n = getNodeCount(); i < n; i++) {
     BezierPath.Node node = getNode(i);
     out.openElement("p");
     out.addAttribute("mask", node.mask, 0);
     out.addAttribute("colinear", true);
     out.addAttribute("x", node.x[0]);
     out.addAttribute("y", node.y[0]);
     out.addAttribute("c1x", node.x[1], node.x[0]);
     out.addAttribute("c1y", node.y[1], node.y[0]);
     out.addAttribute("c2x", node.x[2], node.x[0]);
     out.addAttribute("c2y", node.y[2], node.y[0]);
     out.closeElement();
   }
   out.closeElement();
 }