package org.metalev.multitouch.photosortr;
/**
* MultiTouchController.java
*
* Author: Luke Hutchison (luke.hutch@mit.edu)
* Please drop me an email if you use this code so I can list your project here!
*
* Usage:
* <code>
* public class MyMTView extends View implements MultiTouchObjectCanvas<PinchWidgetType> {
*
* private MultiTouchController<PinchWidgetType> multiTouchController = new MultiTouchController<PinchWidgetType>(this);
*
* // Pass touch events to the MT controller
* public boolean onTouchEvent(MotionEvent event) {
* return multiTouchController.onTouchEvent(event);
* }
*
* // ... then implement the MultiTouchObjectCanvas interface here, see details in the comments of that interface.
* }
* </code>
*
* Changelog:
* 2010-06-09 v1.5.1 Some API changes to make it possible to selectively update or not update scale / rotation.
* Fixed anisotropic zoom. Cleaned up rotation code. Added more comments. Better var names. (LH)
* 2010-06-09 v1.4 Added ability to track pinch rotation (Mickael Despesse, author of "Face Frenzy") and anisotropic pinch-zoom (LH)
* 2010-06-09 v1.3.3 Bugfixes for Android-2.1; added optional debug info (LH)
* 2010-06-09 v1.3 Ported to Android-2.2 (handle ACTION_POINTER_* actions); fixed several bugs; refactoring; documentation (LH)
* 2010-05-17 v1.2.1 Dual-licensed under Apache and GPL licenses
* 2010-02-18 v1.2 Support for compilation under Android 1.5/1.6 using introspection (mmin, author of handyCalc)
* 2010-01-08 v1.1.1 Bugfixes to Cyanogen's patch that only showed up in more complex uses of controller (LH)
* 2010-01-06 v1.1 Modified for official level 5 MT API (Cyanogen)
* 2009-01-25 v1.0 Original MT controller, released for hacked G1 kernel (LH)
*
* TODO:
* - Add inertia (flick-pinch-zoom or flick-scroll)
* - Merge in Paul Bourke's "grab" support for single-finger drag of objects: git://github.com/brk3/android-multitouch-controller.git
* (Initial concern are the two lines of the form "newScale = mCurrXform.scale - 0.04f", and the line in pastThreshold() that says
* "if (newScale == mCurrXform.scale)" -- this doesn't look like a robust solution to convey state, by changing scale by a tiny
* amount, but maybe I'm not understanding the intent behind the code or its behavior).
*
* Known usages: see http://code.google.com/p/android-multitouch-controller/
*
* --
*
* Released under the MIT license (but please notify me if you use this code, so that I can give your project credit at
* http://code.google.com/p/android-multitouch-controller ).
*
* MIT license: http://www.opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
import java.lang.reflect.Method;
import android.util.Log;
import android.view.MotionEvent;
/**
* A class that simplifies the implementation of multitouch in applications. Subclass this and read the fields here as needed in subclasses.
*
* @author Luke Hutchison
*/
public class MultiTouchController<T> {
/**
* Time in ms required after a change in event status (e.g. putting down or lifting off the second finger) before events actually do anything --
* helps eliminate noisy jumps that happen on change of status
*/
private static final long EVENT_SETTLE_TIME_INTERVAL = 20;
/**
* The biggest possible abs val of the change in x or y between multitouch events (larger dx/dy events are ignored) -- helps eliminate jumps in
* pointer position on finger 2 up/down.
*/
private static final float MAX_MULTITOUCH_POS_JUMP_SIZE = 30.0f;
/**
* The biggest possible abs val of the change in multitouchWidth or multitouchHeight between multitouch events (larger-jump events are ignored) --
* helps eliminate jumps in pointer position on finger 2 up/down.
*/
private static final float MAX_MULTITOUCH_DIM_JUMP_SIZE = 40.0f;
/** The smallest possible distance between multitouch points (used to avoid div-by-zero errors and display glitches) */
private static final float MIN_MULTITOUCH_SEPARATION = 30.0f;
/** The max number of touch points that can be present on the screen at once */
public static final int MAX_TOUCH_POINTS = 20;
/** Generate tons of log entries for debugging */
public static final boolean DEBUG = false;
// ----------------------------------------------------------------------------------------------------------------------
MultiTouchObjectCanvas<T> objectCanvas;
/** The current touch point */
private PointInfo mCurrPt;
/** The previous touch point */
private PointInfo mPrevPt;
/** Fields extracted from mCurrPt */
private float mCurrPtX, mCurrPtY, mCurrPtDiam, mCurrPtWidth, mCurrPtHeight, mCurrPtAng;
/**
* Extract fields from mCurrPt, respecting the update* fields of mCurrPt. This just avoids code duplication. I hate that Java doesn't support
* higher-order functions, tuples or multiple return values from functions.
*/
private void extractCurrPtInfo() {
// Get new drag/pinch params. Only read multitouch fields that are needed,
// to avoid unnecessary computation (diameter and angle are expensive operations).
mCurrPtX = mCurrPt.getX();
mCurrPtY = mCurrPt.getY();
mCurrPtDiam = Math.max(MIN_MULTITOUCH_SEPARATION * .71f, !mCurrXform.updateScale ? 0.0f : mCurrPt.getMultiTouchDiameter());
mCurrPtWidth = Math.max(MIN_MULTITOUCH_SEPARATION, !mCurrXform.updateScaleXY ? 0.0f : mCurrPt.getMultiTouchWidth());
mCurrPtHeight = Math.max(MIN_MULTITOUCH_SEPARATION, !mCurrXform.updateScaleXY ? 0.0f : mCurrPt.getMultiTouchHeight());
mCurrPtAng = !mCurrXform.updateAngle ? 0.0f : mCurrPt.getMultiTouchAngle();
}
// ----------------------------------------------------------------------------------------------------------------------
/** Whether to handle single-touch events/drags before multi-touch is initiated or not; if not, they are handled by subclasses */
private boolean handleSingleTouchEvents;
/** The object being dragged/stretched */
private T selectedObject = null;
/** Current position and scale of the dragged object */
private PositionAndScale mCurrXform = new PositionAndScale();
/** Drag/pinch start time and time to ignore spurious events until (to smooth over event noise) */
private long mSettleStartTime, mSettleEndTime;
/** Conversion from object coords to screen coords */
private float startPosX, startPosY;
/** Conversion between scale and width, and object angle and start pinch angle */
private float startScaleOverPinchDiam, startAngleMinusPinchAngle;
/** Conversion between X scale and width, and Y scale and height */
private float startScaleXOverPinchWidth, startScaleYOverPinchHeight;
// ----------------------------------------------------------------------------------------------------------------------
/** No touch points down. */
private static final int MODE_NOTHING = 0;
/** One touch point down, dragging an object. */
p
没有合适的资源?快使用搜索试试~ 我知道了~
Android通过手势对图片进行任意放大绽放旋转源码.rar
共36个文件
class:12个
jpg:5个
java:5个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 114 浏览量
2022-07-03
12:06:02
上传
评论
收藏 1.27MB RAR 举报
温馨提示
Android通过手势对图片进行任意放大绽放旋转源码.rar
资源推荐
资源详情
资源评论
收起资源包目录
通过手势对图片进行任意放大绽放旋转.rar (36个子文件)
通过手势对图片进行任意放大绽放旋转
MTPhotoSortr
bin
classes.dex 28KB
res
drawable
icon.png 4KB
PhotoSorterActivity.apk 430KB
jarlist.cache 119B
dexedLibs
annotations-aaf5d8ceecc13a44ab079f5a691f5bc2.jar 943B
classes
org
metalev
multitouch
photosortr
MultiTouchController$PointInfo.class 5KB
PhotoSortrActivity.class 1KB
MultiTouchController$MultiTouchObjectCanvas.class 1KB
MultiTouchController$PositionAndScale.class 3KB
MultiTouchController.class 11KB
PhotoSortrView$Img.class 6KB
PhotoSortrView.class 8KB
photosorter
BuildConfig.class 377B
R$drawable.class 601B
R$attr.class 388B
R.class 519B
R$string.class 482B
resources.ap_ 417KB
AndroidManifest.xml 762B
res
drawable
tahiti.jpg 93KB
lake.jpg 109KB
sunset.jpg 26KB
catarina.jpg 82KB
icon.png 4KB
m74hubble.jpg 101KB
values
strings.xml 187B
layout
assets
default.properties 120B
gen
org
metalev
multitouch
photosorter
BuildConfig.java 176B
R.java 829B
src
org
metalev
multitouch
photosortr
PhotoSortrActivity.java 2KB
MultiTouchController.java 35KB
PhotoSortrView.java 13KB
.project 819B
.classpath 364B
project.properties 647B
AndroidManifest.xml 762B
共 36 条
- 1
资源评论
reg183
- 粉丝: 1811
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功