本文整理汇总了Java中org.oscim.event.MotionEvent类的典型用法代码示例。如果您正苦于以下问题:Java MotionEvent类的具体用法?Java MotionEvent怎么用?Java MotionEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MotionEvent类属于org.oscim.event包,在下文中一共展示了MotionEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInputEvent
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public void onInputEvent(Event e, MotionEvent motionEvent) {
int action = motionEvent.getAction();
if (action == MotionEvent.ACTION_DOWN) {
downX = motionEvent.getX() - mMap.getWidth() / 2;
downY = motionEvent.getY() - mMap.getHeight() / 2;
}
if (mActiveMarker == null)
return;
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
// Update corresponding waypoint
Waypoint waypoint = (Waypoint) mActiveMarker.getUid();
waypoint.setCoordinates(mActiveMarker.getPoint());
onWaypointSave(waypoint);
mActiveMarker = null;
// Unshift map to its original position
mMap.animator().animateTo(MAP_POSITION_ANIMATION_DURATION / 2, mMap.viewport().fromScreenPoint(mMap.getWidth() / 2, mMap.getHeight() / 2 - mFingerTipSize), 1, true);
mMap.getEventLayer().enableMove(true);
} else if (action == MotionEvent.ACTION_MOVE) {
float eventX = motionEvent.getX() - deltaX;
float eventY = motionEvent.getY() - deltaY - 3 * mFingerTipSize;
mActiveMarker.setPoint(mMap.viewport().fromScreenPoint(eventX, eventY));
mMarkerLayer.updateItems();
mMap.updateMap(true);
}
}
示例2: onInputEvent
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public void onInputEvent(Event event, MotionEvent motionEvent) {
if ((motionEvent.getAction() == MotionEvent.ACTION_CANCEL || motionEvent.getAction() == MotionEvent.ACTION_UP) && currentlyDraggedItem != null) {
currentlyDraggedItem.onDragStop();
currentlyDraggedItem = null;
}
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
dragLastX = motionEvent.getX();
dragLastY = motionEvent.getY();
}
if (motionEvent.getAction() == MotionEvent.ACTION_MOVE && currentlyDraggedItem != null) {
Point out = new Point();
mapView.map().viewport().toScreenPoint(GmsMapsTypeHelper.fromLatLng(currentlyDraggedItem.getPosition()), out);
out.x += mapView.getWidth() / 2;
out.y += mapView.getHeight() / 2;
float mx = motionEvent.getX() - dragLastX;
float my = motionEvent.getY() - dragLastY;
currentlyDraggedItem.setPosition(GmsMapsTypeHelper.toLatLng(mapView.map().viewport().fromScreenPoint((float) out.getX() + mx, (float) out.getY() + my)));
currentlyDraggedItem.onDragProgress();
dragLastX += mx;
dragLastY += my;
}
}
示例3: updateMulti
import org.oscim.event.MotionEvent; //导入依赖的package包/类
private void updateMulti(MotionEvent e) {
int cnt = e.getPointerCount();
mPrevX1 = e.getX(0);
mPrevY1 = e.getY(0);
if (cnt == 2) {
mDoScale = false;
mDoRotate = false;
mDoTilt = false;
mCanScale = mEnableScale;
mCanRotate = mEnableRotate;
mCanTilt = mEnableTilt;
mPrevX2 = e.getX(1);
mPrevY2 = e.getY(1);
double dx = mPrevX1 - mPrevX2;
double dy = mPrevY1 - mPrevY2;
mAngle = Math.atan2(dy, dx);
mPrevPinchWidth = Math.sqrt(dx * dx + dy * dy);
}
}
示例4: touchDown
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if (pointer >= 10)
return true;
if (button != Buttons.LEFT)
return false;
mTime = Gdx.input.getCurrentEventTime();
if (mPointerDown++ == 0) {
mDownTime = getTime();
mType = MotionEvent.ACTION_DOWN;
} else {
mType = MotionEvent.ACTION_POINTER_DOWN;
}
mPointerX[pointer] = mCurX = screenX;
mPointerY[pointer] = mCurY = screenY;
mPointer = pointer;
//GdxMap.log.debug("down " + screenX + ":" + screenY
// + " / " + pointer + " " + mPointerDown
// + " " + (getTime() - mDownTime));
mMap.input.fire(null, this);
return true;
}
示例5: touchDragged
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
if (pointer >= 10)
return true;
mTime = Gdx.input.getCurrentEventTime();
mType = MotionEvent.ACTION_MOVE;
mPointerX[pointer] = mCurX = screenX;
mPointerY[pointer] = mCurY = screenY;
mPointer = pointer;
//GdxMap.log.debug("dragged " + screenX + ":" + screenY
// + " / " + pointer + " " + (getTime() - mDownTime));
mMap.input.fire(null, this);
return true;
}
示例6: onGesture
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean onGesture(Gesture g, MotionEvent e) {
if (!(e instanceof MotionHandler)) return false;
if (g instanceof Gesture.Tap)
return activateSelectedItems(e, mActiveItemSingleTap);
if (g instanceof Gesture.LongPress)
return activateSelectedItems(e, mActiveItemLongPress);
return false;
}
示例7: onGesture
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean onGesture(Gesture g, MotionEvent e) {
if (g instanceof Gesture.Tap)
return activateSelectedItems(e, mActiveItemSingleTap);
//noinspection SimplifiableIfStatement
if (g instanceof Gesture.LongPress)
return activateSelectedItems(e, mActiveItemLongPress);
return false;
}
示例8: onGesture
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean onGesture(Gesture gesture, MotionEvent event) {
Point point = new Point();
mMap.viewport().fromScreenPoint(event.getX(), event.getY(), point);
int tileX = (int) (point.getX() / TILE_SCALE);
int tileY = (int) (point.getY() / TILE_SCALE);
if (tileX < 0 || tileX > 127 || tileY < 0 || tileY > 127)
return false;
Index.MapStatus mapStatus = mMapIndex.getNativeMap(tileX, tileY);
if (gesture instanceof Gesture.LongPress) {
if (mapStatus.downloading != 0L)
mMapIndex.selectNativeMap(tileX, tileY, Index.ACTION.CANCEL);
else if (mapStatus.created > 0)
mMapIndex.selectNativeMap(tileX, tileY, Index.ACTION.REMOVE);
return true;
}
if (gesture instanceof Gesture.Tap || gesture instanceof Gesture.DoubleTap) {
if (mapStatus.downloading != 0L)
return true;
if (mMapIndex.hasDownloadSizes()) {
if (mapStatus.downloadSize == 0L)
return true;
}
mMapIndex.selectNativeMap(tileX, tileY, Index.ACTION.DOWNLOAD);
return true;
}
return false;
}
示例9: onGesture
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean onGesture(final Gesture g, final MotionEvent e) {
if (g instanceof Gesture.Tap) {
return activateSelectedMarker(e, _activeMarker_SingleTap);
}
if (g instanceof Gesture.LongPress) {
return activateSelectedMarker(e, _ActiveMarker_LongPress);
}
return false;
}
示例10: handleGesture
import org.oscim.event.MotionEvent; //导入依赖的package包/类
boolean handleGesture(Gesture g, MotionEvent e) {
if (mDirtyLayers)
updateLayers();
for (Layer o : mLayers)
if (o instanceof GestureListener)
if (((GestureListener) o).onGesture(g, e))
return true;
return false;
}
示例11: Map
import org.oscim.event.MotionEvent; //导入依赖的package包/类
public Map() {
mViewport = new ViewController();
mAnimator = new Animator(this);
mLayers = new Layers(this);
input = new EventDispatcher<InputListener, MotionEvent>() {
@Override
public void tell(InputListener l, Event e, MotionEvent d) {
l.onInputEvent(e, d);
}
};
events = new EventDispatcher<UpdateListener, MapPosition>() {
@Override
public void tell(UpdateListener l, Event e, MapPosition d) {
l.onMapEvent(e, d);
}
};
mAsyncExecutor = new AsyncExecutor(4, this);
mMapPosition = new MapPosition();
mEventLayer = new MapEventLayer(this);
mLayers.add(0, mEventLayer);
}
示例12: onGesture
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean onGesture(Gesture g, MotionEvent e) {
if (g == Gesture.DOUBLE_TAP) {
mDoubleTap = true;
return true;
}
return false;
}
示例13: onGesture
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean onGesture(Gesture g, MotionEvent e) {
if (g instanceof Gesture.Tap)
return activateSelectedItems(e, mActiveItemSingleTap);
if (g instanceof Gesture.LongPress)
return activateSelectedItems(e, mActiveItemLongPress);
return false;
}
示例14: touchUp
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if (pointer >= 10)
return true;
if (button != Buttons.LEFT)
return false;
if (mPointerDown == 0)
return true;
mTime = Gdx.input.getCurrentEventTime();
mType = (--mPointerDown == 0) ?
MotionEvent.ACTION_UP :
MotionEvent.ACTION_POINTER_UP;
mPointerX[pointer] = mCurX = screenX;
mPointerY[pointer] = mCurY = screenY;
mPointer = pointer;
//GdxMap.log.debug("up " + screenX + ":" + screenY
// + " / " + pointer + " " + mPointerDown
// + " " + (getTime() - mDownTime));
mMap.input.fire(null, this);
return true;
}
示例15: mouseMoved
import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean mouseMoved(int screenX, int screenY) {
mTime = Gdx.input.getCurrentEventTime();
mType = MotionEvent.ACTION_MOVE;
mPointerX[Buttons.LEFT] = mCurX = screenX;
mPointerY[Buttons.LEFT] = mCurY = screenY;
mPointer = Buttons.LEFT;
//GdxMap.log.debug("moved " + screenX + ":" + screenY);
mMap.input.fire(null, this);
return true;
}