You can set interpolators when creating KeyValue:
new KeyValue(node.translateYProperty(), 200, Interpolator.LINEAR);
The default interpolator is Interpolator.LINEAR.
Visually, it looks like an abrupt stop at the end of the animation. To soften that, you can use one of the easing interpolators:
- Interpolator.EASE_IN: Starts slowly
- Interpolator.EASE_OUT: Ends slowly
- Interpolator.EASE_BOTH: Starts and ends slowly
You can see them all at work simultaneously by running the following code:
// chapter5/basics/InterpolatorsDemo.java public void start(Stage primaryStage) { VBox root = new VBox(10); Timeline timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); Stream.of(