PenProfile 2.x

com.livescribe.util
Class TapAndHoldGesture

java.lang.Object
  extended by com.livescribe.util.TapAndHoldGesture
All Implemented Interfaces:
Runnable

public abstract class TapAndHoldGesture
extends Object
implements Runnable

This can be used by applications to check if the user has tapped at a point on the paper and held the pen at the same point for a specified period of time.

This is basically a timer that calls handleTick(long) one or more times at the specified interval. It can be reused.


Constructor Summary
TapAndHoldGesture()
          Creates a new tap and hold gesture.
 
Method Summary
 void activate(long timeout)
          Activates the timer.
 void deactivate()
          Deactivates the timer.
protected abstract  boolean handleTick(long elapsed)
          This is called when a timeout has elapsed.
protected  void init()
          Called when the gesture is acivated.
 boolean isActive()
          Check if this is active.
 void run()
          This will run on the timer thread.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TapAndHoldGesture

public TapAndHoldGesture()
Creates a new tap and hold gesture.

Method Detail

activate

public final void activate(long timeout)
Activates the timer. When the timer expires, handleTick(long) is called. This does nothing if the timer is already active.

Additionally, init() is called before the timer is started.

Parameters:
timeout - wait this long before triggering the event
See Also:
handleTick(long), init()

deactivate

public final void deactivate()
Deactivates the timer.


isActive

public final boolean isActive()
Check if this is active.

Returns:
whether this is active.

run

public final void run()
This will run on the timer thread. Outside threads will be ignored.

Specified by:
run in interface Runnable
See Also:
Thread.run()

init

protected void init()
Called when the gesture is acivated.

See Also:
activate(long).

handleTick

protected abstract boolean handleTick(long elapsed)
This is called when a timeout has elapsed. This should return whether we are done handling events.

Parameters:
elapsed - total time that has elapsed since we were activated, in ms
Returns:
true if we are done and don't need to handle more events, and false if more events are expected.
See Also:
activate(long)

PenProfile 2.x

Copyright © 2010 Livescribe Inc. All Rights Reserved.
Confidential and subject to NDA.