0
如何使用包含在其中一个构造函数参数中的数学模式中的变量“t”。 “t”对应于使图表向右移动的时间。KeyFrame - 动画
public void update(final Scene scene) {
final Group root = (Group) scene.getRoot();
final Chart chart = new Chart(x -> Math.exp(-(Math.pow((x-t), 2)))
* Math.cos((2*Math.PI*(x-t))/l),
-1, 1, 0.01,
new Axes(1000, 1000, -1, 1, 0.1, -1, 1, 0.1)
);
root.getChildren().add(chart);
Timeline timeLine = new Timeline(Timeline.INDEFINITE,
new KeyFrame(new Duration(1000),
x -> {}));
timeLine.setAutoReverse(true);
timeLine.play();
}
如果我可以在KeyFrame
之内做到这一点,那可以解决我的问题。但不能。
while(t < 1) {
t+=0.05;
chart = new Chart(x -> Math.exp(-(Math.pow((x-t),2)))*Math.cos((2*Math.PI*(x-t))/l),
-1, 1, 0.01, new Axes(1000, 1000,
-1, 1, 0.1, -1, 1, 0.1)
);
}
那'Chart'类不眼熟。它当然不是'javafx.scene.chart.Chart' ......但是如果它设计得很好,它可以在不重新创建类的情况下分配数据......但是如果你需要访问时间,你应该使用['AnimationTimer' ](https://docs.oracle.com/javase/8/javafx/api/javafx/animation/AnimationTimer.html) – fabian