net.silentlycrashing.gestures
Class GestureListener

java.lang.Object
  extended by net.silentlycrashing.gestures.GestureListener
Direct Known Subclasses:
ConcurrentGestureListener, PostGestureListener

public abstract class GestureListener
extends Object

Listens for a specific gesture and calls the appropriate RegisteredAction when it becomes active or inactive.


Field Summary
protected  boolean active
           
protected  Rectangle bounds
           
protected  GestureAnalyzer ga
           
protected  boolean inBounds
           
protected  RegisteredAction offAction
           
protected  RegisteredAction onAction
           
protected  PApplet p
           
protected  PointInTime startPoint
           
 
Constructor Summary
GestureListener(PApplet parent, GestureAnalyzer analyzer)
          Builds a GestureListener covering the entire canvas.
GestureListener(PApplet parent, GestureAnalyzer analyzer, Rectangle bounds)
          Builds a bounded GestureListener.
 
Method Summary
 void activate()
           
 void deactivate()
           
 PointInTime getStartPoint()
           
 boolean isActive()
           
abstract  void keepListening(PointInTime pt)
          Holds actions to be performed when a new move occurs in the gesture.
 void registerOffAction(String name, Object o)
          Registers the given method with the off action.
 void registerOnAction(String name, Object o)
          Registers the given method with the on action.
 void setBounds(Rectangle newBounds)
           
 void startListening(PointInTime pt)
          Checks that the gesture is starting in the correct bounds and sets the start point.
abstract  void stopListening(PointInTime pt)
          Holds actions to be performed when a gesture completes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

p

protected PApplet p

ga

protected GestureAnalyzer ga

active

protected boolean active

onAction

protected RegisteredAction onAction

offAction

protected RegisteredAction offAction

startPoint

protected PointInTime startPoint

bounds

protected Rectangle bounds

inBounds

protected boolean inBounds
Constructor Detail

GestureListener

public GestureListener(PApplet parent,
                       GestureAnalyzer analyzer)
Builds a GestureListener covering the entire canvas.

Parameters:
parent - the parent PApplet
analyzer - the linked GestureAnalyzer

GestureListener

public GestureListener(PApplet parent,
                       GestureAnalyzer analyzer,
                       Rectangle bounds)
Builds a bounded GestureListener.

Parameters:
parent - the parent PApplet
analyzer - the linked GestureAnalyzer
bounds - the bounding Rectangle of the first mouse press
Method Detail

startListening

public void startListening(PointInTime pt)
Checks that the gesture is starting in the correct bounds and sets the start point.

Parameters:
pt - the first PointInTime of the gesture

keepListening

public abstract void keepListening(PointInTime pt)
Holds actions to be performed when a new move occurs in the gesture.

Parameters:
pt - the current PointInTime of the gesture

stopListening

public abstract void stopListening(PointInTime pt)
Holds actions to be performed when a gesture completes.

Parameters:
pt - the last PointInTime of the gesture

registerOnAction

public void registerOnAction(String name,
                             Object o)
Registers the given method with the on action.

Parameters:
name - the name of the method to register
o - the Object holding the method

registerOffAction

public void registerOffAction(String name,
                              Object o)
Registers the given method with the off action.

Parameters:
name - the name of the method to register
o - the Object holding the method

activate

public void activate()

deactivate

public void deactivate()

isActive

public boolean isActive()

getStartPoint

public PointInTime getStartPoint()

setBounds

public void setBounds(Rectangle newBounds)