Package VASSAL.counters
Class KeyBuffer
java.lang.Object
VASSAL.counters.KeyBuffer
The KeyBuffer is the list of "currently selected pieces" in the VASSAL UI (map windows). Its somewhat confusing name
derives from the idea that if the player then presses a key, a key command will be sent to all of the pieces in the
buffer. KeyBuffer is a "singleton", so there is one for the whole app, across all map windows.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adding a piece to theKeyBuffer
"selects the piece" (and lets it know about in its SELECTED property)asList()
Returns a list of all selected pieces.void
clear()
Deselects all pieces (removes them all from theKeyBuffer
)boolean
Tells if a particular piece is selected (i.e.boolean
containsChild(Stack stack)
Check if any member of the specified Stack is currently selectedstatic KeyBuffer
Deprecated.Returns an iterator for all selected pieces.static void
boolean
isEmpty()
keyCommand(KeyStroke stroke)
Applies a key command to every selected piece (i.e.void
Deselect the specified piece -- removes it from theKeyBuffer
void
setClickPoint(Point p)
void
sort(Comparator<GamePiece> comp)
Sorts the selected pieces based on a particular Comparator
-
Method Details
-
init
-
getBuffer
-
setClickPoint
-
getClickPoint
-
add
Adding a piece to theKeyBuffer
"selects the piece" (and lets it know about in its SELECTED property)- Parameters:
p
- Piece to select
-
clear
public void clear()Deselects all pieces (removes them all from theKeyBuffer
) -
remove
Deselect the specified piece -- removes it from theKeyBuffer
- Parameters:
p
- piece to deselect
-
contains
Tells if a particular piece is selected (i.e. present in the KeyBuffer)- Parameters:
p
- piece to check- Returns:
- True if the piece is in the
KeyBuffer
, i.e. is selected
-
isEmpty
public boolean isEmpty()- Returns:
- true if the
KeyBuffer
is empty - i.e. no pieces are selected
-
keyCommand
Applies a key command to every selected piece (i.e. to piece in theKeyBuffer
)- Parameters:
stroke
- Keystroke to apply- Returns:
- Command that encapsulates any changes to the game state made while processing the key command, for replay on other clients or in logfile.
-
asList
Returns a list of all selected pieces. -
getPiecesIterator
Returns an iterator for all selected pieces. -
getPieces
Deprecated.UsegetPiecesIterator()
instead. -
sort
Sorts the selected pieces based on a particular Comparator- Parameters:
comp
- Comparator to use
-
containsChild
Check if any member of the specified Stack is currently selected- Parameters:
stack
- Stack to check- Returns:
- true if a child of the specified Stack is selected
-
getPiecesIterator()
instead.