当前位置: 首页>>代码示例>>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;未经允许,请勿转载。