我可以调整更多的票据设置吗?

时间:2016-01-15 04:51:25

标签: javafx codenameone ticker

在标签上打勾时,有什么简单的方法可以执行以下操作吗?

  1. 每次文字回到原始位置时暂停3秒?
  2. 缓和并缩短刻度之间的间隔。类似于JavaFX Motion的缓入和放出?
  3. 让滴答声更流畅而不是有点跳跃?

1 个答案:

答案 0 :(得分:1)

是的,但你需要手动完成。

只需覆盖Label并覆盖其animate()方法即可。我没有试过这个,但是这样的东西可以满足你的所有要求:

Label tickeredLabel = new Label(myText) {
    Motion tickeringMotion;
    long pauseTime = System.currentTimeMillis();
    public boolean animate() {
       long currentTime = System.currentTimeMillis();

       // wait 3 seconds for tickering
       if(currentTime - pauseTime < 3000) {
          return false;
       }

       // use ease in/out motion over 5 seconds
       if(tickeringMotion == null) {
          tickeringMotion = Motion.createEaseInOutMotion(0, getStringWidth(getStyle().getFont(), 5000);
          tickeringMotion.start();
       } else {
          // when motion is finished return to 3 second delay
          if(tickeringMotion.isFinished()) {
             tickeringMotion = null;
             pauseTime = System.currentTimeMillis();
          }
       }
       setShiftText(tickeringMotion.getValue());
       return changed;
    }
};

要进一步平滑滴答声,只需让它一次移动一个像素

相关问题