org.metalev.multitouch.controller
Class MultiTouchController.PointInfo

java.lang.Object
  extended by org.metalev.multitouch.controller.MultiTouchController.PointInfo
Enclosing class:
MultiTouchController<T>

public static class MultiTouchController.PointInfo
extends Object

A class that packages up all MotionEvent information with all derived multitouch information (if available)


Constructor Summary
MultiTouchController.PointInfo()
           
 
Method Summary
 int getAction()
           
 long getEventTime()
           
 float getMultiTouchAngle()
          Calculate the angle of a multitouch event, and cache it.
 float getMultiTouchDiameter()
          Calculate the diameter of the multitouch event, and cache it.
 float getMultiTouchDiameterSq()
          Calculate the squared diameter of the multitouch event, and cache it.
 float getMultiTouchHeight()
          Difference between y coords of touchpoint 0 and 1.
 float getMultiTouchWidth()
          Difference between x coords of touchpoint 0 and 1.
 int getNumTouchPoints()
          Return the total number of touch points
 int[] getPointerIds()
          Return the array of pointer ids -- only the first getNumTouchPoints() of these is defined.
 float getPressure()
          Return the pressure the first touch point if there's only one, or the average pressure of first and second touch points if two or more.
 float[] getPressures()
          Return the array of pressures -- only the first getNumTouchPoints() of these is defined.
 float getX()
          Return the X coord of the first touch point if there's only one, or the midpoint between first and second touch points if two or more.
 float[] getXs()
          Return the array of X coords -- only the first getNumTouchPoints() of these is defined.
 float getY()
          Return the X coord of the first touch point if there's only one, or the midpoint between first and second touch points if two or more.
 float[] getYs()
          Return the array of Y coords -- only the first getNumTouchPoints() of these is defined.
 boolean isDown()
           
 boolean isMultiTouch()
          True if number of touch points >= 2.
 void set(MultiTouchController.PointInfo other)
          Copy all fields from one PointInfo class to another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiTouchController.PointInfo

public MultiTouchController.PointInfo()
Method Detail

set

public void set(MultiTouchController.PointInfo other)
Copy all fields from one PointInfo class to another. PointInfo objects are volatile so you should use this if you want to keep track of the last touch event in your own code.


isMultiTouch

public boolean isMultiTouch()
True if number of touch points >= 2.


getMultiTouchWidth

public float getMultiTouchWidth()
Difference between x coords of touchpoint 0 and 1.


getMultiTouchHeight

public float getMultiTouchHeight()
Difference between y coords of touchpoint 0 and 1.


getMultiTouchDiameterSq

public float getMultiTouchDiameterSq()
Calculate the squared diameter of the multitouch event, and cache it. Use this if you don't need to perform the sqrt.


getMultiTouchDiameter

public float getMultiTouchDiameter()
Calculate the diameter of the multitouch event, and cache it. Uses fast int sqrt but gives accuracy to 1/16px.


getMultiTouchAngle

public float getMultiTouchAngle()
Calculate the angle of a multitouch event, and cache it. Actually gives the smaller of the two angles between the x axis and the line between the two touchpoints, so range is [0,Math.PI/2]. Uses Math.atan2().


getNumTouchPoints

public int getNumTouchPoints()
Return the total number of touch points


getX

public float getX()
Return the X coord of the first touch point if there's only one, or the midpoint between first and second touch points if two or more.


getXs

public float[] getXs()
Return the array of X coords -- only the first getNumTouchPoints() of these is defined.


getY

public float getY()
Return the X coord of the first touch point if there's only one, or the midpoint between first and second touch points if two or more.


getYs

public float[] getYs()
Return the array of Y coords -- only the first getNumTouchPoints() of these is defined.


getPointerIds

public int[] getPointerIds()
Return the array of pointer ids -- only the first getNumTouchPoints() of these is defined. These don't have to be all the numbers from 0 to getNumTouchPoints()-1 inclusive, numbers can be skipped if a finger is lifted and the touch sensor is capable of detecting that that particular touch point is no longer down. Note that a lot of sensors do not have this capability: when finger 1 is lifted up finger 2 becomes the new finger 1. However in theory these IDs can correct for that. Convert back to indices using MotionEvent.findPointerIndex().


getPressure

public float getPressure()
Return the pressure the first touch point if there's only one, or the average pressure of first and second touch points if two or more.


getPressures

public float[] getPressures()
Return the array of pressures -- only the first getNumTouchPoints() of these is defined.


isDown

public boolean isDown()

getAction

public int getAction()

getEventTime

public long getEventTime()


Copyright © 2012. All Rights Reserved.