All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.plantuml.klimt.geom.PlacementStrategyX1Y2Y3 Maven / Gradle / Ivy

There is a newer version: 1.2025.0
Show newest version
// 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