- java.lang.Object
-
- com.googlecode.lanterna.gui2.InteractableLookupMap
-
public class InteractableLookupMap extends java.lang.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 Summary
Fields Modifier and Type Field Description private java.util.List<Interactable>
interactables
private int[][]
lookupMap
-
Constructor Summary
Constructors Constructor Description InteractableLookupMap(TerminalSize size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Interactable interactable)
Adds an interactable component to the lookup map(package private) void
debug()
Interactable
findNextDown(Interactable interactable)
Starting from a particularInteractable
and going down, which is the next interactable?Interactable
findNextLeft(Interactable interactable)
Starting from a particularInteractable
and going left, which is the next interactable?private Interactable
findNextLeftOrRight(Interactable interactable, boolean isRight)
Interactable
findNextRight(Interactable interactable)
Starting from a particularInteractable
and going right, which is the next interactable?Interactable
findNextUp(Interactable interactable)
Starting from a particularInteractable
and going up, which is the next interactable?private Interactable
findNextUpOrDown(Interactable interactable, boolean isDown)
private java.util.Set<Interactable>
getDisqualifiedInteractables(TerminalPosition startPosition, boolean scanHorizontally)
Interactable
getInteractableAt(TerminalPosition position)
Looks up what interactable component is as a particular location in the map(package private) TerminalSize
getSize()
(package private) void
reset()
-
-
-
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
Interactable
component at the specified location ornull
if there's nothing there
-
findNextUp
public Interactable findNextUp(Interactable interactable)
Starting from a particularInteractable
and going up, which is the next interactable?- Parameters:
interactable
- WhatInteractable
to start searching from- Returns:
- The next
Interactable
above the one specified ornull
if there are no moreInteractable
:s above it
-
findNextDown
public Interactable findNextDown(Interactable interactable)
Starting from a particularInteractable
and going down, which is the next interactable?- Parameters:
interactable
- WhatInteractable
to start searching from- Returns:
- The next
Interactable
below the one specified ornull
if there are no moreInteractable
:s below it
-
findNextUpOrDown
private Interactable findNextUpOrDown(Interactable interactable, boolean isDown)
-
findNextLeft
public Interactable findNextLeft(Interactable interactable)
Starting from a particularInteractable
and going left, which is the next interactable?- Parameters:
interactable
- WhatInteractable
to start searching from- Returns:
- The next
Interactable
left of the one specified ornull
if there are no moreInteractable
:s left of it
-
findNextRight
public Interactable findNextRight(Interactable interactable)
Starting from a particularInteractable
and going right, which is the next interactable?- Parameters:
interactable
- WhatInteractable
to start searching from- Returns:
- The next
Interactable
right of the one specified ornull
if 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()
-
-