net.sourceforge.plantuml.klimt.drawing.tikz.DriverCenteredCharacterTikz 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.tikz;
import java.awt.font.TextLayout;
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.UFont;
import net.sourceforge.plantuml.klimt.font.UFontContext;
import net.sourceforge.plantuml.klimt.font.UnusedSpace;
import net.sourceforge.plantuml.klimt.shape.UCenteredCharacter;
import net.sourceforge.plantuml.tikz.TikzGraphics;
public class DriverCenteredCharacterTikz implements UDriver {
// ::remove folder when __HAXE__
public void draw(UCenteredCharacter centeredCharacter, double x, double y, ColorMapper mapper, UParam param,
TikzGraphics tikz) {
final char c = centeredCharacter.getChar();
final UFont font = centeredCharacter.getFont();
final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
final double xpos = x - unusedSpace.getCenterX() - 0.5;
final double ypos = y - unusedSpace.getCenterY() - 0.5;
final TextLayout t = UFontContext.TIKZ.createTextLayout(font, "" + c);
tikz.setStrokeColor(param.getColor());
tikz.drawPathIterator(xpos, ypos, t.getOutline(null).getPathIterator(null));
}
}