source: trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/gui/KeyTyped.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:mime-type set to text/plain
File size: 2.7 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.eventcore.gui;
16
17import de.ugoe.cs.autoquest.keyboardmaps.VirtualKey;
18
19/**
20 * <p>
21 * Event type for typing a key, i.e., pressing and releasing it right away.
22 * </p>
23 *
24 * @version 1.0
25 * @author Steffen Herbold
26 */
27public class KeyTyped extends KeyInteraction {
28
29    /**
30     * <p>
31     * Id for object serialization.
32     * </p>
33     */
34    private static final long serialVersionUID = 1L;
35
36    /**
37     * <p>
38     * Constructor. Creates a new {@link KeyTyped} event type.
39     * </p>
40     *
41     * @see KeyInteraction#KeyInteraction(VirtualKey)
42     */
43    public KeyTyped(VirtualKey key) {
44        super(key);
45    }
46
47    /*
48     * (non-Javadoc)
49     *
50     * @see de.harms.attef.userinteraction.Interaction#getName()
51     */
52    public String getName() {
53        return "KeyTyped " + super.getKey();
54    }
55
56    /*
57     * (non-Javadoc)
58     *
59     * @see java.lang.Object#toString()
60     */
61    @Override
62    public String toString() {
63        return "typed key " + super.getKey();
64    }
65
66    /*
67     * (non-Javadoc)
68     *
69     * @see de.harms.attef.userinteraction.Interaction#startsLogicalSequence()
70     */
71    public boolean startsLogicalSequence() {
72        // TODO handle lock keys correctly
73        return super.getKey().isCombinationKey();
74    }
75
76    /*
77     * (non-Javadoc)
78     *
79     * @see de.harms.attef.userinteraction.Interaction#finishesLogicalSequence()
80     */
81    public boolean finishesLogicalSequence() {
82        // TODO handle lock keys correctly
83        return super.getKey().isCombinationKey();
84    }
85
86    /*
87     * (non-Javadoc)
88     *
89     * @see java.lang.Object#equals(java.lang.Object)
90     */
91    @Override
92    public boolean equals(Object other) {
93        if (other instanceof KeyTyped) {
94            return (super.getKey() == ((KeyTyped) other).getKey());
95        }
96        else {
97            return false;
98        }
99    }
100
101    /*
102     * (non-Javadoc)
103     *
104     * @see java.lang.Object#hashCode()
105     */
106    @Override
107    public int hashCode() {
108        return super.getKey().hashCode();
109    }
110
111}
Note: See TracBrowser for help on using the repository browser.