package eu.greenlightning.hypercubepdf.layout;

public abstract class HCPSpacedLayout implements HCPLayout {

	private final float spacing;

	public HCPSpacedLayout(float spacing) {
		if (spacing < 0)
			throw new IllegalArgumentException("Spacing must be equal to or greater than zero, but was "
					+ spacing + ".");
		this.spacing = spacing;
	}

	public float getSpacing() {
		return spacing;
	}

	protected float getTotalSpacing(float[] sizes) {
		if (sizes.length == 0)
			return 0;
		return (sizes.length - 1) * spacing;
	}
	
	protected float getMaxSize(float[] sizes){
		float maxSize = 0;
		for(float elementSize : sizes)
			maxSize = Math.max(maxSize, elementSize);
		return maxSize;
	}

	protected float getTotalSize(float[] sizes) {
		float totalSize = 0;
		for (float elementSize : sizes)
			totalSize += elementSize;
		return totalSize;
	}

}

@@ -45,100 +45,479 @@
 t;%0A%0A
-public abstract class HCPSpacedLayout implements HCPLayout %7B%0A%0A%09private final float spacing;%0A
+/**%0A * Base class for layout algorithms which allow to introduce spacing between adjacent elements.%0A * %3Cp%3E%0A * This class is immutable.%0A * %0A * @author Green Lightning%0A */%0Apublic abstract class HCPSpacedLayout implements HCPLayout %7B%0A%0A%09private final float spacing;%0A%0A%09/**%0A%09 * Creates a new %7B@link HCPSpacedLayout%7D instance which uses the specified spacing.%0A%09 * %0A%09 * @param spacing must be %7B@literal %3E= 0%7D%0A%09 * @throws IllegalArgumentException if spacing is %7B@literal %3C 0%7D%0A%09 */
 %0A%09pu
@@ -672,14 +672,9 @@
 as %22
-%0A%09%09%09%09%09
+ 
 + sp
@@ -678,17 +678,21 @@
  spacing
- 
+%0A%09%09%09%09
 + %22.%22);%0A
@@ -726,200 +726,895 @@
 %7D%0A%0A%09
-public float getSpacing() %7B%0A%09%09return spacing;%0A%09%7D%0A%0A%09protected float getTotalSpacing(float%5B%5D sizes) %7B%0A%09%09if (sizes.length == 0)%0A%09%09%09return 0;%0A%09%09return (sizes.length - 1) * spacing;%0A%09%7D%0A%09%0A%09protected
+/**%0A%09 * Returns the spacing used by this instance.%0A%09 * %0A%09 * @return the spacing used by this instance%0A%09 */%0A%09public float getSpacing() %7B%0A%09%09return spacing;%0A%09%7D%0A%0A%09/**%0A%09 * Returns the total amount of spacing for the specified list of element sizes.%0A%09 * %3Cp%3E%0A%09 * This is helper method for subclasses.%0A%09 * %0A%09 * @param sizes not %7B@code null%7D%0A%09 * @return the total amount of spacing for the specified list of element sizes%0A%09 * @throws NullPointerException if sizes is %7B@code null%7D%0A%09 */%0A%09protected final float getTotalSpacing(float%5B%5D sizes) %7B%0A%09%09if (sizes.length == 0)%0A%09%09%09return 0;%0A%09%09return (sizes.length - 1) * spacing;%0A%09%7D%0A%0A%09/**%0A%09 * Returns the maximum size in the specified list of elements sizes.%0A%09 * %3Cp%3E%0A%09 * This is a helper method for subclasses.%0A%09 * %0A%09 * @param sizes not %7B@code null%7D%0A%09 * @return the maximum size%0A%09 * @throws NullPointerException if sizes is %7B@code null%7D%0A%09 */%0A%09protected final
  flo
@@ -1641,16 +1641,17 @@
 %5D sizes)
+ 
 %7B%0A%09%09floa
@@ -1670,16 +1670,17 @@
 0;%0A%09%09for
+ 
 (float e
@@ -1766,16 +1766,462 @@
 ze;%0A%09%7D%0A%0A
+%09/**%0A%09 * Returns the total size of all element sizes in the specified list.%0A%09 * %3Cp%3E%0A%09 * This method does %3Cb%3Enot%3C/b%3E include spacing between the elements. To include spacing add the result of%0A%09 * %7B@link #getTotalSpacing(float%5B%5D)%7D to the return value of this method.%0A%09 * %3Cp%3E%0A%09 * This is a helper method for subclasses.%0A%09 * %0A%09 * @param sizes not %7B@code null%7D%0A%09 * @return the total size%0A%09 * @throws NullPointerException if sizes is %7B@code null%7D%0A%09 */%0A
 %09protect
@@ -2223,16 +2223,22 @@
 otected 
+final 
 float ge

Document HCPSpacedLayout.