| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthmi.util.InputState
public class InputState
An InputState tracks the current state of the keyboard and mouse, by listening to AWT InputEvents for AWT/Swing Components. The key/mouse button state (pressed or released) is tracked, and used to determine which of a set of defined key patterns is currently "active" Such a pattern is itself defined by a set of keys that must be pressed, and a set of keys that are required to be released. Keys can be specified by means of virtual key codes, possibly combined with a keyboard location (like LEFT, RIGHT, NUMPAD).
| Nested Class Summary | |
|---|---|
static class | 
InputState.Key
A InputState.Key defines a virtual key code and a key location.  | 
 class | 
InputState.KeyPat
standard implementation of InputState.Pattern.  | 
static interface | 
InputState.Pattern
The interface for key patterns: A pattern can be currently active or not, which can be checked by calling the isActive method.  | 
| Field Summary | |
|---|---|
static int | 
A
 | 
private  boolean | 
button1Down
 | 
private  boolean | 
button2Down
 | 
private  boolean | 
button3Down
 | 
private  int | 
clickCount1
 | 
private  int | 
clickCount2
 | 
private  int | 
clickCount3
 | 
private static int | 
KEYDIM
 | 
private  int[] | 
keyDown
 | 
static int | 
KEYLISTENER
various listener modes; they can be combined by means of the | operator  | 
static int | 
L
Constants for referring to keyboard locations.  | 
private  int | 
listenerMode
 | 
static int | 
MB1
 | 
static int | 
MB2
 | 
static int | 
MB3
 | 
static int | 
MOUSELISTENER
 | 
static int | 
N
 | 
private  int[] | 
navKey
 | 
static int | 
NR_OF_KEYCODES
 | 
private static int | 
NR_OF_MOUSE_BUTTONS
 | 
private  ArrayList<InputState.Pattern> | 
patterns
 | 
static int | 
R
 | 
static int | 
S
 | 
private  int | 
x
 | 
private  int | 
x1Pressed
 | 
private  int | 
x1Released
 | 
private  int | 
x2Pressed
 | 
private  int | 
x2Released
 | 
private  int | 
x3Pressed
 | 
private  int | 
x3Released
 | 
private  int | 
y
 | 
private  int | 
y1Pressed
 | 
private  int | 
y1Released
 | 
private  int | 
y2Pressed
 | 
private  int | 
y2Released
 | 
private  int | 
y3Pressed
 | 
private  int | 
y3Released
 | 
| Constructor Summary | |
|---|---|
InputState()
Creates a new InputState, not yet listening to any Component.  | 
|
InputState(Component c)
Create a new InputState and adds it as a KeyListener to the specified Component.  | 
|
InputState(Component c,
           int listenerMode)
 | 
|
| Method Summary | |
|---|---|
 InputState.Pattern | 
addPattern(InputState.Key key)
Adds a key pattern, defined by a single key which must be down for activation.  | 
 InputState.Pattern | 
addPattern(InputState.Key[] down)
Adds a key pattern, consisting of keys required to be down.  | 
 InputState.Pattern | 
addPattern(InputState.Key[] down,
           InputState.Key[] up)
Adds a key pattern, consisting of keys required to be down, and keys required to be up.  | 
 InputState.Pattern | 
addPattern(int[] down,
           int[] up)
Adds a key pattern, consisting of keys required to be down, and keys required to be up.  | 
private  void | 
classify()
 | 
 void | 
detachFrom(Component c)
removes the listeners from Component c  | 
 int | 
getClickCount1()
 | 
 int | 
getClickCount2()
 | 
 int | 
getClickCount3()
 | 
 int | 
getX1pressed()
 | 
 int | 
getX1released()
 | 
 int | 
getX2pressed()
 | 
 int | 
getX2released()
 | 
 int | 
getX3pressed()
 | 
 int | 
getX3released()
 | 
 int | 
getY1pressed()
 | 
 int | 
getY1released()
 | 
 int | 
getY2pressed()
 | 
 int | 
getY2released()
 | 
 int | 
getY3pressed()
 | 
 int | 
getY3released()
 | 
 boolean | 
isButton1Down()
 | 
 boolean | 
isButton2Down()
 | 
 boolean | 
isButton3Down()
 | 
static InputState.Key | 
key(int vkCode)
Creates a InputState.Key, defined by a virtual key code.  | 
static InputState.Key | 
key(int vkCode,
    int locationMask)
Creates a InputState.Key consisting of virtual key code and keylocation.  | 
 void | 
keyPressed(KeyEvent evt)
keyPressed handler from the KeyListener interface for this tracker.  | 
 void | 
keyReleased(KeyEvent evt)
keyReleased handler from the KeyListener interface for this tracker.  | 
 void | 
keyTyped(KeyEvent evt)
keyTyped handler required by the KeyListener interface. ketTyped calls are simply ignored.  | 
static InputState.Key | 
left(int vkCode)
Creates a InputState.Key, defined by a virtual key code.  | 
 void | 
listenTo(Component c)
adds listeners to Component c for all enabled events, according to the listenerMode  | 
 String | 
locationString(int location)
produces a descriptive String for a key location: Left, Right, Numpad, S(tandard), or U(nknown).  | 
 void | 
mouseClicked(MouseEvent e)
mouseClicked handler from the MouseListener interface for this tracker: ignored  | 
 void | 
mouseDragged(MouseEvent e)
mouseDragged handler from the MouseMotionListener interface for this tracker.  | 
 void | 
mouseEntered(MouseEvent e)
mouseEntered handler from the MouseListener interface for this tracker: ignored  | 
 void | 
mouseExited(MouseEvent e)
mouseExited handler from the MouseListener interface for this tracker: ignored  | 
 void | 
mouseMoved(MouseEvent e)
mouseMoved handler from the MouseMotionListener interface for this tracker.  | 
 void | 
mousePressed(MouseEvent e)
mousePressed handler from the MouseListener interface for this tracker.  | 
 void | 
mouseReleased(MouseEvent e)
mouseReleased handler from the MouseListener interface for this tracker.  | 
 void | 
mouseWheelMoved(MouseWheelEvent e)
mouseDragged handler from the MouseWheelListener interface for this tracker.  | 
static InputState.Key | 
numpad(int vkCode)
Creates a InputState.Key, defined by a virtual key code.  | 
 InputState.Pattern | 
orPattern(InputState.Pattern[] pats)
Create a new key patterns from a given list of patterns., It is active iff at least one of the patterns from the list is active.  | 
static InputState.Key | 
right(int vkCode)
Creates a InputState.Key, defined by a virtual key code.  | 
static InputState.Key | 
standard(int vkCode)
Creates a InputState.Key, defined by a virtual key code.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final int NR_OF_KEYCODES
private static final int NR_OF_MOUSE_BUTTONS
private static final int KEYDIM
public static final int MB1
public static final int MB2
public static final int MB3
public static final int L
public static final int R
public static final int S
public static final int N
public static final int A
private int[] navKey
private int[] keyDown
public static final int KEYLISTENER
public static final int MOUSELISTENER
private int listenerMode
private boolean button1Down
private boolean button2Down
private boolean button3Down
private int clickCount1
private int clickCount2
private int clickCount3
private int x1Pressed
private int y1Pressed
private int x1Released
private int y1Released
private int x2Pressed
private int y2Pressed
private int x2Released
private int y2Released
private int x3Pressed
private int y3Pressed
private int x3Released
private int y3Released
private int x
private int y
private ArrayList<InputState.Pattern> patterns
| Constructor Detail | 
|---|
public InputState()
public InputState(Component c)
public InputState(Component c,
                  int listenerMode)
| Method Detail | 
|---|
public boolean isButton1Down()
public boolean isButton2Down()
public boolean isButton3Down()
public int getClickCount1()
public int getClickCount2()
public int getClickCount3()
public int getX1pressed()
public int getX2pressed()
public int getX3pressed()
public int getY1pressed()
public int getY2pressed()
public int getY3pressed()
public int getX1released()
public int getX2released()
public int getX3released()
public int getY1released()
public int getY2released()
public int getY3released()
public void listenTo(Component c)
public void detachFrom(Component c)
public InputState.Pattern addPattern(int[] down,
                                     int[] up)
public InputState.Pattern addPattern(InputState.Key[] down,
                                     InputState.Key[] up)
public InputState.Pattern addPattern(InputState.Key[] down)
public InputState.Pattern addPattern(InputState.Key key)
public InputState.Pattern orPattern(InputState.Pattern[] pats)
public static InputState.Key key(int vkCode,
                                 int locationMask)
public static InputState.Key key(int vkCode)
public static InputState.Key numpad(int vkCode)
public static InputState.Key left(int vkCode)
public static InputState.Key right(int vkCode)
public static InputState.Key standard(int vkCode)
private void classify()
public final void keyPressed(KeyEvent evt)
keyPressed in interface KeyListenerpublic final void keyReleased(KeyEvent evt)
keyReleased in interface KeyListenerpublic final void mouseClicked(MouseEvent e)
mouseClicked in interface MouseListenerpublic final void mouseEntered(MouseEvent e)
mouseEntered in interface MouseListenerpublic final void mouseExited(MouseEvent e)
mouseExited in interface MouseListenerpublic final void mousePressed(MouseEvent e)
mousePressed in interface MouseListenerpublic final void mouseReleased(MouseEvent e)
mouseReleased in interface MouseListenerpublic final void mouseDragged(MouseEvent e)
public final void mouseMoved(MouseEvent e)
public final void mouseWheelMoved(MouseWheelEvent e)
public final void keyTyped(KeyEvent evt)
keyTyped in interface KeyListenerpublic String locationString(int location)
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||