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; }
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; }
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(); }
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)); } }