|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.silentlycrashing.gestures.GestureAnalyzer
public class GestureAnalyzer
Records gestures for analysis by the registered GestureListeners.
The analysis algorithm used here is based on the MouseGestures library by Smardec.
Debugging:
The "verbose" flag can be set to print the recorded gestures to standard output.
The "debug" flag can be set to plot the key points on the display.
| Field Summary | |
|---|---|
private boolean |
debug
|
static String |
DOWN
|
private StringBuffer |
gesture
|
static int |
KEY_SIZE
|
static String |
LEFT
|
private int |
minOffset
|
protected PApplet |
p
|
static String |
RIGHT
|
private Vector |
startActions
|
private Point |
startPoint
|
private Vector |
stopActions
|
static String |
UP
|
private Vector |
updateActions
|
private boolean |
verbose
|
| Constructor Summary | |
|---|---|
GestureAnalyzer(PApplet parent,
int min)
Builds a GestureAnalyzer. |
|
| Method Summary | |
|---|---|
String |
getGesture()
|
int |
getMinOffset()
|
void |
invokeStartActions()
Invokes the start actions. |
void |
invokeStopActions()
Invokes the stop actions. |
void |
invokeUpdateActions()
Invokes the update actions. |
boolean |
isDebug()
|
boolean |
isRecognized()
|
boolean |
isVerbose()
|
boolean |
matches(String regex)
Checks if the passed regular expression matches the saved gesture. |
void |
registerStartAction(String name,
Object o,
Class[] cargs)
Registers the given method as a start action. |
void |
registerStopAction(String name,
Object o,
Class[] cargs)
Registers the given method as a stop action. |
void |
registerUpdateAction(String name,
Object o,
Class[] cargs)
Registers the given method as an update action. |
private void |
reset()
Resets the GestureAnalyzer. |
private void |
saveMove(String move)
Adds a move to the buffer. |
void |
setDebug(boolean d)
|
void |
setMinOffset(int m)
|
void |
setVerbose(boolean v)
|
void |
start(Point pt)
Sets the start Point and invokes all start RegisteredActions. |
void |
stop(Point pt)
Invokes all stop RegisteredActions and resets the GestureAnalyzer. |
void |
update(Point pt)
Checks if a new move has occurred and if so, invokes all update RegisteredActions. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String LEFT
public static final String RIGHT
public static final String UP
public static final String DOWN
public static final int KEY_SIZE
protected PApplet p
private int minOffset
private Point startPoint
private StringBuffer gesture
private Vector startActions
private Vector updateActions
private Vector stopActions
private boolean verbose
private boolean debug
| Constructor Detail |
|---|
public GestureAnalyzer(PApplet parent,
int min)
parent - the parent PAppletmin - the minimum offset| Method Detail |
|---|
public void registerStartAction(String name,
Object o,
Class[] cargs)
name - the name of the method to registero - the Object holding the methodcargs - the argumentspublic void invokeStartActions()
public void registerUpdateAction(String name,
Object o,
Class[] cargs)
name - the name of the method to registero - the Object holding the methodcargs - the argumentspublic void invokeUpdateActions()
public void registerStopAction(String name,
Object o,
Class[] cargs)
name - the name of the method to registero - the Object holding the methodcargs - the argumentspublic void invokeStopActions()
public void start(Point pt)
Called when the mouse is pressed.
pt - the current mouse Pointpublic void update(Point pt)
Called when the mouse is dragged.
pt - the current mouse Pointpublic void stop(Point pt)
Called when the mouse is released.
pt - the current mouse Point (unused)private void reset()
private void saveMove(String move)
move - the recognized movepublic boolean matches(String regex)
regex - the regular expression to check
public int getMinOffset()
public void setMinOffset(int m)
public String getGesture()
public boolean isRecognized()
public void setVerbose(boolean v)
public boolean isVerbose()
public void setDebug(boolean d)
public boolean isDebug()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||