source: trunk/src/org/expeditee/gio/input/InputEventToGestureTranslator.java@ 1097

Last change on this file since 1097 was 1097, checked in by davidb, 6 years ago

Newly structured files from Corey's work on logic/graphics separation

File size: 1.5 KB
Line 
1package org.expeditee.gio.input;
2
3import java.util.HashSet;
4import java.util.List;
5import java.util.Set;
6
7import org.expeditee.Util;
8import org.expeditee.gio.gesture.Gesture;
9import org.expeditee.gio.input.InputEvent.InputType;
10
11public 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}
Note: See TracBrowser for help on using the repository browser.