use of javafx.animation.KeyValue in project JFoenix by jfoenixadmin.
the class JFXTreeCell method createChildAnimation.
private Timeline createChildAnimation(TreeCell<?> cell, int delay) {
cell.setOpacity(0);
cell.setTranslateY(-1);
Timeline f1 = new Timeline(new KeyFrame(Duration.millis(120), new KeyValue(cell.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(cell.translateYProperty(), 0, Interpolator.EASE_BOTH)));
f1.setDelay(Duration.millis(20 + delay * 10));
return f1;
}
use of javafx.animation.KeyValue in project JFoenix by jfoenixadmin.
the class JFXProgressBarSkin method createIndeterminateTimeline.
@Override
protected void createIndeterminateTimeline() {
super.createIndeterminateTimeline();
if (indeterminateTransition != null)
indeterminateTransition.stop();
ProgressIndicator control = getSkinnable();
final double w = control.getWidth() - (snappedLeftInset() + snappedRightInset());
final double bWidth = bar.getWidth();
indeterminateTransition = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(bar.scaleXProperty(), 0, Interpolator.EASE_IN), new KeyValue(bar.translateXProperty(), -bWidth, Interpolator.LINEAR)), new KeyFrame(Duration.seconds(0.5), new KeyValue(bar.scaleXProperty(), 3, Interpolator.LINEAR), new KeyValue(bar.translateXProperty(), w / 2, Interpolator.LINEAR)), new KeyFrame(Duration.seconds(1), new KeyValue(bar.scaleXProperty(), 0, Interpolator.EASE_OUT), new KeyValue(bar.translateXProperty(), w, Interpolator.LINEAR)));
indeterminateTransition.setCycleCount(Timeline.INDEFINITE);
}
use of javafx.animation.KeyValue in project JFoenix by jfoenixadmin.
the class JFXRadioButtonOldSkin method initializeComponents.
private void initializeComponents(final double x, final double y, final double w, final double h) {
radio.setStroke(unSelectedColor);
getSkinnable().selectedProperty().addListener((o, oldVal, newVal) -> {
rippler.setRipplerFill(newVal ? unSelectedColor : selectedColor);
timeline.setRate(newVal ? 1 : -1);
timeline.play();
});
rippler.setRipplerFill(getSkinnable().isSelected() ? unSelectedColor : selectedColor);
timeline = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(dot.radiusProperty(), minRadius, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(200), new KeyValue(dot.radiusProperty(), radioRadius + radio.getStrokeWidth() / 2, Interpolator.EASE_BOTH)));
rippler.setRipplerFill(getSkinnable().isSelected() ? unSelectedColor : selectedColor);
timeline.setRate(getSkinnable().isSelected() ? 1 : -1);
timeline.play();
}
use of javafx.animation.KeyValue in project JFoenix by jfoenixadmin.
the class JFXTableColumnHeader method layoutChildren.
@Override
protected void layoutChildren() {
super.layoutChildren();
double w = snapSize(getWidth()) - (snappedLeftInset() + snappedRightInset());
container.resizeRelocate(snappedLeftInset(), 0, w, getHeight());
if (!getChildren().contains(container)) {
invalid = true;
container.getChildren().remove(arrowContainer);
for (int i = 0; i < getChildren().size(); ) {
Node child = getChildren().get(i);
container.getChildren().add(child);
}
getChildren().add(container);
}
// add animation to sorting arrow
if (invalid) {
if (container.getChildren().size() > 1 && !container.getChildren().contains(arrowContainer)) {
// setup children
arrowPane = (GridPane) container.getChildren().get(1);
arrow = (Region) arrowPane.getChildren().get(0);
arrowContainer.getChildren().clear();
container.getChildren().remove(1);
container.getChildren().add(arrowContainer);
for (int i = 0; i < arrowPane.getChildren().size(); ) {
Node child = arrowPane.getChildren().get(i);
arrowContainer.getChildren().add(child);
if (child instanceof HBox) {
HBox dotsContainer = (HBox) child;
dotsContainer.setMaxHeight(5);
dotsContainer.translateYProperty().bind(Bindings.createDoubleBinding(() -> {
return arrow.getHeight() + 2;
}, arrow.heightProperty()));
} else if (child instanceof Label) {
Label labelContainer = (Label) child;
labelContainer.setMaxHeight(5);
labelContainer.translateYProperty().bind(Bindings.createDoubleBinding(() -> {
return arrow.getHeight() + 3;
}, arrow.heightProperty()));
}
}
arrowContainer.maxWidthProperty().bind(arrow.widthProperty());
StackPane.setAlignment(arrowContainer, Pos.CENTER_RIGHT);
// set padding to the label to replace it with ... if it's too close to the sorting arrow
Label label = (Label) container.getChildren().get(0);
oldMargin = StackPane.getMargin(label);
StackPane.setMargin(label, new Insets(oldMargin == null ? 0 : oldMargin.getTop(), oldMargin == null || oldMargin.getRight() < 30 ? 30 : oldMargin.getRight(), oldMargin == null ? 0 : oldMargin.getBottom(), oldMargin == null || oldMargin.getLeft() < 30 ? 30 : oldMargin.getLeft()));
// fixed the issue of arrow translate X while resizing the column header
arrowContainer.translateXProperty().bind(Bindings.createDoubleBinding(() -> {
if (arrowContainer.getLayoutX() <= 8)
return -arrowContainer.getLayoutX() - 2;
return -10.0;
}, arrowContainer.layoutXProperty()));
if (arrowAnimation != null && arrowAnimation.getStatus().equals(Status.RUNNING))
arrowAnimation.stop();
if (arrow.getRotate() == 180 && arrow.getRotate() != currentArrowRotation) {
arrowContainer.setOpacity(0);
arrowContainer.setTranslateY(getHeight() / 4);
arrowAnimation = new Timeline(new KeyFrame(Duration.millis(320), new KeyValue(arrowContainer.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(arrowContainer.translateYProperty(), 0, Interpolator.EASE_BOTH)));
} else if (arrow.getRotate() == 0 && arrow.getRotate() != currentArrowRotation) {
arrow.setRotate(-180);
arrowAnimation = new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(arrow.rotateProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(arrowContainer.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(arrowContainer.translateYProperty(), 0, Interpolator.EASE_BOTH)));
}
arrowAnimation.setOnFinished((finish) -> currentArrowRotation = arrow.getRotate());
arrowAnimation.play();
}
if (arrowContainer != null && arrowPane != null && container.getChildren().size() == 1 && !arrowPane.isVisible()) {
if (arrowAnimation != null && arrowAnimation.getStatus().equals(Status.RUNNING))
arrowAnimation.stop();
Label label = (Label) container.getChildren().get(0);
// dont change the padding if arrow is not showing
if (currentArrowRotation == 0)
StackPane.setMargin(label, new Insets(oldMargin == null ? 0 : oldMargin.getTop(), oldMargin == null || oldMargin.getRight() < 30 ? 30 : oldMargin.getRight(), oldMargin == null ? 0 : oldMargin.getBottom(), oldMargin == null || oldMargin.getLeft() < 30 ? 30 : oldMargin.getLeft()));
container.getChildren().add(arrowContainer);
arrowAnimation = new Timeline(new KeyFrame(Duration.millis(320), new KeyValue(arrowContainer.opacityProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(arrowContainer.translateYProperty(), getHeight() / 4, Interpolator.EASE_BOTH)));
arrowAnimation.setOnFinished((finish) -> {
currentArrowRotation = -1;
StackPane.setMargin(label, null);
});
arrowAnimation.play();
}
}
}
use of javafx.animation.KeyValue in project JFoenix by jfoenixadmin.
the class JFXListCell method layoutChildren.
/**
* {@inheritDoc}
*/
@Override
protected void layoutChildren() {
super.layoutChildren();
cellRippler.resizeRelocate(0, 0, getWidth(), getHeight());
double gap = getGap();
if (clip == null) {
clip = new Rectangle(0, gap / 2, getWidth(), getHeight() - gap);
setClip(clip);
} else {
if (gap != 0) {
if (playExpandAnimation || selectionChanged) {
// fake list collapse state
if (playExpandAnimation) {
this.setTranslateY(-gap / 2 + (-gap * (getIndex())));
clip.setY(gap / 2);
clip.setHeight(getHeight() - gap);
gapAnimation = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(this.translateYProperty(), 0, Interpolator.EASE_BOTH)));
playExpandAnimation = false;
} else if (selectionChanged) {
clip.setY(0);
clip.setHeight(getHeight());
gapAnimation = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(clip.yProperty(), gap / 2, Interpolator.EASE_BOTH), new KeyValue(clip.heightProperty(), getHeight() - gap, Interpolator.EASE_BOTH)));
}
playExpandAnimation = false;
selectionChanged = false;
gapAnimation.play();
} else {
if (gapAnimation != null)
gapAnimation.stop();
this.setTranslateY(0);
clip.setY(gap / 2);
clip.setHeight(getHeight() - gap);
}
} else {
this.setTranslateY(0);
clip.setY(0);
clip.setHeight(getHeight());
}
clip.setX(0);
clip.setWidth(getWidth());
}
if (!getChildren().contains(cellRippler)) {
makeChildrenTransparent();
getChildren().add(0, cellRippler);
cellRippler.rippler.clear();
}
// refresh sublist style class
if (this.getGraphic() != null && this.getGraphic().getStyleClass().contains("sublist-container"))
this.getStyleClass().add("sublist-item");
else
this.getStyleClass().remove("sublist-item");
}
Aggregations