如何确定过渡是否已在节点上运行? [英] How to find out if a transition is already running on a node?

查看:52
本文介绍了如何确定过渡是否已在节点上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定节点上是否已经存在过渡-例如FadeTransition?

How can i find out if there is already a transition running on the node - for example a FadeTransition ?

推荐答案

感谢您的帮助.我想分享我针对特定问题最终选择的解决方案.其以下内容:我想在单击鼠标时淡化节点.当出现大量点击时,新的FadeTransition仅应在当前点击完成后才开始,以防止闪烁或其他现象.

Thank you for your help. I want to share the solution that i've choosen finally for my specific problem. Its the following: I wanted to fade a node on mouse click. When a lot of clicks appear, a new FadeTransition should only start when the current one is finished to prevent flickering or other phenomena.

在函数的第一行中可以看到我的方法:

My approach can be seen in the first line of the function:

@FXML
public void chartMouseClicked(MouseEvent event){
    if (ft.getCurrentRate()!=0.0d) return;      
    ft.play();
}

在这种情况下,ft是类型为FadeTransition的私有字段,该私有字段在"init"函数中实例化了一次.根据JavaFX文档,当过渡暂停或停止时,getCurrentRate()返回0.0.我不需要暂停过渡,因此这是我的最佳选择-我只是检查该值,并让过渡停止时再次播放.

In this case, ft is a private field of the type FadeTransition which is instantiated once within an "init" function. According to the JavaFX docs, getCurrentRate() returns 0.0 when the transition is paused or stopped. I don't need to pause the transition, so this is the way to go for me - i'm just checking the value and let my transition play again when it's stopped.

这篇关于如何确定过渡是否已在节点上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆