![JAR search and dependency download from the Maven repository](/logo.png)
net.sourceforge.plantuml.klimt.geom.PlacementStrategyX1Y2Y3 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.geom;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.shape.TextBlock;
public class PlacementStrategyX1Y2Y3 extends AbstractPlacementStrategy {
// ::remove file when __HAXE__
public PlacementStrategyX1Y2Y3(StringBounder stringBounder) {
super(stringBounder);
}
public Map getPositions(double width, double height) {
final XDimension2D first = getDimensions().values().iterator().next();
final double maxWidthButFirst = getMaxWidth(butFirst());
final double sumHeightButFirst = getSumHeight(butFirst());
final double space = (width - first.getWidth() - maxWidthButFirst) / 3;
final Map result = new LinkedHashMap<>();
// double x = space * 2;
final Iterator> it = getDimensions().entrySet().iterator();
final Map.Entry ent = it.next();
double y = (height - ent.getValue().getHeight()) / 2;
result.put(ent.getKey(), new XPoint2D(space, y));
// x += ent.getValue().getWidth() + space;
y = (height - sumHeightButFirst) / 2;
while (it.hasNext()) {
final Map.Entry ent2 = it.next();
final TextBlock textBlock = ent2.getKey();
final XDimension2D dim = getDimensions().get(textBlock);
final double x = 2 * space + first.getWidth() + (maxWidthButFirst - dim.getWidth()) / 2;
result.put(textBlock, new XPoint2D(x, y));
y += ent2.getValue().getHeight();
}
return result;
}
private Iterator butFirst() {
final Iterator iterator = getDimensions().values().iterator();
iterator.next();
return iterator;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy