|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.util.KeyTranslatorImpl
public class KeyTranslatorImpl
A basic implementation of the KeyTranslator interface that provides facilities for
mapping key codes to action command strings for use by the KeyboardManager.
| Nested Class Summary | |
|---|---|
protected static class |
KeyTranslatorImpl.KeyRecord
|
| Field Summary | |
|---|---|
protected HashMap<Character,KeyTranslatorImpl.KeyRecord> |
_charCommands
Any commands we wish to perform upon key typed events for characters. |
protected HashIntMap<KeyTranslatorImpl.KeyRecord> |
_keys
The keys for which commands are registered. |
protected static long |
DEFAULT_REPEAT_DELAY
The default delay in milliseconds before auto-repeated key presses will begin. |
protected static int |
DEFAULT_REPEAT_RATE
The default key press repeat rate. |
| Constructor Summary | |
|---|---|
KeyTranslatorImpl()
|
|
| Method Summary | |
|---|---|
void |
addPressCommand(int keyCode,
String command)
Adds a mapping from a key press to an action command string that will auto-repeat at a default repeat rate. |
void |
addPressCommand(int keyCode,
String command,
int rate)
Adds a mapping from a key press to an action command string that will auto-repeat at the specified repeat rate. |
void |
addPressCommand(int keyCode,
String command,
int rate,
long repeatDelay)
Adds a mapping from a key press to an action command string that will auto-repeat at the specified repeat rate after the specified auto-repeat delay has expired. |
void |
addReleaseCommand(int keyCode,
String command)
Adds a mapping from a key release to an action command string. |
Iterator<String> |
enumeratePressCommands()
Returns an iterator that iterates over the available press commands. |
Iterator<String> |
enumerateReleaseCommands()
Returns an iterator that iterates over the available release commands. |
protected KeyTranslatorImpl.KeyRecord |
getKeyRecord(int keyCode)
Returns the key record for the specified key, creating it and inserting it in the key table if necessary. |
String |
getPressCommand(char ch)
Returns the action command string associated with a key press of the given character, or null if there is no associated command. |
String |
getPressCommand(int keyCode)
Returns the action command string associated with a key press of the key corresponding to the given key code, or null if there is no associated command. |
String |
getReleaseCommand(char ch)
Returns the action command string associated with a key release of the given character, or null if there is no associated command. |
String |
getReleaseCommand(int keyCode)
Returns the action command string associated with a key release of the key corresponding to the given key code, or null if there is no associated command. |
long |
getRepeatDelay(char ch)
Returns the delay in milliseconds before generating auto-repeated key press events for the specified key. |
long |
getRepeatDelay(int keyCode)
Returns the delay in milliseconds before generating auto-repeated key press events for the specified key. |
int |
getRepeatRate(char ch)
Returns the number of times each second that key presses are to be automatically repeated while the key is held down, or 0 to disable auto-repeat for the key. |
int |
getRepeatRate(int keyCode)
Returns the number of times each second that key presses are to be automatically repeated while the key is held down, or 0 to disable auto-repeat for the key. |
boolean |
hasCommand(char ch)
Returns whether there is an action command for the key corresponding to the given character in the case of a keyTyped event corresponding to it. |
boolean |
hasCommand(int keyCode)
Returns whether there is an action command for the key corresponding to the given keycode. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected HashIntMap<KeyTranslatorImpl.KeyRecord> _keys
protected HashMap<Character,KeyTranslatorImpl.KeyRecord> _charCommands
protected static final int DEFAULT_REPEAT_RATE
protected static final long DEFAULT_REPEAT_DELAY
| Constructor Detail |
|---|
public KeyTranslatorImpl()
| Method Detail |
|---|
public void addPressCommand(int keyCode,
String command)
public void addPressCommand(int keyCode,
String command,
int rate)
rate - the number of times each second that the key press should be repeated while the
key is down, or 0 to disable auto-repeat for the key.
public void addPressCommand(int keyCode,
String command,
int rate,
long repeatDelay)
rate - the number of times each second that the key press should be repeated while the
key is down; passing 0 will result in no repeating.repeatDelay - the delay in milliseconds before auto-repeating key press events will be
generated for the key.
public void addReleaseCommand(int keyCode,
String command)
protected KeyTranslatorImpl.KeyRecord getKeyRecord(int keyCode)
public boolean hasCommand(int keyCode)
KeyTranslator
hasCommand in interface KeyTranslatorpublic boolean hasCommand(char ch)
KeyTranslator
hasCommand in interface KeyTranslatorpublic String getPressCommand(int keyCode)
KeyTranslatornull if there is no associated command.
getPressCommand in interface KeyTranslatorpublic String getPressCommand(char ch)
KeyTranslatornull if there is no associated command.
getPressCommand in interface KeyTranslatorpublic String getReleaseCommand(int keyCode)
KeyTranslatornull if there is no associated command.
getReleaseCommand in interface KeyTranslatorpublic String getReleaseCommand(char ch)
KeyTranslatornull if there is no associated command.
getReleaseCommand in interface KeyTranslatorpublic int getRepeatRate(int keyCode)
KeyTranslator0 to disable auto-repeat for the key.
getRepeatRate in interface KeyTranslatorpublic int getRepeatRate(char ch)
KeyTranslator0 to disable auto-repeat for the key.
getRepeatRate in interface KeyTranslatorpublic long getRepeatDelay(int keyCode)
KeyTranslator
getRepeatDelay in interface KeyTranslatorpublic long getRepeatDelay(char ch)
KeyTranslator
getRepeatDelay in interface KeyTranslatorpublic Iterator<String> enumeratePressCommands()
KeyTranslator
enumeratePressCommands in interface KeyTranslatorpublic Iterator<String> enumerateReleaseCommands()
KeyTranslator
enumerateReleaseCommands in interface KeyTranslator
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||