use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.
the class MainController method setTool.
// Displays a new tool and applies the slide transitions
public void setTool(Integer id) {
// check if existing animation running
if (timeline != null) {
nextTool = screens.get(id);
timeline.setRate(4);
return;
} else {
nextTool = null;
}
// load new content
sparePane.getChildren().setAll(screens.get(id));
sparePane.setCache(true);
currentPane.setCache(true);
// wait one pulse then animate
Platform.runLater(() -> {
// animate switch
if (id > currentToolIndex) {
// animate from bottom
currentToolIndex = id;
sparePane.setTranslateY(rootContainer.getHeight());
sparePane.setVisible(true);
timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(currentPane.translateYProperty(), 0, INTERPOLATOR), new KeyValue(sparePane.translateYProperty(), rootContainer.getHeight(), INTERPOLATOR)), new KeyFrame(Duration.millis(800), animationEndEventHandler, new KeyValue(currentPane.translateYProperty(), -rootContainer.getHeight(), INTERPOLATOR), new KeyValue(sparePane.translateYProperty(), 0, INTERPOLATOR)));
timeline.play();
} else {
// from top
currentToolIndex = id;
sparePane.setTranslateY(-rootContainer.getHeight());
sparePane.setVisible(true);
timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(currentPane.translateYProperty(), 0, INTERPOLATOR), new KeyValue(sparePane.translateYProperty(), -rootContainer.getHeight(), INTERPOLATOR)), new KeyFrame(Duration.millis(800), animationEndEventHandler, new KeyValue(currentPane.translateYProperty(), rootContainer.getHeight(), INTERPOLATOR), new KeyValue(sparePane.translateYProperty(), 0, INTERPOLATOR)));
timeline.play();
}
});
}
use of javafx.animation.KeyFrame in project Smartcity-Smarthouse by TechnionYP5777.
the class StoveAppController method turnOn.
public void turnOn() {
if (isOn)
return;
isOn = !isOn;
timeline = new Timeline(new KeyFrame(Duration.millis(100), ¢ -> {
time = time.add(((KeyFrame) ¢.getSource()).getTime());
timeSeconds.set(time.toSeconds());
timeLabel.setText("The stove is running for: " + timeSeconds.get() + " (Secs)");
if (timeSeconds.get() <= StoveAppController.this.get_alert_seconds())
alertTime = false;
if (timeSeconds.get() > StoveAppController.this.get_alert_seconds() && !alertTime) {
alert("Stove is running too long");
timeLabel.setTextFill(Color.RED);
alertTime = true;
}
}));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
}
use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.
the class RotateOutUpRightTransition method starting.
@Override
protected void starting() {
super.starting();
rotate = new Rotate(0, node.getBoundsInLocal().getWidth(), node.getBoundsInLocal().getHeight());
timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(rotate.angleProperty(), 0, WEB_EASE)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(rotate.angleProperty(), 90, WEB_EASE)));
node.getTransforms().add(rotate);
}
use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.
the class HingeTransition method starting.
@Override
protected void starting() {
super.starting();
double endY = node.getScene().getHeight() - node.localToScene(0, 0).getY();
rotate = new Rotate(0, 0, 0);
timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(rotate.angleProperty(), 0, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(200), new KeyValue(rotate.angleProperty(), 80, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(400), new KeyValue(rotate.angleProperty(), 60, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(600), new KeyValue(rotate.angleProperty(), 80, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(800), new KeyValue(node.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(node.translateYProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(rotate.angleProperty(), 60, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(node.translateYProperty(), endY, Interpolator.EASE_BOTH), new KeyValue(rotate.angleProperty(), 60, Interpolator.EASE_BOTH)));
node.getTransforms().add(rotate);
}
use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.
the class RollInTransition method starting.
@Override
protected void starting() {
super.starting();
timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(node.translateXProperty(), -node.getBoundsInLocal().getWidth(), WEB_EASE), new KeyValue(node.rotateProperty(), -120, WEB_EASE)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(node.translateXProperty(), 0, WEB_EASE), new KeyValue(node.rotateProperty(), 0, WEB_EASE)));
}
Aggregations