- java.lang.Object
-
- com.googlecode.lanterna.gui2.InteractableLookupMap
-
public class InteractableLookupMap extends java.lang.ObjectThis 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 Summary
Fields Modifier and Type Field Description private java.util.List<Interactable>interactablesprivate int[][]lookupMap
-
Constructor Summary
Constructors Constructor Description InteractableLookupMap(TerminalSize size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Interactable interactable)Adds an interactable component to the lookup map(package private) voiddebug()InteractablefindNextDown(Interactable interactable)Starting from a particularInteractableand going down, which is the next interactable?InteractablefindNextLeft(Interactable interactable)Starting from a particularInteractableand going left, which is the next interactable?private InteractablefindNextLeftOrRight(Interactable interactable, boolean isRight)InteractablefindNextRight(Interactable interactable)Starting from a particularInteractableand going right, which is the next interactable?InteractablefindNextUp(Interactable interactable)Starting from a particularInteractableand going up, which is the next interactable?private InteractablefindNextUpOrDown(Interactable interactable, boolean isDown)private java.util.Set<Interactable>getDisqualifiedInteractables(TerminalPosition startPosition, boolean scanHorizontally)InteractablegetInteractableAt(TerminalPosition position)Looks up what interactable component is as a particular location in the map(package private) TerminalSizegetSize()(package private) voidreset()
-
-
-
Field Detail
-
lookupMap
private final int[][] lookupMap
-
interactables
private final java.util.List<Interactable> interactables
-
-
Constructor Detail
-
InteractableLookupMap
InteractableLookupMap(TerminalSize size)
-
-
Method Detail
-
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
Interactablecomponent at the specified location ornullif there's nothing there
-
findNextUp
public Interactable findNextUp(Interactable interactable)
Starting from a particularInteractableand going up, which is the next interactable?- Parameters:
interactable- WhatInteractableto start searching from- Returns:
- The next
Interactableabove the one specified ornullif there are no moreInteractable:s above it
-
findNextDown
public Interactable findNextDown(Interactable interactable)
Starting from a particularInteractableand going down, which is the next interactable?- Parameters:
interactable- WhatInteractableto start searching from- Returns:
- The next
Interactablebelow the one specified ornullif there are no moreInteractable:s below it
-
findNextUpOrDown
private Interactable findNextUpOrDown(Interactable interactable, boolean isDown)
-
findNextLeft
public Interactable findNextLeft(Interactable interactable)
Starting from a particularInteractableand going left, which is the next interactable?- Parameters:
interactable- WhatInteractableto start searching from- Returns:
- The next
Interactableleft of the one specified ornullif there are no moreInteractable:s left of it
-
findNextRight
public Interactable findNextRight(Interactable interactable)
Starting from a particularInteractableand going right, which is the next interactable?- Parameters:
interactable- WhatInteractableto start searching from- Returns:
- The next
Interactableright of the one specified ornullif there are no moreInteractable:s right of it
-
findNextLeftOrRight
private Interactable findNextLeftOrRight(Interactable interactable, boolean isRight)
-
getDisqualifiedInteractables
private java.util.Set<Interactable> getDisqualifiedInteractables(TerminalPosition startPosition, boolean scanHorizontally)
-
debug
void debug()
-
-