本文整理汇总了Java中android.view.MotionEvent.PointerCoords类的典型用法代码示例。如果您正苦于以下问题:Java PointerCoords类的具体用法?Java PointerCoords怎么用?Java PointerCoords使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PointerCoords类属于android.view.MotionEvent包,在下文中一共展示了PointerCoords类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildMouseEvents
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
private void buildMouseEvents(PointerCoords coords, int clickCount) {
long currMS = System.currentTimeMillis();
// mousePressed
MouseEvent swingMouseEvent =
new MouseEvent(JTable.this, MouseEvent.MOUSE_PRESSED,
currMS, 0, (int)coords.x, (int)coords.y, clickCount, false, MouseEvent.BUTTON1);
JTable.this.processMouseEventAdAPI(swingMouseEvent);
//mouseReleased
swingMouseEvent =
new MouseEvent(JTable.this, MouseEvent.MOUSE_RELEASED,
currMS, 0, (int)coords.x, (int)coords.y, clickCount, false, MouseEvent.BUTTON1);
JTable.this.processMouseEventAdAPI(swingMouseEvent);
//mouseClicked
MouseEvent clickEvent =
new MouseEvent(JTable.this, MouseEvent.MOUSE_CLICKED,
currMS, 0, (int)coords.x, (int)coords.y, clickCount, false, MouseEvent.BUTTON1);
JTable.this.processMouseEventAdAPI(clickEvent);
}
示例2: applyMovements
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
/**
* Applies all changes that were set via {@link #setMovement(int, float, float) the setMovement(...)} method.
*/
public void applyMovements() {
int pointerCount = pointerIds.size();
PointerCoords[] coords = new PointerCoords[pointerCount];
PointerProperties[] properties = new PointerProperties[pointerCount];
int i = 0;
for (Integer pointerId : pointerIds) {
coords[i] = pointerPositionsMap.get(pointerId);
properties[i] = pointerPropertiesMap.get(pointerId);
i++;
}
injectMultipointMotionEvent(coords, properties);
}
示例3: injectMultipointMotionEvent
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
private void injectMultipointMotionEvent(PointerCoords[] coords, PointerProperties[] properties) {
int pointerCount = coords.length;
long now = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(now, now, // when the event happened
MotionEvent.ACTION_MOVE, // event type
pointerCount, // number of pointers
properties, // pointer properties
coords, // pointer coordinate descriptors
DEFAULT_META_STATE,
0,
DEFAULT_PRECISION_X,
DEFAULT_PRECISION_Y,
DEVICE_ID,
DEFAULT_EDGE_FLAGS,
DEFAULT_INPUT_SOURCE,
0 // no flags
);
injectMethodFacade(event);
}
示例4: setPointer
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
@CalledByNative
void setPointer(int index, int x, int y, int id) {
assert (0 <= index && index < MAX_NUM_POINTERS);
// Convert coordinates from density independent pixels to density dependent pixels.
float scaleFactor = getDisplay().getDipScale();
PointerCoords coords = new PointerCoords();
coords.x = scaleFactor * x;
coords.y = scaleFactor * y;
coords.pressure = 1.0f;
mPointerCoords[index] = coords;
PointerProperties properties = new PointerProperties();
properties.id = id;
mPointerProperties[index] = properties;
}
示例5: TouchPointer
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
TouchPointer(int startX, int startY, int deltaX, int deltaY,
int id, float scale) {
mStartX = startX * scale;
mStartY = startY * scale;
mDeltaX = deltaX * scale;
mDeltaY = deltaY * scale;
if (deltaX != 0 || deltaY != 0) {
mStepX = mDeltaX / Math.abs(mDeltaX + mDeltaY);
mStepY = mDeltaY / Math.abs(mDeltaX + mDeltaY);
} else {
mStepX = 0;
mStepY = 0;
}
mProperties = new PointerProperties();
mProperties.id = id;
mProperties.toolType = MotionEvent.TOOL_TYPE_FINGER;
mCoords = new PointerCoords();
mCoords.x = mStartX;
mCoords.y = mStartY;
mCoords.pressure = 1.0f;
}
示例6: GenericTouchGesture
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
GenericTouchGesture(ContentViewCore contentViewCore,
int startX0, int startY0, int deltaX0, int deltaY0,
int startX1, int startY1, int deltaX1, int deltaY1) {
mContentViewCore = contentViewCore;
float scale = mContentViewCore.getRenderCoordinates().getDeviceScaleFactor();
mPointers = new TouchPointer[2];
mPointers[0] = new TouchPointer(startX0, startY0, deltaX0, deltaY0, 0, scale);
mPointers[1] = new TouchPointer(startX1, startY1, deltaX1, deltaY1, 1, scale);
mPointerProperties = new PointerProperties[2];
mPointerProperties[0] = mPointers[0].getProperties();
mPointerProperties[1] = mPointers[1].getProperties();
mPointerCoords = new PointerCoords[2];
mPointerCoords[0] = mPointers[0].getCoords();
mPointerCoords[1] = mPointers[1].getCoords();
}
示例7: GenericTouchGesture
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
GenericTouchGesture(ContentViewCore contentViewCore,
int startX, int startY, int deltaX, int deltaY) {
mContentViewCore = contentViewCore;
float scale = mContentViewCore.getRenderCoordinates().getDeviceScaleFactor();
int scaledTouchSlop = getScaledTouchSlop();
mPointers = new TouchPointer[1];
mPointers[0] = new TouchPointer(startX, startY, deltaX, deltaY, 0,
scale, scaledTouchSlop);
mPointerProperties = new PointerProperties[1];
mPointerProperties[0] = mPointers[0].getProperties();
mPointerCoords = new PointerCoords[1];
mPointerCoords[0] = mPointers[0].getCoords();
}
示例8: setPointer
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
@CalledByNative
void setPointer(int index, int x, int y, int id) {
assert (0 <= index && index < MAX_NUM_POINTERS);
// Convert coordinates from density independent pixels to density dependent pixels.
float scaleFactor = mContentViewCore.getRenderCoordinates().getDeviceScaleFactor();
PointerCoords coords = new PointerCoords();
coords.x = scaleFactor * x;
coords.y = scaleFactor * y;
coords.pressure = 1.0f;
mPointerCoords[index] = coords;
PointerProperties properties = new PointerProperties();
properties.id = id;
mPointerProperties[index] = properties;
}
示例9: transformEventOld
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
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;
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;
}
示例10: getPointerCoords
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
private static PointerCoords[] getPointerCoords(MotionEvent e) {
int n = e.getPointerCount();
PointerCoords[] r = new PointerCoords[n];
for (int i = 0; i < n; i++) {
r[i] = new PointerCoords();
e.getPointerCoords(i, r[i]);
}
return r;
}
示例11: setMovement
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
/**
* Sets the next position of a specified pointer.
*
* @param pointerId
* - the pointer ID which has changed it's position.
* @param toX
* - the new X pointer position.
* @param toY
* - the new Y pointer position.
*/
public void setMovement(int pointerId, float toX, float toY) {
if (!pointerPositionsMap.containsKey(pointerId)) {
return;
}
PointerCoords pointerPosition = pointerPositionsMap.get(pointerId);
pointerPosition.x = toX;
pointerPosition.y = toY;
// pointerPositionsMap.put(pointerId, pointerPosition);
}
示例12: injectFingerRegisterEvent
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
private void injectFingerRegisterEvent(int newPointerId) {
int pointerCount = pointerIds.size();
int action = pointerCount == 1 ? MotionEvent.ACTION_DOWN : MotionEvent.ACTION_POINTER_DOWN;
PointerCoords[] coords = new PointerCoords[pointerCount];
PointerProperties[] properties = new PointerProperties[pointerCount];
int i = 0;
for (Integer pointerId : pointerIds) {
coords[i] = pointerPositionsMap.get(pointerId);
properties[i] = pointerPropertiesMap.get(pointerId);
i++;
}
long now = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(now,
now,
action,
pointerCount,
properties,
coords,
DEFAULT_META_STATE,
0,
DEFAULT_PRECISION_X,
DEFAULT_PRECISION_Y,
DEVICE_ID,
DEFAULT_EDGE_FLAGS,
DEFAULT_INPUT_SOURCE,
0);
if (action == MotionEvent.ACTION_POINTER_DOWN) {
int newPointerIndex = event.findPointerIndex(newPointerId);
event.setAction(action | (newPointerIndex << MotionEvent.ACTION_POINTER_INDEX_SHIFT));
}
injectMethodFacade(event);
}
示例13: injectFingerUnregisterEvent
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
private void injectFingerUnregisterEvent(int upPointerId) {
int pointerCount = pointerIds.size();
int action = pointerCount == 1 ? MotionEvent.ACTION_UP : MotionEvent.ACTION_POINTER_UP;
PointerCoords[] coords = new PointerCoords[pointerCount];
PointerProperties[] properties = new PointerProperties[pointerCount];
int i = 0;
for (Integer pointerId : pointerIds) {
coords[i] = pointerPositionsMap.get(pointerId);
properties[i] = pointerPropertiesMap.get(pointerId);
if (upPointerId == pointerId) {
coords[i].pressure = 0.0f;
}
i++;
}
long now = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(now,
now,
action,
pointerCount,
properties,
coords,
DEFAULT_META_STATE,
0,
DEFAULT_PRECISION_X,
DEFAULT_PRECISION_Y,
DEVICE_ID,
DEFAULT_EDGE_FLAGS,
DEFAULT_INPUT_SOURCE,
0);
if (action == MotionEvent.ACTION_POINTER_UP) {
int newPointerIndex = event.findPointerIndex(upPointerId);
event.setAction(action | (newPointerIndex << MotionEvent.ACTION_POINTER_INDEX_SHIFT));
}
injectMethodFacade(event);
}
示例14: toMotionEventInputParams
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
private static MotionInputEventParams toMotionEventInputParams(
final int actionCode, final PointerCoords coordinates, final int button,
final PointerProperties properties, final long startDelta) {
final MotionInputEventParams evtParams = new MotionInputEventParams();
evtParams.actionCode = actionCode;
evtParams.coordinates = coordinates;
evtParams.button = button;
evtParams.properties = properties;
evtParams.startDelta = startDelta;
return evtParams;
}
示例15: parsePointerCoords
import android.view.MotionEvent.PointerCoords; //导入依赖的package包/类
private PointerCoords[][] parsePointerCoords(final IHttpRequest request)
throws JSONException {
final JSONArray actions = (org.json.JSONArray) getPayload(request).get("actions");
final double time = computeLongestTime(actions);
final PointerCoords[][] pcs = new PointerCoords[actions.length()][];
for (int i = 0; i < actions.length(); i++) {
final JSONArray gestures = actions.getJSONArray(i);
pcs[i] = gesturesToPointerCoords(time, gestures);
}
return pcs;
}