net.sourceforge.plantuml.klimt.drawing.visio.DriverTextVdx 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.klimt.drawing.visio;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.klimt.UParam;
import net.sourceforge.plantuml.klimt.color.ColorMapper;
import net.sourceforge.plantuml.klimt.drawing.UDriver;
import net.sourceforge.plantuml.klimt.font.FontConfiguration;
import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.font.UFont;
import net.sourceforge.plantuml.klimt.font.UFontContext;
import net.sourceforge.plantuml.klimt.geom.XDimension2D;
import net.sourceforge.plantuml.klimt.shape.UText;
public class DriverTextVdx implements UDriver {
private final StringBounder stringBounder;
public DriverTextVdx(StringBounder stringBounder) {
this.stringBounder = stringBounder;
}
public void draw(UText shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
Thread.dumpStack();
final FontConfiguration fontConfiguration = shape.getFontConfiguration();
final UFont font = fontConfiguration.getFont();
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 XDimension2D dim = stringBounder.calculateDimension(font, text);
visio.text(text, x, y, font.getFamily(UFontContext.SVG), font.getSize(), dim.getWidth(), dim.getHeight(),
fontConfiguration.getAttributes());
}
}