public class ComponentStack extends java.util.AbstractList<GuiComponent>
Each component layer has an opportunity to grab some of the GUI element's space for itself before passing a smaller space down to its children.
When computing preferred size, the order is reversed (top down) gathering up the preferred size of each layer based on how it wants to wrap the layer above it. In this way, each layer kind of acts like a decorator for the layer above it.
Preferred size calculation and reshaping are all done in 3D and each layer can choose to reposition or reshape the next layer in any of these dimensions.
[a picture would be worth a thousand words]It is often desirable to be able to insert specific types of components into specific layers in the stack. For example, "insets" on the bottom. Thus the component stack keeps a list of layer names that enforce this default ordering of named layers. Layers don't have to be named, but when they are they are kept in the order defined in this layer ordering list.
Constructor and Description |
---|
ComponentStack(java.lang.String... layerOrder)
Creates a component stack with the specified
layer ordering.
|
Modifier and Type | Method and Description |
---|---|
<T extends GuiComponent> |
addComponent(T c)
Adds a new component to the top of the stack.
|
void |
attach(GuiControl parent) |
void |
detach(GuiControl parent) |
GuiComponent |
get(int index) |
protected GuiComponent[] |
getArray() |
<T extends GuiComponent> |
getComponent(java.lang.String layer)
Returns the component that was previously associated with the specified layer.
|
java.lang.String[] |
getLayerOrder()
Returns the current layer order.
|
boolean |
hasLayer(java.lang.String layerName)
Returns true if the specified layer name exists in
the layer order list.
|
protected void |
rebuildStack()
Completely rebuilds the component stack from the index, layer ordering,
and top list.
|
boolean |
removeComponent(GuiComponent c)
Removes the specified component from the stack.
|
<T extends GuiComponent> |
removeComponent(java.lang.String layer)
Removes the component that was previously associated with the specified layer.
|
<T extends GuiComponent> |
setComponent(java.lang.String layer,
T c)
Sets the specified component to the specified layer and
returns the specified component.
|
void |
setLayerOrder(java.lang.String... layerOrder)
Sets a new layer ordering.
|
int |
size() |
java.lang.String |
toString() |
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public ComponentStack(java.lang.String... layerOrder)
protected GuiComponent[] getArray()
public GuiComponent get(int index)
get
in interface java.util.List<GuiComponent>
get
in class java.util.AbstractList<GuiComponent>
public int size()
size
in interface java.util.Collection<GuiComponent>
size
in interface java.util.List<GuiComponent>
size
in class java.util.AbstractCollection<GuiComponent>
public void setLayerOrder(java.lang.String... layerOrder)
public boolean hasLayer(java.lang.String layerName)
public java.lang.String[] getLayerOrder()
public void attach(GuiControl parent)
public void detach(GuiControl parent)
protected void rebuildStack()
public <T extends GuiComponent> T addComponent(T c)
public <T extends GuiComponent> T setComponent(java.lang.String layer, T c)
public <T extends GuiComponent> T getComponent(java.lang.String layer)
public <T extends GuiComponent> T removeComponent(java.lang.String layer)
public boolean removeComponent(GuiComponent c)
public java.lang.String toString()
toString
in class java.util.AbstractCollection<GuiComponent>