[838] | 1 | |
---|
[922] | 2 | package de.ugoe.cs.autoquest.keyboardmaps; |
---|
[447] | 3 | |
---|
| 4 | /** |
---|
[838] | 5 | * <p> |
---|
| 6 | * This class is used to define key strokes. |
---|
| 7 | * </p> |
---|
[447] | 8 | * |
---|
[838] | 9 | * @version 1.0 |
---|
| 10 | * @author Patrick Harms |
---|
[447] | 11 | */ |
---|
[558] | 12 | public class KeyStroke { |
---|
[447] | 13 | |
---|
[838] | 14 | /** |
---|
| 15 | * <p> |
---|
| 16 | * Name of the key stroke. |
---|
| 17 | * </p> |
---|
| 18 | */ |
---|
[558] | 19 | private String keyStrokeName; |
---|
[447] | 20 | |
---|
[838] | 21 | /** |
---|
| 22 | * <p> |
---|
| 23 | * {@link VirtualKey} associated with the key stroke. |
---|
| 24 | * </p> |
---|
| 25 | */ |
---|
[558] | 26 | private VirtualKey virtualKey; |
---|
[447] | 27 | |
---|
[838] | 28 | /** |
---|
| 29 | * <p> |
---|
| 30 | * Defines whether numlock is pressed during the stroke. |
---|
| 31 | * </p> |
---|
| 32 | */ |
---|
[558] | 33 | private boolean numlock; |
---|
[447] | 34 | |
---|
[838] | 35 | /** |
---|
| 36 | * <p> |
---|
| 37 | * Defines whether localstate is pressed during the stroke. |
---|
| 38 | * </p> |
---|
| 39 | */ |
---|
[558] | 40 | private boolean localstate; |
---|
[447] | 41 | |
---|
[838] | 42 | /** |
---|
| 43 | * <p> |
---|
| 44 | * Defines whether shift is pressed during the stroke. |
---|
| 45 | * </p> |
---|
| 46 | */ |
---|
[558] | 47 | private boolean shift; |
---|
[447] | 48 | |
---|
[838] | 49 | /** |
---|
| 50 | * <p> |
---|
| 51 | * Defines whether altgr is pressed during the stroke. |
---|
| 52 | * </p> |
---|
| 53 | */ |
---|
[558] | 54 | private boolean altgr; |
---|
[447] | 55 | |
---|
[838] | 56 | /** |
---|
| 57 | * <p> |
---|
| 58 | * Defines whether inhibit is pressed during the stroke. |
---|
| 59 | * </p> |
---|
| 60 | */ |
---|
[558] | 61 | private boolean inhibit; |
---|
[447] | 62 | |
---|
[838] | 63 | /** |
---|
| 64 | * <p> |
---|
| 65 | * Defines the character in which the key stroke results. |
---|
| 66 | * </p> |
---|
| 67 | */ |
---|
[558] | 68 | private char character; |
---|
[447] | 69 | |
---|
[558] | 70 | /** |
---|
[838] | 71 | * <p> |
---|
| 72 | * Constructor. Creates a new key stroke |
---|
| 73 | * </p> |
---|
[558] | 74 | * |
---|
| 75 | * @param keyStrokeName |
---|
[838] | 76 | * name of the key stroke |
---|
| 77 | * @param virtualKey |
---|
| 78 | * virtual key associated with the key stroke |
---|
[558] | 79 | * @param numlock |
---|
[838] | 80 | * defines whether numlock is pressed during the key stroke |
---|
[558] | 81 | * @param localstate |
---|
[838] | 82 | * defines whether localstate is pressed during the key stroke |
---|
| 83 | * @param shift |
---|
| 84 | * defines whether shift is pressed during the key stroke |
---|
[558] | 85 | * @param altgr |
---|
[838] | 86 | * defines whether altgr is pressed during the key stroke |
---|
[558] | 87 | * @param inhibit |
---|
[838] | 88 | * defines whether inhibit is pressed during the key stroke |
---|
| 89 | * @param character |
---|
| 90 | * defines that character in which the key stroke results |
---|
[558] | 91 | */ |
---|
| 92 | public KeyStroke(String keyStrokeName, |
---|
| 93 | VirtualKey virtualKey, |
---|
| 94 | boolean numlock, |
---|
| 95 | boolean localstate, |
---|
| 96 | boolean shift, |
---|
| 97 | boolean altgr, |
---|
| 98 | boolean inhibit, |
---|
| 99 | char character) |
---|
| 100 | { |
---|
| 101 | this.keyStrokeName = keyStrokeName; |
---|
| 102 | this.virtualKey = virtualKey; |
---|
| 103 | this.numlock = numlock; |
---|
| 104 | this.localstate = localstate; |
---|
| 105 | this.shift = shift; |
---|
| 106 | this.altgr = altgr; |
---|
| 107 | this.inhibit = inhibit; |
---|
| 108 | this.character = character; |
---|
| 109 | } |
---|
[447] | 110 | |
---|
[558] | 111 | /** |
---|
[838] | 112 | * <p> |
---|
| 113 | * Returns the name of the key stroke. |
---|
| 114 | * </p> |
---|
| 115 | * |
---|
| 116 | * @return the name |
---|
[558] | 117 | */ |
---|
| 118 | public String getKeyStrokeName() { |
---|
| 119 | return keyStrokeName; |
---|
| 120 | } |
---|
[447] | 121 | |
---|
[558] | 122 | /** |
---|
[838] | 123 | * <p> |
---|
| 124 | * Returns the virtual key associated with the key stroke. |
---|
| 125 | * </p> |
---|
[558] | 126 | * |
---|
[838] | 127 | * @return the virtual key |
---|
[558] | 128 | */ |
---|
| 129 | public VirtualKey getVirtualKey() { |
---|
| 130 | return virtualKey; |
---|
| 131 | } |
---|
[447] | 132 | |
---|
[558] | 133 | /** |
---|
[838] | 134 | * <p> |
---|
| 135 | * Returns the character in which the key stroke results. |
---|
| 136 | * </p> |
---|
[558] | 137 | * |
---|
[838] | 138 | * @return the character |
---|
[558] | 139 | */ |
---|
| 140 | public char getCharacter() { |
---|
| 141 | return character; |
---|
| 142 | } |
---|
[447] | 143 | |
---|
[558] | 144 | /** |
---|
[838] | 145 | * <p> |
---|
| 146 | * Returns whether inhibit is pressed. |
---|
| 147 | * </p> |
---|
[558] | 148 | * |
---|
[838] | 149 | * @return true if pressed; false otherwise |
---|
[558] | 150 | */ |
---|
| 151 | public boolean getInhibit() { |
---|
| 152 | return inhibit; |
---|
| 153 | } |
---|
[447] | 154 | |
---|
[558] | 155 | /** |
---|
[838] | 156 | * <p> |
---|
| 157 | * Returns whether altgr is pressed. |
---|
| 158 | * </p> |
---|
[558] | 159 | * |
---|
[838] | 160 | * @return true if pressed; false otherwise |
---|
[558] | 161 | */ |
---|
| 162 | public boolean getAltgr() { |
---|
| 163 | return altgr; |
---|
| 164 | } |
---|
[447] | 165 | |
---|
[558] | 166 | /** |
---|
[838] | 167 | * <p> |
---|
| 168 | * Returns whether shift is pressed. |
---|
| 169 | * </p> |
---|
[558] | 170 | * |
---|
[838] | 171 | * @return true if pressed; false otherwise |
---|
[558] | 172 | */ |
---|
| 173 | public boolean getShift() { |
---|
| 174 | return shift; |
---|
| 175 | } |
---|
[447] | 176 | |
---|
[558] | 177 | /** |
---|
[838] | 178 | * <p> |
---|
| 179 | * Returns whether localstate is pressed. |
---|
| 180 | * </p> |
---|
[558] | 181 | * |
---|
[838] | 182 | * @return true if pressed; false otherwise |
---|
[558] | 183 | */ |
---|
| 184 | public boolean getLocalstate() { |
---|
| 185 | return localstate; |
---|
| 186 | } |
---|
[447] | 187 | |
---|
[558] | 188 | /** |
---|
[838] | 189 | * <p> |
---|
| 190 | * Returns whether numlock is pressed. |
---|
| 191 | * </p> |
---|
[558] | 192 | * |
---|
[838] | 193 | * @return true if pressed; false otherwise |
---|
[558] | 194 | */ |
---|
| 195 | public boolean getNumlock() { |
---|
| 196 | return numlock; |
---|
| 197 | } |
---|
[447] | 198 | |
---|
[558] | 199 | /* |
---|
| 200 | * (non-Javadoc) |
---|
| 201 | * |
---|
| 202 | * @see java.lang.Object#toString() |
---|
| 203 | */ |
---|
| 204 | @Override |
---|
| 205 | public String toString() { |
---|
| 206 | StringBuffer toString = new StringBuffer(); |
---|
| 207 | toString.append("KeyStroke("); |
---|
| 208 | toString.append(keyStrokeName); |
---|
| 209 | toString.append(", "); |
---|
| 210 | toString.append(virtualKey); |
---|
| 211 | |
---|
| 212 | if (character != Character.UNASSIGNED) { |
---|
| 213 | toString.append(", \'"); |
---|
| 214 | toString.append(character); |
---|
| 215 | toString.append("\'"); |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | if (shift) { |
---|
| 219 | toString.append(", shift"); |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | if (altgr) { |
---|
| 223 | toString.append(", altgr"); |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | if (numlock) { |
---|
| 227 | toString.append(", numlock"); |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | if (localstate) { |
---|
| 231 | toString.append(", localstate"); |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | if (inhibit) { |
---|
| 235 | toString.append(", inhibit"); |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | toString.append(")"); |
---|
| 239 | |
---|
| 240 | return toString.toString(); |
---|
[447] | 241 | } |
---|
| 242 | |
---|
| 243 | } |
---|