Changeset 558 for trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps/VirtualKeySynonyms.java
- Timestamp:
- 08/17/12 08:52:45 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.