Class AbstractComposite<T extends Container>
java.lang.Object
com.googlecode.lanterna.gui2.AbstractComponent<T>
com.googlecode.lanterna.gui2.AbstractComposite<T>
- Type Parameters:
T- Should always be itself, seeAbstractComponent
- All Implemented Interfaces:
Component, Composite, Container, TextGUIElement
- Direct Known Subclasses:
AbstractBasePane.ContentHolder, AbstractBorder
public abstract class AbstractComposite<T extends Container>
extends AbstractComponent<T>
implements Composite, Container
This abstract implementation contains common code for the different
Composite implementations. A
Composite component is one that encapsulates a single component, like borders. Because of this, a
Composite can be seen as a special case of a Container and indeed this abstract class does in fact
implement the Container interface as well, to make the composites easier to work with internally.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsComponent(Component component) Returnstrueif this container contains the supplied component either directly or indirectly through intermediate containers.intReturns the number of children this container currently hasReturns collection that is to be considered a copy of the list of children contained inside of this object.Returns list that is to be considered a copy of the list of children inside of this container.Returns the component that this Composite is wrappingbooleanhandleInput(KeyStroke key) If an interactable component inside this container received a keyboard event that wasn't handled, the GUI system will recursively send the event to each parent container to give each of them a chance to consume the event.voidMarks the component as invalid and requiring to be re-drawn at next opportunity.booleanChecks if this element (or any of its child components, if any) has signaled that what it's currently displaying is out of date and needs re-drawing.nextFocus(Interactable fromThis) Given an interactable, find the next one in line to receive focus.previousFocus(Interactable fromThis) Given an interactable, find the previous one in line to receive focus.booleanremoveComponent(Component component) Removes the component from the container.voidsetComponent(Component component) Sets the component which is inside this Composite.voidupdateLookupMap(InteractableLookupMap interactableLookupMap) Takes a lookup map and updates it with information about where all the interactables inside of this container are located.Methods inherited from class AbstractComponent
addTo, calculatePreferredSize, createDefaultRenderer, draw, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getRenderer, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, isInside, isVisible, onAdded, onAfterDrawing, onBeforeDrawing, onRemoved, runOnGUIThreadIfExistsOtherwiseRunDirect, self, setLayoutData, setPosition, setPreferredSize, setRenderer, setSize, setTheme, setVisible, toBasePane, toGlobal, withBorderMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Component
addTo, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getRenderer, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, isInside, isVisible, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, setTheme, setVisible, toBasePane, toGlobal, withBorderMethods inherited from interface TextGUIElement
draw
-
Field Details
-
component
-
-
Constructor Details
-
AbstractComposite
public AbstractComposite()Default constructor
-
-
Method Details
-
setComponent
Description copied from interface:CompositeSets the component which is inside this Composite. If you call this method with null, it removes the component wrapped by this Composite.- Specified by:
setComponentin interfaceComposite- Parameters:
component- Component to wrap
-
getComponent
Description copied from interface:CompositeReturns the component that this Composite is wrapping- Specified by:
getComponentin interfaceComposite- Returns:
- Component the composite is wrapping
-
getChildCount
public int getChildCount()Description copied from interface:ContainerReturns the number of children this container currently has- Specified by:
getChildCountin interfaceContainer- Returns:
- Number of children currently in this container
-
getChildrenList
Description copied from interface:ContainerReturns list that is to be considered a copy of the list of children inside of this container. Modifying this list will not affect any internal state. This method is essentially the same as getChildren but the returned collection is a list.- Specified by:
getChildrenListin interfaceContainer- Returns:
- Child-components inside of this Container
- See Also:
-
getChildren
Description copied from interface:ContainerReturns collection that is to be considered a copy of the list of children contained inside of this object. Modifying this collection will not affect any internal state.This method isn't deprecated but it should have originally been defined as returning a List instead of a Collection. See
getChildrenListfor a method with this signature.- Specified by:
getChildrenin interfaceContainer- Returns:
- Child-components inside of this Container
- See Also:
-
containsComponent
Description copied from interface:ContainerReturnstrueif this container contains the supplied component either directly or indirectly through intermediate containers.- Specified by:
containsComponentin interfaceContainer- Parameters:
component- Component to check if it's part of this container- Returns:
trueif the component is inside this Container, otherwisefalse
-
removeComponent
Description copied from interface:ContainerRemoves the component from the container. This should remove the component from the Container's internal data structure as well as call the onRemoved(..) method on the component itself if it was found inside the container.- Specified by:
removeComponentin interfaceContainer- Parameters:
component- Component to remove from the Container- Returns:
trueif the component existed inside the container and was removed,falseotherwise
-
isInvalid
public boolean isInvalid()Description copied from interface:TextGUIElementChecks if this element (or any of its child components, if any) has signaled that what it's currently displaying is out of date and needs re-drawing.- Specified by:
isInvalidin interfaceTextGUIElement- Overrides:
isInvalidin classAbstractComponent<T extends Container>- Returns:
trueif the component is invalid and needs redrawing,falseotherwise
-
invalidate
public void invalidate()Description copied from interface:ComponentMarks the component as invalid and requiring to be re-drawn at next opportunity. Container components should take this as a hint to layout the child components again.- Specified by:
invalidatein interfaceComponent- Overrides:
invalidatein classAbstractComponent<T extends Container>
-
nextFocus
Description copied from interface:ContainerGiven an interactable, find the next one in line to receive focus. If the interactable isn't inside this container, this method should returnnull. -
previousFocus
Description copied from interface:ContainerGiven an interactable, find the previous one in line to receive focus. If the interactable isn't inside this container, this method should returnnull.- Specified by:
previousFocusin interfaceContainer- Parameters:
fromThis- Component from which to get the previous interactable, or if null, pick the last interactable in the list- Returns:
- The previous interactable component, or null if there are no more interactables in the list
-
handleInput
Description copied from interface:ContainerIf an interactable component inside this container received a keyboard event that wasn't handled, the GUI system will recursively send the event to each parent container to give each of them a chance to consume the event. Returnfalseif the implementer doesn't care about this particular keystroke and it will be automatically sent up the hierarchy the to next container. If you returntrue, the event will stop here and won't be reported as unhandled.- Specified by:
handleInputin interfaceContainer- Parameters:
key- Keystroke that was ignored by the interactable inside this container- Returns:
trueif this event was handled by this container and shouldn't be processed anymore,falseif the container didn't take any action on the event and want to pass it on
-
updateLookupMap
Description copied from interface:ContainerTakes a lookup map and updates it with information about where all the interactables inside of this container are located.- Specified by:
updateLookupMapin interfaceContainer- Parameters:
interactableLookupMap- Interactable map to update
-