public class GazeManager extends Object implements com.theeyetribe.client.GazeApiManager.IGazeApiResponseListener, com.theeyetribe.client.GazeApiManager.IGazeApiConnectionListener
Using this class a developer can 'calibrate' an eye tracking setup and attach listeners to receive live data streams
of GazeData
updates.
Modifier and Type | Class and Description |
---|---|
static class |
GazeManager.ApiVersion
Current running mode of this client
|
static class |
GazeManager.ClientMode
Current running mode of this client
|
static class |
GazeManager.FrameRate
The current state of the connected TrackerDevice.
|
static class |
GazeManager.TrackerState
The current state of the connected TrackerDevice.
|
Modifier and Type | Method and Description |
---|---|
boolean |
activate(GazeManager.ApiVersion version,
GazeManager.ClientMode mode)
Activates TET Java Client and all underlying routines using default values.
|
boolean |
activate(GazeManager.ApiVersion version,
GazeManager.ClientMode mode,
IConnectionStateListener listener)
Activates TET Java Client and all underlying routines using default values.
|
boolean |
activate(GazeManager.ApiVersion version,
GazeManager.ClientMode mode,
String hostname,
int portnumber)
Activates TET Java Client and all underlying routines.
|
boolean |
activate(GazeManager.ApiVersion version,
GazeManager.ClientMode mode,
String hostname,
int portnumber,
IConnectionStateListener listener)
Activates TET Java Client and all underlying routines.
|
void |
addCalibrationResultListener(ICalibrationResultListener listener)
Adds a
ICalibrationResultListener to the TET Java client. |
void |
addConnectionStateListener(IConnectionStateListener listener)
Adds a
IConnectionStateListener to the TET Java client. |
void |
addGazeListener(IGazeListener listener)
Adds a
IGazeListener to the TET Java client. |
void |
addTrackerStateListener(ITrackerStateListener listener)
Adds a
ITrackerStateListener to the TET Java client. |
void |
calibrationAbort()
Cancels an ongoing calibration process.
|
void |
calibrationClear()
Resets calibration state, canceling any previous calibrations.
|
void |
calibrationPointEnd()
Called for every calibration point during a calibration process.
|
void |
calibrationPointStart(int x,
int y)
Called for every calibration point during a calibration process.
|
void |
calibrationStart(int numCalibrationPoints,
ICalibrationProcessHandler listener)
Initiate a new calibration process.
|
void |
clearListeners()
Clear all attached listeners, clears GazeData queue and stop broadcasting
|
void |
deactivate()
Deactivates TET Java Client and all under lying routines.
|
GazeManager.ClientMode |
getClientMode()
Current running mode of this client
|
GazeManager.FrameRate |
getFrameRate()
Number of frames per second delivered by EyeTribe Server
|
int |
getHeartbeatMillis()
Length of a heartbeat in milliseconds
|
static GazeManager |
getInstance() |
CalibrationResult |
getLastCalibrationResult()
The latest performed and valid CalibrationResult.
|
int |
getNumCalibrationResultListeners()
Gets current number of attached
ICalibrationResultListener instances. |
int |
getNumConnectionStateListeners()
Gets current number of attached
IConnectionStateListener instances. |
int |
getNumGazeListeners()
Gets current number of attached
IGazeListener instances. |
int |
getNumTrackerStateListeners()
Gets current number of attached
ITrackerStateListener instances. |
int |
getScreenIndex()
Index of currently used screen.
|
float |
getScreenPhysicalHeight()
Physical height of screen in meters.
|
float |
getScreenPhysicalWidth()
Physical width of screen in meters.
|
int |
getScreenResolutionHeight()
Height of screen resolution in pixels.
|
int |
getScreenResolutionWidth()
Width of screen resolution in pixels.
|
GazeManager.TrackerState |
getTrackerState()
The current state of the connected TrackerDevice
|
GazeManager.ApiVersion |
getVersion()
Current API version compliance of EyeTribe Server
|
boolean |
hasCalibrationResultListener(ICalibrationResultListener listener)
Checks if a given instance of
ICalibrationResultListener is currently attached. |
boolean |
hasConnectionStateListener(IConnectionStateListener listener)
Checks if a given instance of
IConnectionStateListener is currently attached. |
boolean |
hasGazeListener(IGazeListener listener)
Checks if a given instance of
IGazeListener is currently attached. |
boolean |
hasTrackerStateListener(ITrackerStateListener listener)
Checks if a given instance of
ITrackerStateListener is currently attached. |
boolean |
isActivated() |
boolean |
isCalibrated()
Is the client already calibrated?
|
boolean |
isCalibrating()
Is the client in the middle of a calibration process?
|
boolean |
isConnected()
Deprecated.
Use isActivated() instead.
|
void |
onGazeApiConnectionStateChanged(boolean isConnected) |
void |
onGazeApiResponse(String response) |
boolean |
removeCalibrationResultListener(ICalibrationResultListener listener)
Remove a
ICalibrationResultListener from the TET Java client. |
boolean |
removeConnectionStateListener(IConnectionStateListener listener)
Remove a
IConnectionStateListener from the TET Java client. |
boolean |
removeGazeListener(IGazeListener listener)
Remove a
IGazeListener from the TET Java client. |
boolean |
removeTrackerStateListener(ITrackerStateListener listener)
Remove a
ITrackerStateListener from the TET Java client. |
void |
switchScreen(int screenIndex,
int screenResW,
int screenResH,
float screenPsyW,
float screenPsyH)
Switch currently active screen.
|
public static GazeManager getInstance()
public boolean activate(GazeManager.ApiVersion version, GazeManager.ClientMode mode)
When closing down, the deactivate
method must be called.
version
- Version number of the Tracker API that this client will be compliant tomode
- Mode though which the client will receive GazeData. Either ClientMode.PUSH or ClientMode.PULLpublic boolean activate(GazeManager.ApiVersion version, GazeManager.ClientMode mode, IConnectionStateListener listener)
When closing down, the deactivate
method must be called.
version
- Version number of the Tracker API that this client will be compliant tomode
- Mode though which the client will receive GazeData. Either ClientMode.PUSH or ClientMode.PULLlistener
- Listener to notify once the connection to EyeTribe Server has been establishedpublic boolean activate(GazeManager.ApiVersion version, GazeManager.ClientMode mode, String hostname, int portnumber, IConnectionStateListener listener)
When closing down, the deactivate
method must be called.
version
- Version number of the Tracker API that this client will be compliant tomode
- Mode though which the client will receive GazeData. Either ClientMode.PUSH or ClientMode.PULLhostname
- The host name or IP address where the eye tracking server is runninglistener
- Listener to notify once the connection to EyeTribe Server has been establishedpublic boolean activate(GazeManager.ApiVersion version, GazeManager.ClientMode mode, String hostname, int portnumber)
When closing down, the deactivate
method must be called.
version
- Version number of the Tracker API that this client will be compliant tomode
- Mode though which the client will receive GazeData. Either ClientMode.PUSH or ClientMode.PULLhostname
- The host name or IP address where the eye tracking server is runningpublic void deactivate()
public boolean isConnected()
public boolean isActivated()
public boolean isCalibrating()
public boolean isCalibrated()
public int getScreenIndex()
public float getScreenPhysicalWidth()
public float getScreenPhysicalHeight()
public int getScreenResolutionWidth()
public int getScreenResolutionHeight()
public GazeManager.TrackerState getTrackerState()
public int getHeartbeatMillis()
. The EyeTribe Server defines the desired length of a heartbeat and is in this implementation automatically acquired through the Tracker API.
public CalibrationResult getLastCalibrationResult()
public GazeManager.FrameRate getFrameRate()
public GazeManager.ApiVersion getVersion()
public GazeManager.ClientMode getClientMode()
public void calibrationStart(int numCalibrationPoints, ICalibrationProcessHandler listener)
CalibrationPointStart
or calibrationPointEnd
.
Any previous (and possible running) calibration process must be completed or aborted before calling this.
A full calibration process consists of a number of calls to calibrationPointStart
and calibrationPointEnd
matching the total number of
calibration points set by the numCalibrationPoints parameter.
numCalibrationPoints
- The number of calibration points that will be used in this calibrationlistener
- The ICalibrationProcessHandler
instance that will receive
callbacks during the calibration processpublic void calibrationPointStart(int x, int y)
calibrationPointEnd
1-2 seconds later.
The calibration process must be initiated by a call to calibrationStart
before calling this.
x
- X coordinate of the calibration pointy
- Y coordinate of the calibration pointpublic void calibrationPointEnd()
calibrationPointStart
.
The calibration process must be initiated by a call to calibrationStart
before calling this.
public void calibrationAbort()
public void calibrationClear()
public void switchScreen(int screenIndex, int screenResW, int screenResH, float screenPsyW, float screenPsyH)
screenIndex
- Index of next screen. On windows 'Primary Screen' has index 0screenResW
- Screen resolution width in pixelsscreenResH
- Screen resolution height in pixelsscreenPsyW
- Physical Screen width in metersscreenPsyH
- Physical Screen height in meterspublic void addGazeListener(IGazeListener listener)
IGazeListener
to the TET Java client. This listener will receive
GazeData
updates when availablelistener
- The IGazeListener
instance to addpublic boolean removeGazeListener(IGazeListener listener)
IGazeListener
from the TET Java client.listener
- The IGazeListener
instance to removepublic int getNumGazeListeners()
IGazeListener
instances.public boolean hasGazeListener(IGazeListener listener)
IGazeListener
is currently attached.listener
- The IGazeListener
instance check forpublic void addCalibrationResultListener(ICalibrationResultListener listener)
ICalibrationResultListener
to the TET Java client. This listener will
recieve CalibrationResult
updates when availablelistener
- The CalibrationResult
instance to addpublic boolean removeCalibrationResultListener(ICalibrationResultListener listener)
ICalibrationResultListener
from the TET Java client.listener
- The ICalibrationResultListener
instance to removepublic int getNumCalibrationResultListeners()
ICalibrationResultListener
instances.public boolean hasCalibrationResultListener(ICalibrationResultListener listener)
ICalibrationResultListener
is currently attached.listener
- The ICalibrationResultListener
instance check forpublic void addTrackerStateListener(ITrackerStateListener listener)
ITrackerStateListener
to the TET Java client. This listener will recieve
GazeManager.TrackerState
updates and updates about change of active screen index.listener
- The ITrackerStateListener
instance to addpublic boolean removeTrackerStateListener(ITrackerStateListener listener)
ITrackerStateListener
from the TET Java client.listener
- The ITrackerStateListener
instance to removepublic int getNumTrackerStateListeners()
ITrackerStateListener
instances.public boolean hasTrackerStateListener(ITrackerStateListener listener)
ITrackerStateListener
is currently attached.listener
- The ITrackerStateListener
instance check forpublic void addConnectionStateListener(IConnectionStateListener listener)
IConnectionStateListener
to the TET Java client. This listener will receive
updates about change in connection state to the EyeTribe Server.listener
- The IConnectionStateListener
instance to addpublic boolean removeConnectionStateListener(IConnectionStateListener listener)
IConnectionStateListener
from the TET Java client.listener
- The IConnectionStateListener
instance to removepublic int getNumConnectionStateListeners()
IConnectionStateListener
instances.public boolean hasConnectionStateListener(IConnectionStateListener listener)
IConnectionStateListener
is currently attached.listener
- The IConnectionStateListener
instance check forpublic void clearListeners()
public void onGazeApiResponse(String response)
onGazeApiResponse
in interface com.theeyetribe.client.GazeApiManager.IGazeApiResponseListener
public void onGazeApiConnectionStateChanged(boolean isConnected)
onGazeApiConnectionStateChanged
in interface com.theeyetribe.client.GazeApiManager.IGazeApiConnectionListener
Processing library EyeTribeProcessing by Jorge C. S. Cardoso. (c) 2015