當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。