use of javafx.util.Duration in project JFoenix by jfoenixadmin.
the class AnimatedFlowContainer method setViewContext.
@Override
public <U> void setViewContext(ViewContext<U> context) {
updatePlaceholder(context.getRootNode());
if (animation != null) {
animation.stop();
}
animation = new Timeline();
animation.getKeyFrames().addAll(animationProducer.apply(this));
animation.getKeyFrames().add(new KeyFrame(duration, (e) -> clearPlaceholder()));
animation.play();
}
use of javafx.util.Duration in project JFoenix by jfoenixadmin.
the class JFXNodesList method animateList.
/**
* animates the list to show/hide the nodes
*/
public void animateList() {
expanded = !expanded;
if (animateTimeline.getStatus().equals(Status.RUNNING))
animateTimeline.stop();
animateTimeline.getKeyFrames().clear();
double duration = 120 / (double) this.getChildren().size();
// show child nodes
if (expanded)
this.getChildren().forEach(child -> child.setVisible(true));
// add child nodes animation
for (int i = 1; i < this.getChildren().size(); i++) {
Node child = this.getChildren().get(i);
ArrayList<KeyValue> keyValues = animationsMap.get(child).call(expanded);
animateTimeline.getKeyFrames().add(new KeyFrame(Duration.millis(i * duration), keyValues.toArray(new KeyValue[keyValues.size()])));
}
// add 1st element animation
ArrayList<KeyValue> keyValues = animationsMap.get(this.getChildren().get(0)).call(expanded);
animateTimeline.getKeyFrames().add(new KeyFrame(Duration.millis(160), keyValues.toArray(new KeyValue[keyValues.size()])));
// hide child nodes to allow mouse events on the nodes behind them
if (!expanded) {
animateTimeline.setOnFinished((finish) -> {
for (int i = 1; i < this.getChildren().size(); i++) this.getChildren().get(i).setVisible(false);
});
} else {
animateTimeline.setOnFinished(null);
}
animateTimeline.play();
}
use of javafx.util.Duration in project jphp by jphp-compiler.
the class UXMediaPlayer method getCurrentTimeAsPercent.
@Getter
public long getCurrentTimeAsPercent() {
Duration duration = getWrappedObject().getMedia().getDuration();
Duration currentTime = getWrappedObject().getCurrentTime();
return Math.round(currentTime.toMillis() * 100.0 / duration.toMillis());
}
use of javafx.util.Duration in project jphp by jphp-compiler.
the class UXMediaPlayer method setCurrentTimeAsPercent.
@Setter
public void setCurrentTimeAsPercent(long percent) {
if (percent > 100) {
percent = 100;
}
Duration duration = getWrappedObject().getMedia().getDuration();
getWrappedObject().seek(Duration.millis(Math.round(duration.toMillis() * percent / 100.0)));
}
use of javafx.util.Duration in project fx2048 by brunoborges.
the class Board method animateScore.
public void animateScore() {
if (gameMovePoints.get() == 0) {
return;
}
final Timeline timeline = new Timeline();
lblPoints.setText("+" + gameMovePoints.getValue().toString());
lblPoints.setOpacity(1);
double posX = vScore.localToScene(vScore.getWidth() / 2d, 0).getX();
lblPoints.setTranslateX(0);
lblPoints.setTranslateX(lblPoints.sceneToLocal(posX, 0).getX() - lblPoints.getWidth() / 2d);
lblPoints.setLayoutY(20);
final KeyValue kvO = new KeyValue(lblPoints.opacityProperty(), 0);
final KeyValue kvY = new KeyValue(lblPoints.layoutYProperty(), 100);
Duration animationDuration = Duration.millis(600);
final KeyFrame kfO = new KeyFrame(animationDuration, kvO);
final KeyFrame kfY = new KeyFrame(animationDuration, kvY);
timeline.getKeyFrames().add(kfO);
timeline.getKeyFrames().add(kfY);
timeline.play();
}
Aggregations