Пример #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 double getHeight(StringBounder stringBounder) {
   double height = 0;
   for (Item it : project.getValidItems()) {
     final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
     height += dim.getHeight();
   }
   return height;
 }
Пример #3
0
 public double getWidth(StringBounder stringBounder) {
   double width = 0;
   for (Item it : project.getValidItems()) {
     final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
     width = Math.max(width, dim.getWidth());
   }
   return width;
 }
Пример #4
0
 private void drawText(double x, double y, UText text) {
   final Dimension2D dim =
       stringBounder.calculateDimension(text.getFontConfiguration().getFont(), text.getText());
   y -= dim.getHeight() - 1.5;
   minmax.addPoint(x, y);
   minmax.addPoint(x, y + dim.getHeight());
   minmax.addPoint(x + dim.getWidth(), y);
   minmax.addPoint(x + dim.getWidth(), y + dim.getHeight());
 }
Пример #5
0
 public double getPosition(StringBounder stringBounder, Item item) {
   double pos = 0;
   for (Item it : project.getValidItems()) {
     if (it == item) {
       return pos;
     }
     final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
     pos += dim.getHeight();
   }
   throw new IllegalArgumentException();
 }
Пример #6
0
 private double getMonthHeight(StringBounder stringBounder) {
   final Dimension2D dimZZ = stringBounder.calculateDimension(font, "ZZ");
   return dimZZ.getHeight() + 3;
 }
Пример #7
0
 private double getCaseHeight(StringBounder stringBounder) {
   final Dimension2D dim00 = stringBounder.calculateDimension(font, "00");
   return dim00.getHeight() + 3;
 }