frog.gui
Class User

java.lang.Object
  extended by frog.gui.User
All Implemented Interfaces:
DeviceListener, SessionListener

public class User
extends Object
implements SessionListener

This class is the FROGUI abstraction for Session. It listens to the Session and provides access to most of its methods for GUI use.

Author:
Team Better Recognize

Constructor Summary
User(int index)
          Creates a new user with the specified index.
 
Method Summary
 void accelerationPerformed(AccelEvent e)
          Executed whenever a Session detects an acceleration from a Device it is listening to.
 void gestureComplete(boolean good, Device d)
          Executed whenever a Session detects a complete gesture from a Device it is listening to.
 void gestureRecognized(GestureModel g)
          Executed whenever a Session has recognized a gesture performed by the Device it is listening to (requires being in recognition mode).
 Device getDevice()
          Returns the device this user has connected.
 int getIndex()
          Returns the index of this user.
 Session getSession()
          Returns the Session currently associated with this user.
 String getUserName()
          Returns the name of the User this object represents.
 void saveSession(File saveFile)
          Attempts to serialize this User's current Session into a File for later retrieval.
 void setDevice(Device d)
          Sets the Device for this User to use.
 void setSession(File openFile)
          Creates a new Session from the given serialized session file and sets that as the User's current Session.
 void setSession(Session s)
          Sets the Session for the User.
 void setUserName(String userName)
          This method sets the name of the user to be used in dialogs, user files, etc.
 String toString()
           
 void unexpectedDisconnect(Device d)
          Executed whenever a Session detects an unexpected disconnect from a Device it is listening to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

User

public User(int index)
Creates a new user with the specified index.

Parameters:
index - the index of this user.
Method Detail

getDevice

public Device getDevice()
Returns the device this user has connected. If no device is connected, it will return null. You can use hasDeviceConnected() to verify beforehand.

Returns:
device the user has connected or null if no Device is connected.

getIndex

public int getIndex()
Returns the index of this user.

Returns:
the index of this user.

getSession

public Session getSession()
Returns the Session currently associated with this user.

Returns:
this User's current Session.

getUserName

public String getUserName()
Returns the name of the User this object represents.

Returns:
string representing the name of the user.

saveSession

public void saveSession(File saveFile)
                 throws NullPointerException,
                        IOException
Attempts to serialize this User's current Session into a File for later retrieval.

Parameters:
saveFile - a valid File to write the Session object to
Throws:
NullPointerException - if the Session was null
IOException - if a problem occurred while serializing the Session

setDevice

public void setDevice(Device d)
               throws IOException
Sets the Device for this User to use.

Parameters:
d - this User's new Device.
Throws:
IOException

setUserName

public void setUserName(String userName)
This method sets the name of the user to be used in dialogs, user files, etc.

Parameters:
userName - the name to be given to this User.

setSession

public void setSession(Session s)
                throws IOException
Sets the Session for the User.

Parameters:
s - session to be associated to this object.
Throws:
IOException

setSession

public void setSession(File openFile)
                throws Exception
Creates a new Session from the given serialized session file and sets that as the User's current Session.

Parameters:
openFile - a File containing a serialized Session object
Throws:
Exception

toString

public String toString()
Overrides:
toString in class Object

accelerationPerformed

public void accelerationPerformed(AccelEvent e)
Description copied from interface: SessionListener
Executed whenever a Session detects an acceleration from a Device it is listening to.

Specified by:
accelerationPerformed in interface DeviceListener
Specified by:
accelerationPerformed in interface SessionListener
Parameters:
e - contains the acceleration data and the calling device

unexpectedDisconnect

public void unexpectedDisconnect(Device d)
Description copied from interface: SessionListener
Executed whenever a Session detects an unexpected disconnect from a Device it is listening to.

Specified by:
unexpectedDisconnect in interface DeviceListener
Specified by:
unexpectedDisconnect in interface SessionListener
Parameters:
d - Device that was unexpectedly disconnected

gestureComplete

public void gestureComplete(boolean good,
                            Device d)
Description copied from interface: SessionListener
Executed whenever a Session detects a complete gesture from a Device it is listening to.

Specified by:
gestureComplete in interface DeviceListener
Specified by:
gestureComplete in interface SessionListener
Parameters:
good - true if this gesture is complete. false if this gesture should be discarded.
d - the device that completed the gesture

gestureRecognized

public void gestureRecognized(GestureModel g)
Description copied from interface: SessionListener
Executed whenever a Session has recognized a gesture performed by the Device it is listening to (requires being in recognition mode).

Specified by:
gestureRecognized in interface SessionListener
Parameters:
g - The gesture recognized
See Also:
Session.inRecognitionMode()