-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInteractiveGrabberObject.java
180 lines (163 loc) · 5.04 KB
/
InteractiveGrabberObject.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/**************************************************************************************
* bias_tree
* Copyright (c) 2014-2017 National University of Colombia, https://github.com/remixlab
* @author Jean Pierre Charalambos, http://otrolado.info/
*
* All rights reserved. Library that eases the creation of interactive
* scenes, released under the terms of the GNU Public License v3.0
* which is available at http://www.gnu.org/licenses/gpl.html
**************************************************************************************/
package remixlab.bias;
/**
* A {@link remixlab.bias.GrabberObject} with a {@link Profile} instance which allows
* {@link Shortcut} to {@link java.lang.reflect.Method} bindings high-level
* customization (see all the <b>*Binding*()</b> methods). Refer to
* {@link Profile#setBinding(Shortcut, String)} and
* {@link Profile#setBinding(Object, Shortcut, String)} for the type of
* actions and method signatures that may be bound.
*
* @see Profile
*/
public class InteractiveGrabberObject extends GrabberObject {
protected Profile profile;
/**
* Empty constructor.
*/
public InteractiveGrabberObject() {
profile = new Profile(this);
}
/**
* Constructs and adds this interactive-grabber object to the agent pool.
*
* @see Agent#grabbers()
*/
public InteractiveGrabberObject(Agent agent) {
super(agent);
profile = new Profile(this);
}
/**
* Constructs and adds this interactive-grabber object to all agents belonging to the input handler.
*
* @see InputHandler#agents()
*/
public InteractiveGrabberObject(InputHandler inputHandler) {
super(inputHandler);
profile = new Profile(this);
}
/**
* Same as {@code profile.handle(event)}.
*
* @see Profile#handle(BogusEvent)
*/
@Override
public void performInteraction(BogusEvent event) {
profile.handle(event);
}
/**
* Same as {@code profile.setBinding(shortcut, action)}.
* <p>
* Low-level profile handling routine. Call this method to set a binding for a custom bogus event, like this:
* {@code grabber.setBinding(new CustomShortcut(mask, CustomAgent.CUSTOM_ID), "customBehavior")}.
*
* @see Profile#setBinding(Shortcut, String)
* @see BogusEvent
* @see Shortcut
*/
public void setBinding(Shortcut shortcut, String action) {
profile.setBinding(shortcut, action);
}
/**
* Same as {@code profile.setBinding(object, shortcut, action)}.
* <p>
* Low-level profile handling routine. Call this method to set a binding for a custom bogus event, like this:
* {@code grabber.setBinding(object, new CustomShortcut(mask, CustomAgent.CUSTOM_ID), "customBehavior")}.
*
* @see Profile#setBinding(Object, Shortcut, String)
* @see BogusEvent
* @see Shortcut
*/
public void setBinding(Object object, Shortcut shortcut, String action) {
profile.setBinding(object, shortcut, action);
}
/**
* Same as {@code profile.set(otherGrabber.profile)}.
*
* @see Profile#set(Profile)
*/
public void setBindings(InteractiveGrabberObject otherGrabber) {
profile.set(otherGrabber.profile);
}
/**
* Same as {@code return profile.hasBinding(shortcut)}.
* <p>
* <p>
* Low-level profile handling routine. Call this method to query for a binding from a custom bogus event, like this:
* {@code grabber.hasBinding(object, new CustomShortcut(mask, CustomAgent.CUSTOM_ID)}.
*
* @see Profile#hasBinding(Shortcut)
* @see BogusEvent
* @see Shortcut
*/
public boolean hasBinding(Shortcut shortcut) {
return profile.hasBinding(shortcut);
}
/**
* Same as {@code profile.removeBinding(shortcut)}.
* <p>
* Low-level profile handling routine. Call this method to remove a binding for a custom bogus event, like this:
* {@code grabber.removeBinding(new CustomShortcut(mask, CustomAgent.CUSTOM_ID)}.
*
* @see Profile#removeBinding(Shortcut)
* @see BogusEvent
* @see Shortcut
*/
public void removeBinding(Shortcut shortcut) {
profile.removeBinding(shortcut);
}
/**
* Same as {@code profile.removeBindings()}.
*
* @see Profile#removeBindings()
*/
public void removeBindings() {
profile.removeBindings();
}
/**
* Same as {@code profile.removeBindings(cls)}.
*
* @see Profile#removeBindings(Class)
*/
public void removeBindings(Class<? extends Shortcut> cls) {
profile.removeBindings(cls);
}
/**
* Same as {@code profile.info(cls)}.
*
* @see Profile#info(Class)
*/
public String info(Class<? extends Shortcut> cls) {
return profile.info(cls);
}
/**
* Returns a description of all the bindings this grabber holds.
*/
public String info() {
return profile.info();
}
/**
* Same as {@code return profile.action(key)}.
*
* @see Profile#action(Shortcut)
*/
public String action(Shortcut shortcut) {
return profile.action(shortcut);
}
/**
* Same as {@code return profile.isActionBound(action)}.
*
* @see Profile#isActionBound(String)
*/
public boolean isActionBound(String action) {
return profile.isActionBound(action);
}
}