Java 布尔绑定与时间轴

Java 布尔绑定与时间轴,java,javafx,Java,Javafx,我有一个布尔绑定,看起来像这样: public void initQueue(ObservableList<Player> players) { queueIsFree = new BooleanBinding() { { players.forEach( player -> bind(player.getRobot().animatingProperty));

我有一个布尔绑定,看起来像这样:

    public void initQueue(ObservableList<Player> players) {
        queueIsFree = new BooleanBinding() {
            {
            players.forEach(
                player -> bind(player.getRobot().animatingProperty));
            }

            @Override
            protected boolean computeValue() {
            Boolean bool = true;
            for (Player p : players) {
                if (p.getRobot().animatingProperty.get() == true) {
                bool = false;
                break;
                }
            }
            return bool;
            }

        };

   }
public void initQueue(可观察列表玩家){
queueIsFree=新布尔绑定(){
{
弗雷奇(
player->bind(player.getRobot().animatingProperty));
}
@凌驾
受保护的布尔计算值(){
布尔布尔布尔=真;
对于(玩家p:玩家){
if(p.getRobot().animatingProperty.get()==true){
布尔=假;
打破
}
}
返回布尔;
}
};
}
当机器人的所有动画属性都为假时,这应该是真的。一旦其中一个发生更改,此changeListener将被称为:

change = new ChangeListener<Boolean>() {

    @Override
    public void changed(ObservableValue<? extends Boolean> arg0,
        Boolean oldValue, Boolean newValue) {
        if (newValue.equals(true)) {
          if (list.size() > 0) {
        // plays the next animation, which, when finished, sets the animatingProperty back to false
                nextAnimation();
            } else {
                stopQueue();
            }
        }

       }

};
change=newchangestener(){
@凌驾

public void changed(observevalueyou cannot get stack overflow exception,因为调用太频繁,只有当它自己递归调用时才能得到它,我理解。它应该递归调用自己,但只有在动画完成后(timeline.setOnFinished(…),直到列表为空为止。