1 | package org.expeditee.gio.input;
|
---|
2 |
|
---|
3 | import java.util.HashSet;
|
---|
4 | import java.util.List;
|
---|
5 | import java.util.Set;
|
---|
6 |
|
---|
7 | import org.expeditee.Util;
|
---|
8 | import org.expeditee.gio.gesture.Gesture;
|
---|
9 | import org.expeditee.gio.input.InputEvent.InputType;
|
---|
10 |
|
---|
11 | public abstract class InputEventToGestureTranslator
|
---|
12 | {
|
---|
13 | /** The set of monitored input types. */
|
---|
14 | protected HashSet<InputType> _monitoredInputTypes = new HashSet<InputType>();
|
---|
15 |
|
---|
16 | /** Default constructor. */
|
---|
17 | protected InputEventToGestureTranslator()
|
---|
18 | {
|
---|
19 | }
|
---|
20 |
|
---|
21 | /** Constructor tells which input type this translator monitors. */
|
---|
22 | public InputEventToGestureTranslator(InputType monitoredInputType)
|
---|
23 | {
|
---|
24 | if (monitoredInputType != null) _monitoredInputTypes.add(monitoredInputType);
|
---|
25 | }
|
---|
26 |
|
---|
27 | /** Constructor tells which input types this translator monitors. */
|
---|
28 | public InputEventToGestureTranslator(InputType[] monitoredInputTypes)
|
---|
29 | {
|
---|
30 | _monitoredInputTypes = Util.hashSetFromArray(monitoredInputTypes);
|
---|
31 | }
|
---|
32 |
|
---|
33 | /** Returns a string describing this gesture. */
|
---|
34 | public abstract String details();
|
---|
35 |
|
---|
36 | /** Method which receives input events and translates them into Expeditee gestures. */
|
---|
37 | public abstract List<Gesture> onInputEvent(InputEvent event);
|
---|
38 |
|
---|
39 | /** Gets the set of all input types that this translator monitors. */
|
---|
40 | public Set<InputType> getMonitoredInputTypes()
|
---|
41 | {
|
---|
42 | return new HashSet<InputType>(_monitoredInputTypes);
|
---|
43 | }
|
---|
44 |
|
---|
45 | /** Finds out if the given input type is monitored by this translator. */
|
---|
46 | public boolean isMonitoredType(InputType type)
|
---|
47 | {
|
---|
48 | if (_monitoredInputTypes == null) return false;
|
---|
49 | return _monitoredInputTypes.contains(type);
|
---|
50 | }
|
---|
51 |
|
---|
52 | }
|
---|