本文整理汇总了Java中android.graphics.PointF.length方法的典型用法代码示例。如果您正苦于以下问题:Java PointF.length方法的具体用法?Java PointF.length怎么用?Java PointF.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.PointF
的用法示例。
在下文中一共展示了PointF.length方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleTouchEvent
import android.graphics.PointF; //导入方法依赖的package包/类
/**
* Handles the touch events that shows the workspace when clicking outside the bounds of the
* touch delegate target view.
*/
private boolean handleTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
// Check if the touch is outside touch delegate target view
View touchDelegateTargetView = getTouchDelegateTargetView();
float leftBoundPx = touchDelegateTargetView.getLeft();
if (ev.getX() < leftBoundPx ||
ev.getX() > (touchDelegateTargetView.getWidth() + leftBoundPx)) {
mLastTouchDownPosPx.set((int) ev.getX(), (int) ev.getY());
}
break;
case MotionEvent.ACTION_UP:
if (mLastTouchDownPosPx.x > -1) {
ViewConfiguration viewConfig = ViewConfiguration.get(getContext());
float dx = ev.getX() - mLastTouchDownPosPx.x;
float dy = ev.getY() - mLastTouchDownPosPx.y;
float distance = PointF.length(dx, dy);
if (distance < viewConfig.getScaledTouchSlop()) {
// The background was clicked, so just go home
Launcher.getLauncher(getContext()).showWorkspace(true);
return true;
}
}
// Fall through
case MotionEvent.ACTION_CANCEL:
mLastTouchDownPosPx.set(-1, -1);
break;
}
return false;
}
示例2: createPath
import android.graphics.PointF; //导入方法依赖的package包/类
static Path createPath(PointF startPoint, PointF endPoint, PointF cp1, PointF cp2) {
Path path = new Path();
path.moveTo(startPoint.x, startPoint.y);
if (cp1 != null && cp1.length() != 0 && cp2 != null && cp2.length() != 0) {
path.cubicTo(
startPoint.x + cp1.x, startPoint.y + cp1.y,
endPoint.x + cp2.x, endPoint.y + cp2.y,
endPoint.x, endPoint.y);
} else {
path.lineTo(endPoint.x, endPoint.y);
}
return path;
}
示例3: distance
import android.graphics.PointF; //导入方法依赖的package包/类
/** Calculates the distance between the 2 current pointers */
private float distance(MotionEvent event) {
if (event.getPointerCount() < 2) {
return 0;
}
return PointF.length(event.getX(POINTER1) - event.getX(POINTER2), //
event.getY(POINTER1) - event.getY(POINTER2));
}
示例4: normalizeVector
import android.graphics.PointF; //导入方法依赖的package包/类
private void normalizeVector(PointF point) {
final float abs = point.length();
point.set(point.x / abs, point.y / abs);
}
示例5: normalizePoint
import android.graphics.PointF; //导入方法依赖的package包/类
public static PointF normalizePoint(PointF p) {
PointF c = new PointF();
c.x = p.x / p.length();
c.y = p.y / p.length();
return c;
}
示例6: normalizeVector
import android.graphics.PointF; //导入方法依赖的package包/类
private void normalizeVector(PointF point) {
float abs = point.length();
point.set(point.x / abs, point.y / abs);
}
示例7: isClick
import android.graphics.PointF; //导入方法依赖的package包/类
/**
* Test if a MotionEvent with the given start and end offsets
* can be considered as a "click".
* @param upEvent The final finger-up event.
* @param xDown The x-offset of the down event.
* @param yDown The y-offset of the down event.
* @param xUp The x-offset of the up event.
* @param yUp The y-offset of the up event.
* @return true if it's a click, false otherwise
*/
private boolean isClick(MotionEvent upEvent, float xDown, float yDown, float xUp, float yUp) {
if (upEvent == null) return false;
long time = upEvent.getEventTime() - upEvent.getDownTime();
float distance = PointF.length( //
xDown - xUp, //
yDown - yUp);
return time < MAX_CLICK_TIME && distance < MAX_CLICK_DISTANCE;
}
示例8: euclideanDistance
import android.graphics.PointF; //导入方法依赖的package包/类
/**
* Get the euclidean distance between two points
*
* @param firstPoint PointF object
* @param secondPoint PointF object
* @return float value representing the distance in a straight line between two points
*/
public static float euclideanDistance(PointF firstPoint, PointF secondPoint) {
return PointF.length(secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
}