net.sourceforge.plantuml.ebnf.TitleBox Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.ebnf;
import net.sourceforge.plantuml.klimt.UTranslate;
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
import net.sourceforge.plantuml.klimt.font.FontConfiguration;
import net.sourceforge.plantuml.klimt.font.FontStyle;
import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.geom.XDimension2D;
import net.sourceforge.plantuml.klimt.shape.AbstractTextBlock;
import net.sourceforge.plantuml.klimt.shape.UText;
public class TitleBox extends AbstractTextBlock {
private final String value;
private final FontConfiguration fc;
private final UText utext;
public TitleBox(String value, FontConfiguration fc) {
this.value = value;
this.fc = fc.add(FontStyle.BOLD);
this.utext = UText.build(value, this.fc);
}
@Override
public XDimension2D calculateDimension(StringBounder stringBounder) {
return stringBounder.calculateDimension(fc.getFont(), value);
}
@Override
public void drawU(UGraphic ug) {
final XDimension2D dimText = calculateDimension(ug.getStringBounder());
ug.apply(new UTranslate(0, dimText.getHeight() - utext.getDescent(ug.getStringBounder()))).draw(utext);
}
}