Changeset 558 for trunk/quest-misc/src/main/java/de/ugoe
- Timestamp:
- 08/17/12 08:52:45 (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
r447 r558 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: KeyStroke.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: patrick $ $Date: 11.07.2012 $ … … 5 4 // Creation : 2012 by patrick 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 7 8 8 package de.ugoe.cs.tasktree.keyboardmaps; 9 9 10 //-------------------------------------------------------------------------------------------------11 10 /** 12 11 * TODO comment … … 15 14 * @author 2012, last modified by $Author: patrick$ 16 15 */ 17 //------------------------------------------------------------------------------------------------- 18 public class KeyStroke 19 { 16 public class KeyStroke { 20 17 21 /** */22 private String mKeyStrokeName;18 /** */ 19 private String keyStrokeName; 23 20 24 /** */25 private VirtualKey mVirtualKey;21 /** */ 22 private VirtualKey virtualKey; 26 23 27 /** */28 private boolean mNumlock;24 /** */ 25 private boolean numlock; 29 26 30 /** */31 private boolean mLocalstate;27 /** */ 28 private boolean localstate; 32 29 33 /** */34 private boolean mShift;30 /** */ 31 private boolean shift; 35 32 36 /** */37 private boolean mAltgr;33 /** */ 34 private boolean altgr; 38 35 39 /** */40 private boolean mInhibit;36 /** */ 37 private boolean inhibit; 41 38 42 /** */43 private char mCharacter;39 /** */ 40 private char character; 44 41 45 //----------------------------------------------------------------------------------------------- 46 /** 47 * TODO: comment 48 * 49 * @param keyStrokeName 50 * @param mapKeyIdToVirtualKey 51 * @param numlock 52 * @param localstate 53 * @param b 54 * @param altgr 55 * @param inhibit 56 */ 57 //----------------------------------------------------------------------------------------------- 58 public KeyStroke(String keyStrokeName, 59 VirtualKey virtualKey, 60 boolean numlock, 61 boolean localstate, 62 boolean shift, 63 boolean altgr, 64 boolean inhibit, 65 char character) 66 { 67 mKeyStrokeName = keyStrokeName; 68 mVirtualKey = virtualKey; 69 mNumlock = numlock; 70 mLocalstate = localstate; 71 mShift = shift; 72 mAltgr = altgr; 73 mInhibit = inhibit; 74 mCharacter = character; 75 } 42 /** 43 * TODO: comment 44 * 45 * @param keyStrokeName 46 * @param mapKeyIdToVirtualKey 47 * @param numlock 48 * @param localstate 49 * @param b 50 * @param altgr 51 * @param inhibit 52 */ 53 public KeyStroke(String keyStrokeName, 54 VirtualKey virtualKey, 55 boolean numlock, 56 boolean localstate, 57 boolean shift, 58 boolean altgr, 59 boolean inhibit, 60 char character) 61 { 62 this.keyStrokeName = keyStrokeName; 63 this.virtualKey = virtualKey; 64 this.numlock = numlock; 65 this.localstate = localstate; 66 this.shift = shift; 67 this.altgr = altgr; 68 this.inhibit = inhibit; 69 this.character = character; 70 } 76 71 77 //----------------------------------------------------------------------------------------------- 78 /** 79 * @return the keyStrokeName 80 */ 81 //----------------------------------------------------------------------------------------------- 82 public String getKeyStrokeName() 83 { 84 return mKeyStrokeName; 85 } 72 /** 73 * @return the keyStrokeName 74 */ 75 public String getKeyStrokeName() { 76 return keyStrokeName; 77 } 86 78 87 //----------------------------------------------------------------------------------------------- 88 /** 89 * TODO: comment 90 * 91 * @return 92 */ 93 //----------------------------------------------------------------------------------------------- 94 public VirtualKey getVirtualKey() 95 { 96 return mVirtualKey; 97 } 79 /** 80 * TODO: comment 81 * 82 * @return 83 */ 84 public VirtualKey getVirtualKey() { 85 return virtualKey; 86 } 98 87 99 //----------------------------------------------------------------------------------------------- 100 /** 101 * TODO: comment 102 * 103 * @return 104 */ 105 //----------------------------------------------------------------------------------------------- 106 public char getCharacter() 107 { 108 return mCharacter; 109 } 88 /** 89 * TODO: comment 90 * 91 * @return 92 */ 93 public char getCharacter() { 94 return character; 95 } 110 96 111 //----------------------------------------------------------------------------------------------- 112 /** 113 * TODO: comment 114 * 115 * @return 116 */ 117 //----------------------------------------------------------------------------------------------- 118 public boolean getInhibit() 119 { 120 return mInhibit; 121 } 97 /** 98 * TODO: comment 99 * 100 * @return 101 */ 102 public boolean getInhibit() { 103 return inhibit; 104 } 122 105 123 //----------------------------------------------------------------------------------------------- 124 /** 125 * TODO: comment 126 * 127 * @return 128 */ 129 //----------------------------------------------------------------------------------------------- 130 public boolean getAltgr() 131 { 132 return mAltgr; 133 } 106 /** 107 * TODO: comment 108 * 109 * @return 110 */ 111 public boolean getAltgr() { 112 return altgr; 113 } 134 114 135 //----------------------------------------------------------------------------------------------- 136 /** 137 * TODO: comment 138 * 139 * @return 140 */ 141 //----------------------------------------------------------------------------------------------- 142 public boolean getShift() 143 { 144 return mShift; 145 } 115 /** 116 * TODO: comment 117 * 118 * @return 119 */ 120 public boolean getShift() { 121 return shift; 122 } 146 123 147 //----------------------------------------------------------------------------------------------- 148 /** 149 * TODO: comment 150 * 151 * @return 152 */ 153 //----------------------------------------------------------------------------------------------- 154 public boolean getLocalstate() 155 { 156 return mLocalstate; 157 } 124 /** 125 * TODO: comment 126 * 127 * @return 128 */ 129 public boolean getLocalstate() { 130 return localstate; 131 } 158 132 159 //----------------------------------------------------------------------------------------------- 160 /** 161 * TODO: comment 162 * 163 * @return 164 */ 165 //----------------------------------------------------------------------------------------------- 166 public boolean getNumlock() 167 { 168 return mNumlock; 169 } 133 /** 134 * TODO: comment 135 * 136 * @return 137 */ 138 public boolean getNumlock() { 139 return numlock; 140 } 170 141 171 //----------------------------------------------------------------------------------------------- 172 /* (non-Javadoc) 173 * @see java.lang.Object#toString() 174 */ 175 //----------------------------------------------------------------------------------------------- 176 @Override 177 public String toString() 178 { 179 StringBuffer toString = new StringBuffer(); 180 toString.append("KeyStroke("); 181 toString.append(mKeyStrokeName); 182 toString.append(", "); 183 toString.append(mVirtualKey); 184 185 if (mCharacter != Character.UNASSIGNED) 186 { 187 toString.append(", \'"); 188 toString.append(mCharacter); 189 toString.append("\'"); 142 /* 143 * (non-Javadoc) 144 * 145 * @see java.lang.Object#toString() 146 */ 147 @Override 148 public String toString() { 149 StringBuffer toString = new StringBuffer(); 150 toString.append("KeyStroke("); 151 toString.append(keyStrokeName); 152 toString.append(", "); 153 toString.append(virtualKey); 154 155 if (character != Character.UNASSIGNED) { 156 toString.append(", \'"); 157 toString.append(character); 158 toString.append("\'"); 159 } 160 161 if (shift) { 162 toString.append(", shift"); 163 } 164 165 if (altgr) { 166 toString.append(", altgr"); 167 } 168 169 if (numlock) { 170 toString.append(", numlock"); 171 } 172 173 if (localstate) { 174 toString.append(", localstate"); 175 } 176 177 if (inhibit) { 178 toString.append(", inhibit"); 179 } 180 181 toString.append(")"); 182 183 return toString.toString(); 190 184 } 191 192 if (mShift)193 {194 toString.append(", shift");195 }196 197 if (mAltgr)198 {199 toString.append(", altgr");200 }201 202 if (mNumlock)203 {204 toString.append(", numlock");205 }206 207 if (mLocalstate)208 {209 toString.append(", localstate");210 }211 212 if (mInhibit)213 {214 toString.append(", inhibit");215 }216 217 toString.append(")");218 219 return toString.toString();220 }221 185 222 186 } -
trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps/KeyboardMap.java
r447 r558 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: KeyboardMap.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: patrick $ $Date: 11.07.2012 $ … … 5 4 // Creation : 2012 by patrick 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 8 7 package de.ugoe.cs.tasktree.keyboardmaps; 9 8 … … 20 19 import java.util.logging.Logger; 21 20 22 //-------------------------------------------------------------------------------------------------23 21 /** 24 22 * TODO comment … … 27 25 * @author 2012, last modified by $Author: patrick$ 28 26 */ 29 //------------------------------------------------------------------------------------------------- 30 public class KeyboardMap 31 { 32 /** */ 33 private static Logger LOG = Logger.getLogger(KeyboardMap.class.getName()); 34 35 /** */ 36 private Locale mLocale; 37 38 /** */ 39 private String mFileName; 40 41 /** */ 42 private Map<VirtualKey, List<KeyStroke>> mKeyStrokes = new HashMap<VirtualKey, List<KeyStroke>>(); 43 44 /** TODO: remove this stuff */ 45 private List<Object[]> mKeyIds = new ArrayList<Object[]>(); 46 47 //----------------------------------------------------------------------------------------------- 48 /** 49 * TODO: comment 50 * 51 * @param locale 52 */ 53 //----------------------------------------------------------------------------------------------- 54 KeyboardMap(Locale locale) 55 { 56 mLocale = locale; 57 58 if ((mLocale == Locale.ENGLISH) || (mLocale == Locale.US) || (mLocale == Locale.CANADA)) 27 public class KeyboardMap { 28 29 /** */ 30 private static Logger LOG = Logger.getLogger(KeyboardMap.class.getName()); 31 32 /** */ 33 private Locale locale; 34 35 /** */ 36 private String fileName; 37 38 /** */ 39 private Map<VirtualKey, List<KeyStroke>> keyStrokes = 40 new HashMap<VirtualKey, List<KeyStroke>>(); 41 42 /** TODO: remove this stuff */ 43 private List<Object[]> mKeyIds = new ArrayList<Object[]>(); 44 45 /** 46 * TODO: comment 47 * 48 * @param locale 49 */ 50 KeyboardMap(Locale locale) { 51 this.locale = locale; 52 53 if ((this.locale == Locale.ENGLISH) || (this.locale == Locale.US) || 54 (this.locale == Locale.CANADA)) 55 { 56 fileName = "en-us"; 57 } 58 else if (locale == Locale.UK) { 59 fileName = "en-gb"; 60 } 61 else { 62 fileName = locale.getLanguage(); 63 } 64 } 65 66 /** 67 * TODO: comment 68 * 69 * @param digit1 70 * @param b 71 * @param c 72 * @param d 73 * @param e 74 * @param f 75 * @return 76 */ 77 public char getCharacterFor(VirtualKey key, 78 boolean numlock, 79 boolean shift, 80 boolean altgr, 81 boolean inhibit) 82 throws IllegalArgumentException 59 83 { 60 mFileName = "en-us"; 84 List<KeyStroke> candidates = keyStrokes.get(key); 85 86 if (candidates == null) { 87 return Character.UNASSIGNED; 88 } 89 90 // try to find the key stroke 91 for (KeyStroke keyStroke : candidates) { 92 if ((numlock == keyStroke.getNumlock()) && (!keyStroke.getLocalstate()) && 93 (shift == keyStroke.getShift()) && (altgr == keyStroke.getAltgr()) && 94 (inhibit == keyStroke.getInhibit())) 95 { 96 return keyStroke.getCharacter(); 97 } 98 } 99 100 // try to find the key stroke with a local state ignoring the other keys 101 for (KeyStroke keyStroke : candidates) { 102 if ((numlock == keyStroke.getNumlock()) && (keyStroke.getLocalstate()) && 103 (inhibit == keyStroke.getInhibit())) 104 { 105 return keyStroke.getCharacter(); 106 } 107 } 108 109 return Character.UNASSIGNED; 61 110 } 62 else if (mLocale == Locale.UK) 111 112 /** 113 * TODO: comment 114 * 115 */ 116 void init() throws IllegalArgumentException { 117 LOG.info("initializing keymap for locale " + locale); 118 119 List<String[]> deadKeySequences = new ArrayList<String[]>(); 120 List<String[]> keyStrokes = new ArrayList<String[]>(); 121 readStream(getStream(fileName), deadKeySequences, keyStrokes); 122 123 LOG.info("read " + keyStrokes.size() + " key strokes and " + deadKeySequences.size() + 124 " dead key sequences"); 125 126 VirtualKeySynonyms virtualKeySynonyms = determineVirtualKeySynonyms(keyStrokes); 127 processKeyStrokes(keyStrokes, virtualKeySynonyms); 128 processDeadKeySequences(deadKeySequences); 129 130 for (Object[] keyId : mKeyIds) { 131 System.out.println(Integer.toHexString((Integer) keyId[0]) + " " + keyId[1]); 132 } 133 } 134 135 /** 136 * TODO: comment 137 * 138 * @param fileName 139 * @return 140 */ 141 private InputStream getStream(String name) { 142 LOG.info("reading keymap for locale " + locale + " from resource keymaps/" + name); 143 144 InputStream stream = 145 this.getClass().getClassLoader().getResourceAsStream("keymaps/" + name); 146 147 if (stream == null) { 148 throw new IllegalArgumentException("no keyboard map available for locale " + locale); 149 } 150 151 return stream; 152 } 153 154 /** 155 * TODO: comment 156 * 157 * @param stream 158 * @param virtualKeySynonyms 159 * @param deadKeySequences 160 */ 161 private void readStream(InputStream stream, 162 List<String[]> deadKeySequences, 163 List<String[]> keyStrokes) 164 throws IllegalArgumentException 63 165 { 64 mFileName = "en-gb"; 166 BufferedReader in = new BufferedReader(new InputStreamReader(stream)); 167 168 try { 169 String line; 170 while ((line = in.readLine()) != null) { 171 if (!"".equals(line)) { 172 processLine(line, deadKeySequences, keyStrokes); 173 } 174 } 175 } 176 catch (IOException e) { 177 LOG.log(Level.WARNING, "no keyboard map available for locale " + locale, e); 178 throw new IllegalArgumentException("no keyboard map available for locale " + locale, e); 179 } 180 finally { 181 try { 182 in.close(); 183 } 184 catch (IOException e) { 185 LOG.warning("could not close input stream for reading keyboard map"); 186 } 187 } 65 188 } 66 else 189 190 /** 191 * TODO: comment 192 * 193 * @param line 194 * @param deadKeySequences 195 */ 196 private void processLine(String line, 197 List<String[]> deadKeySequences, 198 List<String[]> keyStrokes) 67 199 { 68 mFileName = locale.getLanguage(); 200 String[] values = line.split(" "); 201 202 if (values.length <= 0) { 203 return; 204 } 205 206 // ignore comments 207 if (values[0].startsWith("#")) { 208 return; 209 } 210 211 if ("map".equals(values[0])) { 212 // this is the map id. Ignore it. 213 } 214 else if ("include".equals(values[0])) { 215 // process all includes 216 for (int i = 1; i < values.length; i++) { 217 if (!values[i].startsWith("#")) { 218 readStream(getStream(values[i]), deadKeySequences, keyStrokes); 219 } 220 else { 221 break; 222 } 223 } 224 } 225 else if ("sequence".equals(values[0])) { 226 deadKeySequences.add(values); 227 } 228 else { 229 boolean alreadyAdded = false; 230 231 // check, if there is a replacement 232 for (int i = 0; i < keyStrokes.size(); i++) { 233 if (keyStrokes.get(i)[0].equals(values[0])) { 234 LOG.finest("replacing key stroke " + values[0] + " with former keyid " + 235 keyStrokes.get(i)[1] + " with new key id " + values[1]); 236 keyStrokes.set(i, values); 237 alreadyAdded = true; 238 break; 239 } 240 } 241 242 if (!alreadyAdded) { 243 keyStrokes.add(values); 244 } 245 } 69 246 } 70 } 71 72 //----------------------------------------------------------------------------------------------- 73 /** 74 * TODO: comment 75 * 76 * @param digit1 77 * @param b 78 * @param c 79 * @param d 80 * @param e 81 * @param f 82 * @return 83 */ 84 //----------------------------------------------------------------------------------------------- 85 public char getCharacterFor(VirtualKey key, 247 248 /** 249 * TODO: comment 250 * 251 * @param keyStrokes 252 * @return 253 */ 254 private VirtualKeySynonyms determineVirtualKeySynonyms(List<String[]> keyStrokes) { 255 LOG.info("determining virtual keys and synonyms for the keymap"); 256 257 VirtualKeySynonyms virtualKeySynonyms = new VirtualKeySynonyms(); 258 259 // for debugging purposes, determine which key strokes are not matched to virtual keys. 260 List<String[]> unmatchedKeyStrokes = new ArrayList<String[]>(); 261 262 for (String[] keyStroke : keyStrokes) { 263 String keyStrokeName = keyStroke[0]; 264 int keyId = getKeyId(keyStroke[1]); 265 // System.err.println(keyStrokeName + " 0x" + Integer.toHexString(keyId)); 266 267 VirtualKey virtualKey = determineVirtualKey(keyStrokeName); 268 269 if (virtualKey != null) { 270 virtualKeySynonyms.add(keyId, virtualKey); 271 } 272 else { 273 unmatchedKeyStrokes.add(keyStroke); 274 } 275 } 276 277 for (String[] unmatchedKeyStroke : unmatchedKeyStrokes) { 278 if (!virtualKeySynonyms.containsKey(getKeyId(unmatchedKeyStroke[1]))) { 279 LOG.finest("no virtual key mapped to key stroke " + unmatchedKeyStroke[0] + "(" + 280 unmatchedKeyStroke[1] + ") of keyboard map for locale " + locale); 281 } 282 } 283 284 return virtualKeySynonyms; 285 } 286 287 /** 288 * TODO: comment 289 * 290 * @param string 291 * @return 292 */ 293 private int getKeyId(String keyIdString) { 294 if (keyIdString.startsWith("0x")) { 295 keyIdString = keyIdString.substring(2); 296 } 297 298 return Integer.parseInt(keyIdString, 16); 299 } 300 301 /** 302 * TODO: comment 303 * 304 * @param keyStrokes 305 * @param virtualKeySynonyms 306 */ 307 private void processKeyStrokes(List<String[]> keyStrokes, VirtualKeySynonyms virtualKeySynonyms) 308 { 309 for (String[] keyStroke : keyStrokes) { 310 handleKeyStroke(keyStroke, virtualKeySynonyms); 311 } 312 313 addKeyStrokesIndependentOfNumLock(); 314 } 315 316 /** 317 * TODO: comment 318 * 319 * @param values 320 */ 321 private void handleKeyStroke(String[] values, VirtualKeySynonyms virtualKeySynonyms) { 322 String keyStrokeName = values[0]; 323 String keyIdString = values[1]; 324 if (keyIdString.startsWith("0x")) { 325 keyIdString = keyIdString.substring(2); 326 } 327 328 int keyId = Integer.parseInt(keyIdString, 16); 329 330 // parse the conditions 331 boolean numlock = false; 332 boolean localstate = false; 333 boolean shift = false; 334 boolean altgr = false; 335 boolean addupper = false; 336 boolean inhibit = false; 337 338 for (int i = 2; i < values.length; i++) { 339 if (!values[i].startsWith("#")) { 340 if ("numlock".equals(values[i])) { 341 numlock = true; 342 } 343 else if ("localstate".equals(values[i])) { 344 localstate = true; 345 } 346 else if ("shift".equals(values[i])) { 347 shift = true; 348 } 349 else if ("altgr".equals(values[i])) { 350 altgr = true; 351 } 352 else if ("addupper".equals(values[i])) { 353 addupper = true; 354 } 355 else if ("inhibit".equals(values[i])) { 356 inhibit = true; 357 } 358 else { 359 LOG.severe("unknown condition " + values[i] + " specified for key stroke " + 360 keyStrokeName + " through keyboard map for locale " + locale); 361 throw new IllegalArgumentException 362 ("no keyboard map available for locale " + locale); 363 } 364 } 365 else { 366 break; 367 } 368 } 369 370 addAllRepresentedKeyStrokes(keyStrokeName, keyId, numlock, localstate, shift, altgr, 371 addupper, inhibit, virtualKeySynonyms); 372 } 373 374 /** 375 * TODO: comment 376 * 377 * @param keyStrokeName 378 * @param keyId 379 * @param numlock 380 * @param localstate 381 * @param shift 382 * @param altgr 383 * @param addupper 384 * @param inhibit 385 */ 386 private void addAllRepresentedKeyStrokes(String keyStrokeName, 387 int keyId, 388 boolean numlock, 389 boolean localstate, 390 boolean shift, 391 boolean altgr, 392 boolean addupper, 393 boolean inhibit, 394 VirtualKeySynonyms virtualKeySynonyms) 395 { 396 VirtualKey[] virtualKeys = virtualKeySynonyms.getVirtualKeySynonyms(keyId); 397 398 if (virtualKeys == null) { 399 LOG.severe("no virtual key mapped to key stroke " + keyStrokeName + 400 " of keyboard map for locale " + locale); 401 // throw new IllegalArgumentException("no keyboard map available for locale " + 402 // mLocale); 403 return; 404 } 405 406 for (VirtualKey virtualKey : virtualKeys) { 407 if (addupper) { 408 char c = determineCharacter(keyStrokeName, true); 409 addKeyStroke 410 (keyStrokeName, virtualKey, numlock, localstate, true, altgr, inhibit, c); 411 412 c = determineCharacter(keyStrokeName, false); 413 addKeyStroke 414 (keyStrokeName, virtualKey, numlock, localstate, false, altgr, inhibit, c); 415 } 416 else { 417 char c = determineCharacter(keyStrokeName, false); 418 addKeyStroke 419 (keyStrokeName, virtualKey, numlock, localstate, shift, altgr, inhibit, c); 420 } 421 } 422 } 423 424 /** 425 * TODO: comment 426 * 427 * @param keyStroke 428 */ 429 private void addKeyStroke(String keyStrokeName, 430 VirtualKey virtualKey, 86 431 boolean numlock, 432 boolean localstate, 87 433 boolean shift, 88 434 boolean altgr, 89 boolean inhibit) 90 throws IllegalArgumentException 91 { 92 List<KeyStroke> candidates = mKeyStrokes.get(key); 93 94 if (candidates == null) 435 boolean inhibit, 436 char character) 95 437 { 96 return Character.UNASSIGNED; 438 KeyStroke keyStroke = new KeyStroke 439 (keyStrokeName, virtualKey, numlock, localstate, shift, altgr, inhibit, character); 440 441 List<KeyStroke> keyStrokeList = keyStrokes.get(keyStroke.getVirtualKey()); 442 443 if (keyStrokeList == null) { 444 keyStrokeList = new ArrayList<KeyStroke>(); 445 keyStrokes.put(keyStroke.getVirtualKey(), keyStrokeList); 446 } 447 448 keyStrokeList.add(keyStroke); 97 449 } 98 99 // try to find the key stroke 100 for (KeyStroke keyStroke : candidates) 101 { 102 if ((numlock == keyStroke.getNumlock()) && 103 (!keyStroke.getLocalstate()) && 104 (shift == keyStroke.getShift()) && 105 (altgr == keyStroke.getAltgr()) && 106 (inhibit == keyStroke.getInhibit())) 107 { 108 return keyStroke.getCharacter(); 109 } 450 451 /** 452 * TODO: comment 453 * 454 */ 455 private void addKeyStrokesIndependentOfNumLock() { 456 for (Map.Entry<VirtualKey, List<KeyStroke>> entry : keyStrokes.entrySet()) { 457 List<KeyStroke> keyStrokesToAdd = new ArrayList<KeyStroke>(); 458 for (KeyStroke keyStroke : entry.getValue()) { 459 if (!keyStroke.getNumlock()) { 460 boolean foundPositiveNumlockVariant = false; 461 for (KeyStroke candidate : entry.getValue()) { 462 if ((candidate.getShift() == keyStroke.getShift()) && 463 (candidate.getAltgr() == keyStroke.getAltgr()) && 464 (candidate.getLocalstate() == keyStroke.getLocalstate()) && 465 (candidate.getInhibit() == keyStroke.getInhibit()) && 466 (candidate.getNumlock())) 467 { 468 foundPositiveNumlockVariant = true; 469 break; 470 } 471 } 472 473 if (!foundPositiveNumlockVariant) { 474 keyStrokesToAdd.add(keyStroke); 475 } 476 } 477 } 478 479 for (KeyStroke keyStroke : keyStrokesToAdd) { 480 addKeyStroke(keyStroke.getKeyStrokeName(), keyStroke.getVirtualKey(), true, 481 keyStroke.getLocalstate(), keyStroke.getShift(), keyStroke.getAltgr(), 482 keyStroke.getInhibit(), keyStroke.getCharacter()); 483 } 484 } 110 485 } 111 112 // try to find the key stroke with a local state ignoring the other keys 113 for (KeyStroke keyStroke : candidates) 114 { 115 if ((numlock == keyStroke.getNumlock()) && 116 (keyStroke.getLocalstate()) && 117 (inhibit == keyStroke.getInhibit())) 118 { 119 return keyStroke.getCharacter(); 120 } 486 487 /** 488 * TODO: comment 489 * 490 * @param deadKeySequences 491 */ 492 private void processDeadKeySequences(List<String[]> deadKeySequences) { 493 // TODO Auto-generated method stub 494 // System.out.println("PATRICK: KeyboardMap.processDeadKeySequences "); 121 495 } 122 123 return Character.UNASSIGNED; 124 } 125 126 //----------------------------------------------------------------------------------------------- 127 /** 128 * TODO: comment 129 * 130 */ 131 //----------------------------------------------------------------------------------------------- 132 void init() throws IllegalArgumentException 133 { 134 LOG.info("initializing keymap for locale " + mLocale); 135 136 List<String[]> deadKeySequences = new ArrayList<String[]>(); 137 List<String[]> keyStrokes = new ArrayList<String[]>(); 138 readStream(getStream(mFileName), deadKeySequences, keyStrokes); 139 140 LOG.info("read " + keyStrokes.size() + " key strokes and " + deadKeySequences.size() + 141 " dead key sequences"); 142 143 VirtualKeySynonyms virtualKeySynonyms = determineVirtualKeySynonyms(keyStrokes); 144 processKeyStrokes(keyStrokes, virtualKeySynonyms); 145 processDeadKeySequences(deadKeySequences); 146 147 for (Object[] keyId : mKeyIds) 148 { 149 System.out.println(Integer.toHexString((Integer) keyId[0]) + " " + keyId[1]); 496 497 /** 498 * TODO: comment 499 * 500 * @param keyStrokeName 501 * @param shift 502 * @return 503 */ 504 private VirtualKey determineVirtualKey(String keyStrokeName) { 505 if ("Shift_R".equals(keyStrokeName)) { 506 return VirtualKey.SHIFT; 507 } 508 else if ("Shift_L".equals(keyStrokeName)) { 509 return VirtualKey.SHIFT; 510 } 511 else if ("Alt_R".equals(keyStrokeName)) { 512 return VirtualKey.ALT_GRAPH; 513 } 514 else if ("Mode_switch".equals(keyStrokeName)) { 515 return VirtualKey.MODECHANGE; 516 } 517 else if ("ISO_Level3_Shift".equals(keyStrokeName)) { 518 return VirtualKey.SHIFT; 519 } 520 else if ("Alt_L".equals(keyStrokeName)) { 521 return VirtualKey.ALT; 522 } 523 else if ("Control_R".equals(keyStrokeName)) { 524 return VirtualKey.CONTROL; 525 } 526 else if ("Control_L".equals(keyStrokeName)) { 527 return VirtualKey.CONTROL; 528 } 529 else if ("Menu".equals(keyStrokeName)) { 530 return VirtualKey.WINDOWS; 531 } 532 else if ("1".equals(keyStrokeName)) { 533 return VirtualKey.DIGIT_1; 534 } 535 else if ("2".equals(keyStrokeName)) { 536 return VirtualKey.DIGIT_2; 537 } 538 else if ("3".equals(keyStrokeName)) { 539 return VirtualKey.DIGIT_3; 540 } 541 else if ("4".equals(keyStrokeName)) { 542 return VirtualKey.DIGIT_4; 543 } 544 else if ("5".equals(keyStrokeName)) { 545 return VirtualKey.DIGIT_5; 546 } 547 else if ("6".equals(keyStrokeName)) { 548 return VirtualKey.DIGIT_6; 549 } 550 else if ("7".equals(keyStrokeName)) { 551 return VirtualKey.DIGIT_7; 552 } 553 else if ("8".equals(keyStrokeName)) { 554 return VirtualKey.DIGIT_8; 555 } 556 else if ("9".equals(keyStrokeName)) { 557 return VirtualKey.DIGIT_9; 558 } 559 else if ("0".equals(keyStrokeName)) { 560 return VirtualKey.DIGIT_0; 561 } 562 else if ("BackSpace".equals(keyStrokeName)) { 563 return VirtualKey.BACK_SPACE; 564 } 565 else if ("Tab".equals(keyStrokeName)) { 566 return VirtualKey.TAB; 567 } 568 else if ("q".equals(keyStrokeName)) { 569 return VirtualKey.LETTER_Q; 570 } 571 else if ("w".equals(keyStrokeName)) { 572 return VirtualKey.LETTER_W; 573 } 574 else if ("e".equals(keyStrokeName)) { 575 return VirtualKey.LETTER_E; 576 } 577 else if ("r".equals(keyStrokeName)) { 578 return VirtualKey.LETTER_R; 579 } 580 else if ("t".equals(keyStrokeName)) { 581 return VirtualKey.LETTER_T; 582 } 583 else if ("y".equals(keyStrokeName)) { 584 return VirtualKey.LETTER_Y; 585 } 586 else if ("u".equals(keyStrokeName)) { 587 return VirtualKey.LETTER_U; 588 } 589 else if ("i".equals(keyStrokeName)) { 590 return VirtualKey.LETTER_I; 591 } 592 else if ("o".equals(keyStrokeName)) { 593 return VirtualKey.LETTER_O; 594 } 595 else if ("p".equals(keyStrokeName)) { 596 return VirtualKey.LETTER_P; 597 } 598 else if ("a".equals(keyStrokeName)) { 599 return VirtualKey.LETTER_A; 600 } 601 else if ("s".equals(keyStrokeName)) { 602 return VirtualKey.LETTER_S; 603 } 604 else if ("d".equals(keyStrokeName)) { 605 return VirtualKey.LETTER_D; 606 } 607 else if ("f".equals(keyStrokeName)) { 608 return VirtualKey.LETTER_F; 609 } 610 else if ("g".equals(keyStrokeName)) { 611 return VirtualKey.LETTER_G; 612 } 613 else if ("h".equals(keyStrokeName)) { 614 return VirtualKey.LETTER_H; 615 } 616 else if ("j".equals(keyStrokeName)) { 617 return VirtualKey.LETTER_J; 618 } 619 else if ("k".equals(keyStrokeName)) { 620 return VirtualKey.LETTER_K; 621 } 622 else if ("l".equals(keyStrokeName)) { 623 return VirtualKey.LETTER_L; 624 } 625 else if ("Return".equals(keyStrokeName)) { 626 return VirtualKey.ENTER; 627 } 628 else if ("z".equals(keyStrokeName)) { 629 return VirtualKey.LETTER_Z; 630 } 631 else if ("x".equals(keyStrokeName)) { 632 return VirtualKey.LETTER_X; 633 } 634 else if ("c".equals(keyStrokeName)) { 635 return VirtualKey.LETTER_C; 636 } 637 else if ("v".equals(keyStrokeName)) { 638 return VirtualKey.LETTER_V; 639 } 640 else if ("b".equals(keyStrokeName)) { 641 return VirtualKey.LETTER_B; 642 } 643 else if ("n".equals(keyStrokeName)) { 644 return VirtualKey.LETTER_N; 645 } 646 else if ("m".equals(keyStrokeName)) { 647 return VirtualKey.LETTER_M; 648 } 649 else if ("space".equals(keyStrokeName)) { 650 return VirtualKey.SPACE; 651 } 652 else if ("less".equals(keyStrokeName)) { 653 return VirtualKey.LESS; 654 } 655 else if ("greater".equals(keyStrokeName)) { 656 return VirtualKey.GREATER; 657 } 658 else if ("Escape".equals(keyStrokeName)) { 659 return VirtualKey.ESCAPE; 660 } 661 else if ("F1".equals(keyStrokeName)) { 662 return VirtualKey.F1; 663 } 664 else if ("F2".equals(keyStrokeName)) { 665 return VirtualKey.F2; 666 } 667 else if ("F3".equals(keyStrokeName)) { 668 return VirtualKey.F3; 669 } 670 else if ("F4".equals(keyStrokeName)) { 671 return VirtualKey.F4; 672 } 673 else if ("F5".equals(keyStrokeName)) { 674 return VirtualKey.F5; 675 } 676 else if ("F6".equals(keyStrokeName)) { 677 return VirtualKey.F6; 678 } 679 else if ("F7".equals(keyStrokeName)) { 680 return VirtualKey.F7; 681 } 682 else if ("F8".equals(keyStrokeName)) { 683 return VirtualKey.F8; 684 } 685 else if ("F9".equals(keyStrokeName)) { 686 return VirtualKey.F9; 687 } 688 else if ("F10".equals(keyStrokeName)) { 689 return VirtualKey.F10; 690 } 691 else if ("F11".equals(keyStrokeName)) { 692 return VirtualKey.F11; 693 } 694 else if ("F12".equals(keyStrokeName)) { 695 return VirtualKey.F12; 696 } 697 else if ("F13".equals(keyStrokeName)) { 698 return VirtualKey.F13; 699 } 700 else if ("F14".equals(keyStrokeName)) { 701 return VirtualKey.F14; 702 } 703 else if ("F15".equals(keyStrokeName)) { 704 return VirtualKey.F15; 705 } 706 else if ("F16".equals(keyStrokeName)) { 707 return VirtualKey.F16; 708 } 709 else if ("F17".equals(keyStrokeName)) { 710 return VirtualKey.F17; 711 } 712 else if ("F18".equals(keyStrokeName)) { 713 return VirtualKey.F18; 714 } 715 else if ("F19".equals(keyStrokeName)) { 716 return VirtualKey.F19; 717 } 718 else if ("F20".equals(keyStrokeName)) { 719 return VirtualKey.F20; 720 } 721 else if ("F21".equals(keyStrokeName)) { 722 return VirtualKey.F21; 723 } 724 else if ("F22".equals(keyStrokeName)) { 725 return VirtualKey.F22; 726 } 727 else if ("F23".equals(keyStrokeName)) { 728 return VirtualKey.F23; 729 } 730 else if ("F24".equals(keyStrokeName)) { 731 return VirtualKey.F24; 732 } 733 else if ("Print".equals(keyStrokeName)) { 734 return VirtualKey.PRINTSCREEN; 735 } 736 else if ("Scroll_Lock".equals(keyStrokeName)) { 737 return VirtualKey.SCROLL_LOCK; 738 } 739 else if ("Insert".equals(keyStrokeName)) { 740 return VirtualKey.INSERT; 741 } 742 else if ("Delete".equals(keyStrokeName)) { 743 return VirtualKey.DELETE; 744 } 745 else if ("Home".equals(keyStrokeName)) { 746 return VirtualKey.HOME; 747 } 748 else if ("End".equals(keyStrokeName)) { 749 return VirtualKey.END; 750 } 751 else if ("Page_Up".equals(keyStrokeName)) { 752 return VirtualKey.PAGE_UP; 753 } 754 else if ("Page_Down".equals(keyStrokeName)) { 755 return VirtualKey.PAGE_DOWN; 756 } 757 else if ("Left".equals(keyStrokeName)) { 758 return VirtualKey.LEFT; 759 } 760 else if ("Up".equals(keyStrokeName)) { 761 return VirtualKey.UP; 762 } 763 else if ("Down".equals(keyStrokeName)) { 764 return VirtualKey.DOWN; 765 } 766 else if ("Right".equals(keyStrokeName)) { 767 return VirtualKey.RIGHT; 768 } 769 else if ("Num_Lock".equals(keyStrokeName)) { 770 return VirtualKey.NUM_LOCK; 771 } 772 else if ("KP_Divide".equals(keyStrokeName)) { 773 return VirtualKey.SLASH; 774 } 775 else if ("KP_Multiply".equals(keyStrokeName)) { 776 return VirtualKey.ASTERISK; 777 } 778 else if ("KP_Subtract".equals(keyStrokeName)) { 779 return VirtualKey.MINUS; 780 } 781 else if ("KP_Add".equals(keyStrokeName)) { 782 return VirtualKey.PLUS; 783 } 784 else if ("KP_Enter".equals(keyStrokeName)) { 785 return VirtualKey.ENTER; 786 } 787 else if ("KP_Decimal".equals(keyStrokeName)) { 788 return VirtualKey.DECIMAL; 789 } 790 else if ("KP_Separator".equals(keyStrokeName)) { 791 return VirtualKey.SEPARATOR; 792 } 793 else if ("KP_Delete".equals(keyStrokeName)) { 794 return VirtualKey.DELETE; 795 } 796 else if ("KP_0".equals(keyStrokeName)) { 797 return VirtualKey.NUMPAD_0; 798 } 799 else if ("KP_Insert".equals(keyStrokeName)) { 800 return VirtualKey.INSERT; 801 } 802 else if ("KP_1".equals(keyStrokeName)) { 803 return VirtualKey.NUMPAD_1; 804 } 805 else if ("KP_End".equals(keyStrokeName)) { 806 return VirtualKey.END; 807 } 808 else if ("KP_2".equals(keyStrokeName)) { 809 return VirtualKey.NUMPAD_2; 810 } 811 else if ("KP_Down".equals(keyStrokeName)) { 812 return VirtualKey.KP_DOWN; 813 } 814 else if ("KP_3".equals(keyStrokeName)) { 815 return VirtualKey.NUMPAD_3; 816 } 817 else if ("KP_Next".equals(keyStrokeName)) { 818 return VirtualKey.PAGE_DOWN; 819 } 820 else if ("KP_4".equals(keyStrokeName)) { 821 return VirtualKey.NUMPAD_4; 822 } 823 else if ("KP_Left".equals(keyStrokeName)) { 824 return VirtualKey.KP_LEFT; 825 } 826 else if ("KP_5".equals(keyStrokeName)) { 827 return VirtualKey.NUMPAD_5; 828 } 829 else if ("KP_Begin".equals(keyStrokeName)) { 830 return VirtualKey.BEGIN; 831 } 832 else if ("KP_6".equals(keyStrokeName)) { 833 return VirtualKey.NUMPAD_6; 834 } 835 else if ("KP_Right".equals(keyStrokeName)) { 836 return VirtualKey.KP_RIGHT; 837 } 838 else if ("KP_7".equals(keyStrokeName)) { 839 return VirtualKey.NUMPAD_7; 840 } 841 else if ("KP_Home".equals(keyStrokeName)) { 842 return VirtualKey.HOME; 843 } 844 else if ("KP_8".equals(keyStrokeName)) { 845 return VirtualKey.NUMPAD_8; 846 } 847 else if ("KP_Up".equals(keyStrokeName)) { 848 return VirtualKey.KP_UP; 849 } 850 else if ("KP_9".equals(keyStrokeName)) { 851 return VirtualKey.NUMPAD_9; 852 } 853 else if ("KP_Prior".equals(keyStrokeName)) { 854 return VirtualKey.PAGE_UP; 855 } 856 else if ("Caps_Lock".equals(keyStrokeName)) { 857 return VirtualKey.CAPS_LOCK; 858 } 859 else if ("exclam".equals(keyStrokeName)) { 860 return VirtualKey.EXCLAMATION_MARK; 861 } 862 else if ("exclamdown".equals(keyStrokeName)) { 863 return VirtualKey.INVERTED_EXCLAMATION_MARK; 864 } 865 else if ("quotedbl".equals(keyStrokeName)) { 866 return VirtualKey.QUOTEDBL; 867 } 868 else if ("slash".equals(keyStrokeName)) { 869 return VirtualKey.SLASH; 870 } 871 else if ("backslash".equals(keyStrokeName)) { 872 return VirtualKey.BACK_SLASH; 873 } 874 else if ("dead_acute".equals(keyStrokeName)) { 875 return VirtualKey.DEAD_ACUTE; 876 } 877 else if ("dead_diaresis".equals(keyStrokeName)) { 878 return VirtualKey.DEAD_DIAERESIS; 879 } 880 else if ("dead_abovering".equals(keyStrokeName)) { 881 return VirtualKey.DEAD_ABOVERING; 882 } 883 else if ("plus".equals(keyStrokeName)) { 884 return VirtualKey.PLUS; 885 } 886 else if ("asterisk".equals(keyStrokeName)) { 887 return VirtualKey.ASTERISK; 888 } 889 else if ("dead_tilde".equals(keyStrokeName)) { 890 return VirtualKey.DEAD_TILDE; 891 } 892 else if ("dead_doubleacute".equals(keyStrokeName)) { 893 return VirtualKey.DEAD_DOUBLEACUTE; 894 } 895 else if ("dead_caron".equals(keyStrokeName)) { 896 return VirtualKey.DEAD_CARON; 897 } 898 else if ("dead_circumflex".equals(keyStrokeName)) { 899 return VirtualKey.DEAD_CIRCUMFLEX; 900 } 901 else if ("comma".equals(keyStrokeName)) { 902 return VirtualKey.COMMA; 903 } 904 else if ("semicolon".equals(keyStrokeName)) { 905 return VirtualKey.SEMICOLON; 906 } 907 else if ("multiply".equals(keyStrokeName)) { 908 return VirtualKey.MULTIPLY; 909 } 910 else if ("period".equals(keyStrokeName)) { 911 return VirtualKey.PERIOD; 912 } 913 else if ("colon".equals(keyStrokeName)) { 914 return VirtualKey.COLON; 915 } 916 else if ("dead_breve".equals(keyStrokeName)) { 917 return VirtualKey.DEAD_BREVE; 918 } 919 else if ("division".equals(keyStrokeName)) { 920 return VirtualKey.DIVIDE; 921 } 922 else if ("minus".equals(keyStrokeName)) { 923 return VirtualKey.MINUS; 924 } 925 else if ("underscore".equals(keyStrokeName)) { 926 return VirtualKey.UNDERSCORE; 927 } 928 else if ("dead_abovedot".equals(keyStrokeName)) { 929 return VirtualKey.DEAD_ABOVEDOT; 930 } 931 else if ("bracketleft".equals(keyStrokeName)) { 932 return VirtualKey.OPEN_BRACKET; 933 } 934 else if ("bracketright".equals(keyStrokeName)) { 935 return VirtualKey.CLOSE_BRACKET; 936 } 937 else if ("grave".equals(keyStrokeName)) { 938 return VirtualKey.DEAD_GRAVE; 939 } 940 else if ("equal".equals(keyStrokeName)) { 941 return VirtualKey.EQUALS; 942 } 943 else if ("dead_macron".equals(keyStrokeName)) { 944 return VirtualKey.DEAD_MACRON; 945 } 946 else if ("dead_ogonek".equals(keyStrokeName)) { 947 return VirtualKey.DEAD_OGONEK; 948 } 949 else if ("dead_cedilla".equals(keyStrokeName)) { 950 return VirtualKey.DEAD_CEDILLA; 951 } 952 else if ("ampersand".equals(keyStrokeName)) { 953 return VirtualKey.AMPERSAND; 954 } 955 else if ("parenleft".equals(keyStrokeName)) { 956 return VirtualKey.LEFT_PARENTHESIS; 957 } 958 else if ("parenright".equals(keyStrokeName)) { 959 return VirtualKey.RIGHT_PARENTHESIS; 960 } 961 else if ("braceleft".equals(keyStrokeName)) { 962 return VirtualKey.BRACELEFT; 963 } 964 else if ("braceright".equals(keyStrokeName)) { 965 return VirtualKey.BRACERIGHT; 966 } 967 else if ("at".equals(keyStrokeName)) { 968 return VirtualKey.AT; 969 } 970 else if ("dollar".equals(keyStrokeName)) { 971 return VirtualKey.DOLLAR; 972 } 973 else if ("EuroSign".equals(keyStrokeName)) { 974 return VirtualKey.EURO_SIGN; 975 } 976 else if ("Begin".equals(keyStrokeName)) { 977 return VirtualKey.BEGIN; 978 } 979 else if ("numbersign".equals(keyStrokeName)) { 980 return VirtualKey.NUMBER_SIGN; 981 } 982 else if ("asciicircum".equals(keyStrokeName)) { 983 return VirtualKey.CIRCUMFLEX; 984 } 985 else if ("Kanji".equals(keyStrokeName)) { 986 return VirtualKey.KANJI; 987 } 988 else if ("Katakana".equals(keyStrokeName)) { 989 return VirtualKey.KATAKANA; 990 } 991 else if ("Hiragana_Katakana".equals(keyStrokeName)) { 992 return VirtualKey.HIRAGANA; 993 } 994 else if ("Muhenkan".equals(keyStrokeName)) { 995 // I found this in the KeyEvent description 996 return VirtualKey.NONCONVERT; 997 } 998 else if ("kan".equals(keyStrokeName)) { 999 // I found this in the KeyEvent description 1000 return VirtualKey.NONCONVERT; 1001 } 1002 else if ("Henkan_Mode".equals(keyStrokeName)) { 1003 // I found this in the key event description 1004 return VirtualKey.CONVERT; 1005 } 1006 else if ("voicedsound".equals(keyStrokeName)) { 1007 return VirtualKey.DEAD_VOICED_SOUND; 1008 } 1009 else if ("semivoicedsound".equals(keyStrokeName)) { 1010 return VirtualKey.DEAD_SEMIVOICED_SOUND; 1011 } 1012 else if ("Menu".equals(keyStrokeName)) { 1013 return VirtualKey.CONTEXT_MENU; 1014 } 1015 else { 1016 LOG.finest("unknown virtual key for key stroke " + keyStrokeName + 1017 " specified through " + "keyboard map for locale " + locale); 1018 1019 return null; 1020 } 1021 1022 // for the following virtual keys no key stroke names are provided in the key maps 1023 /* 1024 * CANCEL(KeyEvent.VK_CANCEL), CLEAR(KeyEvent.VK_CLEAR), PAUSE(KeyEvent.VK_PAUSE), 1025 * HELP(KeyEvent.VK_HELP), META(KeyEvent.VK_META), 1026 * 1027 * BACK_QUOTE(KeyEvent.VK_BACK_QUOTE), QUOTE(KeyEvent.VK_QUOTE), 1028 * 1029 * DEAD_IOTA(KeyEvent.VK_DEAD_IOTA), 1030 * 1031 * FINAL(KeyEvent.VK_FINAL), CONVERT(KeyEvent.VK_CONVERT), 1032 * NONCONVERT(KeyEvent.VK_NONCONVERT), ACCEPT(KeyEvent.VK_ACCEPT), KANA(KeyEvent.VK_KANA), 1033 * ALPHANUMERIC(KeyEvent.VK_ALPHANUMERIC), FULL_WIDTH(KeyEvent.VK_FULL_WIDTH), 1034 * HALF_WIDTH(KeyEvent.VK_HALF_WIDTH), ROMAN_CHARACTERS(KeyEvent.VK_ROMAN_CHARACTERS), 1035 * ALL_CANDIDATES(KeyEvent.VK_ALL_CANDIDATES), 1036 * PREVIOUS_CANDIDATE(KeyEvent.VK_PREVIOUS_CANDIDATE), CODE_INPUT(KeyEvent.VK_CODE_INPUT), 1037 * JAPANESE_KATAKANA(KeyEvent.VK_JAPANESE_KATAKANA), 1038 * JAPANESE_HIRAGANA(KeyEvent.VK_JAPANESE_HIRAGANA), 1039 * JAPANESE_ROMAN(KeyEvent.VK_JAPANESE_ROMAN), KANA_LOCK(KeyEvent.VK_KANA_LOCK), 1040 * INPUT_METHOD_ON_OFF(KeyEvent.VK_INPUT_METHOD_ON_OFF), 1041 * 1042 * CUT(KeyEvent.VK_CUT), COPY(KeyEvent.VK_COPY), PASTE(KeyEvent.VK_PASTE), 1043 * UNDO(KeyEvent.VK_UNDO), AGAIN(KeyEvent.VK_AGAIN), FIND(KeyEvent.VK_FIND), 1044 * PROPS(KeyEvent.VK_PROPS), STOP(KeyEvent.VK_STOP), COMPOSE(KeyEvent.VK_COMPOSE), 1045 */ 150 1046 } 151 } 152 153 //----------------------------------------------------------------------------------------------- 154 /** 155 * TODO: comment 156 * 157 * @param fileName 158 * @return 159 */ 160 //----------------------------------------------------------------------------------------------- 161 private InputStream getStream(String name) 162 { 163 LOG.info("reading keymap for locale " + mLocale + " from resource keymaps/" + name); 164 165 InputStream stream = 166 this.getClass().getClassLoader().getResourceAsStream("keymaps/" + name); 167 168 if (stream == null) 169 { 170 throw new IllegalArgumentException("no keyboard map available for locale " + mLocale); 1047 1048 /** 1049 * TODO: comment 1050 * 1051 * @param keyStrokeName 1052 * @param shift 1053 * @return 1054 */ 1055 private char determineCharacter(String keyStrokeName, boolean getUpper) { 1056 if ("Shift_R".equals(keyStrokeName)) { 1057 return Character.UNASSIGNED; 1058 } 1059 else if ("Shift_L".equals(keyStrokeName)) { 1060 return Character.UNASSIGNED; 1061 } 1062 else if ("Alt_R".equals(keyStrokeName)) { 1063 return Character.UNASSIGNED; 1064 } 1065 else if ("Mode_switch".equals(keyStrokeName)) { 1066 return Character.UNASSIGNED; 1067 } 1068 else if ("ISO_Level3_Shift".equals(keyStrokeName)) { 1069 return Character.UNASSIGNED; 1070 } 1071 else if ("Alt_L".equals(keyStrokeName)) { 1072 return Character.UNASSIGNED; 1073 } 1074 else if ("Control_R".equals(keyStrokeName)) { 1075 return Character.UNASSIGNED; 1076 } 1077 else if ("Control_L".equals(keyStrokeName)) { 1078 return Character.UNASSIGNED; 1079 } 1080 else if ("Menu".equals(keyStrokeName)) { 1081 return Character.UNASSIGNED; 1082 } 1083 else if ("1".equals(keyStrokeName)) { 1084 return '1'; 1085 } 1086 else if ("2".equals(keyStrokeName)) { 1087 return '2'; 1088 } 1089 else if ("3".equals(keyStrokeName)) { 1090 return '3'; 1091 } 1092 else if ("4".equals(keyStrokeName)) { 1093 return '4'; 1094 } 1095 else if ("5".equals(keyStrokeName)) { 1096 return '5'; 1097 } 1098 else if ("6".equals(keyStrokeName)) { 1099 return '6'; 1100 } 1101 else if ("7".equals(keyStrokeName)) { 1102 return '7'; 1103 } 1104 else if ("8".equals(keyStrokeName)) { 1105 return '8'; 1106 } 1107 else if ("9".equals(keyStrokeName)) { 1108 return '9'; 1109 } 1110 else if ("0".equals(keyStrokeName)) { 1111 return '0'; 1112 } 1113 else if ("BackSpace".equals(keyStrokeName)) { 1114 return '\b'; 1115 } 1116 else if ("Tab".equals(keyStrokeName)) { 1117 return '\t'; 1118 } 1119 else if ("ISO_Left_Tab".equals(keyStrokeName)) { 1120 return Character.UNASSIGNED; 1121 } 1122 else if ("q".equals(keyStrokeName)) { 1123 return getUpper ? 'Q' : 'q'; 1124 } 1125 else if ("w".equals(keyStrokeName)) { 1126 return getUpper ? 'W' : 'w'; 1127 } 1128 else if ("e".equals(keyStrokeName)) { 1129 return getUpper ? 'E' : 'e'; 1130 } 1131 else if ("r".equals(keyStrokeName)) { 1132 return getUpper ? 'R' : 'r'; 1133 } 1134 else if ("t".equals(keyStrokeName)) { 1135 return getUpper ? 'T' : 't'; 1136 } 1137 else if ("y".equals(keyStrokeName)) { 1138 return getUpper ? 'Y' : 'y'; 1139 } 1140 else if ("u".equals(keyStrokeName)) { 1141 return getUpper ? 'U' : 'u'; 1142 } 1143 else if ("i".equals(keyStrokeName)) { 1144 return getUpper ? 'I' : 'i'; 1145 } 1146 else if ("o".equals(keyStrokeName)) { 1147 return getUpper ? 'O' : 'o'; 1148 } 1149 else if ("p".equals(keyStrokeName)) { 1150 return getUpper ? 'P' : 'p'; 1151 } 1152 else if ("a".equals(keyStrokeName)) { 1153 return getUpper ? 'A' : 'a'; 1154 } 1155 else if ("s".equals(keyStrokeName)) { 1156 return getUpper ? 'S' : 's'; 1157 } 1158 else if ("d".equals(keyStrokeName)) { 1159 return getUpper ? 'D' : 'd'; 1160 } 1161 else if ("f".equals(keyStrokeName)) { 1162 return getUpper ? 'F' : 'f'; 1163 } 1164 else if ("g".equals(keyStrokeName)) { 1165 return getUpper ? 'G' : 'g'; 1166 } 1167 else if ("h".equals(keyStrokeName)) { 1168 return getUpper ? 'H' : 'h'; 1169 } 1170 else if ("j".equals(keyStrokeName)) { 1171 return getUpper ? 'J' : 'j'; 1172 } 1173 else if ("k".equals(keyStrokeName)) { 1174 return getUpper ? 'K' : 'k'; 1175 } 1176 else if ("l".equals(keyStrokeName)) { 1177 return getUpper ? 'L' : 'l'; 1178 } 1179 else if ("Return".equals(keyStrokeName)) { 1180 return '\n'; 1181 } 1182 else if ("z".equals(keyStrokeName)) { 1183 return getUpper ? 'Z' : 'z'; 1184 } 1185 else if ("x".equals(keyStrokeName)) { 1186 return getUpper ? 'X' : 'x'; 1187 } 1188 else if ("c".equals(keyStrokeName)) { 1189 return getUpper ? 'C' : 'c'; 1190 } 1191 else if ("v".equals(keyStrokeName)) { 1192 return getUpper ? 'V' : 'v'; 1193 } 1194 else if ("b".equals(keyStrokeName)) { 1195 return getUpper ? 'B' : 'b'; 1196 } 1197 else if ("n".equals(keyStrokeName)) { 1198 return getUpper ? 'N' : 'n'; 1199 } 1200 else if ("m".equals(keyStrokeName)) { 1201 return getUpper ? 'M' : 'm'; 1202 } 1203 else if ("space".equals(keyStrokeName)) { 1204 return ' '; 1205 } 1206 else if ("less".equals(keyStrokeName)) { 1207 return '<'; 1208 } 1209 else if ("greater".equals(keyStrokeName)) { 1210 return '>'; 1211 } 1212 else if ("bar".equals(keyStrokeName)) { 1213 return '|'; 1214 } 1215 else if ("brokenbar".equals(keyStrokeName)) { 1216 return '¦'; 1217 } 1218 else if ("Escape".equals(keyStrokeName)) { 1219 return Character.UNASSIGNED; 1220 } 1221 else if ("F1".equals(keyStrokeName)) { 1222 return Character.UNASSIGNED; 1223 } 1224 else if ("F2".equals(keyStrokeName)) { 1225 return Character.UNASSIGNED; 1226 } 1227 else if ("F3".equals(keyStrokeName)) { 1228 return Character.UNASSIGNED; 1229 } 1230 else if ("F4".equals(keyStrokeName)) { 1231 return Character.UNASSIGNED; 1232 } 1233 else if ("F5".equals(keyStrokeName)) { 1234 return Character.UNASSIGNED; 1235 } 1236 else if ("F6".equals(keyStrokeName)) { 1237 return Character.UNASSIGNED; 1238 } 1239 else if ("F7".equals(keyStrokeName)) { 1240 return Character.UNASSIGNED; 1241 } 1242 else if ("F8".equals(keyStrokeName)) { 1243 return Character.UNASSIGNED; 1244 } 1245 else if ("F9".equals(keyStrokeName)) { 1246 return Character.UNASSIGNED; 1247 } 1248 else if ("F10".equals(keyStrokeName)) { 1249 return Character.UNASSIGNED; 1250 } 1251 else if ("F11".equals(keyStrokeName)) { 1252 return Character.UNASSIGNED; 1253 } 1254 else if ("SunF36".equals(keyStrokeName)) { 1255 return Character.UNASSIGNED; 1256 } 1257 else if ("F12".equals(keyStrokeName)) { 1258 return Character.UNASSIGNED; 1259 } 1260 else if ("SunF37".equals(keyStrokeName)) { 1261 return Character.UNASSIGNED; 1262 } 1263 else if ("Print".equals(keyStrokeName)) { 1264 return Character.UNASSIGNED; 1265 } 1266 else if ("Sys_Req".equals(keyStrokeName)) { 1267 return Character.UNASSIGNED; 1268 } 1269 else if ("Execute".equals(keyStrokeName)) { 1270 return Character.UNASSIGNED; 1271 } 1272 else if ("F22".equals(keyStrokeName)) { 1273 return Character.UNASSIGNED; 1274 } 1275 else if ("Scroll_Lock".equals(keyStrokeName)) { 1276 return Character.UNASSIGNED; 1277 } 1278 else if ("F23".equals(keyStrokeName)) { 1279 return Character.UNASSIGNED; 1280 } 1281 else if ("Insert".equals(keyStrokeName)) { 1282 return Character.UNASSIGNED; 1283 } 1284 else if ("Delete".equals(keyStrokeName)) { 1285 return Character.UNASSIGNED; 1286 } 1287 else if ("Home".equals(keyStrokeName)) { 1288 return Character.UNASSIGNED; 1289 } 1290 else if ("End".equals(keyStrokeName)) { 1291 return Character.UNASSIGNED; 1292 } 1293 else if ("Page_Up".equals(keyStrokeName)) { 1294 return Character.UNASSIGNED; 1295 } 1296 else if ("Page_Down".equals(keyStrokeName)) { 1297 return Character.UNASSIGNED; 1298 } 1299 else if ("Left".equals(keyStrokeName)) { 1300 return Character.UNASSIGNED; 1301 } 1302 else if ("Up".equals(keyStrokeName)) { 1303 return Character.UNASSIGNED; 1304 } 1305 else if ("Down".equals(keyStrokeName)) { 1306 return Character.UNASSIGNED; 1307 } 1308 else if ("Right".equals(keyStrokeName)) { 1309 return Character.UNASSIGNED; 1310 } 1311 else if ("Num_Lock".equals(keyStrokeName)) { 1312 return Character.UNASSIGNED; 1313 } 1314 else if ("KP_Divide".equals(keyStrokeName)) { 1315 return '/'; 1316 } 1317 else if ("KP_Multiply".equals(keyStrokeName)) { 1318 return '*'; 1319 } 1320 else if ("KP_Subtract".equals(keyStrokeName)) { 1321 return '-'; 1322 } 1323 else if ("KP_Add".equals(keyStrokeName)) { 1324 return '+'; 1325 } 1326 else if ("KP_Enter".equals(keyStrokeName)) { 1327 return '\n'; 1328 } 1329 else if ("KP_Decimal".equals(keyStrokeName)) { 1330 return ','; 1331 } 1332 else if ("KP_Separator".equals(keyStrokeName)) { 1333 return ','; 1334 } 1335 else if ("KP_Delete".equals(keyStrokeName)) { 1336 return Character.UNASSIGNED; 1337 } 1338 else if ("KP_0".equals(keyStrokeName)) { 1339 return '0'; 1340 } 1341 else if ("KP_Insert".equals(keyStrokeName)) { 1342 return Character.UNASSIGNED; 1343 } 1344 else if ("KP_1".equals(keyStrokeName)) { 1345 return '1'; 1346 } 1347 else if ("KP_End".equals(keyStrokeName)) { 1348 return Character.UNASSIGNED; 1349 } 1350 else if ("KP_2".equals(keyStrokeName)) { 1351 return '2'; 1352 } 1353 else if ("KP_Down".equals(keyStrokeName)) { 1354 return Character.UNASSIGNED; 1355 } 1356 else if ("KP_3".equals(keyStrokeName)) { 1357 return '3'; 1358 } 1359 else if ("KP_Next".equals(keyStrokeName)) { 1360 return Character.UNASSIGNED; 1361 } 1362 else if ("KP_4".equals(keyStrokeName)) { 1363 return '4'; 1364 } 1365 else if ("KP_Left".equals(keyStrokeName)) { 1366 return Character.UNASSIGNED; 1367 } 1368 else if ("KP_5".equals(keyStrokeName)) { 1369 return '5'; 1370 } 1371 else if ("KP_Begin".equals(keyStrokeName)) { 1372 return Character.UNASSIGNED; 1373 } 1374 else if ("KP_6".equals(keyStrokeName)) { 1375 return '6'; 1376 } 1377 else if ("KP_Right".equals(keyStrokeName)) { 1378 return Character.UNASSIGNED; 1379 } 1380 else if ("KP_7".equals(keyStrokeName)) { 1381 return '7'; 1382 } 1383 else if ("KP_Home".equals(keyStrokeName)) { 1384 return Character.UNASSIGNED; 1385 } 1386 else if ("KP_8".equals(keyStrokeName)) { 1387 return '8'; 1388 } 1389 else if ("KP_Up".equals(keyStrokeName)) { 1390 return Character.UNASSIGNED; 1391 } 1392 else if ("KP_9".equals(keyStrokeName)) { 1393 return '9'; 1394 } 1395 else if ("KP_Prior".equals(keyStrokeName)) { 1396 return Character.UNASSIGNED; 1397 } 1398 else if ("Caps_Lock".equals(keyStrokeName)) { 1399 return Character.UNASSIGNED; 1400 } 1401 else if ("Multi_key".equals(keyStrokeName)) { 1402 return Character.UNASSIGNED; 1403 } 1404 else if ("exclam".equals(keyStrokeName)) { 1405 return '!'; 1406 } 1407 else if ("onesuperior".equals(keyStrokeName)) { 1408 return '¹'; 1409 } 1410 else if ("exclamdown".equals(keyStrokeName)) { 1411 return '¡'; 1412 } 1413 else if ("quotedbl".equals(keyStrokeName)) { 1414 return '"'; 1415 } 1416 else if ("twosuperior".equals(keyStrokeName)) { 1417 return '²'; 1418 } 1419 else if ("oneeighth".equals(keyStrokeName)) { 1420 return '⅛'; 1421 } 1422 else if ("section".equals(keyStrokeName)) { 1423 return '§'; 1424 } 1425 else if ("threesuperior".equals(keyStrokeName)) { 1426 return '³'; 1427 } 1428 else if ("sterling".equals(keyStrokeName)) { 1429 return '£'; 1430 } 1431 else if ("dollar".equals(keyStrokeName)) { 1432 return '$'; 1433 } 1434 else if ("onequarter".equals(keyStrokeName)) { 1435 return '¼'; 1436 } 1437 else if ("currency".equals(keyStrokeName)) { 1438 return '¤'; 1439 } 1440 else if ("percent".equals(keyStrokeName)) { 1441 return '%'; 1442 } 1443 else if ("onehalf".equals(keyStrokeName)) { 1444 return '½'; 1445 } 1446 else if ("threeeighths".equals(keyStrokeName)) { 1447 return '⅜'; 1448 } 1449 else if ("ampersand".equals(keyStrokeName)) { 1450 return '&'; 1451 } 1452 else if ("threequarters".equals(keyStrokeName)) { 1453 return '¾'; 1454 } 1455 else if ("fiveeighths".equals(keyStrokeName)) { 1456 return '⅝'; 1457 } 1458 else if ("slash".equals(keyStrokeName)) { 1459 return '/'; 1460 } 1461 else if ("braceleft".equals(keyStrokeName)) { 1462 return '{'; 1463 } 1464 else if ("seveneighths".equals(keyStrokeName)) { 1465 return '⅞'; 1466 } 1467 else if ("parenleft".equals(keyStrokeName)) { 1468 return '('; 1469 } 1470 else if ("bracketleft".equals(keyStrokeName)) { 1471 return '['; 1472 } 1473 else if ("trademark".equals(keyStrokeName)) { 1474 return '™'; 1475 } 1476 else if ("parenright".equals(keyStrokeName)) { 1477 return ')'; 1478 } 1479 else if ("bracketright".equals(keyStrokeName)) { 1480 return ']'; 1481 } 1482 else if ("plusminus".equals(keyStrokeName)) { 1483 return '±'; 1484 } 1485 else if ("equal".equals(keyStrokeName)) { 1486 return '='; 1487 } 1488 else if ("braceright".equals(keyStrokeName)) { 1489 return '}'; 1490 } 1491 else if ("ssharp".equals(keyStrokeName)) { 1492 return 'ß'; 1493 } 1494 else if ("question".equals(keyStrokeName)) { 1495 return '?'; 1496 } 1497 else if ("backslash".equals(keyStrokeName)) { 1498 return '\\'; 1499 } 1500 else if ("questiondown".equals(keyStrokeName)) { 1501 return '¿'; 1502 } 1503 else if ("acute".equals(keyStrokeName)) { 1504 return '´'; 1505 } 1506 else if ("dead_acute".equals(keyStrokeName)) { 1507 return 0x0301; 1508 } 1509 else if ("grave".equals(keyStrokeName)) { 1510 return '`'; 1511 } 1512 else if ("dead_grave".equals(keyStrokeName)) { 1513 return 0x0300; 1514 } 1515 else if ("dead_cedilla".equals(keyStrokeName)) { 1516 return 0x0327; 1517 } 1518 else if ("dead_ogonek".equals(keyStrokeName)) { 1519 return 0x0328; 1520 } 1521 else if ("at".equals(keyStrokeName)) { 1522 return '@'; 1523 } 1524 else if ("Greek_OMEGA".equals(keyStrokeName)) { 1525 return 'Ω'; 1526 } 1527 else if ("EuroSign".equals(keyStrokeName)) { 1528 return '€'; 1529 } 1530 else if ("paragraph".equals(keyStrokeName)) { 1531 return 0x2029; 1532 } 1533 else if ("registered".equals(keyStrokeName)) { 1534 return '®'; 1535 } 1536 else if ("tslash".equals(keyStrokeName)) { 1537 return 'ŧ'; 1538 } 1539 else if ("Tslash".equals(keyStrokeName)) { 1540 return 'Ŧ'; 1541 } 1542 else if ("z".equals(keyStrokeName)) { 1543 return getUpper ? 'Z' : 'z'; 1544 } 1545 else if ("leftarrow".equals(keyStrokeName)) { 1546 return '←'; 1547 } 1548 else if ("yen".equals(keyStrokeName)) { 1549 return '¥'; 1550 } 1551 else if ("downarrow".equals(keyStrokeName)) { 1552 return '↓'; 1553 } 1554 else if ("uparrow".equals(keyStrokeName)) { 1555 return '↑'; 1556 } 1557 else if ("rightarrow".equals(keyStrokeName)) { 1558 return '→'; 1559 } 1560 else if ("idotless".equals(keyStrokeName)) { 1561 return 'ı'; 1562 } 1563 else if ("oslash".equals(keyStrokeName)) { 1564 return 'ø'; 1565 } 1566 else if ("Ooblique".equals(keyStrokeName)) { 1567 return 'Ø'; 1568 } 1569 else if ("thorn".equals(keyStrokeName)) { 1570 return 'þ'; 1571 } 1572 else if ("THORN".equals(keyStrokeName)) { 1573 return 'Þ'; 1574 } 1575 else if ("udiaeresis".equals(keyStrokeName)) { 1576 return getUpper ? 'Ü' : 'ü'; 1577 } 1578 else if ("Udiaeresis".equals(keyStrokeName)) { 1579 return getUpper ? 'Ü' : 'ü'; 1580 } 1581 else if ("dead_diaeresis".equals(keyStrokeName)) { 1582 return 0x0308; 1583 } 1584 else if ("dead_abovering".equals(keyStrokeName)) { 1585 return 0x030A; 1586 } 1587 else if ("plus".equals(keyStrokeName)) { 1588 return '+'; 1589 } 1590 else if ("asterisk".equals(keyStrokeName)) { 1591 return '*'; 1592 } 1593 else if ("asciitilde".equals(keyStrokeName)) { 1594 return '~'; 1595 } 1596 else if ("dead_tilde".equals(keyStrokeName)) { 1597 return 0x0303; 1598 } 1599 else if ("dead_macron".equals(keyStrokeName)) { 1600 return 0x0304; 1601 } 1602 else if ("ae".equals(keyStrokeName)) { 1603 return 'æ'; 1604 } 1605 else if ("AE".equals(keyStrokeName)) { 1606 return 'Æ'; 1607 } 1608 else if ("eth".equals(keyStrokeName)) { 1609 return 'ð'; 1610 } 1611 else if ("ETH".equals(keyStrokeName)) { 1612 return 'Ð'; 1613 } 1614 else if ("dstroke".equals(keyStrokeName)) { 1615 return getUpper ? 'Đ' : 'đ'; 1616 } 1617 else if ("ordfeminine".equals(keyStrokeName)) { 1618 return 'ª'; 1619 } 1620 else if ("eng".equals(keyStrokeName)) { 1621 return 'ŋ'; 1622 } 1623 else if ("ENG".equals(keyStrokeName)) { 1624 return 'Ŋ'; 1625 } 1626 else if ("hstroke".equals(keyStrokeName)) { 1627 return 'ħ'; 1628 } 1629 else if ("Hstroke".equals(keyStrokeName)) { 1630 return 'Ħ'; 1631 } 1632 else if ("kra".equals(keyStrokeName)) { 1633 return 'ĸ'; 1634 } 1635 else if ("odiaeresis".equals(keyStrokeName)) { 1636 return 'ö'; 1637 } 1638 else if ("Odiaeresis".equals(keyStrokeName)) { 1639 return 'Ö'; 1640 } 1641 else if ("dead_doubleacute".equals(keyStrokeName)) { 1642 return 0x030B; 1643 } 1644 else if ("adiaeresis".equals(keyStrokeName)) { 1645 return 'ä'; 1646 } 1647 else if ("Adiaeresis".equals(keyStrokeName)) { 1648 return 'Ä'; 1649 } 1650 else if ("dead_caron".equals(keyStrokeName)) { 1651 return 0x030C; 1652 } 1653 else if ("asciicircum".equals(keyStrokeName)) { 1654 return '^'; 1655 } 1656 else if ("dead_circumflex".equals(keyStrokeName)) { 1657 return 0x0302; 1658 } 1659 else if ("degree".equals(keyStrokeName)) { 1660 return '°'; 1661 } 1662 else if ("notsign".equals(keyStrokeName)) { 1663 return '¬'; 1664 } 1665 else if ("numbersign".equals(keyStrokeName)) { 1666 return '#'; 1667 } 1668 else if ("apostrophe".equals(keyStrokeName)) { 1669 return '\''; 1670 } 1671 else if ("dead_breve".equals(keyStrokeName)) { 1672 return 0x0306; 1673 } 1674 else if ("y".equals(keyStrokeName)) { 1675 return getUpper ? 'Y' : 'y'; 1676 } 1677 else if ("guillemotleft".equals(keyStrokeName)) { 1678 return '»'; 1679 } 1680 else if ("guillemotright".equals(keyStrokeName)) { 1681 return '«'; 1682 } 1683 else if ("cent".equals(keyStrokeName)) { 1684 return '¢'; 1685 } 1686 else if ("copyright".equals(keyStrokeName)) { 1687 return '©'; 1688 } 1689 else if ("leftdoublequotemark".equals(keyStrokeName)) { 1690 return '„'; 1691 } 1692 else if ("rightdoublequotemark".equals(keyStrokeName)) { 1693 return '“'; 1694 } 1695 else if ("mu".equals(keyStrokeName)) { 1696 return 'µ'; 1697 } 1698 else if ("masculine".equals(keyStrokeName)) { 1699 return 'º'; 1700 } 1701 else if ("comma".equals(keyStrokeName)) { 1702 return ','; 1703 } 1704 else if ("semicolon".equals(keyStrokeName)) { 1705 return ';'; 1706 } 1707 else if ("horizconnector".equals(keyStrokeName)) { 1708 return '·'; 1709 } 1710 else if ("multiply".equals(keyStrokeName)) { 1711 return '×'; 1712 } 1713 else if ("period".equals(keyStrokeName)) { 1714 return '.'; 1715 } 1716 else if ("colon".equals(keyStrokeName)) { 1717 return ':'; 1718 } 1719 else if ("periodcentered".equals(keyStrokeName)) { 1720 return '…'; 1721 } 1722 else if ("division".equals(keyStrokeName)) { 1723 return '÷'; 1724 } 1725 else if ("minus".equals(keyStrokeName)) { 1726 return '-'; 1727 } 1728 else if ("underscore".equals(keyStrokeName)) { 1729 return '_'; 1730 } 1731 else if ("dead_belowdot".equals(keyStrokeName)) { 1732 return 0x0323; 1733 } 1734 else if ("dead_abovedot".equals(keyStrokeName)) { 1735 return 0x0307; 1736 } 1737 else if ("eacute".equals(keyStrokeName)) { 1738 return getUpper ? 'É' : 'é'; 1739 } 1740 else if ("Eacute".equals(keyStrokeName)) { 1741 return getUpper ? 'É' : 'é'; 1742 } 1743 else if ("egrave".equals(keyStrokeName)) { 1744 return getUpper ? 'È' : 'è'; 1745 } 1746 else if ("Egrave".equals(keyStrokeName)) { 1747 return getUpper ? 'È' : 'è'; 1748 } 1749 else if ("ccedilla".equals(keyStrokeName)) { 1750 return getUpper ? 'Ç' : 'ç'; 1751 } 1752 else if ("Ccedilla".equals(keyStrokeName)) { 1753 return getUpper ? 'Ç' : 'ç'; 1754 } 1755 else if ("agrave".equals(keyStrokeName)) { 1756 return getUpper ? 'À' : 'à'; 1757 } 1758 else if ("Agrave".equals(keyStrokeName)) { 1759 return getUpper ? 'À' : 'à'; 1760 } 1761 else if ("lstroke".equals(keyStrokeName)) { 1762 return getUpper ? 'Ł' : 'ł'; 1763 } 1764 else if ("Lstroke".equals(keyStrokeName)) { 1765 return getUpper ? 'Ł' : 'ł'; 1766 } 1767 else if ("ugrave".equals(keyStrokeName)) { 1768 return getUpper ? 'Ù' : 'ù'; 1769 } 1770 else if ("Ugrave".equals(keyStrokeName)) { 1771 return getUpper ? 'Ù' : 'ù'; 1772 } 1773 else if ("igrave".equals(keyStrokeName)) { 1774 return getUpper ? 'Ì' : 'ì'; 1775 } 1776 else if ("Igrave".equals(keyStrokeName)) { 1777 return getUpper ? 'Ì' : 'ì'; 1778 } 1779 else if ("ograve".equals(keyStrokeName)) { 1780 return getUpper ? 'Ò' : 'ò'; 1781 } 1782 else if ("ograve".equals(keyStrokeName)) { 1783 return getUpper ? 'Ò' : 'ò'; 1784 } 1785 else if ("keyboard_type".equals(keyStrokeName)) { 1786 return Character.UNASSIGNED; 1787 } 1788 else if ("keyboard_subtype".equals(keyStrokeName)) { 1789 return Character.UNASSIGNED; 1790 } 1791 else if ("keyboard_functionkeys".equals(keyStrokeName)) { 1792 return Character.UNASSIGNED; 1793 } 1794 else if ("kana_NU".equals(keyStrokeName)) { 1795 return 'ヌ'; 1796 } 1797 else if ("kana_FU".equals(keyStrokeName)) { 1798 return 'フ'; 1799 } 1800 else if ("kana_A".equals(keyStrokeName)) { 1801 return 'ア'; 1802 } 1803 else if ("kana_a".equals(keyStrokeName)) { 1804 return 'ァ'; 1805 } 1806 else if ("kana_U".equals(keyStrokeName)) { 1807 return 'ウ'; 1808 } 1809 else if ("kana_u".equals(keyStrokeName)) { 1810 return 'ゥ'; 1811 } 1812 else if ("kana_E".equals(keyStrokeName)) { 1813 return 'エ'; 1814 } 1815 else if ("kana_e".equals(keyStrokeName)) { 1816 return 'ェ'; 1817 } 1818 else if ("kana_O".equals(keyStrokeName)) { 1819 return 'オ'; 1820 } 1821 else if ("kana_o".equals(keyStrokeName)) { 1822 return 'ォ'; 1823 } 1824 else if ("kana_YA".equals(keyStrokeName)) { 1825 return 'ヤ'; 1826 } 1827 else if ("kana_ya".equals(keyStrokeName)) { 1828 return 'ャ'; 1829 } 1830 else if ("kana_YU".equals(keyStrokeName)) { 1831 return 'ユ'; 1832 } 1833 else if ("kana_yu".equals(keyStrokeName)) { 1834 return 'ュ'; 1835 } 1836 else if ("kana_YO".equals(keyStrokeName)) { 1837 return 'ヨ'; 1838 } 1839 else if ("kana_yo".equals(keyStrokeName)) { 1840 return 'ョ'; 1841 } 1842 else if ("kana_WA".equals(keyStrokeName)) { 1843 return 'ワ'; 1844 } 1845 else if ("kana_WO".equals(keyStrokeName)) { 1846 return 'ヲ'; 1847 } 1848 else if ("kana_HO".equals(keyStrokeName)) { 1849 return 'ホ'; 1850 } 1851 else if ("kana_HE".equals(keyStrokeName)) { 1852 return 'ヘ'; 1853 } 1854 else if ("kana_TA".equals(keyStrokeName)) { 1855 return 'タ'; 1856 } 1857 else if ("kana_TE".equals(keyStrokeName)) { 1858 return 'テ'; 1859 } 1860 else if ("kana_I".equals(keyStrokeName)) { 1861 return 'イ'; 1862 } 1863 else if ("kana_i".equals(keyStrokeName)) { 1864 return 'ィ'; 1865 } 1866 else if ("kana_SU".equals(keyStrokeName)) { 1867 return 'ス'; 1868 } 1869 else if ("kana_KA".equals(keyStrokeName)) { 1870 return 'カ'; 1871 } 1872 else if ("kana_N".equals(keyStrokeName)) { 1873 return 'ン'; 1874 } 1875 else if ("kana_NA".equals(keyStrokeName)) { 1876 return 'ナ'; 1877 } 1878 else if ("kana_NI".equals(keyStrokeName)) { 1879 return 'ニ'; 1880 } 1881 else if ("kana_RA".equals(keyStrokeName)) { 1882 return 'ラ'; 1883 } 1884 else if ("kana_SE".equals(keyStrokeName)) { 1885 return 'セ'; 1886 } 1887 else if ("voicedsound".equals(keyStrokeName)) { 1888 return 0x3099; 1889 } 1890 else if ("semivoicedsound".equals(keyStrokeName)) { 1891 return 0x309A; 1892 } 1893 else if ("kana_openingbracket".equals(keyStrokeName)) { 1894 return 0x04A2; 1895 } 1896 else if ("kana_closingbracket".equals(keyStrokeName)) { 1897 return 0x04A3; 1898 } 1899 else if ("kana_CHI".equals(keyStrokeName)) { 1900 return 'チ'; 1901 } 1902 else if ("kana_TO".equals(keyStrokeName)) { 1903 return 'ト'; 1904 } 1905 else if ("kana_SHI".equals(keyStrokeName)) { 1906 return 'シ'; 1907 } 1908 else if ("kana_HA".equals(keyStrokeName)) { 1909 return 'ハ'; 1910 } 1911 else if ("kana_KI".equals(keyStrokeName)) { 1912 return 'キ'; 1913 } 1914 else if ("kana_KU".equals(keyStrokeName)) { 1915 return 'ク'; 1916 } 1917 else if ("kana_MA".equals(keyStrokeName)) { 1918 return 'マ'; 1919 } 1920 else if ("kana_NO".equals(keyStrokeName)) { 1921 return 'ノ'; 1922 } 1923 else if ("kana_RI".equals(keyStrokeName)) { 1924 return 'リ'; 1925 } 1926 else if ("kana_RE".equals(keyStrokeName)) { 1927 return 'レ'; 1928 } 1929 else if ("kana_KE".equals(keyStrokeName)) { 1930 return 'ケ'; 1931 } 1932 else if ("Zenkaku_Hankaku".equals(keyStrokeName)) { 1933 return Character.UNASSIGNED; 1934 } 1935 else if ("Kanji".equals(keyStrokeName)) { 1936 return Character.UNASSIGNED; 1937 } 1938 else if ("kana_MU".equals(keyStrokeName)) { 1939 return 'ム'; 1940 } 1941 else if ("kana_TSU".equals(keyStrokeName)) { 1942 return 'ツ'; 1943 } 1944 else if ("kana_tsu".equals(keyStrokeName)) { 1945 return 'ッ'; 1946 } 1947 else if ("kana_SA".equals(keyStrokeName)) { 1948 return 'サ'; 1949 } 1950 else if ("kana_SO".equals(keyStrokeName)) { 1951 return 'ソ'; 1952 } 1953 else if ("kana_HI".equals(keyStrokeName)) { 1954 return 'ヒ'; 1955 } 1956 else if ("kana_KO".equals(keyStrokeName)) { 1957 return 'コ'; 1958 } 1959 else if ("kana_MI".equals(keyStrokeName)) { 1960 return 'ミ'; 1961 } 1962 else if ("kana_MO".equals(keyStrokeName)) { 1963 return 'モ'; 1964 } 1965 else if ("kana_NE".equals(keyStrokeName)) { 1966 return 'ネ'; 1967 } 1968 else if ("kana_comma".equals(keyStrokeName)) { 1969 return '、'; 1970 } 1971 else if ("kana_RU".equals(keyStrokeName)) { 1972 return 'ル'; 1973 } 1974 else if ("kana_fullstop".equals(keyStrokeName)) { 1975 return '。'; 1976 } 1977 else if ("kana_ME".equals(keyStrokeName)) { 1978 return 'メ'; 1979 } 1980 else if ("kana_conjunctive".equals(keyStrokeName)) { 1981 return Character.UNASSIGNED; 1982 } 1983 else if ("Henkan_Mode".equals(keyStrokeName)) { 1984 return Character.UNASSIGNED; 1985 } 1986 else if ("Hiragana_Katakana".equals(keyStrokeName)) { 1987 return Character.UNASSIGNED; 1988 } 1989 else if ("Katakana".equals(keyStrokeName)) { 1990 return Character.UNASSIGNED; 1991 } 1992 else if ("Romaji".equals(keyStrokeName)) { 1993 return Character.UNASSIGNED; 1994 } 1995 else if ("Muhenkan".equals(keyStrokeName)) { 1996 return Character.UNASSIGNED; 1997 } 1998 else if ("Eisu_toggle".equals(keyStrokeName)) { 1999 return Character.UNASSIGNED; 2000 } 2001 else if ("Eisu_toggle".equals(keyStrokeName)) { 2002 return Character.UNASSIGNED; 2003 } 2004 else if ("F13".equals(keyStrokeName)) { 2005 return Character.UNASSIGNED; 2006 } 2007 else if ("Hangul".equals(keyStrokeName)) { 2008 return Character.UNASSIGNED; 2009 } 2010 else if ("Hangul_Hanja".equals(keyStrokeName)) { 2011 return Character.UNASSIGNED; 2012 } 2013 else { 2014 LOG.severe("unknown key stroke name " + keyStrokeName + 2015 " specified through keyboard map " + "for locale " + locale); 2016 2017 // if (shift) 2018 // { 2019 // System.err.println(" else if (\"" + keyStrokeName + "\".equals(keyStrokeName))"); 2020 // System.err.println(" {"); 2021 // System.err.println(" return shift ? '" + 2022 // Character.toUpperCase(keyStrokeName.charAt(0)) + 2023 // "' : '" + Character.toLowerCase(keyStrokeName.charAt(0)) + "';"); 2024 // System.err.println(" }"); 2025 // } 2026 // else 2027 // { 2028 // System.err.println(" else if (\"" + keyStrokeName + "\".equals(keyStrokeName))"); 2029 // System.err.println(" {"); 2030 // System.err.println(" return '" + keyStrokeName + "';"); 2031 // System.err.println(" }"); 2032 // } 2033 // 2034 // return 0x0; 2035 throw new IllegalArgumentException("no keyboard map available for locale " + locale); 2036 } 171 2037 } 172 173 return stream; 174 } 175 176 //----------------------------------------------------------------------------------------------- 177 /** 178 * TODO: comment 179 * 180 * @param stream 181 * @param virtualKeySynonyms 182 * @param deadKeySequences 183 */ 184 //----------------------------------------------------------------------------------------------- 185 private void readStream(InputStream stream, 186 List<String[]> deadKeySequences, 187 List<String[]> keyStrokes) 188 throws IllegalArgumentException 189 { 190 BufferedReader in = new BufferedReader(new InputStreamReader(stream)); 191 192 try 193 { 194 String line; 195 while ((line = in.readLine()) != null) 196 { 197 if (!"".equals(line)) 198 { 199 processLine(line, deadKeySequences, keyStrokes); 200 } 201 } 202 } 203 catch (IOException e) 204 { 205 LOG.log(Level.WARNING, "no keyboard map available for locale " + mLocale, e); 206 throw new IllegalArgumentException("no keyboard map available for locale " + mLocale, e); 207 } 208 finally 209 { 210 try 211 { 212 in.close(); 213 } 214 catch (IOException e) 215 { 216 LOG.warning("could not close input stream for reading keyboard map"); 217 } 218 } 219 } 220 221 //----------------------------------------------------------------------------------------------- 222 /** 223 * TODO: comment 224 * 225 * @param line 226 * @param deadKeySequences 227 */ 228 //----------------------------------------------------------------------------------------------- 229 private void processLine(String line, 230 List<String[]> deadKeySequences, 231 List<String[]> keyStrokes) 232 { 233 String[] values = line.split(" "); 234 235 if (values.length <= 0) 236 { 237 return; 238 } 239 240 // ignore comments 241 if (values[0].startsWith("#")) 242 { 243 return; 244 } 245 246 if ("map".equals(values[0])) 247 { 248 // this is the map id. Ignore it. 249 } 250 else if ("include".equals(values[0])) 251 { 252 // process all includes 253 for (int i = 1; i < values.length; i++) 254 { 255 if (!values[i].startsWith("#")) 256 { 257 readStream(getStream(values[i]), deadKeySequences, keyStrokes); 258 } 259 else 260 { 261 break; 262 } 263 } 264 } 265 else if ("sequence".equals(values[0])) 266 { 267 deadKeySequences.add(values); 268 } 269 else 270 { 271 boolean alreadyAdded = false; 272 273 // check, if there is a replacement 274 for (int i = 0; i < keyStrokes.size(); i++) 275 { 276 if (keyStrokes.get(i)[0].equals(values[0])) 277 { 278 LOG.finest("replacing key stroke " + values[0] + " with former keyid " + 279 keyStrokes.get(i)[1] + " with new key id " + values[1]); 280 keyStrokes.set(i, values); 281 alreadyAdded = true; 282 break; 283 } 284 } 285 286 if (!alreadyAdded) 287 { 288 keyStrokes.add(values); 289 } 290 } 291 } 292 293 //----------------------------------------------------------------------------------------------- 294 /** 295 * TODO: comment 296 * 297 * @param keyStrokes 298 * @return 299 */ 300 //----------------------------------------------------------------------------------------------- 301 private VirtualKeySynonyms determineVirtualKeySynonyms(List<String[]> keyStrokes) 302 { 303 LOG.info("determining virtual keys and synonyms for the keymap"); 304 305 VirtualKeySynonyms virtualKeySynonyms = new VirtualKeySynonyms(); 306 307 // for debugging purposes, determine which key strokes are not matched to virtual keys. 308 List<String[]> unmatchedKeyStrokes = new ArrayList<String[]>(); 309 310 for (String[] keyStroke : keyStrokes) 311 { 312 String keyStrokeName = keyStroke[0]; 313 int keyId = getKeyId(keyStroke[1]); 314 //System.err.println(keyStrokeName + " 0x" + Integer.toHexString(keyId)); 315 316 VirtualKey virtualKey = determineVirtualKey(keyStrokeName); 317 318 if (virtualKey != null) 319 { 320 virtualKeySynonyms.add(keyId, virtualKey); 321 } 322 else 323 { 324 unmatchedKeyStrokes.add(keyStroke); 325 } 326 } 327 328 for (String[] unmatchedKeyStroke : unmatchedKeyStrokes) 329 { 330 if (!virtualKeySynonyms.containsKey(getKeyId(unmatchedKeyStroke[1]))) 331 { 332 LOG.finest("no virtual key mapped to key stroke " + unmatchedKeyStroke[0] + "(" + 333 unmatchedKeyStroke[1] + ") of keyboard map for locale " + mLocale); 334 } 335 } 336 337 return virtualKeySynonyms; 338 } 339 340 //----------------------------------------------------------------------------------------------- 341 /** 342 * TODO: comment 343 * 344 * @param string 345 * @return 346 */ 347 //----------------------------------------------------------------------------------------------- 348 private int getKeyId(String keyIdString) 349 { 350 if (keyIdString.startsWith("0x")) 351 { 352 keyIdString = keyIdString.substring(2); 353 } 354 355 return Integer.parseInt(keyIdString, 16); 356 } 357 358 //----------------------------------------------------------------------------------------------- 359 /** 360 * TODO: comment 361 * 362 * @param keyStrokes 363 * @param virtualKeySynonyms 364 */ 365 //----------------------------------------------------------------------------------------------- 366 private void processKeyStrokes(List<String[]> keyStrokes, VirtualKeySynonyms virtualKeySynonyms) 367 { 368 for (String[] keyStroke : keyStrokes) 369 { 370 handleKeyStroke(keyStroke, virtualKeySynonyms); 371 } 372 373 addKeyStrokesIndependentOfNumLock(); 374 } 375 376 //----------------------------------------------------------------------------------------------- 377 /** 378 * TODO: comment 379 * 380 * @param values 381 */ 382 //----------------------------------------------------------------------------------------------- 383 private void handleKeyStroke(String[] values, 384 VirtualKeySynonyms virtualKeySynonyms) 385 { 386 String keyStrokeName = values[0]; 387 String keyIdString = values[1]; 388 if (keyIdString.startsWith("0x")) 389 { 390 keyIdString = keyIdString.substring(2); 391 } 392 393 int keyId = Integer.parseInt(keyIdString, 16); 394 395 // parse the conditions 396 boolean numlock = false; 397 boolean localstate = false; 398 boolean shift = false; 399 boolean altgr = false; 400 boolean addupper = false; 401 boolean inhibit = false; 402 403 for (int i = 2; i < values.length; i++) 404 { 405 if (!values[i].startsWith("#")) 406 { 407 if ("numlock".equals(values[i])) 408 { 409 numlock = true; 410 } 411 else if ("localstate".equals(values[i])) 412 { 413 localstate = true; 414 } 415 else if ("shift".equals(values[i])) 416 { 417 shift = true; 418 } 419 else if ("altgr".equals(values[i])) 420 { 421 altgr = true; 422 } 423 else if ("addupper".equals(values[i])) 424 { 425 addupper = true; 426 } 427 else if ("inhibit".equals(values[i])) 428 { 429 inhibit = true; 430 } 431 else 432 { 433 LOG.severe("unknown condition " + values[i] + " specified for key stroke " + 434 keyStrokeName + " through keyboard map for locale " + mLocale); 435 throw new IllegalArgumentException("no keyboard map available for locale " + mLocale); 436 } 437 } 438 else 439 { 440 break; 441 } 442 } 443 444 addAllRepresentedKeyStrokes(keyStrokeName, keyId, numlock, localstate, shift, altgr, addupper, 445 inhibit, virtualKeySynonyms); 446 } 447 448 //----------------------------------------------------------------------------------------------- 449 /** 450 * TODO: comment 451 * 452 * @param keyStrokeName 453 * @param keyId 454 * @param numlock 455 * @param localstate 456 * @param shift 457 * @param altgr 458 * @param addupper 459 * @param inhibit 460 */ 461 //----------------------------------------------------------------------------------------------- 462 private void addAllRepresentedKeyStrokes(String keyStrokeName, 463 int keyId, 464 boolean numlock, 465 boolean localstate, 466 boolean shift, 467 boolean altgr, 468 boolean addupper, 469 boolean inhibit, 470 VirtualKeySynonyms virtualKeySynonyms) 471 { 472 VirtualKey[] virtualKeys = virtualKeySynonyms.getVirtualKeySynonyms(keyId); 473 474 if (virtualKeys == null) 475 { 476 LOG.severe("no virtual key mapped to key stroke " + keyStrokeName + 477 " of keyboard map for locale " + mLocale); 478 //throw new IllegalArgumentException("no keyboard map available for locale " + mLocale); 479 return; 480 } 481 482 for (VirtualKey virtualKey : virtualKeys) 483 { 484 if (addupper) 485 { 486 char c = determineCharacter(keyStrokeName, true); 487 addKeyStroke(keyStrokeName, virtualKey, numlock, localstate, true, altgr, inhibit, c); 488 489 c = determineCharacter(keyStrokeName, false); 490 addKeyStroke(keyStrokeName, virtualKey, numlock, localstate, false, altgr, inhibit, c); 491 } 492 else 493 { 494 char c = determineCharacter(keyStrokeName, false); 495 addKeyStroke(keyStrokeName, virtualKey, numlock, localstate, shift, altgr, inhibit, c); 496 } 497 } 498 } 499 500 //----------------------------------------------------------------------------------------------- 501 /** 502 * TODO: comment 503 * 504 * @param keyStroke 505 */ 506 //----------------------------------------------------------------------------------------------- 507 private void addKeyStroke(String keyStrokeName, 508 VirtualKey virtualKey, 509 boolean numlock, 510 boolean localstate, 511 boolean shift, 512 boolean altgr, 513 boolean inhibit, 514 char character) 515 { 516 KeyStroke keyStroke = new KeyStroke 517 (keyStrokeName, virtualKey, numlock, localstate, shift, altgr, inhibit, character); 518 519 List<KeyStroke> keyStrokes = mKeyStrokes.get(keyStroke.getVirtualKey()); 520 521 if (keyStrokes == null) 522 { 523 keyStrokes = new ArrayList<KeyStroke>(); 524 mKeyStrokes.put(keyStroke.getVirtualKey(), keyStrokes); 525 } 526 527 keyStrokes.add(keyStroke); 528 } 529 530 //----------------------------------------------------------------------------------------------- 531 /** 532 * TODO: comment 533 * 534 */ 535 //----------------------------------------------------------------------------------------------- 536 private void addKeyStrokesIndependentOfNumLock() 537 { 538 for (Map.Entry<VirtualKey, List<KeyStroke>> entry : mKeyStrokes.entrySet()) 539 { 540 List<KeyStroke> keyStrokesToAdd = new ArrayList<KeyStroke>(); 541 for (KeyStroke keyStroke : entry.getValue()) 542 { 543 if (!keyStroke.getNumlock()) 544 { 545 boolean foundPositiveNumlockVariant = false; 546 for (KeyStroke candidate : entry.getValue()) 547 { 548 if ((candidate.getShift() == keyStroke.getShift()) && 549 (candidate.getAltgr() == keyStroke.getAltgr()) && 550 (candidate.getLocalstate() == keyStroke.getLocalstate()) && 551 (candidate.getInhibit() == keyStroke.getInhibit()) && 552 (candidate.getNumlock())) 553 { 554 foundPositiveNumlockVariant = true; 555 break; 556 } 557 } 558 559 if (!foundPositiveNumlockVariant) 560 { 561 keyStrokesToAdd.add(keyStroke); 562 } 563 } 564 } 565 566 for (KeyStroke keyStroke : keyStrokesToAdd) 567 { 568 addKeyStroke(keyStroke.getKeyStrokeName(), keyStroke.getVirtualKey(), true, 569 keyStroke.getLocalstate(), keyStroke.getShift(), keyStroke.getAltgr(), 570 keyStroke.getInhibit(), keyStroke.getCharacter()); 571 } 572 } 573 } 574 575 //----------------------------------------------------------------------------------------------- 576 /** 577 * TODO: comment 578 * 579 * @param deadKeySequences 580 */ 581 //----------------------------------------------------------------------------------------------- 582 private void processDeadKeySequences(List<String[]> deadKeySequences) 583 { 584 // TODO Auto-generated method stub 585 //System.out.println("PATRICK: KeyboardMap.processDeadKeySequences "); 586 587 } 588 589 //----------------------------------------------------------------------------------------------- 590 /** 591 * TODO: comment 592 * 593 * @param keyStrokeName 594 * @param shift 595 * @return 596 */ 597 //----------------------------------------------------------------------------------------------- 598 private VirtualKey determineVirtualKey(String keyStrokeName) 599 { 600 if ("Shift_R".equals(keyStrokeName)) 601 { 602 return VirtualKey.SHIFT; 603 } 604 else if ("Shift_L".equals(keyStrokeName)) 605 { 606 return VirtualKey.SHIFT; 607 } 608 else if ("Alt_R".equals(keyStrokeName)) 609 { 610 return VirtualKey.ALT_GRAPH; 611 } 612 else if ("Mode_switch".equals(keyStrokeName)) 613 { 614 return VirtualKey.MODECHANGE; 615 } 616 else if ("ISO_Level3_Shift".equals(keyStrokeName)) 617 { 618 return VirtualKey.SHIFT; 619 } 620 else if ("Alt_L".equals(keyStrokeName)) 621 { 622 return VirtualKey.ALT; 623 } 624 else if ("Control_R".equals(keyStrokeName)) 625 { 626 return VirtualKey.CONTROL; 627 } 628 else if ("Control_L".equals(keyStrokeName)) 629 { 630 return VirtualKey.CONTROL; 631 } 632 else if ("Menu".equals(keyStrokeName)) 633 { 634 return VirtualKey.WINDOWS; 635 } 636 else if ("1".equals(keyStrokeName)) 637 { 638 return VirtualKey.DIGIT_1; 639 } 640 else if ("2".equals(keyStrokeName)) 641 { 642 return VirtualKey.DIGIT_2; 643 } 644 else if ("3".equals(keyStrokeName)) 645 { 646 return VirtualKey.DIGIT_3; 647 } 648 else if ("4".equals(keyStrokeName)) 649 { 650 return VirtualKey.DIGIT_4; 651 } 652 else if ("5".equals(keyStrokeName)) 653 { 654 return VirtualKey.DIGIT_5; 655 } 656 else if ("6".equals(keyStrokeName)) 657 { 658 return VirtualKey.DIGIT_6; 659 } 660 else if ("7".equals(keyStrokeName)) 661 { 662 return VirtualKey.DIGIT_7; 663 } 664 else if ("8".equals(keyStrokeName)) 665 { 666 return VirtualKey.DIGIT_8; 667 } 668 else if ("9".equals(keyStrokeName)) 669 { 670 return VirtualKey.DIGIT_9; 671 } 672 else if ("0".equals(keyStrokeName)) 673 { 674 return VirtualKey.DIGIT_0; 675 } 676 else if ("BackSpace".equals(keyStrokeName)) 677 { 678 return VirtualKey.BACK_SPACE; 679 } 680 else if ("Tab".equals(keyStrokeName)) 681 { 682 return VirtualKey.TAB; 683 } 684 else if ("q".equals(keyStrokeName)) 685 { 686 return VirtualKey.LETTER_Q; 687 } 688 else if ("w".equals(keyStrokeName)) 689 { 690 return VirtualKey.LETTER_W; 691 } 692 else if ("e".equals(keyStrokeName)) 693 { 694 return VirtualKey.LETTER_E; 695 } 696 else if ("r".equals(keyStrokeName)) 697 { 698 return VirtualKey.LETTER_R; 699 } 700 else if ("t".equals(keyStrokeName)) 701 { 702 return VirtualKey.LETTER_T; 703 } 704 else if ("y".equals(keyStrokeName)) 705 { 706 return VirtualKey.LETTER_Y; 707 } 708 else if ("u".equals(keyStrokeName)) 709 { 710 return VirtualKey.LETTER_U; 711 } 712 else if ("i".equals(keyStrokeName)) 713 { 714 return VirtualKey.LETTER_I; 715 } 716 else if ("o".equals(keyStrokeName)) 717 { 718 return VirtualKey.LETTER_O; 719 } 720 else if ("p".equals(keyStrokeName)) 721 { 722 return VirtualKey.LETTER_P; 723 } 724 else if ("a".equals(keyStrokeName)) 725 { 726 return VirtualKey.LETTER_A; 727 } 728 else if ("s".equals(keyStrokeName)) 729 { 730 return VirtualKey.LETTER_S; 731 } 732 else if ("d".equals(keyStrokeName)) 733 { 734 return VirtualKey.LETTER_D; 735 } 736 else if ("f".equals(keyStrokeName)) 737 { 738 return VirtualKey.LETTER_F; 739 } 740 else if ("g".equals(keyStrokeName)) 741 { 742 return VirtualKey.LETTER_G; 743 } 744 else if ("h".equals(keyStrokeName)) 745 { 746 return VirtualKey.LETTER_H; 747 } 748 else if ("j".equals(keyStrokeName)) 749 { 750 return VirtualKey.LETTER_J; 751 } 752 else if ("k".equals(keyStrokeName)) 753 { 754 return VirtualKey.LETTER_K; 755 } 756 else if ("l".equals(keyStrokeName)) 757 { 758 return VirtualKey.LETTER_L; 759 } 760 else if ("Return".equals(keyStrokeName)) 761 { 762 return VirtualKey.ENTER; 763 } 764 else if ("z".equals(keyStrokeName)) 765 { 766 return VirtualKey.LETTER_Z; 767 } 768 else if ("x".equals(keyStrokeName)) 769 { 770 return VirtualKey.LETTER_X; 771 } 772 else if ("c".equals(keyStrokeName)) 773 { 774 return VirtualKey.LETTER_C; 775 } 776 else if ("v".equals(keyStrokeName)) 777 { 778 return VirtualKey.LETTER_V; 779 } 780 else if ("b".equals(keyStrokeName)) 781 { 782 return VirtualKey.LETTER_B; 783 } 784 else if ("n".equals(keyStrokeName)) 785 { 786 return VirtualKey.LETTER_N; 787 } 788 else if ("m".equals(keyStrokeName)) 789 { 790 return VirtualKey.LETTER_M; 791 } 792 else if ("space".equals(keyStrokeName)) 793 { 794 return VirtualKey.SPACE; 795 } 796 else if ("less".equals(keyStrokeName)) 797 { 798 return VirtualKey.LESS; 799 } 800 else if ("greater".equals(keyStrokeName)) 801 { 802 return VirtualKey.GREATER; 803 } 804 else if ("Escape".equals(keyStrokeName)) 805 { 806 return VirtualKey.ESCAPE; 807 } 808 else if ("F1".equals(keyStrokeName)) 809 { 810 return VirtualKey.F1; 811 } 812 else if ("F2".equals(keyStrokeName)) 813 { 814 return VirtualKey.F2; 815 } 816 else if ("F3".equals(keyStrokeName)) 817 { 818 return VirtualKey.F3; 819 } 820 else if ("F4".equals(keyStrokeName)) 821 { 822 return VirtualKey.F4; 823 } 824 else if ("F5".equals(keyStrokeName)) 825 { 826 return VirtualKey.F5; 827 } 828 else if ("F6".equals(keyStrokeName)) 829 { 830 return VirtualKey.F6; 831 } 832 else if ("F7".equals(keyStrokeName)) 833 { 834 return VirtualKey.F7; 835 } 836 else if ("F8".equals(keyStrokeName)) 837 { 838 return VirtualKey.F8; 839 } 840 else if ("F9".equals(keyStrokeName)) 841 { 842 return VirtualKey.F9; 843 } 844 else if ("F10".equals(keyStrokeName)) 845 { 846 return VirtualKey.F10; 847 } 848 else if ("F11".equals(keyStrokeName)) 849 { 850 return VirtualKey.F11; 851 } 852 else if ("F12".equals(keyStrokeName)) 853 { 854 return VirtualKey.F12; 855 } 856 else if ("F13".equals(keyStrokeName)) 857 { 858 return VirtualKey.F13; 859 } 860 else if ("F14".equals(keyStrokeName)) 861 { 862 return VirtualKey.F14; 863 } 864 else if ("F15".equals(keyStrokeName)) 865 { 866 return VirtualKey.F15; 867 } 868 else if ("F16".equals(keyStrokeName)) 869 { 870 return VirtualKey.F16; 871 } 872 else if ("F17".equals(keyStrokeName)) 873 { 874 return VirtualKey.F17; 875 } 876 else if ("F18".equals(keyStrokeName)) 877 { 878 return VirtualKey.F18; 879 } 880 else if ("F19".equals(keyStrokeName)) 881 { 882 return VirtualKey.F19; 883 } 884 else if ("F20".equals(keyStrokeName)) 885 { 886 return VirtualKey.F20; 887 } 888 else if ("F21".equals(keyStrokeName)) 889 { 890 return VirtualKey.F21; 891 } 892 else if ("F22".equals(keyStrokeName)) 893 { 894 return VirtualKey.F22; 895 } 896 else if ("F23".equals(keyStrokeName)) 897 { 898 return VirtualKey.F23; 899 } 900 else if ("F24".equals(keyStrokeName)) 901 { 902 return VirtualKey.F24; 903 } 904 else if ("Print".equals(keyStrokeName)) 905 { 906 return VirtualKey.PRINTSCREEN; 907 } 908 else if ("Scroll_Lock".equals(keyStrokeName)) 909 { 910 return VirtualKey.SCROLL_LOCK; 911 } 912 else if ("Insert".equals(keyStrokeName)) 913 { 914 return VirtualKey.INSERT; 915 } 916 else if ("Delete".equals(keyStrokeName)) 917 { 918 return VirtualKey.DELETE; 919 } 920 else if ("Home".equals(keyStrokeName)) 921 { 922 return VirtualKey.HOME; 923 } 924 else if ("End".equals(keyStrokeName)) 925 { 926 return VirtualKey.END; 927 } 928 else if ("Page_Up".equals(keyStrokeName)) 929 { 930 return VirtualKey.PAGE_UP; 931 } 932 else if ("Page_Down".equals(keyStrokeName)) 933 { 934 return VirtualKey.PAGE_DOWN; 935 } 936 else if ("Left".equals(keyStrokeName)) 937 { 938 return VirtualKey.LEFT; 939 } 940 else if ("Up".equals(keyStrokeName)) 941 { 942 return VirtualKey.UP; 943 } 944 else if ("Down".equals(keyStrokeName)) 945 { 946 return VirtualKey.DOWN; 947 } 948 else if ("Right".equals(keyStrokeName)) 949 { 950 return VirtualKey.RIGHT; 951 } 952 else if ("Num_Lock".equals(keyStrokeName)) 953 { 954 return VirtualKey.NUM_LOCK; 955 } 956 else if ("KP_Divide".equals(keyStrokeName)) 957 { 958 return VirtualKey.SLASH; 959 } 960 else if ("KP_Multiply".equals(keyStrokeName)) 961 { 962 return VirtualKey.ASTERISK; 963 } 964 else if ("KP_Subtract".equals(keyStrokeName)) 965 { 966 return VirtualKey.MINUS; 967 } 968 else if ("KP_Add".equals(keyStrokeName)) 969 { 970 return VirtualKey.PLUS; 971 } 972 else if ("KP_Enter".equals(keyStrokeName)) 973 { 974 return VirtualKey.ENTER; 975 } 976 else if ("KP_Decimal".equals(keyStrokeName)) 977 { 978 return VirtualKey.DECIMAL; 979 } 980 else if ("KP_Separator".equals(keyStrokeName)) 981 { 982 return VirtualKey.SEPARATOR; 983 } 984 else if ("KP_Delete".equals(keyStrokeName)) 985 { 986 return VirtualKey.DELETE; 987 } 988 else if ("KP_0".equals(keyStrokeName)) 989 { 990 return VirtualKey.NUMPAD_0; 991 } 992 else if ("KP_Insert".equals(keyStrokeName)) 993 { 994 return VirtualKey.INSERT; 995 } 996 else if ("KP_1".equals(keyStrokeName)) 997 { 998 return VirtualKey.NUMPAD_1; 999 } 1000 else if ("KP_End".equals(keyStrokeName)) 1001 { 1002 return VirtualKey.END; 1003 } 1004 else if ("KP_2".equals(keyStrokeName)) 1005 { 1006 return VirtualKey.NUMPAD_2; 1007 } 1008 else if ("KP_Down".equals(keyStrokeName)) 1009 { 1010 return VirtualKey.KP_DOWN; 1011 } 1012 else if ("KP_3".equals(keyStrokeName)) 1013 { 1014 return VirtualKey.NUMPAD_3; 1015 } 1016 else if ("KP_Next".equals(keyStrokeName)) 1017 { 1018 return VirtualKey.PAGE_DOWN; 1019 } 1020 else if ("KP_4".equals(keyStrokeName)) 1021 { 1022 return VirtualKey.NUMPAD_4; 1023 } 1024 else if ("KP_Left".equals(keyStrokeName)) 1025 { 1026 return VirtualKey.KP_LEFT; 1027 } 1028 else if ("KP_5".equals(keyStrokeName)) 1029 { 1030 return VirtualKey.NUMPAD_5; 1031 } 1032 else if ("KP_Begin".equals(keyStrokeName)) 1033 { 1034 return VirtualKey.BEGIN; 1035 } 1036 else if ("KP_6".equals(keyStrokeName)) 1037 { 1038 return VirtualKey.NUMPAD_6; 1039 } 1040 else if ("KP_Right".equals(keyStrokeName)) 1041 { 1042 return VirtualKey.KP_RIGHT; 1043 } 1044 else if ("KP_7".equals(keyStrokeName)) 1045 { 1046 return VirtualKey.NUMPAD_7; 1047 } 1048 else if ("KP_Home".equals(keyStrokeName)) 1049 { 1050 return VirtualKey.HOME; 1051 } 1052 else if ("KP_8".equals(keyStrokeName)) 1053 { 1054 return VirtualKey.NUMPAD_8; 1055 } 1056 else if ("KP_Up".equals(keyStrokeName)) 1057 { 1058 return VirtualKey.KP_UP; 1059 } 1060 else if ("KP_9".equals(keyStrokeName)) 1061 { 1062 return VirtualKey.NUMPAD_9; 1063 } 1064 else if ("KP_Prior".equals(keyStrokeName)) 1065 { 1066 return VirtualKey.PAGE_UP; 1067 } 1068 else if ("Caps_Lock".equals(keyStrokeName)) 1069 { 1070 return VirtualKey.CAPS_LOCK; 1071 } 1072 else if ("exclam".equals(keyStrokeName)) 1073 { 1074 return VirtualKey.EXCLAMATION_MARK; 1075 } 1076 else if ("exclamdown".equals(keyStrokeName)) 1077 { 1078 return VirtualKey.INVERTED_EXCLAMATION_MARK; 1079 } 1080 else if ("quotedbl".equals(keyStrokeName)) 1081 { 1082 return VirtualKey.QUOTEDBL; 1083 } 1084 else if ("slash".equals(keyStrokeName)) 1085 { 1086 return VirtualKey.SLASH; 1087 } 1088 else if ("backslash".equals(keyStrokeName)) 1089 { 1090 return VirtualKey.BACK_SLASH; 1091 } 1092 else if ("dead_acute".equals(keyStrokeName)) 1093 { 1094 return VirtualKey.DEAD_ACUTE; 1095 } 1096 else if ("dead_diaresis".equals(keyStrokeName)) 1097 { 1098 return VirtualKey.DEAD_DIAERESIS; 1099 } 1100 else if ("dead_abovering".equals(keyStrokeName)) 1101 { 1102 return VirtualKey.DEAD_ABOVERING; 1103 } 1104 else if ("plus".equals(keyStrokeName)) 1105 { 1106 return VirtualKey.PLUS; 1107 } 1108 else if ("asterisk".equals(keyStrokeName)) 1109 { 1110 return VirtualKey.ASTERISK; 1111 } 1112 else if ("dead_tilde".equals(keyStrokeName)) 1113 { 1114 return VirtualKey.DEAD_TILDE; 1115 } 1116 else if ("dead_doubleacute".equals(keyStrokeName)) 1117 { 1118 return VirtualKey.DEAD_DOUBLEACUTE; 1119 } 1120 else if ("dead_caron".equals(keyStrokeName)) 1121 { 1122 return VirtualKey.DEAD_CARON; 1123 } 1124 else if ("dead_circumflex".equals(keyStrokeName)) 1125 { 1126 return VirtualKey.DEAD_CIRCUMFLEX; 1127 } 1128 else if ("comma".equals(keyStrokeName)) 1129 { 1130 return VirtualKey.COMMA; 1131 } 1132 else if ("semicolon".equals(keyStrokeName)) 1133 { 1134 return VirtualKey.SEMICOLON; 1135 } 1136 else if ("multiply".equals(keyStrokeName)) 1137 { 1138 return VirtualKey.MULTIPLY; 1139 } 1140 else if ("period".equals(keyStrokeName)) 1141 { 1142 return VirtualKey.PERIOD; 1143 } 1144 else if ("colon".equals(keyStrokeName)) 1145 { 1146 return VirtualKey.COLON; 1147 } 1148 else if ("dead_breve".equals(keyStrokeName)) 1149 { 1150 return VirtualKey.DEAD_BREVE; 1151 } 1152 else if ("division".equals(keyStrokeName)) 1153 { 1154 return VirtualKey.DIVIDE; 1155 } 1156 else if ("minus".equals(keyStrokeName)) 1157 { 1158 return VirtualKey.MINUS; 1159 } 1160 else if ("underscore".equals(keyStrokeName)) 1161 { 1162 return VirtualKey.UNDERSCORE; 1163 } 1164 else if ("dead_abovedot".equals(keyStrokeName)) 1165 { 1166 return VirtualKey.DEAD_ABOVEDOT; 1167 } 1168 else if ("bracketleft".equals(keyStrokeName)) 1169 { 1170 return VirtualKey.OPEN_BRACKET; 1171 } 1172 else if ("bracketright".equals(keyStrokeName)) 1173 { 1174 return VirtualKey.CLOSE_BRACKET; 1175 } 1176 else if ("grave".equals(keyStrokeName)) 1177 { 1178 return VirtualKey.DEAD_GRAVE; 1179 } 1180 else if ("equal".equals(keyStrokeName)) 1181 { 1182 return VirtualKey.EQUALS; 1183 } 1184 else if ("dead_macron".equals(keyStrokeName)) 1185 { 1186 return VirtualKey.DEAD_MACRON; 1187 } 1188 else if ("dead_ogonek".equals(keyStrokeName)) 1189 { 1190 return VirtualKey.DEAD_OGONEK; 1191 } 1192 else if ("dead_cedilla".equals(keyStrokeName)) 1193 { 1194 return VirtualKey.DEAD_CEDILLA; 1195 } 1196 else if ("ampersand".equals(keyStrokeName)) 1197 { 1198 return VirtualKey.AMPERSAND; 1199 } 1200 else if ("parenleft".equals(keyStrokeName)) 1201 { 1202 return VirtualKey.LEFT_PARENTHESIS; 1203 } 1204 else if ("parenright".equals(keyStrokeName)) 1205 { 1206 return VirtualKey.RIGHT_PARENTHESIS; 1207 } 1208 else if ("braceleft".equals(keyStrokeName)) 1209 { 1210 return VirtualKey.BRACELEFT; 1211 } 1212 else if ("braceright".equals(keyStrokeName)) 1213 { 1214 return VirtualKey.BRACERIGHT; 1215 } 1216 else if ("at".equals(keyStrokeName)) 1217 { 1218 return VirtualKey.AT; 1219 } 1220 else if ("dollar".equals(keyStrokeName)) 1221 { 1222 return VirtualKey.DOLLAR; 1223 } 1224 else if ("EuroSign".equals(keyStrokeName)) 1225 { 1226 return VirtualKey.EURO_SIGN; 1227 } 1228 else if ("Begin".equals(keyStrokeName)) 1229 { 1230 return VirtualKey.BEGIN; 1231 } 1232 else if ("numbersign".equals(keyStrokeName)) 1233 { 1234 return VirtualKey.NUMBER_SIGN; 1235 } 1236 else if ("asciicircum".equals(keyStrokeName)) 1237 { 1238 return VirtualKey.CIRCUMFLEX; 1239 } 1240 else if ("Kanji".equals(keyStrokeName)) 1241 { 1242 return VirtualKey.KANJI; 1243 } 1244 else if ("Katakana".equals(keyStrokeName)) 1245 { 1246 return VirtualKey.KATAKANA; 1247 } 1248 else if ("Hiragana_Katakana".equals(keyStrokeName)) 1249 { 1250 return VirtualKey.HIRAGANA; 1251 } 1252 else if ("Muhenkan".equals(keyStrokeName)) 1253 { 1254 // I found this in the KeyEvent description 1255 return VirtualKey.NONCONVERT; 1256 } 1257 else if ("kan".equals(keyStrokeName)) 1258 { 1259 // I found this in the KeyEvent description 1260 return VirtualKey.NONCONVERT; 1261 } 1262 else if ("Henkan_Mode".equals(keyStrokeName)) 1263 { 1264 // I found this in the key event description 1265 return VirtualKey.CONVERT; 1266 } 1267 else if ("voicedsound".equals(keyStrokeName)) 1268 { 1269 return VirtualKey.DEAD_VOICED_SOUND; 1270 } 1271 else if ("semivoicedsound".equals(keyStrokeName)) 1272 { 1273 return VirtualKey.DEAD_SEMIVOICED_SOUND; 1274 } 1275 else if ("Menu".equals(keyStrokeName)) 1276 { 1277 return VirtualKey.CONTEXT_MENU; 1278 } 1279 else 1280 { 1281 LOG.finest("unknown virtual key for key stroke " + keyStrokeName + " specified through " + 1282 "keyboard map for locale " + mLocale); 1283 1284 return null; 1285 } 1286 1287 // for the following virtual keys no key stroke names are provided in the key maps 1288 /*CANCEL(KeyEvent.VK_CANCEL), 1289 CLEAR(KeyEvent.VK_CLEAR), 1290 PAUSE(KeyEvent.VK_PAUSE), 1291 HELP(KeyEvent.VK_HELP), 1292 META(KeyEvent.VK_META), 1293 1294 BACK_QUOTE(KeyEvent.VK_BACK_QUOTE), 1295 QUOTE(KeyEvent.VK_QUOTE), 1296 1297 DEAD_IOTA(KeyEvent.VK_DEAD_IOTA), 1298 1299 FINAL(KeyEvent.VK_FINAL), 1300 CONVERT(KeyEvent.VK_CONVERT), 1301 NONCONVERT(KeyEvent.VK_NONCONVERT), 1302 ACCEPT(KeyEvent.VK_ACCEPT), 1303 KANA(KeyEvent.VK_KANA), 1304 ALPHANUMERIC(KeyEvent.VK_ALPHANUMERIC), 1305 FULL_WIDTH(KeyEvent.VK_FULL_WIDTH), 1306 HALF_WIDTH(KeyEvent.VK_HALF_WIDTH), 1307 ROMAN_CHARACTERS(KeyEvent.VK_ROMAN_CHARACTERS), 1308 ALL_CANDIDATES(KeyEvent.VK_ALL_CANDIDATES), 1309 PREVIOUS_CANDIDATE(KeyEvent.VK_PREVIOUS_CANDIDATE), 1310 CODE_INPUT(KeyEvent.VK_CODE_INPUT), 1311 JAPANESE_KATAKANA(KeyEvent.VK_JAPANESE_KATAKANA), 1312 JAPANESE_HIRAGANA(KeyEvent.VK_JAPANESE_HIRAGANA), 1313 JAPANESE_ROMAN(KeyEvent.VK_JAPANESE_ROMAN), 1314 KANA_LOCK(KeyEvent.VK_KANA_LOCK), 1315 INPUT_METHOD_ON_OFF(KeyEvent.VK_INPUT_METHOD_ON_OFF), 1316 1317 CUT(KeyEvent.VK_CUT), 1318 COPY(KeyEvent.VK_COPY), 1319 PASTE(KeyEvent.VK_PASTE), 1320 UNDO(KeyEvent.VK_UNDO), 1321 AGAIN(KeyEvent.VK_AGAIN), 1322 FIND(KeyEvent.VK_FIND), 1323 PROPS(KeyEvent.VK_PROPS), 1324 STOP(KeyEvent.VK_STOP), 1325 COMPOSE(KeyEvent.VK_COMPOSE),*/ 1326 } 1327 1328 //----------------------------------------------------------------------------------------------- 1329 /** 1330 * TODO: comment 1331 * 1332 * @param keyStrokeName 1333 * @param shift 1334 * @return 1335 */ 1336 //----------------------------------------------------------------------------------------------- 1337 private char determineCharacter(String keyStrokeName, boolean getUpper) 1338 { 1339 if ("Shift_R".equals(keyStrokeName)) 1340 { 1341 return Character.UNASSIGNED; 1342 } 1343 else if ("Shift_L".equals(keyStrokeName)) 1344 { 1345 return Character.UNASSIGNED; 1346 } 1347 else if ("Alt_R".equals(keyStrokeName)) 1348 { 1349 return Character.UNASSIGNED; 1350 } 1351 else if ("Mode_switch".equals(keyStrokeName)) 1352 { 1353 return Character.UNASSIGNED; 1354 } 1355 else if ("ISO_Level3_Shift".equals(keyStrokeName)) 1356 { 1357 return Character.UNASSIGNED; 1358 } 1359 else if ("Alt_L".equals(keyStrokeName)) 1360 { 1361 return Character.UNASSIGNED; 1362 } 1363 else if ("Control_R".equals(keyStrokeName)) 1364 { 1365 return Character.UNASSIGNED; 1366 } 1367 else if ("Control_L".equals(keyStrokeName)) 1368 { 1369 return Character.UNASSIGNED; 1370 } 1371 else if ("Menu".equals(keyStrokeName)) 1372 { 1373 return Character.UNASSIGNED; 1374 } 1375 else if ("1".equals(keyStrokeName)) 1376 { 1377 return '1'; 1378 } 1379 else if ("2".equals(keyStrokeName)) 1380 { 1381 return '2'; 1382 } 1383 else if ("3".equals(keyStrokeName)) 1384 { 1385 return '3'; 1386 } 1387 else if ("4".equals(keyStrokeName)) 1388 { 1389 return '4'; 1390 } 1391 else if ("5".equals(keyStrokeName)) 1392 { 1393 return '5'; 1394 } 1395 else if ("6".equals(keyStrokeName)) 1396 { 1397 return '6'; 1398 } 1399 else if ("7".equals(keyStrokeName)) 1400 { 1401 return '7'; 1402 } 1403 else if ("8".equals(keyStrokeName)) 1404 { 1405 return '8'; 1406 } 1407 else if ("9".equals(keyStrokeName)) 1408 { 1409 return '9'; 1410 } 1411 else if ("0".equals(keyStrokeName)) 1412 { 1413 return '0'; 1414 } 1415 else if ("BackSpace".equals(keyStrokeName)) 1416 { 1417 return '\b'; 1418 } 1419 else if ("Tab".equals(keyStrokeName)) 1420 { 1421 return '\t'; 1422 } 1423 else if ("ISO_Left_Tab".equals(keyStrokeName)) 1424 { 1425 return Character.UNASSIGNED; 1426 } 1427 else if ("q".equals(keyStrokeName)) 1428 { 1429 return getUpper ? 'Q' : 'q'; 1430 } 1431 else if ("w".equals(keyStrokeName)) 1432 { 1433 return getUpper ? 'W' : 'w'; 1434 } 1435 else if ("e".equals(keyStrokeName)) 1436 { 1437 return getUpper ? 'E' : 'e'; 1438 } 1439 else if ("r".equals(keyStrokeName)) 1440 { 1441 return getUpper ? 'R' : 'r'; 1442 } 1443 else if ("t".equals(keyStrokeName)) 1444 { 1445 return getUpper ? 'T' : 't'; 1446 } 1447 else if ("y".equals(keyStrokeName)) 1448 { 1449 return getUpper ? 'Y' : 'y'; 1450 } 1451 else if ("u".equals(keyStrokeName)) 1452 { 1453 return getUpper ? 'U' : 'u'; 1454 } 1455 else if ("i".equals(keyStrokeName)) 1456 { 1457 return getUpper ? 'I' : 'i'; 1458 } 1459 else if ("o".equals(keyStrokeName)) 1460 { 1461 return getUpper ? 'O' : 'o'; 1462 } 1463 else if ("p".equals(keyStrokeName)) 1464 { 1465 return getUpper ? 'P' : 'p'; 1466 } 1467 else if ("a".equals(keyStrokeName)) 1468 { 1469 return getUpper ? 'A' : 'a'; 1470 } 1471 else if ("s".equals(keyStrokeName)) 1472 { 1473 return getUpper ? 'S' : 's'; 1474 } 1475 else if ("d".equals(keyStrokeName)) 1476 { 1477 return getUpper ? 'D' : 'd'; 1478 } 1479 else if ("f".equals(keyStrokeName)) 1480 { 1481 return getUpper ? 'F' : 'f'; 1482 } 1483 else if ("g".equals(keyStrokeName)) 1484 { 1485 return getUpper ? 'G' : 'g'; 1486 } 1487 else if ("h".equals(keyStrokeName)) 1488 { 1489 return getUpper ? 'H' : 'h'; 1490 } 1491 else if ("j".equals(keyStrokeName)) 1492 { 1493 return getUpper ? 'J' : 'j'; 1494 } 1495 else if ("k".equals(keyStrokeName)) 1496 { 1497 return getUpper ? 'K' : 'k'; 1498 } 1499 else if ("l".equals(keyStrokeName)) 1500 { 1501 return getUpper ? 'L' : 'l'; 1502 } 1503 else if ("Return".equals(keyStrokeName)) 1504 { 1505 return '\n'; 1506 } 1507 else if ("z".equals(keyStrokeName)) 1508 { 1509 return getUpper ? 'Z' : 'z'; 1510 } 1511 else if ("x".equals(keyStrokeName)) 1512 { 1513 return getUpper ? 'X' : 'x'; 1514 } 1515 else if ("c".equals(keyStrokeName)) 1516 { 1517 return getUpper ? 'C' : 'c'; 1518 } 1519 else if ("v".equals(keyStrokeName)) 1520 { 1521 return getUpper ? 'V' : 'v'; 1522 } 1523 else if ("b".equals(keyStrokeName)) 1524 { 1525 return getUpper ? 'B' : 'b'; 1526 } 1527 else if ("n".equals(keyStrokeName)) 1528 { 1529 return getUpper ? 'N' : 'n'; 1530 } 1531 else if ("m".equals(keyStrokeName)) 1532 { 1533 return getUpper ? 'M' : 'm'; 1534 } 1535 else if ("space".equals(keyStrokeName)) 1536 { 1537 return ' '; 1538 } 1539 else if ("less".equals(keyStrokeName)) 1540 { 1541 return '<'; 1542 } 1543 else if ("greater".equals(keyStrokeName)) 1544 { 1545 return '>'; 1546 } 1547 else if ("bar".equals(keyStrokeName)) 1548 { 1549 return '|'; 1550 } 1551 else if ("brokenbar".equals(keyStrokeName)) 1552 { 1553 return '¦'; 1554 } 1555 else if ("Escape".equals(keyStrokeName)) 1556 { 1557 return Character.UNASSIGNED; 1558 } 1559 else if ("F1".equals(keyStrokeName)) 1560 { 1561 return Character.UNASSIGNED; 1562 } 1563 else if ("F2".equals(keyStrokeName)) 1564 { 1565 return Character.UNASSIGNED; 1566 } 1567 else if ("F3".equals(keyStrokeName)) 1568 { 1569 return Character.UNASSIGNED; 1570 } 1571 else if ("F4".equals(keyStrokeName)) 1572 { 1573 return Character.UNASSIGNED; 1574 } 1575 else if ("F5".equals(keyStrokeName)) 1576 { 1577 return Character.UNASSIGNED; 1578 } 1579 else if ("F6".equals(keyStrokeName)) 1580 { 1581 return Character.UNASSIGNED; 1582 } 1583 else if ("F7".equals(keyStrokeName)) 1584 { 1585 return Character.UNASSIGNED; 1586 } 1587 else if ("F8".equals(keyStrokeName)) 1588 { 1589 return Character.UNASSIGNED; 1590 } 1591 else if ("F9".equals(keyStrokeName)) 1592 { 1593 return Character.UNASSIGNED; 1594 } 1595 else if ("F10".equals(keyStrokeName)) 1596 { 1597 return Character.UNASSIGNED; 1598 } 1599 else if ("F11".equals(keyStrokeName)) 1600 { 1601 return Character.UNASSIGNED; 1602 } 1603 else if ("SunF36".equals(keyStrokeName)) 1604 { 1605 return Character.UNASSIGNED; 1606 } 1607 else if ("F12".equals(keyStrokeName)) 1608 { 1609 return Character.UNASSIGNED; 1610 } 1611 else if ("SunF37".equals(keyStrokeName)) 1612 { 1613 return Character.UNASSIGNED; 1614 } 1615 else if ("Print".equals(keyStrokeName)) 1616 { 1617 return Character.UNASSIGNED; 1618 } 1619 else if ("Sys_Req".equals(keyStrokeName)) 1620 { 1621 return Character.UNASSIGNED; 1622 } 1623 else if ("Execute".equals(keyStrokeName)) 1624 { 1625 return Character.UNASSIGNED; 1626 } 1627 else if ("F22".equals(keyStrokeName)) 1628 { 1629 return Character.UNASSIGNED; 1630 } 1631 else if ("Scroll_Lock".equals(keyStrokeName)) 1632 { 1633 return Character.UNASSIGNED; 1634 } 1635 else if ("F23".equals(keyStrokeName)) 1636 { 1637 return Character.UNASSIGNED; 1638 } 1639 else if ("Insert".equals(keyStrokeName)) 1640 { 1641 return Character.UNASSIGNED; 1642 } 1643 else if ("Delete".equals(keyStrokeName)) 1644 { 1645 return Character.UNASSIGNED; 1646 } 1647 else if ("Home".equals(keyStrokeName)) 1648 { 1649 return Character.UNASSIGNED; 1650 } 1651 else if ("End".equals(keyStrokeName)) 1652 { 1653 return Character.UNASSIGNED; 1654 } 1655 else if ("Page_Up".equals(keyStrokeName)) 1656 { 1657 return Character.UNASSIGNED; 1658 } 1659 else if ("Page_Down".equals(keyStrokeName)) 1660 { 1661 return Character.UNASSIGNED; 1662 } 1663 else if ("Left".equals(keyStrokeName)) 1664 { 1665 return Character.UNASSIGNED; 1666 } 1667 else if ("Up".equals(keyStrokeName)) 1668 { 1669 return Character.UNASSIGNED; 1670 } 1671 else if ("Down".equals(keyStrokeName)) 1672 { 1673 return Character.UNASSIGNED; 1674 } 1675 else if ("Right".equals(keyStrokeName)) 1676 { 1677 return Character.UNASSIGNED; 1678 } 1679 else if ("Num_Lock".equals(keyStrokeName)) 1680 { 1681 return Character.UNASSIGNED; 1682 } 1683 else if ("KP_Divide".equals(keyStrokeName)) 1684 { 1685 return '/'; 1686 } 1687 else if ("KP_Multiply".equals(keyStrokeName)) 1688 { 1689 return '*'; 1690 } 1691 else if ("KP_Subtract".equals(keyStrokeName)) 1692 { 1693 return '-'; 1694 } 1695 else if ("KP_Add".equals(keyStrokeName)) 1696 { 1697 return '+'; 1698 } 1699 else if ("KP_Enter".equals(keyStrokeName)) 1700 { 1701 return '\n'; 1702 } 1703 else if ("KP_Decimal".equals(keyStrokeName)) 1704 { 1705 return ','; 1706 } 1707 else if ("KP_Separator".equals(keyStrokeName)) 1708 { 1709 return ','; 1710 } 1711 else if ("KP_Delete".equals(keyStrokeName)) 1712 { 1713 return Character.UNASSIGNED; 1714 } 1715 else if ("KP_0".equals(keyStrokeName)) 1716 { 1717 return '0'; 1718 } 1719 else if ("KP_Insert".equals(keyStrokeName)) 1720 { 1721 return Character.UNASSIGNED; 1722 } 1723 else if ("KP_1".equals(keyStrokeName)) 1724 { 1725 return '1'; 1726 } 1727 else if ("KP_End".equals(keyStrokeName)) 1728 { 1729 return Character.UNASSIGNED; 1730 } 1731 else if ("KP_2".equals(keyStrokeName)) 1732 { 1733 return '2'; 1734 } 1735 else if ("KP_Down".equals(keyStrokeName)) 1736 { 1737 return Character.UNASSIGNED; 1738 } 1739 else if ("KP_3".equals(keyStrokeName)) 1740 { 1741 return '3'; 1742 } 1743 else if ("KP_Next".equals(keyStrokeName)) 1744 { 1745 return Character.UNASSIGNED; 1746 } 1747 else if ("KP_4".equals(keyStrokeName)) 1748 { 1749 return '4'; 1750 } 1751 else if ("KP_Left".equals(keyStrokeName)) 1752 { 1753 return Character.UNASSIGNED; 1754 } 1755 else if ("KP_5".equals(keyStrokeName)) 1756 { 1757 return '5'; 1758 } 1759 else if ("KP_Begin".equals(keyStrokeName)) 1760 { 1761 return Character.UNASSIGNED; 1762 } 1763 else if ("KP_6".equals(keyStrokeName)) 1764 { 1765 return '6'; 1766 } 1767 else if ("KP_Right".equals(keyStrokeName)) 1768 { 1769 return Character.UNASSIGNED; 1770 } 1771 else if ("KP_7".equals(keyStrokeName)) 1772 { 1773 return '7'; 1774 } 1775 else if ("KP_Home".equals(keyStrokeName)) 1776 { 1777 return Character.UNASSIGNED; 1778 } 1779 else if ("KP_8".equals(keyStrokeName)) 1780 { 1781 return '8'; 1782 } 1783 else if ("KP_Up".equals(keyStrokeName)) 1784 { 1785 return Character.UNASSIGNED; 1786 } 1787 else if ("KP_9".equals(keyStrokeName)) 1788 { 1789 return '9'; 1790 } 1791 else if ("KP_Prior".equals(keyStrokeName)) 1792 { 1793 return Character.UNASSIGNED; 1794 } 1795 else if ("Caps_Lock".equals(keyStrokeName)) 1796 { 1797 return Character.UNASSIGNED; 1798 } 1799 else if ("Multi_key".equals(keyStrokeName)) 1800 { 1801 return Character.UNASSIGNED; 1802 } 1803 else if ("exclam".equals(keyStrokeName)) 1804 { 1805 return '!'; 1806 } 1807 else if ("onesuperior".equals(keyStrokeName)) 1808 { 1809 return '¹'; 1810 } 1811 else if ("exclamdown".equals(keyStrokeName)) 1812 { 1813 return '¡'; 1814 } 1815 else if ("quotedbl".equals(keyStrokeName)) 1816 { 1817 return '"'; 1818 } 1819 else if ("twosuperior".equals(keyStrokeName)) 1820 { 1821 return '²'; 1822 } 1823 else if ("oneeighth".equals(keyStrokeName)) 1824 { 1825 return '⅛'; 1826 } 1827 else if ("section".equals(keyStrokeName)) 1828 { 1829 return '§'; 1830 } 1831 else if ("threesuperior".equals(keyStrokeName)) 1832 { 1833 return '³'; 1834 } 1835 else if ("sterling".equals(keyStrokeName)) 1836 { 1837 return '£'; 1838 } 1839 else if ("dollar".equals(keyStrokeName)) 1840 { 1841 return '$'; 1842 } 1843 else if ("onequarter".equals(keyStrokeName)) 1844 { 1845 return '¼'; 1846 } 1847 else if ("currency".equals(keyStrokeName)) 1848 { 1849 return '¤'; 1850 } 1851 else if ("percent".equals(keyStrokeName)) 1852 { 1853 return '%'; 1854 } 1855 else if ("onehalf".equals(keyStrokeName)) 1856 { 1857 return '½'; 1858 } 1859 else if ("threeeighths".equals(keyStrokeName)) 1860 { 1861 return '⅜'; 1862 } 1863 else if ("ampersand".equals(keyStrokeName)) 1864 { 1865 return '&'; 1866 } 1867 else if ("threequarters".equals(keyStrokeName)) 1868 { 1869 return '¾'; 1870 } 1871 else if ("fiveeighths".equals(keyStrokeName)) 1872 { 1873 return '⅝'; 1874 } 1875 else if ("slash".equals(keyStrokeName)) 1876 { 1877 return '/'; 1878 } 1879 else if ("braceleft".equals(keyStrokeName)) 1880 { 1881 return '{'; 1882 } 1883 else if ("seveneighths".equals(keyStrokeName)) 1884 { 1885 return '⅞'; 1886 } 1887 else if ("parenleft".equals(keyStrokeName)) 1888 { 1889 return '('; 1890 } 1891 else if ("bracketleft".equals(keyStrokeName)) 1892 { 1893 return '['; 1894 } 1895 else if ("trademark".equals(keyStrokeName)) 1896 { 1897 return '™'; 1898 } 1899 else if ("parenright".equals(keyStrokeName)) 1900 { 1901 return ')'; 1902 } 1903 else if ("bracketright".equals(keyStrokeName)) 1904 { 1905 return ']'; 1906 } 1907 else if ("plusminus".equals(keyStrokeName)) 1908 { 1909 return '±'; 1910 } 1911 else if ("equal".equals(keyStrokeName)) 1912 { 1913 return '='; 1914 } 1915 else if ("braceright".equals(keyStrokeName)) 1916 { 1917 return '}'; 1918 } 1919 else if ("ssharp".equals(keyStrokeName)) 1920 { 1921 return 'ß'; 1922 } 1923 else if ("question".equals(keyStrokeName)) 1924 { 1925 return '?'; 1926 } 1927 else if ("backslash".equals(keyStrokeName)) 1928 { 1929 return '\\'; 1930 } 1931 else if ("questiondown".equals(keyStrokeName)) 1932 { 1933 return '¿'; 1934 } 1935 else if ("acute".equals(keyStrokeName)) 1936 { 1937 return '´'; 1938 } 1939 else if ("dead_acute".equals(keyStrokeName)) 1940 { 1941 return 0x0301; 1942 } 1943 else if ("grave".equals(keyStrokeName)) 1944 { 1945 return '`'; 1946 } 1947 else if ("dead_grave".equals(keyStrokeName)) 1948 { 1949 return 0x0300; 1950 } 1951 else if ("dead_cedilla".equals(keyStrokeName)) 1952 { 1953 return 0x0327; 1954 } 1955 else if ("dead_ogonek".equals(keyStrokeName)) 1956 { 1957 return 0x0328; 1958 } 1959 else if ("at".equals(keyStrokeName)) 1960 { 1961 return '@'; 1962 } 1963 else if ("Greek_OMEGA".equals(keyStrokeName)) 1964 { 1965 return 'Ω'; 1966 } 1967 else if ("EuroSign".equals(keyStrokeName)) 1968 { 1969 return '€'; 1970 } 1971 else if ("paragraph".equals(keyStrokeName)) 1972 { 1973 return 0x2029; 1974 } 1975 else if ("registered".equals(keyStrokeName)) 1976 { 1977 return '®'; 1978 } 1979 else if ("tslash".equals(keyStrokeName)) 1980 { 1981 return 'ŧ'; 1982 } 1983 else if ("Tslash".equals(keyStrokeName)) 1984 { 1985 return 'Ŧ'; 1986 } 1987 else if ("z".equals(keyStrokeName)) 1988 { 1989 return getUpper ? 'Z' : 'z'; 1990 } 1991 else if ("leftarrow".equals(keyStrokeName)) 1992 { 1993 return '←'; 1994 } 1995 else if ("yen".equals(keyStrokeName)) 1996 { 1997 return '¥'; 1998 } 1999 else if ("downarrow".equals(keyStrokeName)) 2000 { 2001 return '↓'; 2002 } 2003 else if ("uparrow".equals(keyStrokeName)) 2004 { 2005 return '↑'; 2006 } 2007 else if ("rightarrow".equals(keyStrokeName)) 2008 { 2009 return '→'; 2010 } 2011 else if ("idotless".equals(keyStrokeName)) 2012 { 2013 return 'ı'; 2014 } 2015 else if ("oslash".equals(keyStrokeName)) 2016 { 2017 return 'ø'; 2018 } 2019 else if ("Ooblique".equals(keyStrokeName)) 2020 { 2021 return 'Ø'; 2022 } 2023 else if ("thorn".equals(keyStrokeName)) 2024 { 2025 return 'þ'; 2026 } 2027 else if ("THORN".equals(keyStrokeName)) 2028 { 2029 return 'Þ'; 2030 } 2031 else if ("udiaeresis".equals(keyStrokeName)) 2032 { 2033 return getUpper ? 'Ü' : 'ü'; 2034 } 2035 else if ("Udiaeresis".equals(keyStrokeName)) 2036 { 2037 return getUpper ? 'Ü' : 'ü'; 2038 } 2039 else if ("dead_diaeresis".equals(keyStrokeName)) 2040 { 2041 return 0x0308; 2042 } 2043 else if ("dead_abovering".equals(keyStrokeName)) 2044 { 2045 return 0x030A; 2046 } 2047 else if ("plus".equals(keyStrokeName)) 2048 { 2049 return '+'; 2050 } 2051 else if ("asterisk".equals(keyStrokeName)) 2052 { 2053 return '*'; 2054 } 2055 else if ("asciitilde".equals(keyStrokeName)) 2056 { 2057 return '~'; 2058 } 2059 else if ("dead_tilde".equals(keyStrokeName)) 2060 { 2061 return 0x0303; 2062 } 2063 else if ("dead_macron".equals(keyStrokeName)) 2064 { 2065 return 0x0304; 2066 } 2067 else if ("ae".equals(keyStrokeName)) 2068 { 2069 return 'æ'; 2070 } 2071 else if ("AE".equals(keyStrokeName)) 2072 { 2073 return 'Æ'; 2074 } 2075 else if ("eth".equals(keyStrokeName)) 2076 { 2077 return 'ð'; 2078 } 2079 else if ("ETH".equals(keyStrokeName)) 2080 { 2081 return 'Ð'; 2082 } 2083 else if ("dstroke".equals(keyStrokeName)) 2084 { 2085 return getUpper ? 'Đ' : 'đ'; 2086 } 2087 else if ("ordfeminine".equals(keyStrokeName)) 2088 { 2089 return 'ª'; 2090 } 2091 else if ("eng".equals(keyStrokeName)) 2092 { 2093 return 'ŋ'; 2094 } 2095 else if ("ENG".equals(keyStrokeName)) 2096 { 2097 return 'Ŋ'; 2098 } 2099 else if ("hstroke".equals(keyStrokeName)) 2100 { 2101 return 'ħ'; 2102 } 2103 else if ("Hstroke".equals(keyStrokeName)) 2104 { 2105 return 'Ħ'; 2106 } 2107 else if ("kra".equals(keyStrokeName)) 2108 { 2109 return 'ĸ'; 2110 } 2111 else if ("odiaeresis".equals(keyStrokeName)) 2112 { 2113 return 'ö'; 2114 } 2115 else if ("Odiaeresis".equals(keyStrokeName)) 2116 { 2117 return 'Ö'; 2118 } 2119 else if ("dead_doubleacute".equals(keyStrokeName)) 2120 { 2121 return 0x030B; 2122 } 2123 else if ("adiaeresis".equals(keyStrokeName)) 2124 { 2125 return 'ä'; 2126 } 2127 else if ("Adiaeresis".equals(keyStrokeName)) 2128 { 2129 return 'Ä'; 2130 } 2131 else if ("dead_caron".equals(keyStrokeName)) 2132 { 2133 return 0x030C; 2134 } 2135 else if ("asciicircum".equals(keyStrokeName)) 2136 { 2137 return '^'; 2138 } 2139 else if ("dead_circumflex".equals(keyStrokeName)) 2140 { 2141 return 0x0302; 2142 } 2143 else if ("degree".equals(keyStrokeName)) 2144 { 2145 return '°'; 2146 } 2147 else if ("notsign".equals(keyStrokeName)) 2148 { 2149 return '¬'; 2150 } 2151 else if ("numbersign".equals(keyStrokeName)) 2152 { 2153 return '#'; 2154 } 2155 else if ("apostrophe".equals(keyStrokeName)) 2156 { 2157 return '\''; 2158 } 2159 else if ("dead_breve".equals(keyStrokeName)) 2160 { 2161 return 0x0306; 2162 } 2163 else if ("y".equals(keyStrokeName)) 2164 { 2165 return getUpper ? 'Y' : 'y'; 2166 } 2167 else if ("guillemotleft".equals(keyStrokeName)) 2168 { 2169 return '»'; 2170 } 2171 else if ("guillemotright".equals(keyStrokeName)) 2172 { 2173 return '«'; 2174 } 2175 else if ("cent".equals(keyStrokeName)) 2176 { 2177 return '¢'; 2178 } 2179 else if ("copyright".equals(keyStrokeName)) 2180 { 2181 return '©'; 2182 } 2183 else if ("leftdoublequotemark".equals(keyStrokeName)) 2184 { 2185 return '„'; 2186 } 2187 else if ("rightdoublequotemark".equals(keyStrokeName)) 2188 { 2189 return '“'; 2190 } 2191 else if ("mu".equals(keyStrokeName)) 2192 { 2193 return 'µ'; 2194 } 2195 else if ("masculine".equals(keyStrokeName)) 2196 { 2197 return 'º'; 2198 } 2199 else if ("comma".equals(keyStrokeName)) 2200 { 2201 return ','; 2202 } 2203 else if ("semicolon".equals(keyStrokeName)) 2204 { 2205 return ';'; 2206 } 2207 else if ("horizconnector".equals(keyStrokeName)) 2208 { 2209 return '·'; 2210 } 2211 else if ("multiply".equals(keyStrokeName)) 2212 { 2213 return '×'; 2214 } 2215 else if ("period".equals(keyStrokeName)) 2216 { 2217 return '.'; 2218 } 2219 else if ("colon".equals(keyStrokeName)) 2220 { 2221 return ':'; 2222 } 2223 else if ("periodcentered".equals(keyStrokeName)) 2224 { 2225 return '…'; 2226 } 2227 else if ("division".equals(keyStrokeName)) 2228 { 2229 return '÷'; 2230 } 2231 else if ("minus".equals(keyStrokeName)) 2232 { 2233 return '-'; 2234 } 2235 else if ("underscore".equals(keyStrokeName)) 2236 { 2237 return '_'; 2238 } 2239 else if ("dead_belowdot".equals(keyStrokeName)) 2240 { 2241 return 0x0323; 2242 } 2243 else if ("dead_abovedot".equals(keyStrokeName)) 2244 { 2245 return 0x0307; 2246 } 2247 else if ("eacute".equals(keyStrokeName)) 2248 { 2249 return getUpper ? 'É' : 'é'; 2250 } 2251 else if ("Eacute".equals(keyStrokeName)) 2252 { 2253 return getUpper ? 'É' : 'é'; 2254 } 2255 else if ("egrave".equals(keyStrokeName)) 2256 { 2257 return getUpper ? 'È' : 'è'; 2258 } 2259 else if ("Egrave".equals(keyStrokeName)) 2260 { 2261 return getUpper ? 'È' : 'è'; 2262 } 2263 else if ("ccedilla".equals(keyStrokeName)) 2264 { 2265 return getUpper ? 'Ç' : 'ç'; 2266 } 2267 else if ("Ccedilla".equals(keyStrokeName)) 2268 { 2269 return getUpper ? 'Ç' : 'ç'; 2270 } 2271 else if ("agrave".equals(keyStrokeName)) 2272 { 2273 return getUpper ? 'À' : 'à'; 2274 } 2275 else if ("Agrave".equals(keyStrokeName)) 2276 { 2277 return getUpper ? 'À' : 'à'; 2278 } 2279 else if ("lstroke".equals(keyStrokeName)) 2280 { 2281 return getUpper ? 'Ł' : 'ł'; 2282 } 2283 else if ("Lstroke".equals(keyStrokeName)) 2284 { 2285 return getUpper ? 'Ł' : 'ł'; 2286 } 2287 else if ("ugrave".equals(keyStrokeName)) 2288 { 2289 return getUpper ? 'Ù' : 'ù'; 2290 } 2291 else if ("Ugrave".equals(keyStrokeName)) 2292 { 2293 return getUpper ? 'Ù' : 'ù'; 2294 } 2295 else if ("igrave".equals(keyStrokeName)) 2296 { 2297 return getUpper ? 'Ì' : 'ì'; 2298 } 2299 else if ("Igrave".equals(keyStrokeName)) 2300 { 2301 return getUpper ? 'Ì' : 'ì'; 2302 } 2303 else if ("ograve".equals(keyStrokeName)) 2304 { 2305 return getUpper ? 'Ò' : 'ò'; 2306 } 2307 else if ("ograve".equals(keyStrokeName)) 2308 { 2309 return getUpper ? 'Ò' : 'ò'; 2310 } 2311 else if ("keyboard_type".equals(keyStrokeName)) 2312 { 2313 return Character.UNASSIGNED; 2314 } 2315 else if ("keyboard_subtype".equals(keyStrokeName)) 2316 { 2317 return Character.UNASSIGNED; 2318 } 2319 else if ("keyboard_functionkeys".equals(keyStrokeName)) 2320 { 2321 return Character.UNASSIGNED; 2322 } 2323 else if ("kana_NU".equals(keyStrokeName)) 2324 { 2325 return 'ヌ'; 2326 } 2327 else if ("kana_FU".equals(keyStrokeName)) 2328 { 2329 return 'フ'; 2330 } 2331 else if ("kana_A".equals(keyStrokeName)) 2332 { 2333 return 'ア'; 2334 } 2335 else if ("kana_a".equals(keyStrokeName)) 2336 { 2337 return 'ァ'; 2338 } 2339 else if ("kana_U".equals(keyStrokeName)) 2340 { 2341 return 'ウ'; 2342 } 2343 else if ("kana_u".equals(keyStrokeName)) 2344 { 2345 return 'ゥ'; 2346 } 2347 else if ("kana_E".equals(keyStrokeName)) 2348 { 2349 return 'エ'; 2350 } 2351 else if ("kana_e".equals(keyStrokeName)) 2352 { 2353 return 'ェ'; 2354 } 2355 else if ("kana_O".equals(keyStrokeName)) 2356 { 2357 return 'オ'; 2358 } 2359 else if ("kana_o".equals(keyStrokeName)) 2360 { 2361 return 'ォ'; 2362 } 2363 else if ("kana_YA".equals(keyStrokeName)) 2364 { 2365 return 'ヤ'; 2366 } 2367 else if ("kana_ya".equals(keyStrokeName)) 2368 { 2369 return 'ャ'; 2370 } 2371 else if ("kana_YU".equals(keyStrokeName)) 2372 { 2373 return 'ユ'; 2374 } 2375 else if ("kana_yu".equals(keyStrokeName)) 2376 { 2377 return 'ュ'; 2378 } 2379 else if ("kana_YO".equals(keyStrokeName)) 2380 { 2381 return 'ヨ'; 2382 } 2383 else if ("kana_yo".equals(keyStrokeName)) 2384 { 2385 return 'ョ'; 2386 } 2387 else if ("kana_WA".equals(keyStrokeName)) 2388 { 2389 return 'ワ'; 2390 } 2391 else if ("kana_WO".equals(keyStrokeName)) 2392 { 2393 return 'ヲ'; 2394 } 2395 else if ("kana_HO".equals(keyStrokeName)) 2396 { 2397 return 'ホ'; 2398 } 2399 else if ("kana_HE".equals(keyStrokeName)) 2400 { 2401 return 'ヘ'; 2402 } 2403 else if ("kana_TA".equals(keyStrokeName)) 2404 { 2405 return 'タ'; 2406 } 2407 else if ("kana_TE".equals(keyStrokeName)) 2408 { 2409 return 'テ'; 2410 } 2411 else if ("kana_I".equals(keyStrokeName)) 2412 { 2413 return 'イ'; 2414 } 2415 else if ("kana_i".equals(keyStrokeName)) 2416 { 2417 return 'ィ'; 2418 } 2419 else if ("kana_SU".equals(keyStrokeName)) 2420 { 2421 return 'ス'; 2422 } 2423 else if ("kana_KA".equals(keyStrokeName)) 2424 { 2425 return 'カ'; 2426 } 2427 else if ("kana_N".equals(keyStrokeName)) 2428 { 2429 return 'ン'; 2430 } 2431 else if ("kana_NA".equals(keyStrokeName)) 2432 { 2433 return 'ナ'; 2434 } 2435 else if ("kana_NI".equals(keyStrokeName)) 2436 { 2437 return 'ニ'; 2438 } 2439 else if ("kana_RA".equals(keyStrokeName)) 2440 { 2441 return 'ラ'; 2442 } 2443 else if ("kana_SE".equals(keyStrokeName)) 2444 { 2445 return 'セ'; 2446 } 2447 else if ("voicedsound".equals(keyStrokeName)) 2448 { 2449 return 0x3099; 2450 } 2451 else if ("semivoicedsound".equals(keyStrokeName)) 2452 { 2453 return 0x309A; 2454 } 2455 else if ("kana_openingbracket".equals(keyStrokeName)) 2456 { 2457 return 0x04A2; 2458 } 2459 else if ("kana_closingbracket".equals(keyStrokeName)) 2460 { 2461 return 0x04A3; 2462 } 2463 else if ("kana_CHI".equals(keyStrokeName)) 2464 { 2465 return 'チ'; 2466 } 2467 else if ("kana_TO".equals(keyStrokeName)) 2468 { 2469 return 'ト'; 2470 } 2471 else if ("kana_SHI".equals(keyStrokeName)) 2472 { 2473 return 'シ'; 2474 } 2475 else if ("kana_HA".equals(keyStrokeName)) 2476 { 2477 return 'ハ'; 2478 } 2479 else if ("kana_KI".equals(keyStrokeName)) 2480 { 2481 return 'キ'; 2482 } 2483 else if ("kana_KU".equals(keyStrokeName)) 2484 { 2485 return 'ク'; 2486 } 2487 else if ("kana_MA".equals(keyStrokeName)) 2488 { 2489 return 'マ'; 2490 } 2491 else if ("kana_NO".equals(keyStrokeName)) 2492 { 2493 return 'ノ'; 2494 } 2495 else if ("kana_RI".equals(keyStrokeName)) 2496 { 2497 return 'リ'; 2498 } 2499 else if ("kana_RE".equals(keyStrokeName)) 2500 { 2501 return 'レ'; 2502 } 2503 else if ("kana_KE".equals(keyStrokeName)) 2504 { 2505 return 'ケ'; 2506 } 2507 else if ("Zenkaku_Hankaku".equals(keyStrokeName)) 2508 { 2509 return Character.UNASSIGNED; 2510 } 2511 else if ("Kanji".equals(keyStrokeName)) 2512 { 2513 return Character.UNASSIGNED; 2514 } 2515 else if ("kana_MU".equals(keyStrokeName)) 2516 { 2517 return 'ム'; 2518 } 2519 else if ("kana_TSU".equals(keyStrokeName)) 2520 { 2521 return 'ツ'; 2522 } 2523 else if ("kana_tsu".equals(keyStrokeName)) 2524 { 2525 return 'ッ'; 2526 } 2527 else if ("kana_SA".equals(keyStrokeName)) 2528 { 2529 return 'サ'; 2530 } 2531 else if ("kana_SO".equals(keyStrokeName)) 2532 { 2533 return 'ソ'; 2534 } 2535 else if ("kana_HI".equals(keyStrokeName)) 2536 { 2537 return 'ヒ'; 2538 } 2539 else if ("kana_KO".equals(keyStrokeName)) 2540 { 2541 return 'コ'; 2542 } 2543 else if ("kana_MI".equals(keyStrokeName)) 2544 { 2545 return 'ミ'; 2546 } 2547 else if ("kana_MO".equals(keyStrokeName)) 2548 { 2549 return 'モ'; 2550 } 2551 else if ("kana_NE".equals(keyStrokeName)) 2552 { 2553 return 'ネ'; 2554 } 2555 else if ("kana_comma".equals(keyStrokeName)) 2556 { 2557 return '、'; 2558 } 2559 else if ("kana_RU".equals(keyStrokeName)) 2560 { 2561 return 'ル'; 2562 } 2563 else if ("kana_fullstop".equals(keyStrokeName)) 2564 { 2565 return '。'; 2566 } 2567 else if ("kana_ME".equals(keyStrokeName)) 2568 { 2569 return 'メ'; 2570 } 2571 else if ("kana_conjunctive".equals(keyStrokeName)) 2572 { 2573 return Character.UNASSIGNED; 2574 } 2575 else if ("Henkan_Mode".equals(keyStrokeName)) 2576 { 2577 return Character.UNASSIGNED; 2578 } 2579 else if ("Hiragana_Katakana".equals(keyStrokeName)) 2580 { 2581 return Character.UNASSIGNED; 2582 } 2583 else if ("Katakana".equals(keyStrokeName)) 2584 { 2585 return Character.UNASSIGNED; 2586 } 2587 else if ("Romaji".equals(keyStrokeName)) 2588 { 2589 return Character.UNASSIGNED; 2590 } 2591 else if ("Muhenkan".equals(keyStrokeName)) 2592 { 2593 return Character.UNASSIGNED; 2594 } 2595 else if ("Eisu_toggle".equals(keyStrokeName)) 2596 { 2597 return Character.UNASSIGNED; 2598 } 2599 else if ("Eisu_toggle".equals(keyStrokeName)) 2600 { 2601 return Character.UNASSIGNED; 2602 } 2603 else if ("F13".equals(keyStrokeName)) 2604 { 2605 return Character.UNASSIGNED; 2606 } 2607 else if ("Hangul".equals(keyStrokeName)) 2608 { 2609 return Character.UNASSIGNED; 2610 } 2611 else if ("Hangul_Hanja".equals(keyStrokeName)) 2612 { 2613 return Character.UNASSIGNED; 2614 } 2615 else 2616 { 2617 LOG.severe("unknown key stroke name " + keyStrokeName + " specified through keyboard map " + 2618 "for locale " + mLocale); 2619 2620 // if (shift) 2621 // { 2622 // System.err.println(" else if (\"" + keyStrokeName + "\".equals(keyStrokeName))"); 2623 // System.err.println(" {"); 2624 // System.err.println(" return shift ? '" + Character.toUpperCase(keyStrokeName.charAt(0)) + 2625 // "' : '" + Character.toLowerCase(keyStrokeName.charAt(0)) + "';"); 2626 // System.err.println(" }"); 2627 // } 2628 // else 2629 // { 2630 // System.err.println(" else if (\"" + keyStrokeName + "\".equals(keyStrokeName))"); 2631 // System.err.println(" {"); 2632 // System.err.println(" return '" + keyStrokeName + "';"); 2633 // System.err.println(" }"); 2634 // } 2635 // 2636 // return 0x0; 2637 throw new IllegalArgumentException("no keyboard map available for locale " + mLocale); 2638 } 2639 } 2640 2641 //----------------------------------------------------------------------------------------------- 2642 /** 2643 * this is a former implementation 2644 * 2645 * @param keyId 2646 * @return 2647 */ 2648 //----------------------------------------------------------------------------------------------- 2649 /*private VirtualKey[] mapKeyIdToVirtualKeys(int keyId, 2650 String keyStrokeName) 2651 { 2652 2653 Set<String> names = null; 2654 2655 for (int i = 0; i < mKeyIds.size(); i++) 2656 { 2657 if (((Integer) mKeyIds.get(i)[0]) == keyId) 2658 { 2659 names = (Set<String>) mKeyIds.get(i)[1]; 2660 break; 2661 } 2662 } 2663 2664 if (names == null) 2665 { 2666 names = new HashSet<String>(); 2667 boolean added = false; 2668 2669 for (int i = 0; i < mKeyIds.size(); i++) 2670 { 2671 if (((Integer) mKeyIds.get(i)[0]) > keyId) 2672 { 2673 mKeyIds.add(i, new Object[] { keyId, names }); 2674 added = true; 2675 break; 2676 } 2677 } 2678 2679 if (!added) 2680 { 2681 mKeyIds.add(new Object[] { keyId, names }); 2682 } 2683 } 2684 2685 names.add(keyStrokeName); 2686 2687 2688 switch(keyId) 2689 { 2690 case 0x36: 2691 case 0x2a: 2692 return new VirtualKey[] { VirtualKey.SHIFT }; 2693 case 0xb8: 2694 return new VirtualKey[] { VirtualKey.ALT_GRAPH }; 2695 case 0x38: 2696 return new VirtualKey[] { VirtualKey.ALT }; 2697 case 0x9d: 2698 case 0x1d: 2699 return new VirtualKey[] { VirtualKey.CONTROL }; 2700 case 0xdd: 2701 return new VirtualKey[] { VirtualKey.WINDOWS }; 2702 case 0x2: 2703 return new VirtualKey[] { VirtualKey.DIGIT_1 }; 2704 case 0x3: 2705 return new VirtualKey[] { VirtualKey.DIGIT_2 }; 2706 case 0x4: 2707 return new VirtualKey[] { VirtualKey.DIGIT_3 }; 2708 case 0x5: 2709 return new VirtualKey[] { VirtualKey.DIGIT_4 }; 2710 case 0x6: 2711 return new VirtualKey[] { VirtualKey.DIGIT_5 }; 2712 case 0x7: 2713 return new VirtualKey[] { VirtualKey.DIGIT_6 }; 2714 case 0x8: 2715 return new VirtualKey[] { VirtualKey.DIGIT_7 }; 2716 case 0x9: 2717 return new VirtualKey[] { VirtualKey.DIGIT_8 }; 2718 case 0xa: 2719 return new VirtualKey[] { VirtualKey.DIGIT_9 }; 2720 case 0xb: 2721 return new VirtualKey[] { VirtualKey.DIGIT_0 }; 2722 case 0xe: 2723 return new VirtualKey[] { VirtualKey.BACK_SPACE }; 2724 case 0xf: 2725 return new VirtualKey[] { VirtualKey.TAB }; 2726 case 0x10: 2727 return new VirtualKey[] { VirtualKey.LETTER_Q }; 2728 case 0x11: 2729 return new VirtualKey[] { VirtualKey.LETTER_W }; 2730 case 0x12: 2731 return new VirtualKey[] { VirtualKey.LETTER_E }; 2732 case 0x13: 2733 return new VirtualKey[] { VirtualKey.LETTER_R }; 2734 case 0x14: 2735 return new VirtualKey[] { VirtualKey.LETTER_T }; 2736 case 0x15: 2737 return new VirtualKey[] { VirtualKey.LETTER_Y }; 2738 case 0x16: 2739 return new VirtualKey[] { VirtualKey.LETTER_U }; 2740 case 0x17: 2741 return new VirtualKey[] { VirtualKey.LETTER_I }; 2742 case 0x18: 2743 return new VirtualKey[] { VirtualKey.LETTER_O }; 2744 case 0x19: 2745 return new VirtualKey[] { VirtualKey.LETTER_P }; 2746 case 0x1e: 2747 return new VirtualKey[] { VirtualKey.LETTER_A }; 2748 case 0x1f: 2749 return new VirtualKey[] { VirtualKey.LETTER_S }; 2750 case 0x20: 2751 return new VirtualKey[] { VirtualKey.LETTER_D }; 2752 case 0x21: 2753 return new VirtualKey[] { VirtualKey.LETTER_F }; 2754 case 0x22: 2755 return new VirtualKey[] { VirtualKey.LETTER_G }; 2756 case 0x23: 2757 return new VirtualKey[] { VirtualKey.LETTER_H }; 2758 case 0x24: 2759 return new VirtualKey[] { VirtualKey.LETTER_J }; 2760 case 0x25: 2761 return new VirtualKey[] { VirtualKey.LETTER_K }; 2762 case 0x26: 2763 return new VirtualKey[] { VirtualKey.LETTER_L }; 2764 case 0x1c: 2765 return new VirtualKey[] { VirtualKey.ENTER }; 2766 case 0x2c: 2767 return new VirtualKey[] { VirtualKey.LETTER_Z }; 2768 case 0x2d: 2769 return new VirtualKey[] { VirtualKey.LETTER_X }; 2770 case 0x2e: 2771 return new VirtualKey[] { VirtualKey.LETTER_C }; 2772 case 0x2f: 2773 return new VirtualKey[] { VirtualKey.LETTER_V }; 2774 case 0x30: 2775 return new VirtualKey[] { VirtualKey.LETTER_B }; 2776 case 0x31: 2777 return new VirtualKey[] { VirtualKey.LETTER_N }; 2778 case 0x32: 2779 return new VirtualKey[] { VirtualKey.LETTER_M }; 2780 case 0x39: 2781 return new VirtualKey[] { VirtualKey.SPACE }; 2782 case 0x56: 2783 return new VirtualKey[] { VirtualKey.LESS }; 2784 case 0x1: 2785 return new VirtualKey[] { VirtualKey.ESCAPE }; 2786 case 0x3b: 2787 return new VirtualKey[] { VirtualKey.F1 }; 2788 case 0x3c: 2789 return new VirtualKey[] { VirtualKey.F2 }; 2790 case 0x3d: 2791 return new VirtualKey[] { VirtualKey.F3 }; 2792 case 0x3e: 2793 return new VirtualKey[] { VirtualKey.F4 }; 2794 case 0x3f: 2795 return new VirtualKey[] { VirtualKey.F5 }; 2796 case 0x40: 2797 return new VirtualKey[] { VirtualKey.F6 }; 2798 case 0x41: 2799 return new VirtualKey[] { VirtualKey.F7 }; 2800 case 0x42: 2801 return new VirtualKey[] { VirtualKey.F8 }; 2802 case 0x43: 2803 return new VirtualKey[] { VirtualKey.F9 }; 2804 case 0x44: 2805 return new VirtualKey[] { VirtualKey.F10 }; 2806 case 0x57: 2807 return new VirtualKey[] { VirtualKey.F11 }; 2808 case 0x58: 2809 return new VirtualKey[] { VirtualKey.F12 }; 2810 case 0xb7: 2811 return new VirtualKey[] { VirtualKey.PRINTSCREEN }; 2812 case 0x46: 2813 return new VirtualKey[] { VirtualKey.SCROLL_LOCK }; 2814 case 0xd2: 2815 return new VirtualKey[] { VirtualKey.INSERT }; 2816 case 0xd3: 2817 return new VirtualKey[] { VirtualKey.DELETE }; 2818 case 0xc7: 2819 return new VirtualKey[] { VirtualKey.HOME }; 2820 case 0xcf: 2821 return new VirtualKey[] { VirtualKey.END }; 2822 case 0xc9: 2823 return new VirtualKey[] { VirtualKey.PAGE_UP }; 2824 case 0xd1: 2825 return new VirtualKey[] { VirtualKey.PAGE_DOWN }; 2826 case 0xcb: 2827 return new VirtualKey[] { VirtualKey.LEFT }; 2828 case 0xc8: 2829 return new VirtualKey[] { VirtualKey.UP }; 2830 case 0xd0: 2831 return new VirtualKey[] { VirtualKey.DOWN }; 2832 case 0xcd: 2833 return new VirtualKey[] { VirtualKey.RIGHT }; 2834 case 0x45: 2835 return new VirtualKey[] { VirtualKey.NUM_LOCK }; 2836 case 0xb5: 2837 return new VirtualKey[] { VirtualKey.DIVIDE }; 2838 case 0x37: 2839 return new VirtualKey[] { VirtualKey.MULTIPLY }; 2840 case 0x4a: 2841 return new VirtualKey[] { VirtualKey.SUBTRACT }; 2842 case 0x4e: 2843 return new VirtualKey[] { VirtualKey.ADD }; 2844 case 0x9c: 2845 return new VirtualKey[] { VirtualKey.ENTER }; 2846 case 0x53: 2847 return new VirtualKey[] { VirtualKey.DECIMAL, VirtualKey.DELETE }; 2848 case 0x52: 2849 return new VirtualKey[] { VirtualKey.NUMPAD_0, VirtualKey.INSERT }; 2850 case 0x4f: 2851 return new VirtualKey[] { VirtualKey.NUMPAD_1, VirtualKey.END }; 2852 case 0x50: 2853 return new VirtualKey[] { VirtualKey.NUMPAD_2, VirtualKey.KP_DOWN }; 2854 case 0x51: 2855 return new VirtualKey[] { VirtualKey.NUMPAD_3, VirtualKey.PAGE_UP }; 2856 case 0x4b: 2857 return new VirtualKey[] { VirtualKey.NUMPAD_4, VirtualKey.KP_LEFT }; 2858 case 0x4c: 2859 return new VirtualKey[] { VirtualKey.NUMPAD_5, VirtualKey.BEGIN }; 2860 case 0x4d: 2861 return new VirtualKey[] { VirtualKey.NUMPAD_6, VirtualKey.KP_RIGHT }; 2862 case 0x47: 2863 return new VirtualKey[] { VirtualKey.NUMPAD_7, VirtualKey.HOME }; 2864 case 0x48: 2865 return new VirtualKey[] { VirtualKey.NUMPAD_8, VirtualKey.KP_UP }; 2866 case 0x49: 2867 return new VirtualKey[] { VirtualKey.NUMPAD_9, VirtualKey.PAGE_DOWN }; 2868 case 0x0: 2869 return new VirtualKey[] { VirtualKey.CAPS_LOCK }; 2870 case 0xc: 2871 return new VirtualKey[] { VirtualKey.MINUS, VirtualKey.UNDERSCORE }; 2872 case 0xd: 2873 return new VirtualKey[] { VirtualKey.EQUALS, VirtualKey.PLUS }; 2874 case 0x1a: 2875 return new VirtualKey[] { VirtualKey.OPEN_BRACKET, VirtualKey.BRACELEFT }; 2876 case 0x1b: 2877 return new VirtualKey[] { VirtualKey.CLOSE_BRACKET, VirtualKey.BRACERIGHT }; 2878 case 0x27: 2879 return new VirtualKey[] { VirtualKey.SEMICOLON, VirtualKey.COLON }; 2880 /* case 0x28: 2881 return new VirtualKey[] { VirtualKey.APOSTROPHE, VirtualKey.QUOTEDBL }; 2882 case 0x29: 2883 return new VirtualKey[] { VirtualKey.DEAD_GRAVE, VirtualKey.DEAD_TILDE }; 2884 case 0x2b: 2885 return new VirtualKey[] { VirtualKey.BACK_SLASH, VirtualKey.BAR }; 2886 case 0x33: 2887 return new VirtualKey[] { VirtualKey.COMMA, VirtualKey.LESS }; 2888 case 0x34: 2889 return new VirtualKey[] { VirtualKey.PERIOD, VirtualKey.GREATER }; 2890 case 0x35: 2891 return new VirtualKey[] { VirtualKey.SLASH, VirtualKey.QUESTIONMARK }; 2892 case 0x73: 2893 return new VirtualKey[] { VirtualKey.BACK_SLASH, VirtualKey.DEGREE, 2894 VirtualKey.QUESTIONMARK, VirtualKey.UNDERSCORE }; 2895 case 0x7d: 2896 return new VirtualKey[] { VirtualKey.BAR }; 2897 case 0x79: 2898 return new VirtualKey[] { VirtualKey.HENKAN_MODE }; 2899 case 0x70: 2900 return new VirtualKey[] { VirtualKey.KATAKANA }; 2901 case 0x7b: 2902 return new VirtualKey[] { VirtualKey.MUHENKAN }; 2903 case 0x3a: 2904 return new VirtualKey[] { VirtualKey.EISU_TOGGLE, VirtualKey.CAPS_LOCK }; 2905 case 0xdc: 2906 return new VirtualKey[] { VirtualKey.F13 }; 2907 case 0xf2: 2908 return new VirtualKey[] { VirtualKey.HANGUL }; 2909 case 0xf1: 2910 return new VirtualKey[] { VirtualKey.HANGUL_HANJA }; 2911 case 0x54: 2912 return new VirtualKey[] { VirtualKey.EXECUTE }; 2913 default: 2914 LOG.severe("unknown key id 0x" + Integer.toHexString(keyId) + " specified for key stroke " + 2915 keyStrokeName + " through keyboard map for locale " + mLocale); 2916 throw new IllegalArgumentException("no keyboard map available for locale " + mLocale); 2917 } 2918 }*/ 2038 2039 /** 2040 * this is a former implementation 2041 * 2042 * @param keyId 2043 * @return 2044 */ 2045 /* 2046 * private VirtualKey[] mapKeyIdToVirtualKeys(int keyId, String keyStrokeName) { 2047 * 2048 * Set<String> names = null; 2049 * 2050 * for (int i = 0; i < mKeyIds.size(); i++) { if (((Integer) mKeyIds.get(i)[0]) == keyId) { 2051 * names = (Set<String>) mKeyIds.get(i)[1]; break; } } 2052 * 2053 * if (names == null) { names = new HashSet<String>(); boolean added = false; 2054 * 2055 * for (int i = 0; i < mKeyIds.size(); i++) { if (((Integer) mKeyIds.get(i)[0]) > keyId) { 2056 * mKeyIds.add(i, new Object[] { keyId, names }); added = true; break; } } 2057 * 2058 * if (!added) { mKeyIds.add(new Object[] { keyId, names }); } } 2059 * 2060 * names.add(keyStrokeName); 2061 * 2062 * 2063 * switch(keyId) { case 0x36: case 0x2a: return new VirtualKey[] { VirtualKey.SHIFT }; case 2064 * 0xb8: return new VirtualKey[] { VirtualKey.ALT_GRAPH }; case 0x38: return new VirtualKey[] { 2065 * VirtualKey.ALT }; case 0x9d: case 0x1d: return new VirtualKey[] { VirtualKey.CONTROL }; case 2066 * 0xdd: return new VirtualKey[] { VirtualKey.WINDOWS }; case 0x2: return new VirtualKey[] { 2067 * VirtualKey.DIGIT_1 }; case 0x3: return new VirtualKey[] { VirtualKey.DIGIT_2 }; case 0x4: 2068 * return new VirtualKey[] { VirtualKey.DIGIT_3 }; case 0x5: return new VirtualKey[] { 2069 * VirtualKey.DIGIT_4 }; case 0x6: return new VirtualKey[] { VirtualKey.DIGIT_5 }; case 0x7: 2070 * return new VirtualKey[] { VirtualKey.DIGIT_6 }; case 0x8: return new VirtualKey[] { 2071 * VirtualKey.DIGIT_7 }; case 0x9: return new VirtualKey[] { VirtualKey.DIGIT_8 }; case 0xa: 2072 * return new VirtualKey[] { VirtualKey.DIGIT_9 }; case 0xb: return new VirtualKey[] { 2073 * VirtualKey.DIGIT_0 }; case 0xe: return new VirtualKey[] { VirtualKey.BACK_SPACE }; case 0xf: 2074 * return new VirtualKey[] { VirtualKey.TAB }; case 0x10: return new VirtualKey[] { 2075 * VirtualKey.LETTER_Q }; case 0x11: return new VirtualKey[] { VirtualKey.LETTER_W }; case 0x12: 2076 * return new VirtualKey[] { VirtualKey.LETTER_E }; case 0x13: return new VirtualKey[] { 2077 * VirtualKey.LETTER_R }; case 0x14: return new VirtualKey[] { VirtualKey.LETTER_T }; case 0x15: 2078 * return new VirtualKey[] { VirtualKey.LETTER_Y }; case 0x16: return new VirtualKey[] { 2079 * VirtualKey.LETTER_U }; case 0x17: return new VirtualKey[] { VirtualKey.LETTER_I }; case 0x18: 2080 * return new VirtualKey[] { VirtualKey.LETTER_O }; case 0x19: return new VirtualKey[] { 2081 * VirtualKey.LETTER_P }; case 0x1e: return new VirtualKey[] { VirtualKey.LETTER_A }; case 0x1f: 2082 * return new VirtualKey[] { VirtualKey.LETTER_S }; case 0x20: return new VirtualKey[] { 2083 * VirtualKey.LETTER_D }; case 0x21: return new VirtualKey[] { VirtualKey.LETTER_F }; case 0x22: 2084 * return new VirtualKey[] { VirtualKey.LETTER_G }; case 0x23: return new VirtualKey[] { 2085 * VirtualKey.LETTER_H }; case 0x24: return new VirtualKey[] { VirtualKey.LETTER_J }; case 0x25: 2086 * return new VirtualKey[] { VirtualKey.LETTER_K }; case 0x26: return new VirtualKey[] { 2087 * VirtualKey.LETTER_L }; case 0x1c: return new VirtualKey[] { VirtualKey.ENTER }; case 0x2c: 2088 * return new VirtualKey[] { VirtualKey.LETTER_Z }; case 0x2d: return new VirtualKey[] { 2089 * VirtualKey.LETTER_X }; case 0x2e: return new VirtualKey[] { VirtualKey.LETTER_C }; case 0x2f: 2090 * return new VirtualKey[] { VirtualKey.LETTER_V }; case 0x30: return new VirtualKey[] { 2091 * VirtualKey.LETTER_B }; case 0x31: return new VirtualKey[] { VirtualKey.LETTER_N }; case 0x32: 2092 * return new VirtualKey[] { VirtualKey.LETTER_M }; case 0x39: return new VirtualKey[] { 2093 * VirtualKey.SPACE }; case 0x56: return new VirtualKey[] { VirtualKey.LESS }; case 0x1: return 2094 * new VirtualKey[] { VirtualKey.ESCAPE }; case 0x3b: return new VirtualKey[] { VirtualKey.F1 }; 2095 * case 0x3c: return new VirtualKey[] { VirtualKey.F2 }; case 0x3d: return new VirtualKey[] { 2096 * VirtualKey.F3 }; case 0x3e: return new VirtualKey[] { VirtualKey.F4 }; case 0x3f: return new 2097 * VirtualKey[] { VirtualKey.F5 }; case 0x40: return new VirtualKey[] { VirtualKey.F6 }; case 2098 * 0x41: return new VirtualKey[] { VirtualKey.F7 }; case 0x42: return new VirtualKey[] { 2099 * VirtualKey.F8 }; case 0x43: return new VirtualKey[] { VirtualKey.F9 }; case 0x44: return new 2100 * VirtualKey[] { VirtualKey.F10 }; case 0x57: return new VirtualKey[] { VirtualKey.F11 }; case 2101 * 0x58: return new VirtualKey[] { VirtualKey.F12 }; case 0xb7: return new VirtualKey[] { 2102 * VirtualKey.PRINTSCREEN }; case 0x46: return new VirtualKey[] { VirtualKey.SCROLL_LOCK }; case 2103 * 0xd2: return new VirtualKey[] { VirtualKey.INSERT }; case 0xd3: return new VirtualKey[] { 2104 * VirtualKey.DELETE }; case 0xc7: return new VirtualKey[] { VirtualKey.HOME }; case 0xcf: 2105 * return new VirtualKey[] { VirtualKey.END }; case 0xc9: return new VirtualKey[] { 2106 * VirtualKey.PAGE_UP }; case 0xd1: return new VirtualKey[] { VirtualKey.PAGE_DOWN }; case 0xcb: 2107 * return new VirtualKey[] { VirtualKey.LEFT }; case 0xc8: return new VirtualKey[] { 2108 * VirtualKey.UP }; case 0xd0: return new VirtualKey[] { VirtualKey.DOWN }; case 0xcd: return 2109 * new VirtualKey[] { VirtualKey.RIGHT }; case 0x45: return new VirtualKey[] { 2110 * VirtualKey.NUM_LOCK }; case 0xb5: return new VirtualKey[] { VirtualKey.DIVIDE }; case 0x37: 2111 * return new VirtualKey[] { VirtualKey.MULTIPLY }; case 0x4a: return new VirtualKey[] { 2112 * VirtualKey.SUBTRACT }; case 0x4e: return new VirtualKey[] { VirtualKey.ADD }; case 0x9c: 2113 * return new VirtualKey[] { VirtualKey.ENTER }; case 0x53: return new VirtualKey[] { 2114 * VirtualKey.DECIMAL, VirtualKey.DELETE }; case 0x52: return new VirtualKey[] { 2115 * VirtualKey.NUMPAD_0, VirtualKey.INSERT }; case 0x4f: return new VirtualKey[] { 2116 * VirtualKey.NUMPAD_1, VirtualKey.END }; case 0x50: return new VirtualKey[] { 2117 * VirtualKey.NUMPAD_2, VirtualKey.KP_DOWN }; case 0x51: return new VirtualKey[] { 2118 * VirtualKey.NUMPAD_3, VirtualKey.PAGE_UP }; case 0x4b: return new VirtualKey[] { 2119 * VirtualKey.NUMPAD_4, VirtualKey.KP_LEFT }; case 0x4c: return new VirtualKey[] { 2120 * VirtualKey.NUMPAD_5, VirtualKey.BEGIN }; case 0x4d: return new VirtualKey[] { 2121 * VirtualKey.NUMPAD_6, VirtualKey.KP_RIGHT }; case 0x47: return new VirtualKey[] { 2122 * VirtualKey.NUMPAD_7, VirtualKey.HOME }; case 0x48: return new VirtualKey[] { 2123 * VirtualKey.NUMPAD_8, VirtualKey.KP_UP }; case 0x49: return new VirtualKey[] { 2124 * VirtualKey.NUMPAD_9, VirtualKey.PAGE_DOWN }; case 0x0: return new VirtualKey[] { 2125 * VirtualKey.CAPS_LOCK }; case 0xc: return new VirtualKey[] { VirtualKey.MINUS, 2126 * VirtualKey.UNDERSCORE }; case 0xd: return new VirtualKey[] { VirtualKey.EQUALS, 2127 * VirtualKey.PLUS }; case 0x1a: return new VirtualKey[] { VirtualKey.OPEN_BRACKET, 2128 * VirtualKey.BRACELEFT }; case 0x1b: return new VirtualKey[] { VirtualKey.CLOSE_BRACKET, 2129 * VirtualKey.BRACERIGHT }; case 0x27: return new VirtualKey[] { VirtualKey.SEMICOLON, 2130 * VirtualKey.COLON }; /* case 0x28: return new VirtualKey[] { VirtualKey.APOSTROPHE, 2131 * VirtualKey.QUOTEDBL }; case 0x29: return new VirtualKey[] { VirtualKey.DEAD_GRAVE, 2132 * VirtualKey.DEAD_TILDE }; case 0x2b: return new VirtualKey[] { VirtualKey.BACK_SLASH, 2133 * VirtualKey.BAR }; case 0x33: return new VirtualKey[] { VirtualKey.COMMA, VirtualKey.LESS }; 2134 * case 0x34: return new VirtualKey[] { VirtualKey.PERIOD, VirtualKey.GREATER }; case 0x35: 2135 * return new VirtualKey[] { VirtualKey.SLASH, VirtualKey.QUESTIONMARK }; case 0x73: return new 2136 * VirtualKey[] { VirtualKey.BACK_SLASH, VirtualKey.DEGREE, VirtualKey.QUESTIONMARK, 2137 * VirtualKey.UNDERSCORE }; case 0x7d: return new VirtualKey[] { VirtualKey.BAR }; case 0x79: 2138 * return new VirtualKey[] { VirtualKey.HENKAN_MODE }; case 0x70: return new VirtualKey[] { 2139 * VirtualKey.KATAKANA }; case 0x7b: return new VirtualKey[] { VirtualKey.MUHENKAN }; case 0x3a: 2140 * return new VirtualKey[] { VirtualKey.EISU_TOGGLE, VirtualKey.CAPS_LOCK }; case 0xdc: return 2141 * new VirtualKey[] { VirtualKey.F13 }; case 0xf2: return new VirtualKey[] { VirtualKey.HANGUL 2142 * }; case 0xf1: return new VirtualKey[] { VirtualKey.HANGUL_HANJA }; case 0x54: return new 2143 * VirtualKey[] { VirtualKey.EXECUTE }; default: LOG.severe("unknown key id 0x" + 2144 * Integer.toHexString(keyId) + " specified for key stroke " + keyStrokeName + 2145 * " through keyboard map for locale " + mLocale); throw new 2146 * IllegalArgumentException("no keyboard map available for locale " + mLocale); } } 2147 */ 2919 2148 2920 2149 } -
trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps/KeyboardMapFactory.java
r447 r558 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: KeyboardMapFactory.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: patrick $ $Date: 11.07.2012 $ … … 5 4 // Creation : 2012 by patrick 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 7 8 8 package de.ugoe.cs.tasktree.keyboardmaps; 9 9 10 10 import java.util.Locale; 11 11 12 //-------------------------------------------------------------------------------------------------13 12 /** 14 13 * TODO comment … … 17 16 * @author 2012, last modified by $Author: patrick$ 18 17 */ 19 //------------------------------------------------------------------------------------------------- 20 public class KeyboardMapFactory 21 { 18 public class KeyboardMapFactory { 22 19 23 //----------------------------------------------------------------------------------------------- 24 /** 25 * TODO: comment 26 * 27 */ 28 //----------------------------------------------------------------------------------------------- 29 private KeyboardMapFactory() 30 { 31 // TODO Auto-generated constructor stub 32 } 20 /** 21 * TODO: comment 22 * 23 */ 24 private KeyboardMapFactory() { 25 // TODO Auto-generated constructor stub 26 } 33 27 34 //----------------------------------------------------------------------------------------------- 35 /** 36 * TODO: comment 37 * 38 */ 39 //----------------------------------------------------------------------------------------------- 40 public static KeyboardMap createKeyboardMap(Locale locale) 41 { 42 KeyboardMap keyboardMap = new KeyboardMap(locale); 43 keyboardMap.init(); 44 return keyboardMap; 45 } 28 /** 29 * TODO: comment 30 * 31 */ 32 public static KeyboardMap createKeyboardMap(Locale locale) { 33 KeyboardMap keyboardMap = new KeyboardMap(locale); 34 keyboardMap.init(); 35 return keyboardMap; 36 } 46 37 } -
trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps/VirtualKey.java
r447 r558 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: Key.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: patrick $ $Date: 01.04.2012 $ … … 5 4 // Creation : 2012 by patrick 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 7 8 8 package de.ugoe.cs.tasktree.keyboardmaps; 9 9 10 10 import java.awt.event.KeyEvent; 11 11 12 //-------------------------------------------------------------------------------------------------13 12 /** 14 13 * TODO comment 15 * 14 * 16 15 * @version $Revision: $ $Date: 01.04.2012$ 17 16 * @author 2012, last modified by $Author: patrick$ 18 17 */ 19 //------------------------------------------------------------------------------------------------- 20 public enum VirtualKey 21 { 18 public enum VirtualKey { 19 22 20 ENTER(KeyEvent.VK_ENTER), 23 21 BACK_SPACE(KeyEvent.VK_BACK_SPACE), … … 228 226 229 227 UNDEFINED(KeyEvent.VK_UNDEFINED); 230 231 /*BAR(KeyEvent.VK_UNDEFINED), 232 APOSTROPHE(KeyEvent.VK_UNDEFINED), 233 QUESTIONMARK(KeyEvent.VK_UNDEFINED), 234 DEGREE(KeyEvent.VK_UNDEFINED), 235 HENKAN_MODE(KeyEvent.VK_UNDEFINED), 236 MUHENKAN(KeyEvent.VK_UNDEFINED), 237 EISU_TOGGLE(KeyEvent.VK_UNDEFINED), 238 HANGUL(KeyEvent.VK_UNDEFINED), 239 HANGUL_HANJA(KeyEvent.VK_UNDEFINED), 240 EXECUTE(KeyEvent.VK_UNDEFINED);*/ 241 242 /** the virtual key code of the virtual key. */ 243 private int mVirtualKeyCode = -1; 244 245 /** the description of the virtual key */ 246 private String mDescription; 247 248 //----------------------------------------------------------------------------------------------- 249 /** 250 * 251 */ 252 //----------------------------------------------------------------------------------------------- 253 private VirtualKey(int virtualKeyCode) 254 { 255 mVirtualKeyCode = virtualKeyCode; 256 mDescription = KeyEvent.getKeyText(mVirtualKeyCode); 257 } 258 259 //----------------------------------------------------------------------------------------------- 260 /** 261 * @return Returns the description. 262 */ 263 //----------------------------------------------------------------------------------------------- 264 String getDescription() 265 { 266 return mDescription; 267 } 268 269 //----------------------------------------------------------------------------------------------- 270 /** 271 * 272 */ 273 //----------------------------------------------------------------------------------------------- 274 public boolean isCombinationKey() 275 { 276 switch (this) 277 { 278 case SHIFT: 279 case CONTROL: 280 case ALT: 281 case ALT_GRAPH: 282 case WINDOWS: 283 return true; 284 285 default: 286 return false; 287 } 288 } 289 290 //----------------------------------------------------------------------------------------------- 291 /** 292 * 293 */ 294 //----------------------------------------------------------------------------------------------- 295 public boolean isLockKey() 296 { 297 switch (this) 298 { 299 case CAPS_LOCK : 300 case NUM_LOCK: 301 case SCROLL_LOCK: 302 303 return true; 304 305 default: 306 return false; 307 } 308 } 309 310 //----------------------------------------------------------------------------------------------- 311 /** 312 * 313 */ 314 //----------------------------------------------------------------------------------------------- 315 public boolean isShiftKey() 316 { 317 switch (this) 318 { 319 case SHIFT: 320 return true; 321 322 default: 323 return false; 324 } 325 } 326 327 //----------------------------------------------------------------------------------------------- 328 /** 329 * 330 */ 331 //----------------------------------------------------------------------------------------------- 332 public boolean isAltKey() 333 { 334 switch (this) 335 { 336 case ALT: 337 case ALT_GRAPH: 338 return true; 339 340 default: 341 return false; 342 } 343 } 344 345 //----------------------------------------------------------------------------------------------- 346 /** 347 * 348 */ 349 //----------------------------------------------------------------------------------------------- 350 public boolean isControlKey() 351 { 352 switch (this) 353 { 354 case CONTROL: 355 return true; 356 357 default: 358 return false; 359 } 360 } 361 362 //----------------------------------------------------------------------------------------------- 363 /** 364 * 365 */ 366 //----------------------------------------------------------------------------------------------- 367 public boolean isWindowsKey() 368 { 369 switch (this) 370 { 371 case WINDOWS: 372 return true; 373 374 default: 375 return false; 376 } 377 } 378 379 //----------------------------------------------------------------------------------------------- 380 /** 381 * 382 */ 383 //----------------------------------------------------------------------------------------------- 384 public boolean isMetaKey() 385 { 386 switch (this) 387 { 388 case META: 389 return true; 390 391 default: 392 return false; 393 } 394 } 395 396 //----------------------------------------------------------------------------------------------- 397 /** 398 * 399 */ 400 //----------------------------------------------------------------------------------------------- 401 public boolean isLetter() 402 { 403 if (mVirtualKeyCode > -1) 404 { 405 return Character.isLetter((char) mVirtualKeyCode); 406 } 407 else 408 { 409 return false; 410 } 411 } 412 413 //----------------------------------------------------------------------------------------------- 414 /** 415 * 416 */ 417 //----------------------------------------------------------------------------------------------- 418 public boolean isDigit() 419 { 420 if (mVirtualKeyCode > -1) 421 { 422 return Character.isDigit(mVirtualKeyCode); 423 } 424 else 425 { 426 return false; 427 } 428 } 429 430 //----------------------------------------------------------------------------------------------- 431 /** 432 * TODO: comment 433 * 434 * @param parameter 435 * @return 436 */ 437 //----------------------------------------------------------------------------------------------- 438 public static VirtualKey parseVirtualKey(String string) 439 { 440 int virtualKeyCode = Integer.parseInt(string); 441 for (VirtualKey key1 : VirtualKey.values()) 442 { 443 if (key1.mVirtualKeyCode == virtualKeyCode) 444 { 445 return key1; 446 } 447 } 448 449 throw new IllegalArgumentException("there is no virtual key with id " + string); 450 } 451 452 //----------------------------------------------------------------------------------------------- 453 /** 454 * 455 */ 456 //----------------------------------------------------------------------------------------------- 457 public static VirtualKey valueOf(int number) 458 { 459 for (VirtualKey virtualKey : VirtualKey.values()) 460 { 461 if (virtualKey.mVirtualKeyCode == number) 462 { 463 return virtualKey; 464 } 465 } 466 467 throw new IllegalArgumentException("there is no virtual key with number " + number); 468 } 228 229 /* 230 * BAR(KeyEvent.VK_UNDEFINED), 231 * APOSTROPHE(KeyEvent.VK_UNDEFINED), 232 * QUESTIONMARK(KeyEvent.VK_UNDEFINED), 233 * DEGREE(KeyEvent.VK_UNDEFINED), 234 * HENKAN_MODE(KeyEvent.VK_UNDEFINED), 235 * MUHENKAN(KeyEvent.VK_UNDEFINED), 236 * EISU_TOGGLE(KeyEvent.VK_UNDEFINED), 237 * HANGUL(KeyEvent.VK_UNDEFINED), 238 * HANGUL_HANJA(KeyEvent.VK_UNDEFINED), 239 * EXECUTE(KeyEvent.VK_UNDEFINED); 240 */ 241 242 /** the virtual key code of the virtual key. */ 243 private int virtualKeyCode = -1; 244 245 /** the description of the virtual key */ 246 private String description; 247 248 /** 249 * 250 */ 251 private VirtualKey(int virtualKeyCode) { 252 this.virtualKeyCode = virtualKeyCode; 253 this.description = KeyEvent.getKeyText(this.virtualKeyCode); 254 } 255 256 /** 257 * @return Returns the description. 258 */ 259 String getDescription() { 260 return description; 261 } 262 263 /** 264 * 265 */ 266 public boolean isCombinationKey() { 267 switch (this) 268 { 269 case SHIFT: 270 case CONTROL: 271 case ALT: 272 case ALT_GRAPH: 273 case WINDOWS: 274 return true; 275 276 default: 277 return false; 278 } 279 } 280 281 /** 282 * 283 */ 284 public boolean isLockKey() { 285 switch (this) 286 { 287 case CAPS_LOCK: 288 case NUM_LOCK: 289 case SCROLL_LOCK: 290 return true; 291 292 default: 293 return false; 294 } 295 } 296 297 /** 298 * 299 */ 300 public boolean isShiftKey() { 301 switch (this) 302 { 303 case SHIFT: 304 return true; 305 306 default: 307 return false; 308 } 309 } 310 311 /** 312 * 313 */ 314 public boolean isAltKey() { 315 switch (this) 316 { 317 case ALT: 318 case ALT_GRAPH: 319 return true; 320 321 default: 322 return false; 323 } 324 } 325 326 /** 327 * 328 */ 329 public boolean isControlKey() { 330 switch (this) 331 { 332 case CONTROL: 333 return true; 334 335 default: 336 return false; 337 } 338 } 339 340 /** 341 * 342 */ 343 public boolean isWindowsKey() { 344 switch (this) 345 { 346 case WINDOWS: 347 return true; 348 349 default: 350 return false; 351 } 352 } 353 354 /** 355 * 356 */ 357 public boolean isMetaKey() { 358 switch (this) 359 { 360 case META: 361 return true; 362 363 default: 364 return false; 365 } 366 } 367 368 /** 369 * 370 */ 371 public boolean isLetter() { 372 if (virtualKeyCode > -1) { 373 return Character.isLetter((char) virtualKeyCode); 374 } 375 else { 376 return false; 377 } 378 } 379 380 /** 381 * 382 */ 383 public boolean isDigit() { 384 if (virtualKeyCode > -1) { 385 return Character.isDigit(virtualKeyCode); 386 } 387 else { 388 return false; 389 } 390 } 391 392 /** 393 * TODO: comment 394 * 395 * @param parameter 396 * @return 397 */ 398 public static VirtualKey parseVirtualKey(String string) { 399 int virtualKeyCode = Integer.parseInt(string); 400 for (VirtualKey key1 : VirtualKey.values()) { 401 if (key1.virtualKeyCode == virtualKeyCode) { 402 return key1; 403 } 404 } 405 406 throw new IllegalArgumentException("there is no virtual key with id " + string); 407 } 408 409 /** 410 * 411 */ 412 public static VirtualKey valueOf(int number) { 413 for (VirtualKey virtualKey : VirtualKey.values()) { 414 if (virtualKey.virtualKeyCode == number) { 415 return virtualKey; 416 } 417 } 418 419 throw new IllegalArgumentException("there is no virtual key with number " + number); 420 } 469 421 470 422 } -
trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps/VirtualKeySynonyms.java
r447 r558 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: VirtualKeySynonyms.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 12.07.2012 $ … … 5 4 // Creation : 2012 by pharms 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 8 7 package de.ugoe.cs.tasktree.keyboardmaps; 9 8 … … 14 13 import java.util.logging.Logger; 15 14 16 //-------------------------------------------------------------------------------------------------17 15 /** 18 16 * TODO comment … … 21 19 * @author 2012, last modified by $Author: pharms$ 22 20 */ 23 //------------------------------------------------------------------------------------------------- 24 class VirtualKeySynonyms 25 { 26 /** */ 27 private static Logger LOG = Logger.getLogger(KeyboardMap.class.getName()); 21 class VirtualKeySynonyms { 22 23 /** */ 24 private static Logger LOG = Logger.getLogger(KeyboardMap.class.getName()); 28 25 29 /** */ 30 private Map<Integer, List<VirtualKey>> mSynonyms = new HashMap<Integer, List<VirtualKey>>(); 31 32 /** */ 33 private Map<VirtualKey, Integer> mKeyIds = new HashMap<VirtualKey, Integer>(); 26 /** */ 27 private Map<Integer, List<VirtualKey>> synonyms = new HashMap<Integer, List<VirtualKey>>(); 34 28 35 //----------------------------------------------------------------------------------------------- 36 /** 37 * TODO: comment 38 * 39 * @param keyId 40 * @param virtualKey 41 */ 42 //----------------------------------------------------------------------------------------------- 43 public void add(int keyId, VirtualKey virtualKey) 44 { 45 List<VirtualKey> synonyms = mSynonyms.get(keyId); 46 47 if (synonyms == null) 48 { 49 synonyms = new ArrayList<VirtualKey>(); 50 mSynonyms.put(keyId, synonyms); 29 /** */ 30 private Map<VirtualKey, Integer> keyIds = new HashMap<VirtualKey, Integer>(); 31 32 /** 33 * TODO: comment 34 * 35 * @param keyId 36 * @param virtualKey 37 */ 38 public void add(int keyId, VirtualKey virtualKey) { 39 List<VirtualKey> synonymList = synonyms.get(keyId); 40 41 if (synonymList == null) { 42 synonymList = new ArrayList<VirtualKey>(); 43 synonyms.put(keyId, synonymList); 44 } 45 46 if (!synonymList.contains(virtualKey)) { 47 // ensure that the latest determined virtual keys are considered first 48 synonymList.add(0, virtualKey); 49 } 50 51 Integer existingKeyId = keyIds.get(virtualKey); 52 53 if ((existingKeyId != null) && (existingKeyId != keyId)) { 54 LOG.finest("virtual key " + virtualKey + 55 " is mapped to more than one key id (current is " + existingKeyId + 56 ", new is " + keyId + "). New key id will be used (" + keyId + ")."); 57 } 58 59 keyIds.put(virtualKey, keyId); 51 60 } 52 53 if (!synonyms.contains(virtualKey))54 {55 // ensure that the latest determined virtual keys are considered first56 synonyms.add(0, virtualKey);57 }58 59 Integer existingKeyId = mKeyIds.get(virtualKey);60 61 if ((existingKeyId != null) && (existingKeyId != keyId))62 {63 LOG.finest("virtual key " + virtualKey + " is mapped to more than one key id (current is " +64 existingKeyId + ", new is " + keyId + "). New key id will be used (" + keyId +65 ").");66 }67 68 mKeyIds.put(virtualKey, keyId);69 }70 61 71 //----------------------------------------------------------------------------------------------- 72 /** 62 /** 73 63 * 74 64 */ 75 //----------------------------------------------------------------------------------------------- 76 public boolean containsKey(int keyId) 77 { 78 return mSynonyms.containsKey(keyId); 79 } 65 public boolean containsKey(int keyId) { 66 return synonyms.containsKey(keyId); 67 } 80 68 81 //----------------------------------------------------------------------------------------------- 82 /** 83 * TODO: comment 84 * 85 * @param keyId 86 * @return 87 */ 88 //----------------------------------------------------------------------------------------------- 89 public VirtualKey[] getVirtualKeySynonyms(int keyId) 90 { 91 List<VirtualKey> virtualKeys = mSynonyms.get(keyId); 92 if (virtualKeys != null) 93 { 94 return virtualKeys.toArray(new VirtualKey[virtualKeys.size()]); 69 /** 70 * TODO: comment 71 * 72 * @param keyId 73 * @return 74 */ 75 public VirtualKey[] getVirtualKeySynonyms(int keyId) { 76 List<VirtualKey> virtualKeys = synonyms.get(keyId); 77 if (virtualKeys != null) { 78 return virtualKeys.toArray(new VirtualKey[virtualKeys.size()]); 79 } 80 else { 81 LOG.warning("no virtual key define for key id " + keyId); 82 return null; 83 } 95 84 } 96 else 97 { 98 LOG.warning("no virtual key define for key id " + keyId); 99 return null; 100 } 101 } 102 85 103 86 }
Note: See TracChangeset
for help on using the changeset viewer.