touchscreen
Class Touch

java.lang.Object
  extended by touchscreen.Touch

public class Touch
extends java.lang.Object

Represents one hand touching a screen. Has a current position and size, status, and an ArrayList of Points representing the path the hand moved on.

Author:
Kevin Cox, http://www.jibberia.com/

Field Summary
 int h
          height of box around this touch
 int id
          a unique id for this Touch - can be used as a key for data in your application
static int IS_DRAGGING
          this Touch went down in the past and is dragging across the screen - akin to mouseDragged
static int JUST_WENT_DOWN
          this Touch just started - akin to mousePressed
static int JUST_WENT_UP
          this Touch ended last frame - the user's hand left the screen - akin to mouseReleased
static java.lang.String[] STATUS_MAP
          maps the status variables to their textual representations (ie 2="IS_DRAGGING")
 int w
          width of box around this touch
 int x
          current position, top left corner
 int y
          current position, top left corner
 
Constructor Summary
Touch()
           
Touch(int x, int y, int w, int h, int id)
           
 
Method Summary
 float[] getCenter()
          returns the center point of a Touch box as an array of floats {x, y}
 int getID()
           
 java.util.ArrayList getPath()
          get a list of Points that this Touch traveled on (essentially, a history of x,y,w,h)
 int getStatus()
          What the hand is doing.
 boolean matches(Touch that)
          determines if a touch is close enough to another touch to be considered IS_DRAGGING
 void setID(int id)
           
 void setStatus(int status)
          You never need to use this.
 java.lang.String toString()
           
 void update(int x, int y, int w, int h, int status)
          You never need to use this.
 void update(Touch t, int status)
          You never need to use this.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JUST_WENT_DOWN

public static final int JUST_WENT_DOWN
this Touch just started - akin to mousePressed

See Also:
Constant Field Values

IS_DRAGGING

public static final int IS_DRAGGING
this Touch went down in the past and is dragging across the screen - akin to mouseDragged

See Also:
Constant Field Values

JUST_WENT_UP

public static final int JUST_WENT_UP
this Touch ended last frame - the user's hand left the screen - akin to mouseReleased

See Also:
Constant Field Values

STATUS_MAP

public static final java.lang.String[] STATUS_MAP
maps the status variables to their textual representations (ie 2="IS_DRAGGING")


x

public int x
current position, top left corner


y

public int y
current position, top left corner


w

public int w
width of box around this touch


h

public int h
height of box around this touch


id

public int id
a unique id for this Touch - can be used as a key for data in your application

Constructor Detail

Touch

public Touch()

Touch

public Touch(int x,
             int y,
             int w,
             int h,
             int id)
Method Detail

update

public void update(int x,
                   int y,
                   int w,
                   int h,
                   int status)
You never need to use this. It is used by your TouchReceiver. Update this touch's coordinates and status.


update

public void update(Touch t,
                   int status)
You never need to use this. It is used by your TouchReceiver. Update this touch's coordinates and status.


setStatus

public void setStatus(int status)
You never need to use this. It is used by your TouchReceiver. Update this touch's status.


getStatus

public int getStatus()
What the hand is doing. Uses constants. static String[] STATUS_MAP can be used to get a textual representation of the status from the integer.
        1 : JUST_WENT_DOWN : this Touch just started.
        2 : IS_DRAGGING    : this Touch has existed in the past, and is dragging along the screen.
        3 : JUST_WENT_UP   : this Touch existed last frame, but the person took her hand off the screen.
 
use it like:
if (someTouch.getStatus() == Touch.JUST_WENT_UP) { doSomething(); }


setID

public void setID(int id)

getID

public int getID()

matches

public boolean matches(Touch that)
determines if a touch is close enough to another touch to be considered IS_DRAGGING


getCenter

public float[] getCenter()
returns the center point of a Touch box as an array of floats {x, y}


getPath

public java.util.ArrayList getPath()
get a list of Points that this Touch traveled on (essentially, a history of x,y,w,h)

Returns:
ArrayList path

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object