當前位置: 首頁>>代碼示例>>Java>>正文


Java MotionEvent.TOOL_TYPE_STYLUS屬性代碼示例

本文整理匯總了Java中android.view.MotionEvent.TOOL_TYPE_STYLUS屬性的典型用法代碼示例。如果您正苦於以下問題:Java MotionEvent.TOOL_TYPE_STYLUS屬性的具體用法?Java MotionEvent.TOOL_TYPE_STYLUS怎麽用?Java MotionEvent.TOOL_TYPE_STYLUS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.MotionEvent的用法示例。


在下文中一共展示了MotionEvent.TOOL_TYPE_STYLUS屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: plot

@Override
        public void plot(Spot s) {
            final float pressureNorm;
        
            if (ASSUME_STYLUS_CALIBRATED && s.tool == MotionEvent.TOOL_TYPE_STYLUS) {
                pressureNorm = s.pressure;
            } else {
                pressureNorm = mPressureCooker.getAdjustedPressure(s.pressure);
            }

            final float radius = lerp(mRadiusMin, mRadiusMax,
                    (float) Math.pow(pressureNorm, mPressureExponent));

            mTmpPoint[0] = s.x - mPanX;
            mTmpPoint[1] = s.y - mPanY;
            mZoomMatrixInv.mapPoints(mTmpPoint);
            
            final RectF dirtyF = mRenderer.strokeTo(mTiledCanvas,
                    mTmpPoint[0],
                    mTmpPoint[1], radius);
            dirty(dirtyF);
//            dirtyF.roundOut(tmpDirtyRect);
//            tmpDirtyRect.inset((int)-INVALIDATE_PADDING,(int)-INVALIDATE_PADDING);
//            invalidate(tmpDirtyRect);
        }
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:25,代碼來源:Slate.java

示例2: getToolTypeCompat

@SuppressLint("NewApi")
final static int getToolTypeCompat(MotionEvent me, int index) {
    if (hasToolType()) {
        return me.getToolType(index);
    }
    
    // dirty hack for the HTC Flyer
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        if ("flyer".equals(Build.HARDWARE)) {
            if (me.getSize(index) <= 0.1f) {
                // with very high probability this is the stylus
                return MotionEvent.TOOL_TYPE_STYLUS;
            }
        }
    }

    return MotionEvent.TOOL_TYPE_FINGER;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:18,代碼來源:Slate.java

示例3: filteredOutput

public Spot filteredOutput(Spot out) {
    if (out == null) out = new Spot();
    
    float wi = 1, w = 0;
    float wi_press = 1, w_press = 0;
    float x = 0, y = 0, pressure = 0, size = 0;
    long time = 0;
    for (Spot pi : mSpots) {
        x += pi.x * wi;
        y += pi.y * wi;
        time += pi.time * wi;
        
        pressure += pi.pressure * wi_press;
        size += pi.size * wi_press;

        w += wi;
        wi *= mPosDecay; // exponential backoff

        w_press += wi_press;
        wi_press *= mPressureDecay;

        if (PRECISE_STYLUS_INPUT && pi.tool == MotionEvent.TOOL_TYPE_STYLUS) {
            // just take the top one, no need to average
            break;
        }
    }

    out.x = x / w;
    out.y = y / w;
    out.pressure = pressure / w_press;
    out.size = size / w_press;
    out.time = time;
    out.tool = mSpots.get(0).tool;
    return out;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:35,代碼來源:SpotFilter.java

示例4: isStylusButtonPressed

/**
 * Identifies if the provided {@link MotionEvent} is a stylus with the primary stylus button
 * pressed.
 *
 * @param event The event to check.
 * @return Whether a stylus button press occurred.
 */
private static boolean isStylusButtonPressed(MotionEvent event) {
    return event.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS
            && ((event.getButtonState() & MotionEvent.BUTTON_SECONDARY)
                    == MotionEvent.BUTTON_SECONDARY);
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:12,代碼來源:StylusEventHelper.java


注:本文中的android.view.MotionEvent.TOOL_TYPE_STYLUS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。