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();
    }
  }
 /** Applies all attributes of this figure to that figure. */
 @SuppressWarnings("unchecked")
 protected void applyAttributesTo(Figure that) {
   for (Map.Entry<AttributeKey, Object> entry : attributes.entrySet()) {
     entry.getKey().basicSet(that, entry.getValue());
   }
 }