package eu.greenlightning.hypercubepdf.layout;

public class HCPFlowLayout extends HCPSpacedLayout {

	private final static HCPFlowLayout NO_SPACING = new HCPFlowLayout(0);

	public static HCPFlowLayout getInstance() {
		return NO_SPACING;
	}

	public static HCPFlowLayout getInstance(float spacing) {
		return spacing == 0 ? NO_SPACING : new HCPFlowLayout(spacing);
	}

	private HCPFlowLayout(float spacing) {
		super(spacing);
	}

	@Override
	public float getSize(float[] sizes) {
		return getTotalSize(sizes) + getTotalSpacing(sizes);
	}

	@Override
	public HCPLayoutResults apply(HCPLayoutSpace space, float[] sizes) {
		return new HCPFlowLayoutResults(space, sizes, getSpacing());
	}

}

@@ -45,203 +45,927 @@
 t;%0A%0A
-public class HCPFlowLayout extends HCPSpacedLayout %7B%0A%0A%09private final static HCPFlowLayout NO_SPACING = new HCPFlowLayout(0);%0A%0A%09public static HCPFlowLayout getInstance() %7B%0A%09%09return NO_SPACING;%0A%09%7D%0A
+/**%0A * A layout algorithm which always uses the elements preferred size. If an element's size is larger than the remaining%0A * space, the element is painted inside the remaining space and all further elements are ignored.%0A * %3Cp%3E%0A * This class is immutable.%0A * %0A * @author Green Lightning%0A */%0Apublic class HCPFlowLayout extends HCPSpacedLayout %7B%0A%0A%09private final static HCPFlowLayout NO_SPACING = new HCPFlowLayout(0);%0A%0A%09/**%0A%09 * Returns an %7B@link HCPFlowLayout%7D instance which places elements next to each other.%0A%09 * %0A%09 * @return an instance with no spacing%0A%09 */%0A%09public static HCPFlowLayout getInstance() %7B%0A%09%09return NO_SPACING;%0A%09%7D%0A%0A%09/**%0A%09 * Returns an %7B@link HCPFlowLayout%7D instance which maintains the specified spacing between two adjacent elements.%0A%09 * %0A%09 * @param spacing must be %7B@literal %3E= 0%7D%0A%09 * @return an instance with the specified spacing%0A%09 * @throws IllegalArgumentException if spacing is %7B@literal %3C 0%7D%0A%09 */
 %0A%09pu

Document HCPFlowLayout.