net.sourceforge.plantuml.salt.element.ElementTreeEntry 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.salt.element;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
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;
public class ElementTreeEntry {
private final Element firstElement;
private final int level;
private final List otherElements = new ArrayList<>();
public ElementTreeEntry(int level, Element elmt) {
this.firstElement = elmt;
this.level = level;
}
public void addCell(Element elmt) {
this.otherElements.add(elmt);
}
public XDimension2D getPreferredDimensionFirstCell(StringBounder stringBounder) {
return firstElement.getPreferredDimension(stringBounder, 0, 0).delta(getXDelta(), 0);
}
public ListWidth getPreferredDimensionOtherCell(StringBounder stringBounder) {
final ListWidth result = new ListWidth();
for (Element element : otherElements) {
result.add(element.getPreferredDimension(stringBounder, 0, 0).getWidth());
}
return result;
}
public double getXDelta() {
return level * 10;
}
public void drawFirstCell(UGraphic ug, double x, double y) {
firstElement.drawU(ug.apply(new UTranslate(x + getXDelta(), y)), 0, null);
}
public void drawSecondCell(UGraphic ug, double x, double y, ListWidth otherWidth, double margin) {
final Iterator it = otherWidth.iterator();
for (Element element : otherElements) {
element.drawU(ug.apply(new UTranslate(x, y)), 0, null);
x += it.next() + margin;
}
}
}