• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MotionEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.oscim.event.MotionEvent的典型用法代码示例。如果您正苦于以下问题:Java MotionEvent类的具体用法?Java MotionEvent怎么用?Java MotionEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MotionEvent类属于org.oscim.event包,在下文中一共展示了MotionEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
    }
}
 
开发者ID:andreynovikov,项目名称:trekarta,代码行数:27,代码来源:MainActivity.java


示例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;
    }
}
 
开发者ID:microg,项目名称:android_packages_apps_GmsCore,代码行数:24,代码来源:BackendMap.java


示例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);
	}
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:24,代码来源:MapEventLayer.java


示例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;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:27,代码来源:MotionHandler.java


示例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;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:19,代码来源:MotionHandler.java


示例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;
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:12,代码来源:WaypointLayer.java


示例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;
}
 
开发者ID:andreynovikov,项目名称:trekarta,代码行数:12,代码来源:ItemizedLayer.java


示例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;
}
 
开发者ID:andreynovikov,项目名称:trekarta,代码行数:29,代码来源:MapCoverageLayer.java


示例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;
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:14,代码来源:MarkerLayer.java


示例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;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:12,代码来源:Layers.java


示例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);

}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:28,代码来源:Map.java


示例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;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:9,代码来源:MapEventLayer.java


示例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;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:11,代码来源:ItemizedLayer.java


示例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;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:28,代码来源:MotionHandler.java


示例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;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:15,代码来源:MotionHandler.java


示例16: onGesture

import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean onGesture(Gesture g, MotionEvent e) {
	if (g instanceof Gesture.LongPress) {
		GeoPoint p = mMap.viewport().fromScreenPoint(e.getX(), e.getY());
		return mReceiver.longPressHelper(p);
	}
	return false;
}
 
开发者ID:opensciencemap,项目名称:vtm-app,代码行数:9,代码来源:DistanceTouchOverlay.java


示例17: activateSelectedItems

import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
protected boolean activateSelectedItems(MotionEvent event, ActiveItem task) {
	boolean hit = super.activateSelectedItems(event, task);

	if (!hit)
		hideBubble();

	return hit;
}
 
开发者ID:opensciencemap,项目名称:vtm-app,代码行数:10,代码来源:ItemizedOverlayWithBubble.java


示例18: handleGesture

import org.oscim.event.MotionEvent; //导入依赖的package包/类
public boolean handleGesture(Gesture g, MotionEvent e) {
    this.updateMap(true);
    return super.handleGesture(g, e);
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:5,代码来源:CacheboxMapAdapter.java


示例19: onGesture

import org.oscim.event.MotionEvent; //导入依赖的package包/类
@Override
public boolean onGesture(Gesture g, MotionEvent e) {
    return mListener.onGesture(g, e);
}
 
开发者ID:andreynovikov,项目名称:trekarta,代码行数:5,代码来源:MapEventLayer.java


示例20: activateSelectedItems

import org.oscim.event.MotionEvent; //导入依赖的package包/类
/**
   * When a content sensitive action is performed the content item needs to be
   * identified. This method does that and then performs the assigned task on
   * that item.
   *
   * @return true if event is handled false otherwise
   */
  protected boolean activateSelectedItems(MotionEvent event, ActiveItem task) {
      int size = mItemList.size();
      if (size == 0)
          return false;

      int eventX = (int) event.getX() - mMap.getWidth() / 2;
      int eventY = (int) event.getY() - mMap.getHeight() / 2;
      Viewport mapPosition = mMap.viewport();

      Box box = mapPosition.getBBox(null, 128);
      box.map2mercator();
      box.scale(1E6);

      int nearest = -1;
      int inside = -1;
      double insideY = -Double.MAX_VALUE;

/* squared dist: 50*50 pixel ~ 2mm on 400dpi */
      double dist = 2500;

      for (int i = 0; i < size; i++) {
          Item item = mItemList.get(i);

          if (!box.contains(item.getPoint().longitudeE6,
                  item.getPoint().latitudeE6))
              continue;

          mapPosition.toScreenPoint(item.getPoint(), mTmpPoint);

          float dx = (float) (mTmpPoint.x - eventX);
          float dy = (float) (mTmpPoint.y - eventY);

          MarkerSymbol it = item.getMarker();
          if (it == null)
              it = mMarkerRenderer.mDefaultMarker;

          if (it.isInside(dx, dy)) {
              if (mTmpPoint.y > insideY) {
                  insideY = mTmpPoint.y;
                  inside = i;
              }
          }
          if (inside >= 0)
              continue;

          double d = dx * dx + dy * dy;
          if (d > dist)
              continue;

          dist = d;
          nearest = i;
      }

      if (inside >= 0)
          nearest = inside;

      if (nearest >= 0 && task.run(nearest)) {
          mMarkerRenderer.update();
          mMap.render();
          return true;
      }
      return false;
  }
 
开发者ID:andreynovikov,项目名称:trekarta,代码行数:71,代码来源:ItemizedLayer.java



注:本文中的org.oscim.event.MotionEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StatusInfo类代码示例发布时间:2022-05-23
下一篇:
Java ChainedAggregatorDeclarer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap