Пример #1
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;
 }
Пример #2
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;
 }
Пример #3
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();
 }
Пример #4
0
  public void draw(UGraphic ug, double x, double y) {

    final StringBounder stringBounder = ug.getStringBounder();

    ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
    ug.apply(new UTranslate(x, y))
        .draw(new URectangle(getWidth(stringBounder), getHeight(stringBounder)));

    for (Item it : project.getValidItems()) {
      final TextBlock b =
          Display.create("" + it.getCode())
              .create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty());
      final Dimension2D dim = b.calculateDimension(stringBounder);
      b.drawU(ug.apply(new UTranslate(x, y)));
      y += dim.getHeight();
      ug.apply(new UTranslate(x, y)).draw(new ULine(getWidth(stringBounder), 0));
    }
  }