Search in sources :

Example 66 with KeyFrame

use of javafx.animation.KeyFrame 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);
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) ProgressIndicator(javafx.scene.control.ProgressIndicator) KeyFrame(javafx.animation.KeyFrame)

Example 67 with KeyFrame

use of javafx.animation.KeyFrame 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();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 68 with KeyFrame

use of javafx.animation.KeyFrame 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();
        }
    }
}
Also used : HBox(javafx.scene.layout.HBox) Timeline(javafx.animation.Timeline) Insets(javafx.geometry.Insets) KeyValue(javafx.animation.KeyValue) Node(javafx.scene.Node) Label(javafx.scene.control.Label) KeyFrame(javafx.animation.KeyFrame)

Example 69 with KeyFrame

use of javafx.animation.KeyFrame 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");
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) Rectangle(javafx.scene.shape.Rectangle) KeyFrame(javafx.animation.KeyFrame)

Example 70 with KeyFrame

use of javafx.animation.KeyFrame in project JFoenix by jfoenixadmin.

the class MasonryPaneController method init.

@PostConstruct
public void init() throws FlowException, VetoException {
    ArrayList<Node> children = new ArrayList<>();
    for (int i = 0; i < 20; i++) {
        StackPane child = new StackPane();
        double width = Math.random() * 100 + 100;
        child.setMinWidth(width);
        child.setMaxWidth(width);
        child.setPrefWidth(width);
        double height = Math.random() * 100 + 100;
        child.setMinHeight(height);
        child.setMaxHeight(height);
        child.setPrefHeight(height);
        JFXDepthManager.setDepth(child, 1);
        children.add(child);
        // create content
        VBox content = new VBox();
        StackPane header = new StackPane();
        String headerColor = getDefaultColor(i % 12);
        header.setStyle("-fx-background-radius: 5 5 0 0; -fx-background-color: " + headerColor);
        VBox.setVgrow(header, Priority.ALWAYS);
        StackPane body = new StackPane();
        body.setMinHeight(Math.random() * 20 + 50);
        content.getChildren().addAll(header, body);
        body.setStyle("-fx-background-radius: 0 0 5 5; -fx-background-color: rgb(255,255,255,0.87);");
        // create button
        JFXButton button = new JFXButton("");
        button.setButtonType(ButtonType.RAISED);
        button.setStyle("-fx-background-radius: 40;-fx-background-color: " + getDefaultColor((int) ((Math.random() * 12) % 12)));
        button.setPrefSize(40, 40);
        button.setRipplerFill(Color.valueOf(headerColor));
        button.setScaleX(0);
        button.setScaleY(0);
        SVGGlyph glyph = new SVGGlyph(-1, "test", "M1008 6.286q18.857 13.714 15.429 36.571l-146.286 877.714q-2.857 16.571-18.286 25.714-8 4.571-17.714 4.571-6.286 0-13.714-2.857l-258.857-105.714-138.286 168.571q-10.286 13.143-28 13.143-7.429 0-12.571-2.286-10.857-4-17.429-13.429t-6.571-20.857v-199.429l493.714-605.143-610.857 528.571-225.714-92.571q-21.143-8-22.857-31.429-1.143-22.857 18.286-33.714l950.857-548.571q8.571-5.143 18.286-5.143 11.429 0 20.571 6.286z", Color.WHITE);
        glyph.setSize(20, 20);
        button.setGraphic(glyph);
        button.translateYProperty().bind(Bindings.createDoubleBinding(() -> {
            return header.getBoundsInParent().getHeight() - button.getHeight() / 2;
        }, header.boundsInParentProperty(), button.heightProperty()));
        StackPane.setMargin(button, new Insets(0, 12, 0, 0));
        StackPane.setAlignment(button, Pos.TOP_RIGHT);
        Timeline animation = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(button.scaleXProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(button.scaleYProperty(), 1, Interpolator.EASE_BOTH)));
        animation.setDelay(Duration.millis(100 * i + (1000)));
        animation.play();
        child.getChildren().addAll(content, button);
    }
    masonryPane.getChildren().addAll(children);
    Platform.runLater(() -> scrollPane.requestLayout());
    JFXScrollPane.smoothScrolling(scrollPane);
}
Also used : Insets(javafx.geometry.Insets) KeyValue(javafx.animation.KeyValue) Node(javafx.scene.Node) ArrayList(java.util.ArrayList) JFXButton(com.jfoenix.controls.JFXButton) Timeline(javafx.animation.Timeline) SVGGlyph(com.jfoenix.svg.SVGGlyph) KeyFrame(javafx.animation.KeyFrame) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane) PostConstruct(javax.annotation.PostConstruct)

Aggregations

KeyFrame (javafx.animation.KeyFrame)108 Timeline (javafx.animation.Timeline)107 KeyValue (javafx.animation.KeyValue)82 Duration (javafx.util.Duration)32 ActionEvent (javafx.event.ActionEvent)21 JFXButton (com.jfoenix.controls.JFXButton)20 IOException (java.io.IOException)19 URL (java.net.URL)19 ResourceBundle (java.util.ResourceBundle)19 FXML (javafx.fxml.FXML)19 Initializable (javafx.fxml.Initializable)18 FXMLLoader (javafx.fxml.FXMLLoader)17 AnchorPane (javafx.scene.layout.AnchorPane)16 Pane (javafx.scene.layout.Pane)16 Level (java.util.logging.Level)15 Logger (java.util.logging.Logger)15 MouseEvent (javafx.scene.input.MouseEvent)13 Rotate (javafx.scene.transform.Rotate)13 JFXTextField (com.jfoenix.controls.JFXTextField)12 Interpolator (javafx.animation.Interpolator)12