Class InteractableLookupMap

java.lang.Object
com.googlecode.lanterna.gui2.InteractableLookupMap

public class InteractableLookupMap extends Object
This class is used to keep a 'map' of the usable area and note where all the interact:ables are. It can then be used to find the next interactable in any direction. It is used inside the GUI system to drive arrow key navigation.
  • Field Details

    • lookupMap

      private final int[][] lookupMap
    • interactables

      private final List<Interactable> interactables
  • Constructor Details

    • InteractableLookupMap

      InteractableLookupMap(TerminalSize size)
  • Method Details

    • reset

      void reset()
    • getSize

      TerminalSize getSize()
    • add

      public void add(Interactable interactable)
      Adds an interactable component to the lookup map
      Parameters:
      interactable - Interactable to add to the lookup map
    • getInteractableAt

      public Interactable getInteractableAt(TerminalPosition position)
      Looks up what interactable component is as a particular location in the map
      Parameters:
      position - Position to look up
      Returns:
      The Interactable component at the specified location or null if there's nothing there
    • findNextUp

      public Interactable findNextUp(Interactable interactable)
      Starting from a particular Interactable and going up, which is the next interactable?
      Parameters:
      interactable - What Interactable to start searching from
      Returns:
      The next Interactable above the one specified or null if there are no more Interactable:s above it
    • findNextDown

      public Interactable findNextDown(Interactable interactable)
      Starting from a particular Interactable and going down, which is the next interactable?
      Parameters:
      interactable - What Interactable to start searching from
      Returns:
      The next Interactable below the one specified or null if there are no more Interactable:s below it
    • findNextUpOrDown

      private Interactable findNextUpOrDown(Interactable interactable, boolean isDown)
    • findNextLeft

      public Interactable findNextLeft(Interactable interactable)
      Starting from a particular Interactable and going left, which is the next interactable?
      Parameters:
      interactable - What Interactable to start searching from
      Returns:
      The next Interactable left of the one specified or null if there are no more Interactable:s left of it
    • findNextRight

      public Interactable findNextRight(Interactable interactable)
      Starting from a particular Interactable and going right, which is the next interactable?
      Parameters:
      interactable - What Interactable to start searching from
      Returns:
      The next Interactable right of the one specified or null if there are no more Interactable:s right of it
    • findNextLeftOrRight

      private Interactable findNextLeftOrRight(Interactable interactable, boolean isRight)
    • getDisqualifiedInteractables

      private Set<Interactable> getDisqualifiedInteractables(TerminalPosition startPosition, boolean scanHorizontally)
    • debug

      void debug()