Changeset 838 for trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree
- Timestamp:
- 09/20/12 14:13:07 (12 years ago)
- Location:
- trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps/KeyStroke.java
r655 r838 1 1 2 package de.ugoe.cs.tasktree.keyboardmaps; 2 3 3 4 /** 4 * TODO comment 5 * <p> 6 * This class is used to define key strokes. 7 * </p> 5 8 * 6 * @version $Revision: $ $Date: 11.07.2012$7 * @author 2012, last modified by $Author: patrick$9 * @version 1.0 10 * @author Patrick Harms 8 11 */ 9 12 public class KeyStroke { 10 13 11 /** */ 14 /** 15 * <p> 16 * Name of the key stroke. 17 * </p> 18 */ 12 19 private String keyStrokeName; 13 20 14 /** */ 21 /** 22 * <p> 23 * {@link VirtualKey} associated with the key stroke. 24 * </p> 25 */ 15 26 private VirtualKey virtualKey; 16 27 17 /** */ 28 /** 29 * <p> 30 * Defines whether numlock is pressed during the stroke. 31 * </p> 32 */ 18 33 private boolean numlock; 19 34 20 /** */ 35 /** 36 * <p> 37 * Defines whether localstate is pressed during the stroke. 38 * </p> 39 */ 21 40 private boolean localstate; 22 41 23 /** */ 42 /** 43 * <p> 44 * Defines whether shift is pressed during the stroke. 45 * </p> 46 */ 24 47 private boolean shift; 25 48 26 /** */ 49 /** 50 * <p> 51 * Defines whether altgr is pressed during the stroke. 52 * </p> 53 */ 27 54 private boolean altgr; 28 55 29 /** */ 56 /** 57 * <p> 58 * Defines whether inhibit is pressed during the stroke. 59 * </p> 60 */ 30 61 private boolean inhibit; 31 62 32 /** */ 63 /** 64 * <p> 65 * Defines the character in which the key stroke results. 66 * </p> 67 */ 33 68 private char character; 34 69 35 70 /** 36 * TODO: comment 71 * <p> 72 * Constructor. Creates a new key stroke 73 * </p> 37 74 * 38 75 * @param keyStrokeName 39 * @param mapKeyIdToVirtualKey 76 * name of the key stroke 77 * @param virtualKey 78 * virtual key associated with the key stroke 40 79 * @param numlock 80 * defines whether numlock is pressed during the key stroke 41 81 * @param localstate 42 * @param b 82 * defines whether localstate is pressed during the key stroke 83 * @param shift 84 * defines whether shift is pressed during the key stroke 43 85 * @param altgr 86 * defines whether altgr is pressed during the key stroke 44 87 * @param inhibit 88 * defines whether inhibit is pressed during the key stroke 89 * @param character 90 * defines that character in which the key stroke results 45 91 */ 46 92 public KeyStroke(String keyStrokeName, … … 64 110 65 111 /** 66 * @return the keyStrokeName 112 * <p> 113 * Returns the name of the key stroke. 114 * </p> 115 * 116 * @return the name 67 117 */ 68 118 public String getKeyStrokeName() { … … 71 121 72 122 /** 73 * TODO: comment 74 * 75 * @return 123 * <p> 124 * Returns the virtual key associated with the key stroke. 125 * </p> 126 * 127 * @return the virtual key 76 128 */ 77 129 public VirtualKey getVirtualKey() { … … 80 132 81 133 /** 82 * TODO: comment 83 * 84 * @return 134 * <p> 135 * Returns the character in which the key stroke results. 136 * </p> 137 * 138 * @return the character 85 139 */ 86 140 public char getCharacter() { … … 89 143 90 144 /** 91 * TODO: comment 92 * 93 * @return 145 * <p> 146 * Returns whether inhibit is pressed. 147 * </p> 148 * 149 * @return true if pressed; false otherwise 94 150 */ 95 151 public boolean getInhibit() { … … 98 154 99 155 /** 100 * TODO: comment 101 * 102 * @return 156 * <p> 157 * Returns whether altgr is pressed. 158 * </p> 159 * 160 * @return true if pressed; false otherwise 103 161 */ 104 162 public boolean getAltgr() { … … 107 165 108 166 /** 109 * TODO: comment 110 * 111 * @return 167 * <p> 168 * Returns whether shift is pressed. 169 * </p> 170 * 171 * @return true if pressed; false otherwise 112 172 */ 113 173 public boolean getShift() { … … 116 176 117 177 /** 118 * TODO: comment 119 * 120 * @return 178 * <p> 179 * Returns whether localstate is pressed. 180 * </p> 181 * 182 * @return true if pressed; false otherwise 121 183 */ 122 184 public boolean getLocalstate() { … … 125 187 126 188 /** 127 * TODO: comment 128 * 129 * @return 189 * <p> 190 * Returns whether numlock is pressed. 191 * </p> 192 * 193 * @return true if pressed; false otherwise 130 194 */ 131 195 public boolean getNumlock() { -
trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps/KeyboardMap.java
r725 r838 1 1 2 package de.ugoe.cs.tasktree.keyboardmaps; 2 3 … … 16 17 17 18 /** 18 * TODO comment 19 * <p> 20 * Helper class that maps keyboard input based on a key map. 21 * </p> 19 22 * 20 * @version $Revision: $ $Date: 11.07.2012$21 * @author 2012, last modified by $Author: patrick$23 * @version 1.0 24 * @author Patrick Harms 22 25 */ 23 26 public class KeyboardMap { 24 27 25 /** */ 28 /** 29 * <p> 30 * Locale used for the mapping. 31 * </p> 32 */ 26 33 private Locale locale; 27 34 28 /** */ 35 /** 36 * <p> 37 * Name of the mappings-file. 38 * </p> 39 */ 29 40 private String fileName; 30 41 31 /** */ 42 /** 43 * <p> 44 * Map that defines which key strokes define a virtual key. 45 * </p> 46 */ 32 47 private Map<VirtualKey, List<KeyStroke>> keyStrokes = 33 48 new HashMap<VirtualKey, List<KeyStroke>>(); 34 49 35 /** TODO: remove this stuff */36 private List<Object[]> mKeyIds = new ArrayList<Object[]>();37 38 50 /** 39 * TODO: comment 51 * <p> 52 * Creates a new KeyboardMap. 53 * </p> 40 54 * 41 55 * @param locale 56 * Locale that is used for the keyboard map 42 57 */ 43 58 KeyboardMap(Locale locale) { … … 58 73 59 74 /** 60 * TODO: comment 75 * <p> 76 * Returns a character that is generated, given a {@link VirtualKey} is pressed while the 77 * respective modifiers are active. 78 * </p> 61 79 * 62 * @param digit1 63 * @param b 64 * @param c 65 * @param d 66 * @param e 67 * @param f 68 * @return 80 * @param key 81 * key that is pressed 82 * @param numlock 83 * true, if numlock is pressed; false otherwise 84 * @param shift 85 * true, if shift is pressed; false otherwise 86 * @param altgr 87 * true, if altgr is pressed; false otherwise 88 * @param inhibit 89 * true, if inhibit is pressed; false otherwise 90 * @return generated character 69 91 */ 70 92 public char getCharacterFor(VirtualKey key, 71 boolean numlock, 72 boolean shift, 73 boolean altgr, 74 boolean inhibit) 75 throws IllegalArgumentException 93 boolean numlock, 94 boolean shift, 95 boolean altgr, 96 boolean inhibit) 76 97 { 77 98 List<KeyStroke> candidates = keyStrokes.get(key); … … 104 125 105 126 /** 106 * TODO: comment107 127 * 128 * <p> 129 * Initializes the keyboard map. 130 * </p> 131 * 132 * @throws IllegalArgumentException thrown if there is a problem loading the keyboard map 108 133 */ 109 134 void init() throws IllegalArgumentException { … … 115 140 116 141 Console.traceln(Level.FINER, "read " + keyStrokes.size() + " key strokes and " + 117 142 deadKeySequences.size() + " dead key sequences"); 118 143 119 144 VirtualKeySynonyms virtualKeySynonyms = determineVirtualKeySynonyms(keyStrokes); 120 145 processKeyStrokes(keyStrokes, virtualKeySynonyms); 121 processDeadKeySequences(deadKeySequences); 122 123 for (Object[] keyId : mKeyIds) { 124 System.out.println(Integer.toHexString((Integer) keyId[0]) + " " + keyId[1]); 125 } 146 // TODO still required? processDeadKeySequences(deadKeySequences); 126 147 } 127 148 128 149 /** 129 * TODO: comment 150 * <p> 151 * Returns a {@link InputStream} for a given filename. 152 * </p> 130 153 * 131 * @param fileName 132 * @return 154 * @param name 155 * the filename 156 * @return the {@link InputStream} 133 157 */ 134 158 private InputStream getStream(String name) { 135 Console.traceln 136 (Level.FINER, "reading keymap for locale " + locale +" from resource keymaps/" + name);159 Console.traceln(Level.FINER, "reading keymap for locale " + locale + 160 " from resource keymaps/" + name); 137 161 138 162 InputStream stream = … … 147 171 148 172 /** 149 * TODO: comment 173 * <p> 174 * Reads a keyboard map from a input stream. 175 * </p> 150 176 * 151 177 * @param stream 152 * @param virtualKeySynonyms178 * input stream with the keyboard map 153 179 * @param deadKeySequences 180 * the dead key sequences 181 * @param keyStrokes 182 * the keystrokes 183 * @throws IllegalArgumentException 184 * thrown if there is an error reading the keyboard map 154 185 */ 155 private void readStream(InputStream 186 private void readStream(InputStream stream, 156 187 List<String[]> deadKeySequences, 157 List<String[]> keyStrokes) 158 throws IllegalArgumentException 188 List<String[]> keyStrokes) throws IllegalArgumentException 159 189 { 160 190 BufferedReader in = null; … … 164 194 catch (UnsupportedEncodingException e) { 165 195 Console.traceln(Level.WARNING, "no keyboard map available for locale " + locale); 166 throw new IllegalArgumentException 167 ("provided stream can not be read due to invalid encoding",e);196 throw new IllegalArgumentException("provided stream can not be read due to invalid encoding", 197 e); 168 198 } 169 199 … … 185 215 } 186 216 catch (IOException e) { 187 Console.traceln 188 (Level.WARNING,"could not close input stream for reading keyboard map");217 Console.traceln(Level.WARNING, 218 "could not close input stream for reading keyboard map"); 189 219 } 190 220 } … … 192 222 193 223 /** 194 * TODO: comment 224 * <p> 225 * Processes a line of a keyboard map file. 226 * </p> 195 227 * 196 228 * @param line 229 * the line in the keyboard map file 197 230 * @param deadKeySequences 231 * the dead key sequences 232 * @param keyStrokes 233 * the keystrokes 198 234 */ 199 private void processLine(String line, 200 List<String[]> deadKeySequences, 201 List<String[]> keyStrokes) 235 private void processLine(String line, List<String[]> deadKeySequences, List<String[]> keyStrokes) 202 236 { 203 237 String[] values = line.split(" "); … … 251 285 252 286 /** 253 * TODO: comment 287 * <p> 288 * Determines synonyms for virtual keys for the keyboard map. 289 * </p> 254 290 * 255 291 * @param keyStrokes 256 * @return 292 * the keystrokes 293 * @return the synonyms 257 294 */ 258 295 private VirtualKeySynonyms determineVirtualKeySynonyms(List<String[]> keyStrokes) { … … 291 328 292 329 /** 293 * TODO: comment 330 * <p> 331 * Converts a hexadecimal Id that is contained in a string into the integer Id of the key. 332 * </p> 294 333 * 295 * @param string 296 * @return 334 * @param keyIdString 335 * the Id string 336 * @return the Id as integer 297 337 */ 298 338 private int getKeyId(String keyIdString) { … … 305 345 306 346 /** 307 * TODO: comment 347 * <p> 348 * Processes a list of key strokes. 349 * </p> 308 350 * 309 351 * @param keyStrokes 352 * the key strokes 310 353 * @param virtualKeySynonyms 354 * synonyms of the involved virtual keys 311 355 */ 312 356 private void processKeyStrokes(List<String[]> keyStrokes, VirtualKeySynonyms virtualKeySynonyms) … … 320 364 321 365 /** 322 * TODO: comment 366 * <p> 367 * Handles a key stroke. 368 * </p> 323 369 * 324 370 * @param values 371 * contains the name, string Id, and modifiers of the key stroke 372 * @param virtualKeySynonyms 373 * synonyms of the involved virtual keys 325 374 */ 326 375 private void handleKeyStroke(String[] values, VirtualKeySynonyms virtualKeySynonyms) { … … 379 428 380 429 /** 381 * TODO: comment 430 * <p> 431 * Adds a key stroke and all synonyms to the keyboard map. 432 * </p> 382 433 * 383 434 * @param keyStrokeName 435 * name of the key stroke 384 436 * @param keyId 437 * id of the key stroke 385 438 * @param numlock 439 * true, if numlock is pressed; false otherwise 386 440 * @param localstate 441 * true, if localstate is pressed; false otherwise 387 442 * @param shift 443 * true, if shift is pressed; false otherwise 388 444 * @param altgr 445 * true, if altgr is pressed; false otherwise 389 446 * @param addupper 447 * true, if addupper is pressed; false otherwise 390 448 * @param inhibit 449 * true, if inhibit is pressed; false otherwise 450 * @param virtualKeySynonyms 451 * synonyms of the involved virtual keys 391 452 */ 392 private void addAllRepresentedKeyStrokes(String 393 int 394 boolean 395 boolean 396 boolean 397 boolean 398 boolean 399 boolean 453 private void addAllRepresentedKeyStrokes(String keyStrokeName, 454 int keyId, 455 boolean numlock, 456 boolean localstate, 457 boolean shift, 458 boolean altgr, 459 boolean addupper, 460 boolean inhibit, 400 461 VirtualKeySynonyms virtualKeySynonyms) 401 462 { … … 404 465 if (virtualKeys == null) { 405 466 Console.traceln(Level.SEVERE, "no virtual key mapped to key stroke " + keyStrokeName + 406 " of keyboard map for locale " + locale); 407 // throw new IllegalArgumentException("no keyboard map available for locale " + 408 // mLocale); 467 " of keyboard map for locale " + locale); 409 468 return; 410 469 } … … 413 472 if (addupper) { 414 473 char c = determineCharacter(keyStrokeName, true); 415 addKeyStroke 416 (keyStrokeName, virtualKey, numlock, localstate, true, altgr, inhibit,c);474 addKeyStroke(keyStrokeName, virtualKey, numlock, localstate, true, altgr, inhibit, 475 c); 417 476 418 477 c = determineCharacter(keyStrokeName, false); 419 addKeyStroke 420 (keyStrokeName, virtualKey, numlock, localstate, false, altgr, inhibit,c);478 addKeyStroke(keyStrokeName, virtualKey, numlock, localstate, false, altgr, inhibit, 479 c); 421 480 } 422 481 else { 423 482 char c = determineCharacter(keyStrokeName, false); 424 addKeyStroke 425 (keyStrokeName, virtualKey, numlock, localstate, shift, altgr, inhibit,c);483 addKeyStroke(keyStrokeName, virtualKey, numlock, localstate, shift, altgr, inhibit, 484 c); 426 485 } 427 486 } … … 429 488 430 489 /** 431 * TODO: comment 490 * <p> 491 * Adds a key stroke and to the keyboard map. 492 * </p> 432 493 * 433 * @param keyStroke 494 * @param keyStrokeName 495 * name of the key stroke 496 * @param virtualKey 497 * the associated virtual key 498 * @param numlock 499 * true, if numlock is pressed; false otherwise 500 * @param localstate 501 * true, if localstate is pressed; false otherwise 502 * @param shift 503 * true, if shift is pressed; false otherwise 504 * @param altgr 505 * true, if altgr is pressed; false otherwise 506 * @param addupper 507 * true, if addupper is pressed; false otherwise 508 * @param inhibit 509 * true, if inhibit is pressed; false otherwise 510 * @param character 511 * the resulting character 434 512 */ 435 private void addKeyStroke(String 513 private void addKeyStroke(String keyStrokeName, 436 514 VirtualKey virtualKey, 437 boolean 438 boolean 439 boolean 440 boolean 441 boolean 442 char 515 boolean numlock, 516 boolean localstate, 517 boolean shift, 518 boolean altgr, 519 boolean inhibit, 520 char character) 443 521 { 444 KeyStroke keyStroke = new KeyStroke 445 (keyStrokeName, virtualKey, numlock, localstate, shift, altgr, inhibit, character); 522 KeyStroke keyStroke = 523 new KeyStroke(keyStrokeName, virtualKey, numlock, localstate, shift, altgr, inhibit, 524 character); 446 525 447 526 List<KeyStroke> keyStrokeList = keyStrokes.get(keyStroke.getVirtualKey()); … … 456 535 457 536 /** 458 * TODO: comment 459 * 537 * <p> 538 * Adds key strokes independent of numlock. 539 * </p> 460 540 */ 461 541 private void addKeyStrokesIndependentOfNumLock() { … … 492 572 493 573 /** 494 * TODO: comment 495 * 496 * @param deadKeySequences 497 */ 498 private void processDeadKeySequences(List<String[]> deadKeySequences) { 499 // TODO Auto-generated method stub 500 // System.out.println("PATRICK: KeyboardMap.processDeadKeySequences "); 501 } 502 503 /** 504 * TODO: comment 574 * <p> 575 * Determines a {@link VirtualKey} depending on a key stroke name 576 * </p> 505 577 * 506 578 * @param keyStrokeName 507 * @param shift508 * @return 579 * name of the key stroke 580 * @return related virtual key 509 581 */ 510 582 private VirtualKey determineVirtualKey(String keyStrokeName) { … … 1021 1093 else { 1022 1094 Console.traceln(Level.FINEST, "unknown virtual key for key stroke " + keyStrokeName + 1023 1095 " specified through " + "keyboard map for locale " + locale); 1024 1096 1025 1097 return null; … … 1053 1125 1054 1126 /** 1055 * TODO: comment 1056 * 1057 * @param keyStrokeName 1058 * @param shift 1059 * @return 1127 * <p> 1128 * Determines the character that is generated by a key stroke. 1129 * </p> 1130 * 1131 * @param keyStrokeName name of the key stroke 1132 * @param getUpper defines whether the upper case version of the key stroke is returned or not 1133 * @return the character 1060 1134 */ 1061 1135 private char determineCharacter(String keyStrokeName, boolean getUpper) { … … 2042 2116 } 2043 2117 } 2044 2045 /**2046 * this is a former implementation2047 *2048 * @param keyId2049 * @return2050 */2051 /*2052 * private VirtualKey[] mapKeyIdToVirtualKeys(int keyId, String keyStrokeName) {2053 *2054 * Set<String> names = null;2055 *2056 * for (int i = 0; i < mKeyIds.size(); i++) { if (((Integer) mKeyIds.get(i)[0]) == keyId) {2057 * names = (Set<String>) mKeyIds.get(i)[1]; break; } }2058 *2059 * if (names == null) { names = new HashSet<String>(); boolean added = false;2060 *2061 * for (int i = 0; i < mKeyIds.size(); i++) { if (((Integer) mKeyIds.get(i)[0]) > keyId) {2062 * mKeyIds.add(i, new Object[] { keyId, names }); added = true; break; } }2063 *2064 * if (!added) { mKeyIds.add(new Object[] { keyId, names }); } }2065 *2066 * names.add(keyStrokeName);2067 *2068 *2069 * switch(keyId) { case 0x36: case 0x2a: return new VirtualKey[] { VirtualKey.SHIFT }; case2070 * 0xb8: return new VirtualKey[] { VirtualKey.ALT_GRAPH }; case 0x38: return new VirtualKey[] {2071 * VirtualKey.ALT }; case 0x9d: case 0x1d: return new VirtualKey[] { VirtualKey.CONTROL }; case2072 * 0xdd: return new VirtualKey[] { VirtualKey.WINDOWS }; case 0x2: return new VirtualKey[] {2073 * VirtualKey.DIGIT_1 }; case 0x3: return new VirtualKey[] { VirtualKey.DIGIT_2 }; case 0x4:2074 * return new VirtualKey[] { VirtualKey.DIGIT_3 }; case 0x5: return new VirtualKey[] {2075 * VirtualKey.DIGIT_4 }; case 0x6: return new VirtualKey[] { VirtualKey.DIGIT_5 }; case 0x7:2076 * return new VirtualKey[] { VirtualKey.DIGIT_6 }; case 0x8: return new VirtualKey[] {2077 * VirtualKey.DIGIT_7 }; case 0x9: return new VirtualKey[] { VirtualKey.DIGIT_8 }; case 0xa:2078 * return new VirtualKey[] { VirtualKey.DIGIT_9 }; case 0xb: return new VirtualKey[] {2079 * VirtualKey.DIGIT_0 }; case 0xe: return new VirtualKey[] { VirtualKey.BACK_SPACE }; case 0xf:2080 * return new VirtualKey[] { VirtualKey.TAB }; case 0x10: return new VirtualKey[] {2081 * VirtualKey.LETTER_Q }; case 0x11: return new VirtualKey[] { VirtualKey.LETTER_W }; case 0x12:2082 * return new VirtualKey[] { VirtualKey.LETTER_E }; case 0x13: return new VirtualKey[] {2083 * VirtualKey.LETTER_R }; case 0x14: return new VirtualKey[] { VirtualKey.LETTER_T }; case 0x15:2084 * return new VirtualKey[] { VirtualKey.LETTER_Y }; case 0x16: return new VirtualKey[] {2085 * VirtualKey.LETTER_U }; case 0x17: return new VirtualKey[] { VirtualKey.LETTER_I }; case 0x18:2086 * return new VirtualKey[] { VirtualKey.LETTER_O }; case 0x19: return new VirtualKey[] {2087 * VirtualKey.LETTER_P }; case 0x1e: return new VirtualKey[] { VirtualKey.LETTER_A }; case 0x1f:2088 * return new VirtualKey[] { VirtualKey.LETTER_S }; case 0x20: return new VirtualKey[] {2089 * VirtualKey.LETTER_D }; case 0x21: return new VirtualKey[] { VirtualKey.LETTER_F }; case 0x22:2090 * return new VirtualKey[] { VirtualKey.LETTER_G }; case 0x23: return new VirtualKey[] {2091 * VirtualKey.LETTER_H }; case 0x24: return new VirtualKey[] { VirtualKey.LETTER_J }; case 0x25:2092 * return new VirtualKey[] { VirtualKey.LETTER_K }; case 0x26: return new VirtualKey[] {2093 * VirtualKey.LETTER_L }; case 0x1c: return new VirtualKey[] { VirtualKey.ENTER }; case 0x2c:2094 * return new VirtualKey[] { VirtualKey.LETTER_Z }; case 0x2d: return new VirtualKey[] {2095 * VirtualKey.LETTER_X }; case 0x2e: return new VirtualKey[] { VirtualKey.LETTER_C }; case 0x2f:2096 * return new VirtualKey[] { VirtualKey.LETTER_V }; case 0x30: return new VirtualKey[] {2097 * VirtualKey.LETTER_B }; case 0x31: return new VirtualKey[] { VirtualKey.LETTER_N }; case 0x32:2098 * return new VirtualKey[] { VirtualKey.LETTER_M }; case 0x39: return new VirtualKey[] {2099 * VirtualKey.SPACE }; case 0x56: return new VirtualKey[] { VirtualKey.LESS }; case 0x1: return2100 * new VirtualKey[] { VirtualKey.ESCAPE }; case 0x3b: return new VirtualKey[] { VirtualKey.F1 };2101 * case 0x3c: return new VirtualKey[] { VirtualKey.F2 }; case 0x3d: return new VirtualKey[] {2102 * VirtualKey.F3 }; case 0x3e: return new VirtualKey[] { VirtualKey.F4 }; case 0x3f: return new2103 * VirtualKey[] { VirtualKey.F5 }; case 0x40: return new VirtualKey[] { VirtualKey.F6 }; case2104 * 0x41: return new VirtualKey[] { VirtualKey.F7 }; case 0x42: return new VirtualKey[] {2105 * VirtualKey.F8 }; case 0x43: return new VirtualKey[] { VirtualKey.F9 }; case 0x44: return new2106 * VirtualKey[] { VirtualKey.F10 }; case 0x57: return new VirtualKey[] { VirtualKey.F11 }; case2107 * 0x58: return new VirtualKey[] { VirtualKey.F12 }; case 0xb7: return new VirtualKey[] {2108 * VirtualKey.PRINTSCREEN }; case 0x46: return new VirtualKey[] { VirtualKey.SCROLL_LOCK }; case2109 * 0xd2: return new VirtualKey[] { VirtualKey.INSERT }; case 0xd3: return new VirtualKey[] {2110 * VirtualKey.DELETE }; case 0xc7: return new VirtualKey[] { VirtualKey.HOME }; case 0xcf:2111 * return new VirtualKey[] { VirtualKey.END }; case 0xc9: return new VirtualKey[] {2112 * VirtualKey.PAGE_UP }; case 0xd1: return new VirtualKey[] { VirtualKey.PAGE_DOWN }; case 0xcb:2113 * return new VirtualKey[] { VirtualKey.LEFT }; case 0xc8: return new VirtualKey[] {2114 * VirtualKey.UP }; case 0xd0: return new VirtualKey[] { VirtualKey.DOWN }; case 0xcd: return2115 * new VirtualKey[] { VirtualKey.RIGHT }; case 0x45: return new VirtualKey[] {2116 * VirtualKey.NUM_LOCK }; case 0xb5: return new VirtualKey[] { VirtualKey.DIVIDE }; case 0x37:2117 * return new VirtualKey[] { VirtualKey.MULTIPLY }; case 0x4a: return new VirtualKey[] {2118 * VirtualKey.SUBTRACT }; case 0x4e: return new VirtualKey[] { VirtualKey.ADD }; case 0x9c:2119 * return new VirtualKey[] { VirtualKey.ENTER }; case 0x53: return new VirtualKey[] {2120 * VirtualKey.DECIMAL, VirtualKey.DELETE }; case 0x52: return new VirtualKey[] {2121 * VirtualKey.NUMPAD_0, VirtualKey.INSERT }; case 0x4f: return new VirtualKey[] {2122 * VirtualKey.NUMPAD_1, VirtualKey.END }; case 0x50: return new VirtualKey[] {2123 * VirtualKey.NUMPAD_2, VirtualKey.KP_DOWN }; case 0x51: return new VirtualKey[] {2124 * VirtualKey.NUMPAD_3, VirtualKey.PAGE_UP }; case 0x4b: return new VirtualKey[] {2125 * VirtualKey.NUMPAD_4, VirtualKey.KP_LEFT }; case 0x4c: return new VirtualKey[] {2126 * VirtualKey.NUMPAD_5, VirtualKey.BEGIN }; case 0x4d: return new VirtualKey[] {2127 * VirtualKey.NUMPAD_6, VirtualKey.KP_RIGHT }; case 0x47: return new VirtualKey[] {2128 * VirtualKey.NUMPAD_7, VirtualKey.HOME }; case 0x48: return new VirtualKey[] {2129 * VirtualKey.NUMPAD_8, VirtualKey.KP_UP }; case 0x49: return new VirtualKey[] {2130 * VirtualKey.NUMPAD_9, VirtualKey.PAGE_DOWN }; case 0x0: return new VirtualKey[] {2131 * VirtualKey.CAPS_LOCK }; case 0xc: return new VirtualKey[] { VirtualKey.MINUS,2132 * VirtualKey.UNDERSCORE }; case 0xd: return new VirtualKey[] { VirtualKey.EQUALS,2133 * VirtualKey.PLUS }; case 0x1a: return new VirtualKey[] { VirtualKey.OPEN_BRACKET,2134 * VirtualKey.BRACELEFT }; case 0x1b: return new VirtualKey[] { VirtualKey.CLOSE_BRACKET,2135 * VirtualKey.BRACERIGHT }; case 0x27: return new VirtualKey[] { VirtualKey.SEMICOLON,2136 * VirtualKey.COLON }; /* case 0x28: return new VirtualKey[] { VirtualKey.APOSTROPHE,2137 * VirtualKey.QUOTEDBL }; case 0x29: return new VirtualKey[] { VirtualKey.DEAD_GRAVE,2138 * VirtualKey.DEAD_TILDE }; case 0x2b: return new VirtualKey[] { VirtualKey.BACK_SLASH,2139 * VirtualKey.BAR }; case 0x33: return new VirtualKey[] { VirtualKey.COMMA, VirtualKey.LESS };2140 * case 0x34: return new VirtualKey[] { VirtualKey.PERIOD, VirtualKey.GREATER }; case 0x35:2141 * return new VirtualKey[] { VirtualKey.SLASH, VirtualKey.QUESTIONMARK }; case 0x73: return new2142 * VirtualKey[] { VirtualKey.BACK_SLASH, VirtualKey.DEGREE, VirtualKey.QUESTIONMARK,2143 * VirtualKey.UNDERSCORE }; case 0x7d: return new VirtualKey[] { VirtualKey.BAR }; case 0x79:2144 * return new VirtualKey[] { VirtualKey.HENKAN_MODE }; case 0x70: return new VirtualKey[] {2145 * VirtualKey.KATAKANA }; case 0x7b: return new VirtualKey[] { VirtualKey.MUHENKAN }; case 0x3a:2146 * return new VirtualKey[] { VirtualKey.EISU_TOGGLE, VirtualKey.CAPS_LOCK }; case 0xdc: return2147 * new VirtualKey[] { VirtualKey.F13 }; case 0xf2: return new VirtualKey[] { VirtualKey.HANGUL2148 * }; case 0xf1: return new VirtualKey[] { VirtualKey.HANGUL_HANJA }; case 0x54: return new2149 * VirtualKey[] { VirtualKey.EXECUTE }; default: LOG.severe("unknown key id 0x" +2150 * Integer.toHexString(keyId) + " specified for key stroke " + keyStrokeName +2151 * " through keyboard map for locale " + mLocale); throw new2152 * IllegalArgumentException("no keyboard map available for locale " + mLocale); } }2153 */2154 2155 2118 } -
trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps/KeyboardMapFactory.java
r655 r838 4 4 5 5 /** 6 * TODO comment 6 * <p> 7 * Creates keyboard maps. 8 * </p> 7 9 * 8 * @version $Revision: $ $Date: 11.07.2012$9 * @author 2012, last modified by $Author: patrick$10 * @version 1.0 11 * @author Patrick Harms 10 12 */ 11 13 public class KeyboardMapFactory { 12 14 13 15 /** 14 * TODO: comment 15 * 16 * <p> 17 * Constructor. Private to prevent initialization of this class. 18 * </p> 16 19 */ 17 20 private KeyboardMapFactory() { 18 // TODO Auto-generated constructor stub19 21 } 20 22 21 23 /** 22 * TODO: comment 23 * 24 * <p> 25 * Returns a {@link KeyboardMap} for the given {@link Locale}. 26 * </p> 27 * 28 * @param locale the locale 29 * @return the keyboard map 24 30 */ 25 31 public static KeyboardMap createKeyboardMap(Locale locale) { -
trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps/VirtualKey.java
r655 r838 4 4 5 5 /** 6 * TODO comment 6 * <p> 7 * Enumeration of virtual keys. 8 * </p> 7 9 * 8 * @version $Revision: $ $Date: 01.04.2012$9 * @author 2012, last modified by $Author: patrick$10 * @version 1.0 11 * @author Patrick Harms 10 12 */ 11 13 public enum VirtualKey { … … 233 235 */ 234 236 235 /** the virtual key code of the virtual key. */ 237 /** 238 * <p> 239 * Virtual key code of the virtual key. 240 * </p> 241 */ 236 242 private int virtualKeyCode = -1; 237 243 238 /** the description of the virtual key */ 244 /** 245 * <p> 246 * Description of the virtual key. 247 * </p> 248 */ 239 249 private String description; 240 250 241 251 /** 242 * 243 */ 252 * <p> 253 * Constructor. Creates a new VirtualKey. 254 * </p> 255 * 256 * @param virtualKeyCode 257 * key code of the virtual key 258 */ 244 259 private VirtualKey(int virtualKeyCode) { 245 260 this.virtualKeyCode = virtualKeyCode; … … 248 263 249 264 /** 250 * @return Returns the description. 265 * <p> 266 * Returns the description of the virtual key. 267 * </p> 268 * 269 * @return the description. 251 270 */ 252 271 String getDescription() { … … 255 274 256 275 /** 257 * 258 */ 276 * <p> 277 * Returns whether the key is a combination key (e.g., shift, alt) or not. 278 * </p> 279 * 280 * @return true, if the key is a combiniation key; false otherwise 281 */ 259 282 public boolean isCombinationKey() { 260 283 switch (this) … … 273 296 274 297 /** 275 * 276 */ 298 * <p> 299 * Returns whether the key is a lock key (e.g., caps lock, num lock) or not. 300 * </p> 301 * 302 * @return true, if the key is a lock key; false otherwise 303 */ 277 304 public boolean isLockKey() { 278 305 switch (this) … … 289 316 290 317 /** 291 * 292 */ 318 * <p> 319 * Returns whether the key is shift. 320 * </p> 321 * 322 * @return true, if the key is shift; false otherwise 323 */ 293 324 public boolean isShiftKey() { 294 325 switch (this) … … 303 334 304 335 /** 305 * 306 */ 336 * <p> 337 * Returns whether the is an alt key. 338 * </p> 339 * 340 * @return true, if the key is alt or altgr; false otherwise 341 */ 307 342 public boolean isAltKey() { 308 343 switch (this) … … 318 353 319 354 /** 320 * 321 */ 355 * <p> 356 * Returns whether the key is control. 357 * </p> 358 * 359 * @return true, if the key is control; false otherwise 360 */ 322 361 public boolean isControlKey() { 323 362 switch (this) … … 332 371 333 372 /** 334 * 335 */ 373 * <p> 374 * Returns whether the key is the windows key. 375 * </p> 376 * 377 * @return true, if the key is the windows key; false otherwise 378 */ 336 379 public boolean isWindowsKey() { 337 380 switch (this) … … 346 389 347 390 /** 348 * 349 */ 391 * <p> 392 * Returns whether the key is the meta key. 393 * </p> 394 * 395 * @return true, if the key is the meta key; false otherwise 396 */ 350 397 public boolean isMetaKey() { 351 398 switch (this) … … 360 407 361 408 /** 362 * 363 */ 409 * <p> 410 * Returns whether the key is a letter. 411 * </p> 412 * 413 * @return true, if the key is a letter; false otherwise 414 */ 364 415 public boolean isLetter() { 365 416 if (virtualKeyCode > -1) { … … 372 423 373 424 /** 374 * 375 */ 425 * <p> 426 * Returns whether the key is a digit. 427 * </p> 428 * 429 * @return true, if the key is a digit; false otherwise 430 */ 376 431 public boolean isDigit() { 377 432 if (virtualKeyCode > -1) { … … 384 439 385 440 /** 386 * TODO: comment 387 * 388 * @param parameter 389 * @return 441 * <p> 442 * Parses an {@link String} and returns the respective VirtualKey if possible. 443 * </p> 444 * 445 * @param numberString 446 * String representation of the virtual key 447 * @return created VirtualKey 448 * @throws IllegalArgumentException 449 * thrown if there is no VirtualKey that correlates to string 390 450 */ 391 451 public static VirtualKey parseVirtualKey(String string) { … … 401 461 402 462 /** 403 * 404 */ 463 * <p> 464 * Returns the VirtualKey associated with an integer. 465 * </p> 466 * 467 * @param number 468 * integer to which the according VirtualKey is returned 469 * @return the VirtualKey 470 * @throws IllegalArgumentException 471 * thrown if there is no VirtualKey that correlates to number 472 */ 405 473 public static VirtualKey valueOf(int number) { 406 474 for (VirtualKey virtualKey : VirtualKey.values()) { -
trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps/VirtualKeySynonyms.java
r725 r838 1 1 2 package de.ugoe.cs.tasktree.keyboardmaps; 2 3 … … 10 11 11 12 /** 12 * TODO comment 13 * <p> 14 * Helper class to handle synonymous {@link VirtualKey}s. 15 * </p> 13 16 * 14 * @version $Revision: $ $Date: 12.07.2012$15 * @author 2012, last modified by $Author: pharms$17 * @version 1.0 18 * @author Patrick Harms 16 19 */ 17 20 class VirtualKeySynonyms { 18 19 /** */ 21 22 /** 23 * <p> 24 * Map of synonymous keys. 25 * </p> 26 */ 20 27 private Map<Integer, List<VirtualKey>> synonyms = new HashMap<Integer, List<VirtualKey>>(); 21 28 22 /** */ 29 /** 30 * <p> 31 * Mapping of {@link VirtualKey}s to integer Ids. 32 * </p> 33 */ 23 34 private Map<VirtualKey, Integer> keyIds = new HashMap<VirtualKey, Integer>(); 24 35 25 36 /** 26 * TODO: comment 37 * <p> 38 * Adds a new synonymous key. 39 * </p> 27 40 * 28 41 * @param keyId 42 * id of the synonym 29 43 * @param virtualKey 44 * the synonym 30 45 */ 31 46 public void add(int keyId, VirtualKey virtualKey) { … … 46 61 if ((existingKeyId != null) && (existingKeyId != keyId)) { 47 62 Console.traceln(Level.FINEST, "virtual key " + virtualKey + " is mapped to more " + 48 49 63 "than one key id (current is " + existingKeyId + ", new is " + keyId + 64 "). New key id will be used (" + keyId + ")."); 50 65 } 51 66 … … 54 69 55 70 /** 56 * 57 */ 71 * <p> 72 * Returns whether a key is contained in the set of synonyms. 73 * </p> 74 * 75 * @param keyId 76 * id of the key 77 * @return true, if the key is contained; false otherwise 78 */ 58 79 public boolean containsKey(int keyId) { 59 80 return synonyms.containsKey(keyId); … … 61 82 62 83 /** 63 * TODO: comment 84 * <p> 85 * Returns all synonyms known for a given key. 86 * </p> 64 87 * 65 88 * @param keyId 66 * @return 89 * the id of the key 90 * @return the synonyms 67 91 */ 68 92 public VirtualKey[] getVirtualKeySynonyms(int keyId) {
Note: See TracChangeset
for help on using the changeset viewer.