Example usage for android.view MotionEvent getYPrecision

List of usage examples for android.view MotionEvent getYPrecision

Introduction

In this page you can find the example usage for android.view MotionEvent getYPrecision.

Prototype

public final float getYPrecision() 

Source Link

Document

Return the precision of the Y coordinates being reported.

Usage

From source file:Main.java

private static MotionEvent transformEventOld(MotionEvent e, Matrix m) {
    long downTime = e.getDownTime();
    long eventTime = e.getEventTime();
    int action = e.getAction();
    int pointerCount = e.getPointerCount();
    int[] pointerIds = getPointerIds(e);
    PointerCoords[] pointerCoords = getPointerCoords(e);
    int metaState = e.getMetaState();
    float xPrecision = e.getXPrecision();
    float yPrecision = e.getYPrecision();
    int deviceId = e.getDeviceId();
    int edgeFlags = e.getEdgeFlags();
    int source = e.getSource();
    int flags = e.getFlags();

    // Copy the x and y coordinates into an array, map them, and copy back.
    float[] xy = new float[pointerCoords.length * 2];
    for (int i = 0; i < pointerCount; i++) {
        xy[2 * i] = pointerCoords[i].x;//ww  w  .  j  a  v  a  2  s. co  m
        xy[2 * i + 1] = pointerCoords[i].y;
    }
    m.mapPoints(xy);
    for (int i = 0; i < pointerCount; i++) {
        pointerCoords[i].x = xy[2 * i];
        pointerCoords[i].y = xy[2 * i + 1];
        pointerCoords[i].orientation = transformAngle(m, pointerCoords[i].orientation);
    }

    MotionEvent n = MotionEvent.obtain(downTime, eventTime, action, pointerCount, pointerIds, pointerCoords,
            metaState, xPrecision, yPrecision, deviceId, edgeFlags, source, flags);

    return n;
}

From source file:Main.java

private static MotionEvent transformEventOld(MotionEvent e, Matrix m) {
    long downTime = e.getDownTime();
    long eventTime = e.getEventTime();
    int action = e.getAction();
    int pointerCount = e.getPointerCount();
    int[] pointerIds = getPointerIds(e);
    PointerCoords[] pointerCoords = getPointerCoords(e);
    int metaState = e.getMetaState();
    float xPrecision = e.getXPrecision();
    float yPrecision = e.getYPrecision();
    int deviceId = e.getDeviceId();
    int edgeFlags = e.getEdgeFlags();
    int source = e.getSource();
    int flags = e.getFlags();
    // Copy the x and y coordinates into an array, map them, and copy back.
    float[] xy = new float[pointerCoords.length * 2];
    for (int i = 0; i < pointerCount; i++) {
        xy[2 * i] = pointerCoords[i].x;//from w  ww. j  a va 2s.  c o m
        xy[2 * i + 1] = pointerCoords[i].y;
    }
    m.mapPoints(xy);
    for (int i = 0; i < pointerCount; i++) {
        pointerCoords[i].x = xy[2 * i];
        pointerCoords[i].y = xy[2 * i + 1];
        pointerCoords[i].orientation = transformAngle(m, pointerCoords[i].orientation);
    }
    MotionEvent n = MotionEvent.obtain(downTime, eventTime, action, pointerCount, pointerIds, pointerCoords,
            metaState, xPrecision, yPrecision, deviceId, edgeFlags, source, flags);
    return n;
}

From source file:Main.java

public static JSONObject CreateJSonObjectFromMotionEvent(MotionEvent e) throws JSONException {
    JSONObject jObj = new JSONObject();
    jObj.put("downTime", e.getDownTime());
    jObj.put("eventTime", e.getEventTime());
    jObj.put("action", e.getAction());
    jObj.put("pointerCount", e.getPointerCount());
    jObj.put("metaState", e.getMetaState());
    jObj.put("buttonState", e.getButtonState());
    jObj.put("xPrecision", e.getXPrecision());
    jObj.put("yPrecision", e.getYPrecision());
    jObj.put("deviceId", e.getDeviceId());
    jObj.put("edgeFlags", e.getEdgeFlags());
    jObj.put("source", e.getSource());
    jObj.put("flags", e.getFlags());

    for (int i = 0; i < e.getPointerCount(); i++) {
        PointerProperties prop = new PointerProperties();
        e.getPointerProperties(i, prop);

        PointerCoords coords = new PointerCoords();
        e.getPointerCoords(i, coords);//from   w  w w .java2  s.  c  o  m

        JSONObject pointer = JObjFromPointer(prop, coords);
        jObj.accumulate("pointers", pointer);
    }

    return jObj;
}

From source file:Main.java

public static MotionEvent hoverMotionEventAtPosition(View view, int action, int xPercent, int yPercent) {
    MotionEvent ev = motionEventAtPosition(view, action, xPercent, yPercent);

    MotionEvent.PointerProperties[] pointerProperties = new MotionEvent.PointerProperties[1];
    pointerProperties[0] = new MotionEvent.PointerProperties();

    MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[1];
    pointerCoords[0] = new MotionEvent.PointerCoords();
    pointerCoords[0].x = ev.getX();/*from   w ww . jav a  2 s  . c om*/
    pointerCoords[0].y = ev.getY();

    return MotionEvent.obtain(ev.getDownTime(), ev.getEventTime(), ev.getAction(), 1, pointerProperties,
            pointerCoords, ev.getMetaState(), 0, ev.getXPrecision(), ev.getYPrecision(), ev.getDeviceId(),
            ev.getEdgeFlags(), InputDevice.SOURCE_CLASS_POINTER, ev.getFlags());
}