Как сделать анимацию перехода между елементами дерева JavaFX?
У меня есть такое дерево и мне нужно сделать анимацию обхода дерева через таймер либо Swing или Timeline javaFX. Пробовал сделать на том и на том, но получается что елементы обходят одновременно даже если я создаю каждый раз для елемента новый обьект класа.
Вот кнопка по нажатии которой должна быть анимация обхода.
btInorder.setOnAction(e -> {
btInorder.setDisable(true);
tree.inorder();
view.setStatus("Inorder: " + tree.getListInorder().toString());
Map<Integer, Circle> map = view.map;
ArrayList<Integer> list = tree.getListInorder();
Iterator<Integer> iterator = list.iterator();
while(iterator.hasNext()) {
Integer key = iterator.next();
if(map.containsKey(key));
Circle circle = map.get(key);
Animation animation = new Animation(circle);
animation.play();
}
btInorder.setDisable(false);
});
А это клас анимации
public class Animation {
private Circle circle;
Timer timer = new Timer(1000, e-> changeCircle(Color.LIGHTPINK,Color.RED,3));
public Animation(Circle circle) {
this.circle=circle;
}
public void play() {
timer.start();
}
private void changeCircle(Color fill, Color stroke, int strokeWidth) {
circle.setFill(fill);
circle.setStroke(stroke);
circle.setStrokeWidth(strokeWidth);
}
}
Подскажите что я делаю не правильно, почему у меня все елементы подсвечиваются одновременно.

