synergynetframework.mtinput
Class ClickDetector

java.lang.Object
  extended by synergynetframework.mtinput.ClickDetector

public class ClickDetector
extends java.lang.Object

Determines whether cursor released events constitute a single click. Needs to know when new cursors are pressed, via newCursorPressed. When a cursor is released, use isCursorReleaseASingleClick to determine whether a single click event occurred, based on the current sensitivity.

Author:
dcs0ah1

Constructor Summary
ClickDetector(long time, float distance)
          Click detector, based on supplied sensitivity values.
 
Method Summary
 int cursorReleasedGetClickCount(long id, java.awt.geom.Point2D.Float position)
          Returns true if the released cursor is within the sensitivity values required to constitute a single click.
 float getDistanceSensitivity()
          Gets the distance sensitivity.
 long getDoubleClickTimeThreshold()
          Gets the double click time threshold.
 long getTimeSensitivity()
          Gets the time sensitivity.
 boolean isCursorReleaseADoubleClick(long id, java.awt.geom.Point2D.Float position, synergynetframework.mtinput.ClickDetector.CursorDownRecord causedBy)
          Checks if is cursor release a double click.
 void newCursorPressed(long id, java.awt.geom.Point2D.Float position)
          Register cursor - only registered cursors will ever pass the test of being a single click when isCursorReleaseASingleClick is called.
 void setDoubleClickTimeThreshold(long doubleClickTimeThreshold)
          Sets the double click time threshold.
 void setSensitivity(long time, float distance)
          Set new sensitivity values.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClickDetector

public ClickDetector(long time,
                     float distance)
Click detector, based on supplied sensitivity values.

Parameters:
time - the time
distance - the distance
Method Detail

cursorReleasedGetClickCount

public int cursorReleasedGetClickCount(long id,
                                       java.awt.geom.Point2D.Float position)
Returns true if the released cursor is within the sensitivity values required to constitute a single click.

Parameters:
id - the id
position - the position
Returns:
the int

getDistanceSensitivity

public float getDistanceSensitivity()
Gets the distance sensitivity.

Returns:
the distance sensitivity

getDoubleClickTimeThreshold

public long getDoubleClickTimeThreshold()
Gets the double click time threshold.

Returns:
the double click time threshold

getTimeSensitivity

public long getTimeSensitivity()
Gets the time sensitivity.

Returns:
the time sensitivity

isCursorReleaseADoubleClick

public boolean isCursorReleaseADoubleClick(long id,
                                           java.awt.geom.Point2D.Float position,
                                           synergynetframework.mtinput.ClickDetector.CursorDownRecord causedBy)
Checks if is cursor release a double click.

Parameters:
id - the id
position - the position
causedBy - the caused by
Returns:
true, if is cursor release a double click

newCursorPressed

public void newCursorPressed(long id,
                             java.awt.geom.Point2D.Float position)
Register cursor - only registered cursors will ever pass the test of being a single click when isCursorReleaseASingleClick is called.

Parameters:
id - the id
position - the position

setDoubleClickTimeThreshold

public void setDoubleClickTimeThreshold(long doubleClickTimeThreshold)
Sets the double click time threshold.

Parameters:
doubleClickTimeThreshold - the new double click time threshold

setSensitivity

public void setSensitivity(long time,
                           float distance)
Set new sensitivity values.

Parameters:
time - the time
distance - the distance