Search in sources :

Example 56 with KeyValue

use of javafx.animation.KeyValue 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)

Example 57 with KeyValue

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

the class ProgressBarController method init.

@PostConstruct
public void init() throws FlowException, VetoException {
    Timeline task = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(progress1.progressProperty(), 0), new KeyValue(progress2.progressProperty(), 0)), new KeyFrame(Duration.seconds(2), new KeyValue(progress1.progressProperty(), 1), new KeyValue(progress2.progressProperty(), 1)));
    task.setCycleCount(Timeline.INDEFINITE);
    task.play();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) PostConstruct(javax.annotation.PostConstruct)

Example 58 with KeyValue

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

the class NodesListDemo method start.

@Override
public void start(Stage primaryStage) throws Exception {
    try {
        JFXButton ssbutton1 = new JFXButton();
        Label sslabel = new Label("R1");
        sslabel.setStyle("-fx-text-fill:WHITE");
        ssbutton1.setGraphic(sslabel);
        ssbutton1.setButtonType(ButtonType.RAISED);
        ssbutton1.getStyleClass().addAll("animated-option-button", "animated-option-sub-button2");
        JFXButton ssbutton2 = new JFXButton("R2");
        ssbutton2.setTooltip(new Tooltip("Button 2"));
        ssbutton2.setButtonType(ButtonType.RAISED);
        ssbutton2.getStyleClass().addAll("animated-option-button", "animated-option-sub-button2");
        JFXButton ssbutton3 = new JFXButton("R3");
        ssbutton3.setButtonType(ButtonType.RAISED);
        ssbutton3.getStyleClass().addAll("animated-option-button", "animated-option-sub-button2");
        JFXNodesList nodesList3 = new JFXNodesList();
        nodesList3.setSpacing(10);
        // init nodes
        nodesList3.addAnimatedNode(ssbutton1, (expanded) -> {
            return new ArrayList<KeyValue>() {

                {
                    add(new KeyValue(sslabel.rotateProperty(), expanded ? 360 : 0, Interpolator.EASE_BOTH));
                }
            };
        });
        nodesList3.addAnimatedNode(ssbutton2);
        nodesList3.addAnimatedNode(ssbutton3);
        JFXButton sbutton1 = new JFXButton();
        Label slabel = new Label("B1");
        slabel.setStyle("-fx-text-fill:WHITE");
        sbutton1.setGraphic(slabel);
        sbutton1.setButtonType(ButtonType.RAISED);
        sbutton1.getStyleClass().addAll("animated-option-button", "animated-option-sub-button");
        JFXButton sbutton2 = new JFXButton("B2");
        sbutton2.setTooltip(new Tooltip("Button 2"));
        sbutton2.setButtonType(ButtonType.RAISED);
        sbutton2.getStyleClass().addAll("animated-option-button", "animated-option-sub-button");
        JFXButton sbutton3 = new JFXButton("B3");
        sbutton3.setButtonType(ButtonType.RAISED);
        sbutton3.getStyleClass().addAll("animated-option-button", "animated-option-sub-button");
        JFXNodesList nodesList2 = new JFXNodesList();
        nodesList2.setSpacing(10);
        // init nodes
        nodesList2.addAnimatedNode(sbutton1, (expanded) -> {
            return new ArrayList<KeyValue>() {

                {
                    add(new KeyValue(slabel.rotateProperty(), expanded ? 360 : 0, Interpolator.EASE_BOTH));
                }
            };
        });
        nodesList2.addAnimatedNode(nodesList3);
        nodesList2.addAnimatedNode(sbutton2);
        nodesList2.addAnimatedNode(sbutton3);
        nodesList2.setRotate(90);
        JFXButton button1 = new JFXButton();
        Label label = new Label("G1");
        button1.setGraphic(label);
        label.setStyle("-fx-text-fill:WHITE");
        button1.setButtonType(ButtonType.RAISED);
        button1.getStyleClass().add("animated-option-button");
        JFXButton button2 = new JFXButton("G2");
        button2.setTooltip(new Tooltip("Button 2"));
        button2.setButtonType(ButtonType.RAISED);
        button2.getStyleClass().add("animated-option-button");
        JFXButton button3 = new JFXButton("G3");
        button3.setButtonType(ButtonType.RAISED);
        button3.getStyleClass().add("animated-option-button");
        JFXNodesList nodesList = new JFXNodesList();
        nodesList.setSpacing(10);
        nodesList.addAnimatedNode(button1, (expanded) -> {
            return new ArrayList<KeyValue>() {

                {
                    add(new KeyValue(label.rotateProperty(), expanded ? 360 : 0, Interpolator.EASE_BOTH));
                }
            };
        });
        nodesList.addAnimatedNode(button2);
        nodesList.addAnimatedNode(nodesList2);
        nodesList.addAnimatedNode(button3);
        nodesList.setRotate(180);
        StackPane main = new StackPane();
        main.setPadding(new Insets(10));
        JFXButton e = new JFXButton("Click Me");
        e.setTranslateY(-50);
        e.setTranslateX(-100);
        main.getChildren().add(e);
        main.getChildren().add(nodesList);
        Scene scene = new Scene(main, 600, 600);
        scene.getStylesheets().add(NodesListDemo.class.getResource("/resources/css/jfoenix-components.css").toExternalForm());
        primaryStage.setScene(scene);
        primaryStage.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : KeyValue(javafx.animation.KeyValue) Insets(javafx.geometry.Insets) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) ArrayList(java.util.ArrayList) JFXButton(com.jfoenix.controls.JFXButton) JFXNodesList(com.jfoenix.controls.JFXNodesList) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Example 59 with KeyValue

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

the class ProgressBarDemo method start.

@Override
public void start(Stage stage) throws Exception {
    pane = new VBox();
    pane.setSpacing(30);
    pane.setStyle("-fx-background-color:WHITE");
    ProgressBar bar = new ProgressBar();
    bar.setPrefWidth(500);
    ProgressBar cssBar = new ProgressBar();
    cssBar.setPrefWidth(500);
    cssBar.setProgress(-1.0f);
    JFXProgressBar jfxBar = new JFXProgressBar();
    jfxBar.setPrefWidth(500);
    JFXProgressBar jfxBarInf = new JFXProgressBar();
    jfxBarInf.setPrefWidth(500);
    jfxBarInf.setProgress(-1.0f);
    Timeline timeline = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(bar.progressProperty(), 0), new KeyValue(jfxBar.progressProperty(), 0)), new KeyFrame(Duration.seconds(2), new KeyValue(bar.progressProperty(), 1), new KeyValue(jfxBar.progressProperty(), 1)));
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.play();
    pane.getChildren().addAll(bar, jfxBar, cssBar, jfxBarInf);
    StackPane main = new StackPane();
    main.getChildren().add(pane);
    main.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
    StackPane.setMargin(pane, new Insets(20, 0, 0, 20));
    final Scene scene = new Scene(main, 600, 200, Color.WHITE);
    scene.getStylesheets().add(ProgressBarDemo.class.getResource("/resources/css/jfoenix-components.css").toExternalForm());
    stage.setTitle("JFX ProgressBar Demo ");
    stage.setScene(scene);
    stage.setResizable(false);
    stage.show();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) Insets(javafx.geometry.Insets) JFXProgressBar(com.jfoenix.controls.JFXProgressBar) KeyFrame(javafx.animation.KeyFrame) Scene(javafx.scene.Scene) JFXProgressBar(com.jfoenix.controls.JFXProgressBar) ProgressBar(javafx.scene.control.ProgressBar)

Example 60 with KeyValue

use of javafx.animation.KeyValue in project fxexperience2 by EricCanull.

the class FadeOutLeftBigTransition method starting.

@Override
protected void starting() {
    double endX = -node.localToScene(0, 0).getX() - node.getBoundsInParent().getWidth();
    timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(node.translateXProperty(), 0, WEB_EASE)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(node.translateXProperty(), endX, WEB_EASE)));
    super.starting();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Aggregations

KeyValue (javafx.animation.KeyValue)85 KeyFrame (javafx.animation.KeyFrame)83 Timeline (javafx.animation.Timeline)82 Interpolator (javafx.animation.Interpolator)12 Rotate (javafx.scene.transform.Rotate)12 Duration (javafx.util.Duration)12 Insets (javafx.geometry.Insets)11 MouseEvent (javafx.scene.input.MouseEvent)10 PerspectiveCamera (javafx.scene.PerspectiveCamera)9 ArrayList (java.util.ArrayList)8 Scene (javafx.scene.Scene)7 Label (javafx.scene.control.Label)7 Rectangle (javafx.scene.shape.Rectangle)7 ActionEvent (javafx.event.ActionEvent)6 EventHandler (javafx.event.EventHandler)6 Group (javafx.scene.Group)6 Node (javafx.scene.Node)6 KeyCode (javafx.scene.input.KeyCode)6 VBox (javafx.scene.layout.VBox)6 JFXButton (com.jfoenix.controls.JFXButton)5