001: package org.uispec4j;
002:
003: import java.awt.event.InputEvent;
004: import java.awt.event.KeyEvent;
005:
006: /**
007: * Contants class defining keyboard keys.
008: */
009: public class Key {
010: public static final Key A = new Key(KeyEvent.VK_A, true);
011: public static final Key B = new Key(KeyEvent.VK_B, true);
012: public static final Key C = new Key(KeyEvent.VK_C, true);
013: public static final Key D = new Key(KeyEvent.VK_D, true);
014: public static final Key E = new Key(KeyEvent.VK_E, true);
015: public static final Key F = new Key(KeyEvent.VK_F, true);
016: public static final Key G = new Key(KeyEvent.VK_G, true);
017: public static final Key H = new Key(KeyEvent.VK_H, true);
018: public static final Key I = new Key(KeyEvent.VK_I, true);
019: public static final Key J = new Key(KeyEvent.VK_J, true);
020: public static final Key K = new Key(KeyEvent.VK_K, true);
021: public static final Key L = new Key(KeyEvent.VK_L, true);
022: public static final Key M = new Key(KeyEvent.VK_M, true);
023: public static final Key N = new Key(KeyEvent.VK_N, true);
024: public static final Key O = new Key(KeyEvent.VK_O, true);
025: public static final Key P = new Key(KeyEvent.VK_P, true);
026: public static final Key Q = new Key(KeyEvent.VK_Q, true);
027: public static final Key R = new Key(KeyEvent.VK_R, true);
028: public static final Key S = new Key(KeyEvent.VK_S, true);
029: public static final Key T = new Key(KeyEvent.VK_T, true);
030: public static final Key U = new Key(KeyEvent.VK_U, true);
031: public static final Key V = new Key(KeyEvent.VK_V, true);
032: public static final Key W = new Key(KeyEvent.VK_W, true);
033: public static final Key X = new Key(KeyEvent.VK_X, true);
034: public static final Key Y = new Key(KeyEvent.VK_Y, true);
035: public static final Key Z = new Key(KeyEvent.VK_Z, true);
036: public static final Key d0 = new Key(KeyEvent.VK_0, true);
037: public static final Key d1 = new Key(KeyEvent.VK_1, true);
038: public static final Key d2 = new Key(KeyEvent.VK_2, true);
039: public static final Key d3 = new Key(KeyEvent.VK_3, true);
040: public static final Key d4 = new Key(KeyEvent.VK_4, true);
041: public static final Key d5 = new Key(KeyEvent.VK_5, true);
042: public static final Key d6 = new Key(KeyEvent.VK_6, true);
043: public static final Key d7 = new Key(KeyEvent.VK_7, true);
044: public static final Key d8 = new Key(KeyEvent.VK_8, true);
045: public static final Key d9 = new Key(KeyEvent.VK_9, true);
046: public static final Key SLASH = new Key(KeyEvent.VK_SLASH, true);
047: public static final Key BACKSLASH = new Key(KeyEvent.VK_BACK_SLASH,
048: true);
049: public static final Key EQUALS = new Key(KeyEvent.VK_EQUALS, true);
050: public static final Key ASTERISK = new Key(KeyEvent.VK_ASTERISK,
051: true);
052: public static final Key DOLLAR = new Key(KeyEvent.VK_DOLLAR, true);
053:
054: public static final Key ENTER = new Key(KeyEvent.VK_ENTER, false);
055: public static final Key DELETE = new Key(KeyEvent.VK_DELETE, false);
056: public static final Key UP = new Key(KeyEvent.VK_UP, false);
057: public static final Key DOWN = new Key(KeyEvent.VK_DOWN, false);
058: public static final Key LEFT = new Key(KeyEvent.VK_LEFT, false);
059: public static final Key RIGHT = new Key(KeyEvent.VK_RIGHT, false);
060: public static final Key PAGE_DOWN = new Key(KeyEvent.VK_PAGE_DOWN,
061: false);
062: public static final Key PAGE_UP = new Key(KeyEvent.VK_PAGE_UP,
063: false);
064: public static final Key CONTROL = new Key(KeyEvent.VK_CONTROL,
065: false);
066: public static final Key SHIFT = new Key(KeyEvent.VK_SHIFT, false);
067: public static final Key ALT = new Key(KeyEvent.VK_ALT, false);
068:
069: private int code;
070: private Modifier modifier;
071: private boolean printable;
072:
073: private Key(int code, boolean printable) {
074: this (code, Modifier.NONE, printable);
075: }
076:
077: private Key(int code, Modifier modifier, boolean printable) {
078: this .code = code;
079: this .modifier = modifier;
080: this .printable = printable;
081: }
082:
083: public static Key control(Key key) {
084: return new Key(key.getCode(), Modifier.CONTROL, false);
085: }
086:
087: public static Key alt(Key key) {
088: return new Key(key.getCode(), Modifier.ALT, false);
089: }
090:
091: public static Key shift(Key key) {
092: return new Key(key.getCode(), Modifier.SHIFT, false);
093: }
094:
095: public int getCode() {
096: return code;
097: }
098:
099: public Modifier getModifier() {
100: return modifier;
101: }
102:
103: public boolean isPrintable() {
104: return printable;
105: }
106:
107: /**
108: * Constants class for keyboard modifiers such as Control or Shift.
109: */
110: public static final class Modifier {
111: public static final Modifier CONTROL = new Modifier(
112: InputEvent.CTRL_MASK);
113: public static final Modifier SHIFT = new Modifier(
114: InputEvent.SHIFT_MASK);
115: public static final Modifier ALT = new Modifier(
116: InputEvent.ALT_MASK);
117: public static final Modifier NONE = new Modifier(0);
118:
119: private int code;
120:
121: private Modifier(int code) {
122: this .code = code;
123: }
124:
125: public int getCode() {
126: return code;
127: }
128: }
129: }
|