package eu.greenlightning.hypercubepdf.container;

import java.io.IOException;
import java.util.Collection;

import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;

import eu.greenlightning.hypercubepdf.HCPElement;

public class HCPStack implements HCPElement {

	private final HCPElements elements;

	public HCPStack(Collection<HCPElement> elements) {
		this.elements = new HCPElements(elements);
	}

	public HCPStack(HCPElement... elements) {
		this.elements = new HCPElements(elements);
	}

	@Override
	public float getWidth() throws IOException {
		return elements.getMaxWidth();
	}

	@Override
	public float getHeight() throws IOException {
		return elements.getMaxHeight();
	}

	@Override
	public void paint(PDPageContentStream content, PDRectangle shape) throws IOException {
		for (HCPElement element : elements) {
			element.paint(content, shape);
		}
	}

}

@@ -270,193 +270,1202 @@
 t;%0A%0A
-public class HCPStack implements HCPElement %7B%0A%0A%09private final HCPElements elements;%0A%0A%09public HCPStack(Collection%3CHCPElement%3E elements) %7B%0A%09%09this.elements = new HCPElements(elements);%0A%09%7D%0A
+/**%0A * Paints multiple %7B@link HCPElement%7Ds on top of each other. The elements are painted in the order they are%0A * provided in, i.&nbsp;e. the first element is painted first and the last element is painted last%0A * (bottom-to-top ordering).%0A * %3Cp%3E%0A * The width of the widest and the height of the highest element are used as the size of the stack.%0A * %3Cp%3E%0A * This class is immutable.%0A * %0A * @author Green Lightning%0A */%0Apublic class HCPStack implements HCPElement %7B%0A%0A%09private final HCPElements elements;%0A%0A%09/**%0A%09 * Creates an %7B@link HCPStack%7D from a %7B@link Collection%7D of elements.%0A%09 * %0A%09 * @param elements not %7B@code null%7D; must not contain %7B@code null%7D%0A%09 * @throws NullPointerException if elements is %7B@code null%7D%0A%09 * @throws IllegalArgumentException if elements contains %7B@code null%7D%0A%09 */%0A%09public HCPStack(Collection%3CHCPElement%3E elements) %7B%0A%09%09this.elements = new HCPElements(elements);%0A%09%7D%0A%0A%09/**%0A%09 * Creates an %7B@link HCPStack%7D instance from an array or from a varargs list of elements.%0A%09 * %0A%09 * @param elements not %7B@code null%7D; must not contain %7B@code null%7D%0A%09 * @throws NullPointerException if elements is %7B@code null%7D%0A%09 * @throws IllegalArgumentException if elements contains %7B@code null%7D%0A%09 */
 %0A%09pu

Document HCPStack.