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;
            }
        }
  • 相关阅读:
    hdu6055(求正方形个数)
    树状数组模板(改点求段 / 该段求点 / 改段求段)
    poj2763(lca / RMQ + 线段树)
    poj3728(lca / tarjan离线)
    JDK8-废弃永久代(PermGen)迎来元空间(Metaspace)
    JVM垃圾回收机制
    虚拟机字节码执行引擎
    Java中程序初始化的顺序
    Java中ClassLoader浅析.
    Python中的self
  • 原文地址:https://www.cnblogs.com/datong/p/1542594.html
Copyright © 2011-2022 走看看