Esempio n. 1
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");
  }
Esempio n. 2
0
 public Color getFillColor() {
   return FILL_COLOR.get(this) == null || FILL_COLOR.get(this).equals(Color.white)
       ? Color.black
       : Color.WHITE;
   //  return FILL_COLOR.get(this);
 }
Esempio n. 3
0
 public Color getTextColor() {
   return FILL_COLOR.get(this);
   //   return TEXT_COLOR.get(this);
 }