1 |
|
---|
2 | package de.ugoe.cs.autoquest.eventcore.gui;
|
---|
3 |
|
---|
4 | import de.ugoe.cs.autoquest.keyboardmaps.VirtualKey;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * <p>
|
---|
8 | * Event type for pressing down a key.
|
---|
9 | * </p>
|
---|
10 | *
|
---|
11 | * @version 1.0
|
---|
12 | * @author Patrick Harms
|
---|
13 | */
|
---|
14 | public class KeyPressed extends KeyInteraction {
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * <p>
|
---|
18 | * Id for object serialization.
|
---|
19 | * </p>
|
---|
20 | */
|
---|
21 | private static final long serialVersionUID = 1L;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * <p>
|
---|
25 | * Constructor. Creates a new {@link KeyPressed} event type.
|
---|
26 | * </p>
|
---|
27 | *
|
---|
28 | * @see KeyInteraction#KeyInteraction(VirtualKey)
|
---|
29 | */
|
---|
30 | public KeyPressed(VirtualKey key) {
|
---|
31 | super(key);
|
---|
32 | }
|
---|
33 |
|
---|
34 | /*
|
---|
35 | * (non-Javadoc)
|
---|
36 | *
|
---|
37 | * @see de.harms.attef.userinteraction.Interaction#getName()
|
---|
38 | */
|
---|
39 | public String getName() {
|
---|
40 | return "KeyPressed " + super.getKey();
|
---|
41 | }
|
---|
42 |
|
---|
43 | /*
|
---|
44 | * (non-Javadoc)
|
---|
45 | *
|
---|
46 | * @see java.lang.Object#toString()
|
---|
47 | */
|
---|
48 | @Override
|
---|
49 | public String toString() {
|
---|
50 | return "pressing key " + super.getKey();
|
---|
51 | }
|
---|
52 |
|
---|
53 | /*
|
---|
54 | * (non-Javadoc)
|
---|
55 | *
|
---|
56 | * @see de.harms.attef.userinteraction.Interaction#startsLogicalSequence()
|
---|
57 | */
|
---|
58 | public boolean startsLogicalSequence() {
|
---|
59 | // TODO handle lock keys correctly
|
---|
60 | return super.getKey().isCombinationKey();
|
---|
61 | }
|
---|
62 |
|
---|
63 | /*
|
---|
64 | * (non-Javadoc)
|
---|
65 | *
|
---|
66 | * @see de.harms.attef.userinteraction.Interaction#finishesLogicalSequence()
|
---|
67 | */
|
---|
68 | public boolean finishesLogicalSequence() {
|
---|
69 | return false;
|
---|
70 | }
|
---|
71 |
|
---|
72 | /*
|
---|
73 | * (non-Javadoc)
|
---|
74 | *
|
---|
75 | * @see java.lang.Object#equals(java.lang.Object)
|
---|
76 | */
|
---|
77 | @Override
|
---|
78 | public boolean equals(Object other) {
|
---|
79 | if (other instanceof KeyPressed) {
|
---|
80 | return (super.getKey() == ((KeyPressed) other).getKey());
|
---|
81 | }
|
---|
82 | else {
|
---|
83 | return false;
|
---|
84 | }
|
---|
85 | }
|
---|
86 |
|
---|
87 | /*
|
---|
88 | * (non-Javadoc)
|
---|
89 | *
|
---|
90 | * @see java.lang.Object#hashCode()
|
---|
91 | */
|
---|
92 | @Override
|
---|
93 | public int hashCode() {
|
---|
94 | return super.getKey().hashCode();
|
---|
95 | }
|
---|
96 |
|
---|
97 | }
|
---|