public class MultiTouchListener
extends java.lang.Object
implements android.view.View.OnTouchListener
This class enables easy interpretation of multitouch gestures such as pinching, rotating etc.
TODO Implement convex hull algorithm (static method) TODO Implement touch grouping by evaluating touch proximity TODO Implement get touch numbers ordered by x- or y-axis alignmentConstructor and Description |
---|
MultiTouchListener() |
Modifier and Type | Method and Description |
---|---|
static float |
angle(android.view.MotionEvent event,
int pointerA,
int pointerB,
boolean isPointerAPivot)
Calculates the angle between two points.
|
int |
getId(int touchNo)
Returns the pointer id for the given index of subsequent touch points.
|
java.lang.Integer[] |
getIdArray(java.lang.Integer[] ids)
Returns an array containing all pointer ids.
|
android.graphics.PointF |
getStartPoint(int touchNo)
Returns the start point for the given touch number (where the user initially pressed down).
|
int |
getTouchCount()
Returns the current amount of touch points.
|
boolean |
isTouching()
Indicates if one or more touches are currently in progress.
|
static void |
midPoint(android.graphics.PointF point,
android.view.MotionEvent event,
int pointerA,
int pointerB)
Calculates the mid point between two pointers.
|
static void |
midPoint(android.graphics.Point point,
android.view.MotionEvent event,
int pointerA,
int pointerB)
Calculates the mid point between two pointers.
|
boolean |
onTouch(android.view.View view,
android.view.MotionEvent event) |
static float |
pinchVelocity(android.view.MotionEvent event,
int pointerA,
int pointerB,
long timeWindow)
Calculates the pinch velocity for the last
timeWindow milliseconds. |
static void |
point(android.graphics.Point point,
android.view.MotionEvent event,
int id) |
static float |
spacing(android.view.MotionEvent event,
int pointerA,
int pointerB)
Calculates the space between two pointers.
|
static boolean |
startedLower(android.graphics.PointF pointA,
android.graphics.PointF pointB)
Convenience method to determine whether starting point A has a lower y-axis value than starting point B.
|
void |
updateStartPoints(android.view.MotionEvent event)
Updates the start points with the current coordinate configuration.
|
public boolean onTouch(android.view.View view, android.view.MotionEvent event)
onTouch
in interface android.view.View.OnTouchListener
public int getTouchCount()
Returns the current amount of touch points.
public boolean isTouching()
Indicates if one or more touches are currently in progress.
public int getId(int touchNo)
Returns the pointer id for the given index of subsequent touch points.
touchNo
- public android.graphics.PointF getStartPoint(int touchNo)
Returns the start point for the given touch number (where the user initially pressed down).
touchNo
- public void updateStartPoints(android.view.MotionEvent event)
Updates the start points with the current coordinate configuration.
event
- public java.lang.Integer[] getIdArray(java.lang.Integer[] ids)
Returns an array containing all pointer ids.
ids
- public static final void point(android.graphics.Point point, android.view.MotionEvent event, int id)
point
- event
- id
- public static final float spacing(android.view.MotionEvent event, int pointerA, int pointerB)
Calculates the space between two pointers.
event
- pointerA
- id of pointer ApointerB
- id of pointer Bpublic static final float pinchVelocity(android.view.MotionEvent event, int pointerA, int pointerB, long timeWindow)
Calculates the pinch velocity for the last timeWindow
milliseconds.
event
- pointerA
- id of pointer ApointerB
- id of pointer BtimeWindow
- public static final void midPoint(android.graphics.Point point, android.view.MotionEvent event, int pointerA, int pointerB)
Calculates the mid point between two pointers.
point
- event
- pointerA
- id of pointer ApointerB
- id of pointer Bpublic static final void midPoint(android.graphics.PointF point, android.view.MotionEvent event, int pointerA, int pointerB)
Calculates the mid point between two pointers.
point
- event
- pointerA
- id of pointer ApointerB
- id of pointer Bpublic static final float angle(android.view.MotionEvent event, int pointerA, int pointerB, boolean isPointerAPivot)
Calculates the angle between two points.
event
- pointerA
- id of pointer ApointerB
- id of pointer BisPointerAPivot
- indicates if pointer A is considered to be the pivot, else pointer B is. Use startedLower(PointF, PointF)
public static final boolean startedLower(android.graphics.PointF pointA, android.graphics.PointF pointB)
Convenience method to determine whether starting point A has a lower y-axis value than starting point B.
Useful in conjunction with angle(MotionEvent, int, int, boolean)
.
pointA
- pointB
-