当前位置: 首页>>代码示例>>Java>>正文


Java PointF.length方法代码示例

本文整理汇总了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;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:35,代码来源:BaseContainerView.java

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

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

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:PieChartRenderer.java

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

示例6: normalizeVector

import android.graphics.PointF; //导入方法依赖的package包/类
private void normalizeVector(PointF point) {
    float abs = point.length();
    point.set(point.x / abs, point.y / abs);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:5,代码来源:PieChartRenderer.java

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

示例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);
}
 
开发者ID:willowtreeapps,项目名称:spruce-android,代码行数:11,代码来源:Utils.java


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