zoukankan      html  css  js  c++  java
  • lwuit调整滚动条灵敏度值

    Component类中:
            //设置滚动条灵敏度
            public void pointerReleased(int x, int y) {
            
    if (dragActivated) {
                
    long currentTime = System.currentTimeMillis();

                
    // replace x and y if this is an x scrolling container
                if (!isScrollableY()) {
                    y 
    = x;
                }

                
    if (currentTime != lastTime[(pLastDragged + lastTime.length + 1% lastTime.length]) {
                    lastTime[pLastDragged] 
    = System.currentTimeMillis();
                    lastDragged[pLastDragged] 
    = y;
                    pLastDragged 
    = (++pLastDragged) % lastTime.length;
                }
                
    float velocity = (float) (lastDragged[pLastDragged] - lastDragged[(pLastDragged + lastDragged.length + 1% lastDragged.length]) / (lastTime[pLastDragged] - lastTime[(pLastDragged + lastTime.length + 1% lastTime.length]);
                velocity 
    = velocity * -1;

           
    //默认为0.0004f ,越小灵敏度越高
                if (isScrollableY()) {
                    draggedMotion 
    = Motion.createFrictionMotion(scrollY, velocity, 0.0008f);
                } 
    else {
                    draggedMotion 
    = Motion.createFrictionMotion(scrollX, velocity, 0.0008f);
                }


                draggedMotion.start();
                dragActivated 
    = false;
            }
        }
  • 相关阅读:
    finalShell 文件上传拖拽失败
    centos6.x 启动docker报错
    笔记本查看当前登录用户
    保存文件到D盘时显示“你没有权限在此文件夹中保存文件,请联系管理员“其他文件夹正常?
    关于MongoDB配置文件的一个小细节
    ubuntu: mongoDB安装,无需下载
    Java 连接虚拟机中MongoDB 所需依赖
    信息知识竞赛刷题助手
    python超多常用知识记录
    python字典键或值去重
  • 原文地址:https://www.cnblogs.com/datong/p/1542594.html
Copyright © 2011-2022 走看看