示例#1
0
 @Override
 public void write(DOMOutput out) throws IOException {
   super.write(out);
   out.openElement("locator");
   out.writeObject(locator);
   out.closeElement();
 }
 public void write(DOMOutput out) throws IOException {
   Rectangle2D.Double r = getBounds();
   out.addAttribute("x", r.x);
   out.addAttribute("y", r.y);
   out.addAttribute("w", r.width);
   out.addAttribute("h", r.height);
   writeAttributes(out);
 }
示例#3
0
 @Override
 public void write(DOMOutput out) {
   // Das bringt nichts, da bei Paste ein neues PathModel mit den Default-Parametern erzeugt wird
   //    SelectionProperty pLinerType = (SelectionProperty)
   // getModel().getProperty(ElementPropKeys.PATH_CONN_TYPE);
   //    PathModel.LinerType value = (PathModel.LinerType) pLinerType.getValue();
   //    out.addAttribute("liner", value.name());
   FigureComponent startModel = requireNonNull(getStartFigure().get(FigureConstants.MODEL));
   FigureComponent endModel = requireNonNull(getEndFigure().get(FigureConstants.MODEL));
   out.addAttribute("sourceName", startModel.getName());
   out.addAttribute("destName", endModel.getName());
 }
示例#4
0
 @Override
 public void write(DOMOutput out) throws IOException {
   Rectangle2D.Double b = getBounds();
   out.addAttribute("x", b.x);
   out.addAttribute("y", b.y);
   writeAttributes(out);
   writeDecorator(out);
 }
示例#5
0
 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();
 }
  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();
    }
  }
示例#7
0
  /** Writes the attributes of the figure into the specified DOMOutput. */
  public static void writeAttributes(Figure f, DOMOutput out) throws IOException {
    Color color;
    Double dbl;
    String value;

    // Fill attributes
    color = FILL_COLOR.get(f);
    if (color == null) {
      value = "none";
    } else {
      value = "000000" + Integer.toHexString(color.getRGB());
      value = "#" + value.substring(value.length() - 6);
    }
    out.addAttribute("fill", value);
    if (WINDING_RULE.get(f) != WindingRule.NON_ZERO) {
      out.addAttribute("fill-rule", "evenodd");
    }

    // Stroke attributes
    color = STROKE_COLOR.get(f);
    if (color == null) {
      value = "none";
    } else {
      value = "000000" + Integer.toHexString(color.getRGB());
      value = "#" + value.substring(value.length() - 6);
    }
    out.addAttribute("stroke", value);
    out.addAttribute("stroke-width", STROKE_WIDTH.get(f), 1d);
    out.addAttribute(
        "stroke-miterlimit", STROKE_MITER_LIMIT_FACTOR.get(f) / STROKE_WIDTH.get(f), 4d);
    double[] dashes = STROKE_DASHES.get(f);
    dbl = (STROKE_DASH_FACTOR.get(f) == null) ? STROKE_WIDTH.get(f) : STROKE_DASH_FACTOR.get(f);
    if (dashes != null) {
      StringBuilder buf = new StringBuilder();
      for (int i = 0; i < dashes.length; i++) {
        if (i != 0) {
          buf.append(',');
          buf.append(dashes[i] * dbl);
        }
        out.addAttribute("stroke-dasharray", buf.toString());
      }
    }
    out.addAttribute("stroke-dashoffset", STROKE_DASH_PHASE.get(f), 0d);

    // Text attributes
    out.addAttribute("font-size", FONT_SIZE.get(f));
    // out.addAttribute("text-anchor", "start");
  }
示例#8
0
 public static void setPath(DOMOutput out, String attributeName, BezierPath path) {
   out.addAttribute(attributeName, toPathData(path));
 }