コード例 #1
0
  public void draw(
      UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {

    final UClip clip = clipContainer.getClip();
    if (clip != null && clip.isInside(x, y) == false) {
      return;
    }

    final UText shape = (UText) ushape;
    final FontConfiguration fontConfiguration = shape.getFontConfiguration();
    final UFont font = fontConfiguration.getFont();
    String fontWeight = null;
    if (fontConfiguration.containsStyle(FontStyle.BOLD) || font.isBold()) {
      fontWeight = "bold";
    }
    String fontStyle = null;
    if (fontConfiguration.containsStyle(FontStyle.ITALIC) || font.isItalic()) {
      fontStyle = "italic";
    }
    String textDecoration = null;
    if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
      textDecoration = "underline";
    } else if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
      textDecoration = "line-through";
    }

    String backColor = null;
    if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
      backColor =
          StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getExtendedColor()));
    }

    svg.setFillColor(StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getColor())));
    String text = shape.getText();
    if (text.startsWith(" ")) {
      final double space = stringBounder.calculateDimension(font, " ").getWidth();
      while (text.startsWith(" ")) {
        x += space;
        text = text.substring(1);
      }
    }
    text = StringUtils.trin(text);
    final Dimension2D dim = stringBounder.calculateDimension(font, text);
    svg.text(
        text,
        x,
        y,
        font.getFamily(UFontContext.SVG),
        font.getSize(),
        fontWeight,
        fontStyle,
        textDecoration,
        dim.getWidth(),
        fontConfiguration.getAttributes(),
        backColor);
  }
コード例 #2
0
  public void draw(
      UShape ushape, double x, double y, ColorMapper mapper, UParam param, Html5Drawer html) {
    final URectangle rect = (URectangle) ushape;

    double width = rect.getWidth();
    double height = rect.getHeight();

    final UClip clip = clipContainer.getClip();
    if (clip != null) {
      final Rectangle2D.Double r =
          clip.getClippedRectangle(new Rectangle2D.Double(x, y, width, height));
      x = r.x;
      y = r.y;
      width = r.width;
      height = r.height;
    }

    final double rx = rect.getRx();
    final double ry = rect.getRy();

    //		// Shadow
    //		if (rect.getDeltaShadow() != 0) {
    //			eps.epsRectangleShadow(x, y, width, height, rx / 2, ry / 2, rect.getDeltaShadow());
    //		}

    final HtmlColor back = param.getBackcolor();
    if (back instanceof HtmlColorGradient) {
      //			eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
      //			eps.epsRectangle(x, y, width, height, rx / 2, ry / 2, (HtmlColorGradient) back, mapper);
    } else {
      final String color =
          param.getColor() == null
              ? null
              : StringUtils.getAsHtml(mapper.getMappedColor(param.getColor()));
      final String backcolor =
          param.getColor() == null
              ? null
              : StringUtils.getAsHtml(mapper.getMappedColor(param.getBackcolor()));

      html.setStrokeColor(color);
      html.setFillColor(backcolor);
      //			eps.setStrokeWidth("" + param.getStroke().getThickness(),
      // param.getStroke().getDashVisible(), param
      //					.getStroke().getDashSpace());
      html.htmlRectangle(x, y, width, height, rx / 2, ry / 2);
    }
  }
コード例 #3
0
  public void draw(
      UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
    final URectangle rect = (URectangle) ushape;

    final double rx = rect.getRx();
    final double ry = rect.getRy();
    double width = rect.getWidth();
    double height = rect.getHeight();

    final UGradient gr = param.getGradient();
    if (gr == null) {
      final String color =
          param.getColor() == null
              ? "none"
              : StringUtils.getAsHtml(mapper.getMappedColor(param.getColor()));
      final String backcolor =
          param.getBackcolor() == null
              ? "none"
              : StringUtils.getAsHtml(mapper.getMappedColor(param.getBackcolor()));
      svg.setFillColor(backcolor);
      svg.setStrokeColor(color);
    } else {
      final String id =
          svg.createSvgGradient(
              StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
              StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())));
      svg.setFillColor("url(#" + id + ")");
      svg.setStrokeColor(null);
    }

    svg.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDasharraySvg());

    final UClip clip = clipContainer.getClip();
    if (clip != null) {
      final Rectangle2D.Double r =
          clip.getClippedRectangle(new Rectangle2D.Double(x, y, width, height));
      x = r.x;
      y = r.y;
      width = r.width;
      height = r.height;
    }

    svg.svgRectangle(x, y, width, height, rx / 2, ry / 2);
  }
コード例 #4
0
ファイル: DriverTextEps.java プロジェクト: grze/euml
  public void draw(
      UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {

    final UClip clip = clipContainer.getClip();
    if (clip != null && clip.isInside(x, y) == false) {
      return;
    }

    final UText shape = (UText) ushape;

    if (strategy == EpsStrategy.WITH_MACRO_AND_TEXT) {
      drawAsText(shape, x, y, param, eps, mapper);
      return;
    }

    final FontConfiguration fontConfiguration = shape.getFontConfiguration();
    final UFont font = fontConfiguration.getFont();

    final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext);
    eps.setStrokeColor(mapper.getMappedColor(fontConfiguration.getColor()));
    drawPathIterator(eps, x, y, t.getOutline(null).getPathIterator(null));

    if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
      final HtmlColor extended = fontConfiguration.getExtendedColor();
      if (extended != null) {
        eps.setStrokeColor(mapper.getMappedColor(extended));
      }
      final Dimension2D dim =
          DriverTextG2d.calculateDimension(stringBounder, font, shape.getText());
      eps.setStrokeWidth("1.1", 0, 0);
      eps.epsLine(x, y + 1.5, x + dim.getWidth(), y + 1.5);
      eps.setStrokeWidth("1", 0, 0);
    }
    if (fontConfiguration.containsStyle(FontStyle.WAVE)) {
      final Dimension2D dim =
          DriverTextG2d.calculateDimension(stringBounder, font, shape.getText());
      final int ypos = (int) (y + 2.5) - 1;
      final HtmlColor extended = fontConfiguration.getExtendedColor();
      if (extended != null) {
        eps.setStrokeColor(mapper.getMappedColor(extended));
      }
      eps.setStrokeWidth("1.1", 0, 0);
      for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) {
        eps.epsLine(i, ypos - 0, i + 3, ypos + 1);
        eps.epsLine(i + 3, ypos + 1, i + 6, ypos - 0);
      }
      eps.setStrokeWidth("1", 0, 0);
    }
    if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
      final HtmlColor extended = fontConfiguration.getExtendedColor();
      if (extended != null) {
        eps.setStrokeColor(mapper.getMappedColor(extended));
      }
      final Dimension2D dim =
          DriverTextG2d.calculateDimension(stringBounder, font, shape.getText());
      final FontMetrics fm = g2dummy.getFontMetrics(font.getFont());
      final int ypos = (int) (y - fm.getDescent() - 0.5);
      eps.setStrokeWidth("1.3", 0, 0);
      eps.epsLine(x, ypos, x + dim.getWidth(), ypos);
      eps.setStrokeWidth("1", 0, 0);
    }
  }