public class Profile extends Object
Grabber
extension which allows to define
Shortcut
to Method
bindings. See
setBinding(Shortcut, String)
and setBinding(Object, Shortcut, String)
.
To attach a profile to a grabber first override your
Grabber.performInteraction(BogusEvent)
method like this:
public void performInteraction(BogusEvent event) {
profile.handle(event);
}
(see handle(BogusEvent)
) and then simply pass the grabber instance to the
Profile(Grabber)
constructor.
Constructor and Description |
---|
Profile(Grabber g)
Attaches a profile to the given grabber.
|
Modifier and Type | Method and Description |
---|---|
String |
action(Shortcut shortcut)
|
Grabber |
grabber()
Returns the grabber to which this profile is attached.
|
boolean |
handle(BogusEvent event)
Main class method to be called from
Grabber.performInteraction(BogusEvent) . |
boolean |
hasBinding(Shortcut shortcut)
Returns true if this object contains a binding for the specified shortcut.
|
String |
info()
Returns a description of all the bindings this profile holds.
|
String |
info(Class<? extends Shortcut> cls)
Returns a description of all the bindings this profile holds from the given shortcut
class.
|
boolean |
isActionBound(String action)
Returns true if this object maps one or more shortcuts to the action specified by the
grabber() . |
Method |
method(Shortcut shortcut)
|
Object |
object(Shortcut shortcut)
Returns the action performing object.
|
static void |
registerVKeys(Class<? extends Shortcut> shortcutClass,
Class<?> keyEventClass)
Utility function to programmatically register virtual keys to a
Shortcut class,
typically KeyboardShortcuts . |
void |
removeBinding(Shortcut shortcut)
Removes the shortcut binding.
|
void |
removeBindings()
Removes all the shortcuts from this object.
|
void |
removeBindings(Class<? extends Shortcut> cls)
Removes all the shortcuts from the given shortcut class.
|
void |
set(Profile p)
Instantiates this profile from another profile.
|
boolean |
setBinding(Object object,
Shortcut shortcut,
String action)
Defines the shortcut that triggers the given action.
|
boolean |
setBinding(Shortcut shortcut,
String action)
Defines the shortcut that triggers the given action.
|
Set<Shortcut> |
shortcuts()
Returns this profile set of shortcuts.
|
public static Object context
public Profile(Grabber g)
public static void registerVKeys(Class<? extends Shortcut> shortcutClass, Class<?> keyEventClass)
Shortcut
class,
typically KeyboardShortcuts
.public void set(Profile p)
grabber()
should be of the same type.public Grabber grabber()
public Method method(Shortcut shortcut)
action(Shortcut)
public String action(Shortcut shortcut)
method(Shortcut)
public Object object(Shortcut shortcut)
grabber()
or an external
object.public boolean handle(BogusEvent event)
Grabber.performInteraction(BogusEvent)
. Calls an action
handler if the BogusEvent.shortcut()
is bound.public boolean setBinding(Shortcut shortcut, String action)
Attempt to set a shortcut for the action
implemented by the context
(e.g., the PApplet
in the case of a Processing application) or the
grabber()
(e.g., the InteractiveFrame
instance this profile is
attached to, in the case of a Processing application) when no prototype is found in
the context
.
The available action prototypes for the context
are:
The available action prototypes for the grabber()
are:
The bogus-event type that may be passed to the above prototypes is the one specified
by the Shortcut.eventClass()
method:
ClickEvent
for a
ClickShortcut
KeyboardEvent
for a
KeyboardShortcut
DOFnEvent
for a MotionShortcut
, where
n
is the MotionShortcut.dofs(int)
of the
motion-shortcut Shortcut.id()
.MotionEvent
may be
passed too.shortcut
- Shortcut
action
- String
setBinding(Object, Shortcut, String)
,
Shortcut.eventClass()
,
MotionShortcut.eventClass()
,
MotionShortcut.dofs(int)
,
MotionShortcut.registerID(int, int, String)
public boolean setBinding(Object object, Shortcut shortcut, String action)
Attempt to set a shortcut for the action
implemented by object
. The
action procedure may have two different prototypes:
Shortcut.eventClass()
method:
ClickEvent
for a
ClickShortcut
KeyboardEvent
for a
KeyboardShortcut
DOFnEvent
for a MotionShortcut
, where
n
is the MotionShortcut.dofs(int)
of the
motion-shortcut Shortcut.id()
.MotionEvent
may be
passed too.object
- Object
shortcut
- Shortcut
action
- String
setBinding(Object, Shortcut, String)
,
Shortcut.eventClass()
,
MotionShortcut.eventClass()
,
MotionShortcut.dofs(int)
,
MotionShortcut.registerID(int, int, String)
public void removeBinding(Shortcut shortcut)
shortcut
- Shortcut
public void removeBindings()
public void removeBindings(Class<? extends Shortcut> cls)
public String info(Class<? extends Shortcut> cls)
public String info()
public boolean hasBinding(Shortcut shortcut)
shortcut
- Shortcut
Processing Library proscene by Jean Pierre Charalambos. (c) 2014-2017 National University of Colombia