![JAR search and dependency download from the Maven repository](/logo.png)
net.sourceforge.plantuml.klimt.shape.TextBlockInEllipse 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.shape;
import net.sourceforge.plantuml.klimt.UTranslate;
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.geom.XDimension2D;
import net.sourceforge.plantuml.klimt.geom.XPoint2D;
import net.sourceforge.plantuml.svek.image.ContainingEllipse;
import net.sourceforge.plantuml.svek.image.Footprint;
public class TextBlockInEllipse extends AbstractTextBlock implements TextBlock {
// ::remove file when __HAXE__
private final TextBlock text;
private final ContainingEllipse ellipse;
public TextBlockInEllipse(TextBlock text, StringBounder stringBounder) {
this.text = text;
final XDimension2D textDim = text.calculateDimension(stringBounder);
double alpha = textDim.getHeight() / textDim.getWidth();
if (alpha < .2) {
alpha = .2;
} else if (alpha > .8) {
alpha = .8;
}
final Footprint footprint = new Footprint(stringBounder);
ellipse = footprint.getEllipse(text, alpha);
}
public UEllipse getUEllipse() {
return ellipse.asUEllipse().bigger(6);
}
public void drawU(UGraphic ug) {
final UEllipse sh = getUEllipse();
final XPoint2D center = ellipse.getCenter();
final double dx = sh.getWidth() / 2 - center.getX();
final double dy = sh.getHeight() / 2 - center.getY();
ug.draw(sh);
text.drawU(ug.apply(new UTranslate(dx, (dy - 2))));
}
public XDimension2D calculateDimension(StringBounder stringBounder) {
return getUEllipse().getDimension();
}
public void setDeltaShadow(double deltaShadow) {
ellipse.setDeltaShadow(deltaShadow);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy