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, see AbstractComponent
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 Details

  • Constructor Details

    • AbstractComposite

      public AbstractComposite()
      Default constructor
  • Method Details

    • setComponent

      public void setComponent(Component component)
      Description copied from interface: Composite
      Sets the component which is inside this Composite. If you call this method with null, it removes the component wrapped by this Composite.
      Specified by:
      setComponent in interface Composite
      Parameters:
      component - Component to wrap
    • getComponent

      public Component getComponent()
      Description copied from interface: Composite
      Returns the component that this Composite is wrapping
      Specified by:
      getComponent in interface Composite
      Returns:
      Component the composite is wrapping
    • getChildCount

      public int getChildCount()
      Description copied from interface: Container
      Returns the number of children this container currently has
      Specified by:
      getChildCount in interface Container
      Returns:
      Number of children currently in this container
    • getChildrenList

      public List<Component> getChildrenList()
      Description copied from interface: Container
      Returns 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:
      getChildrenList in interface Container
      Returns:
      Child-components inside of this Container
      See Also:
    • getChildren

      public Collection<Component> getChildren()
      Description copied from interface: Container
      Returns 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 getChildrenList for a method with this signature.

      Specified by:
      getChildren in interface Container
      Returns:
      Child-components inside of this Container
      See Also:
    • containsComponent

      public boolean containsComponent(Component component)
      Description copied from interface: Container
      Returns true if this container contains the supplied component either directly or indirectly through intermediate containers.
      Specified by:
      containsComponent in interface Container
      Parameters:
      component - Component to check if it's part of this container
      Returns:
      true if the component is inside this Container, otherwise false
    • removeComponent

      public boolean removeComponent(Component component)
      Description copied from interface: Container
      Removes 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:
      removeComponent in interface Container
      Parameters:
      component - Component to remove from the Container
      Returns:
      true if the component existed inside the container and was removed, false otherwise
    • isInvalid

      public boolean isInvalid()
      Description copied from interface: TextGUIElement
      Checks 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:
      isInvalid in interface TextGUIElement
      Overrides:
      isInvalid in class AbstractComponent<T extends Container>
      Returns:
      true if the component is invalid and needs redrawing, false otherwise
    • invalidate

      public void invalidate()
      Description copied from interface: Component
      Marks 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:
      invalidate in interface Component
      Overrides:
      invalidate in class AbstractComponent<T extends Container>
    • nextFocus

      public Interactable nextFocus(Interactable fromThis)
      Description copied from interface: Container
      Given an interactable, find the next one in line to receive focus. If the interactable isn't inside this container, this method should return null.
      Specified by:
      nextFocus in interface Container
      Parameters:
      fromThis - Component from which to get the next interactable, or if null, pick the first available interactable
      Returns:
      The next interactable component, or null if there are no more interactables in the list
    • previousFocus

      public Interactable previousFocus(Interactable fromThis)
      Description copied from interface: Container
      Given an interactable, find the previous one in line to receive focus. If the interactable isn't inside this container, this method should return null.
      Specified by:
      previousFocus in interface Container
      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

      public boolean handleInput(KeyStroke key)
      Description copied from interface: Container
      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. Return false if the implementer doesn't care about this particular keystroke and it will be automatically sent up the hierarchy the to next container. If you return true, the event will stop here and won't be reported as unhandled.
      Specified by:
      handleInput in interface Container
      Parameters:
      key - Keystroke that was ignored by the interactable inside this container
      Returns:
      true if this event was handled by this container and shouldn't be processed anymore, false if the container didn't take any action on the event and want to pass it on
    • updateLookupMap

      public void updateLookupMap(InteractableLookupMap interactableLookupMap)
      Description copied from interface: Container
      Takes a lookup map and updates it with information about where all the interactables inside of this container are located.
      Specified by:
      updateLookupMap in interface Container
      Parameters:
      interactableLookupMap - Interactable map to update