frog.plugin
Interface DeviceListener

All Known Subinterfaces:
SessionListener
All Known Implementing Classes:
DeviceDialog, EvaluationPanel, Player, PlayerPanel, RecognitionSectionPanel, Session, TrainPanel, User

public interface DeviceListener

Interface for listening to a device. Since FROG is an event-driven program there is an obvious need to be able to react as gestures come in from the user.

It is also important for handling device operations such as abrupt disconnects or other failures.

Author:
Team Better Recognize

Method Summary
 void accelerationPerformed(AccelEvent e)
          Run every time a single acceleration has come in.
 void gestureComplete(boolean good, Device d)
          Run when a single gesture has been completed.
 void unexpectedDisconnect(Device d)
          For handling an unexpected disconnect from a device.
 

Method Detail

unexpectedDisconnect

void unexpectedDisconnect(Device d)
For handling an unexpected disconnect from a device. This is not called when a user has specified that they wish to disconnect. If a Device has gone out of range or the battery dies, that is an appropriate time to use this.

Common sense would dictate this is a job for Exceptions. However, if a disconnect occurs while idle, it is impossible to throw an exception beyond the Plugin. Devices need a listener to notify when something goes wrong.

Parameters:
d - Device that was unexpectedly disconnected

accelerationPerformed

void accelerationPerformed(AccelEvent e)
Run every time a single acceleration has come in.

It is highly recommended you keep this method simple or execute in a new Thread. There may be many listeners all wanting to execute some code when an event happens.

Parameters:
e - contains the acceleration data and the calling device

gestureComplete

void gestureComplete(boolean good,
                     Device d)
Run when a single gesture has been completed. If the gesture was cut unexpectedly short either due to an error or hardware failure the boolean will be false and appropriate action should be taken to discard all acceleration data up to this point since the last known good gesture.

Parameters:
good - true if this gesture is complete. false if this gesture should be discarded.
d - the device that completed the gesture