source: trunk/quest-misc/src/main/java/de/ugoe/cs/tasktree/keyboardmaps/KeyStroke.java @ 838

Last change on this file since 838 was 838, checked in by sherbold, 12 years ago
  • code documentation and clean-up
File size: 5.1 KB
Line 
1
2package de.ugoe.cs.tasktree.keyboardmaps;
3
4/**
5 * <p>
6 * This class is used to define key strokes.
7 * </p>
8 *
9 * @version 1.0
10 * @author Patrick Harms
11 */
12public class KeyStroke {
13
14    /**
15     * <p>
16     * Name of the key stroke.
17     * </p>
18     */
19    private String keyStrokeName;
20
21    /**
22     * <p>
23     * {@link VirtualKey} associated with the key stroke.
24     * </p>
25     */
26    private VirtualKey virtualKey;
27
28    /**
29     * <p>
30     * Defines whether numlock is pressed during the stroke.
31     * </p>
32     */
33    private boolean numlock;
34
35    /**
36     * <p>
37     * Defines whether localstate is pressed during the stroke.
38     * </p>
39     */
40    private boolean localstate;
41
42    /**
43     * <p>
44     * Defines whether shift is pressed during the stroke.
45     * </p>
46     */
47    private boolean shift;
48
49    /**
50     * <p>
51     * Defines whether altgr is pressed during the stroke.
52     * </p>
53     */
54    private boolean altgr;
55
56    /**
57     * <p>
58     * Defines whether inhibit is pressed during the stroke.
59     * </p>
60     */
61    private boolean inhibit;
62
63    /**
64     * <p>
65     * Defines the character in which the key stroke results.
66     * </p>
67     */
68    private char character;
69
70    /**
71     * <p>
72     * Constructor. Creates a new key stroke
73     * </p>
74     *
75     * @param keyStrokeName
76     *            name of the key stroke
77     * @param virtualKey
78     *            virtual key associated with the key stroke
79     * @param numlock
80     *            defines whether numlock is pressed during the key stroke
81     * @param localstate
82     *            defines whether localstate is pressed during the key stroke
83     * @param shift
84     *            defines whether shift is pressed during the key stroke
85     * @param altgr
86     *            defines whether altgr is pressed during the key stroke
87     * @param inhibit
88     *            defines whether inhibit is pressed during the key stroke
89     * @param character
90     *            defines that character in which the key stroke results
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    }
110
111    /**
112     * <p>
113     * Returns the name of the key stroke.
114     * </p>
115     *
116     * @return the name
117     */
118    public String getKeyStrokeName() {
119        return keyStrokeName;
120    }
121
122    /**
123     * <p>
124     * Returns the virtual key associated with the key stroke.
125     * </p>
126     *
127     * @return the virtual key
128     */
129    public VirtualKey getVirtualKey() {
130        return virtualKey;
131    }
132
133    /**
134     * <p>
135     * Returns the character in which the key stroke results.
136     * </p>
137     *
138     * @return the character
139     */
140    public char getCharacter() {
141        return character;
142    }
143
144    /**
145     * <p>
146     * Returns whether inhibit is pressed.
147     * </p>
148     *
149     * @return true if pressed; false otherwise
150     */
151    public boolean getInhibit() {
152        return inhibit;
153    }
154
155    /**
156     * <p>
157     * Returns whether altgr is pressed.
158     * </p>
159     *
160     * @return true if pressed; false otherwise
161     */
162    public boolean getAltgr() {
163        return altgr;
164    }
165
166    /**
167     * <p>
168     * Returns whether shift is pressed.
169     * </p>
170     *
171     * @return true if pressed; false otherwise
172     */
173    public boolean getShift() {
174        return shift;
175    }
176
177    /**
178     * <p>
179     * Returns whether localstate is pressed.
180     * </p>
181     *
182     * @return true if pressed; false otherwise
183     */
184    public boolean getLocalstate() {
185        return localstate;
186    }
187
188    /**
189     * <p>
190     * Returns whether numlock is pressed.
191     * </p>
192     *
193     * @return true if pressed; false otherwise
194     */
195    public boolean getNumlock() {
196        return numlock;
197    }
198
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();
241    }
242
243}
Note: See TracBrowser for help on using the repository browser.