Class ComponentStack
- All Implemented Interfaces:
Iterable<GuiComponent>
,Collection<GuiComponent>
,List<GuiComponent>
,SequencedCollection<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.
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorsConstructorDescriptionComponentStack
(String... layerOrder) Creates a component stack with the specified layer ordering. -
Method Summary
Modifier and TypeMethodDescription<T extends GuiComponent>
TaddComponent
(T c) Adds a new component to the top of the stack.void
attach
(GuiControl parent) void
detach
(GuiControl parent) get
(int index) protected GuiComponent[]
getArray()
<T extends GuiComponent>
TgetComponent
(String layer) Returns the component that was previously associated with the specified layer.String[]
Returns the current layer order.boolean
Returns true if the specified layer name exists in the layer order list.protected void
Completely rebuilds the component stack from the index, layer ordering, and top list.boolean
Removes the specified component from the stack.<T extends GuiComponent>
TremoveComponent
(String layer) Removes the component that was previously associated with the specified layer.<T extends GuiComponent>
TsetComponent
(String layer, T c) Sets the specified component to the specified layer and returns the specified component.void
setLayerOrder
(String... layerOrder) Sets a new layer ordering.int
size()
toString()
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, isEmpty, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray, toArray
-
Constructor Details
-
ComponentStack
Creates a component stack with the specified layer ordering.
-
-
Method Details
-
getArray
-
get
- Specified by:
get
in interfaceList<GuiComponent>
- Specified by:
get
in classAbstractList<GuiComponent>
-
size
public int size()- Specified by:
size
in interfaceCollection<GuiComponent>
- Specified by:
size
in interfaceList<GuiComponent>
- Specified by:
size
in classAbstractCollection<GuiComponent>
-
setLayerOrder
Sets a new layer ordering. This will invalidate and rebuild the component stack. -
hasLayer
Returns true if the specified layer name exists in the layer order list. -
getLayerOrder
Returns the current layer order. -
attach
-
detach
-
rebuildStack
protected void rebuildStack()Completely rebuilds the component stack from the index, layer ordering, and top list. This should be called whenever changes are made to these data structures that cannot be reconciled with surgical changes to the components list. -
addComponent
Adds a new component to the top of the stack. -
setComponent
Sets the specified component to the specified layer and returns the specified component. Note: this is different than java.util.List.set() behavior where it would return the previous value. -
getComponent
Returns the component that was previously associated with the specified layer. -
removeComponent
Removes the component that was previously associated with the specified layer. -
removeComponent
Removes the specified component from the stack. -
toString
- Overrides:
toString
in classAbstractCollection<GuiComponent>
-