Java Code Examples for javafx.util.Duration#ZERO

The following examples show how to use javafx.util.Duration#ZERO . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Notifications.java    From yfiton with Apache License 2.0 6 votes vote down vote up
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay, Notifications notification) {
    KeyValue fadeOutBegin = new KeyValue(bar.opacityProperty(), 1.0);
    KeyValue fadeOutEnd = new KeyValue(bar.opacityProperty(), 0.0);

    KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
    KeyFrame kfEnd = new KeyFrame(Duration.millis(500), fadeOutEnd);

    Timeline timeline = new Timeline(kfBegin, kfEnd);
    timeline.setDelay(startDelay);
    timeline.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            hide(popup, p);
            notification.onHideAction.handle(e);
        }
    });

    return timeline;
}
 
Example 2
Source File: SpinnerController.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    Timeline timeline = new Timeline(
        new KeyFrame(
            Duration.ZERO,
            new KeyValue(blueSpinner.progressProperty(), 0),
            new KeyValue(greenSpinner.progressProperty(), 0)
        ),
        new KeyFrame(
            Duration.seconds(0.5),
            new KeyValue(greenSpinner.progressProperty(), 0.5)
        ),
        new KeyFrame(
            Duration.seconds(2),
            new KeyValue(blueSpinner.progressProperty(), 1),
            new KeyValue(greenSpinner.progressProperty(), 1)
        )
    );
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.play();
}
 
Example 3
Source File: JFXDialog.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
TopTransition() {
    super(contentHolder, new Timeline(
        new KeyFrame(Duration.ZERO,
            new KeyValue(contentHolder.translateYProperty(), -offsetY, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.visibleProperty(), false, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(10),
            new KeyValue(JFXDialog.this.visibleProperty(), true, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.opacityProperty(), 0, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(1000),
            new KeyValue(contentHolder.translateYProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.opacityProperty(), 1, Interpolator.EASE_BOTH)))
    );
    // reduce the number to increase the shifting , increase number to reduce shifting
    setCycleDuration(Duration.seconds(0.4));
    setDelay(Duration.seconds(0));
}
 
Example 4
Source File: JFXDialog.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
CenterTransition() {
    super(contentHolder, new Timeline(
        new KeyFrame(Duration.ZERO,
            new KeyValue(contentHolder.scaleXProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(contentHolder.scaleYProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.visibleProperty(), false, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(10),
            new KeyValue(JFXDialog.this.visibleProperty(), true, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.opacityProperty(), 0, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(1000),
            new KeyValue(contentHolder.scaleXProperty(), 1, Interpolator.EASE_BOTH),
            new KeyValue(contentHolder.scaleYProperty(), 1, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.opacityProperty(), 1, Interpolator.EASE_BOTH)
        ))
    );
    // reduce the number to increase the shifting , increase number to reduce shifting
    setCycleDuration(Duration.seconds(0.4));
    setDelay(Duration.seconds(0));
}
 
Example 5
Source File: JFXDialog.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
LeftTransition() {
    super(contentHolder, new Timeline(
        new KeyFrame(Duration.ZERO,
            new KeyValue(contentHolder.translateXProperty(), -offsetX, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.visibleProperty(), false, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(10),
            new KeyValue(JFXDialog.this.visibleProperty(), true, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.opacityProperty(), 0, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(1000),
            new KeyValue(contentHolder.translateXProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.opacityProperty(), 1, Interpolator.EASE_BOTH)
        ))
    );
    // reduce the number to increase the shifting , increase number to reduce shifting
    setCycleDuration(Duration.seconds(0.4));
    setDelay(Duration.seconds(0));
}
 
Example 6
Source File: Notifications.java    From oim-fx with MIT License 6 votes vote down vote up
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay) {
    KeyValue fadeOutBegin = new KeyValue(bar.opacityProperty(), 1.0);
    KeyValue fadeOutEnd = new KeyValue(bar.opacityProperty(), 0.0);

    KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
    KeyFrame kfEnd = new KeyFrame(Duration.millis(500), fadeOutEnd);

    Timeline timeline = new Timeline(kfBegin, kfEnd);
    timeline.setDelay(startDelay);
    timeline.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            hide(popup, p);
        }
    });

    return timeline;
}
 
Example 7
Source File: ProgressBarController.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
/**
 * init fxml when loaded.
 */
@PostConstruct
public void init() {
    Timeline task = new Timeline(
        new KeyFrame(
            Duration.ZERO,
            new KeyValue(progress1.progressProperty(), 0),
            new KeyValue(progress2.progressProperty(), 0),
            new KeyValue(progress2.secondaryProgressProperty(), 0.5)),
        new KeyFrame(
            Duration.seconds(1),
            new KeyValue(progress2.secondaryProgressProperty(), 1)),
        new KeyFrame(
            Duration.seconds(2),
            new KeyValue(progress1.progressProperty(), 1),
            new KeyValue(progress2.progressProperty(), 1)));
    task.setCycleCount(Timeline.INDEFINITE);
    task.play();
}
 
Example 8
Source File: JFXDialog.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
RightTransition() {
    super(contentHolder, new Timeline(
        new KeyFrame(Duration.ZERO,
            new KeyValue(contentHolder.translateXProperty(), offsetX, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.visibleProperty(), false, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(10),
            new KeyValue(JFXDialog.this.visibleProperty(), true, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.opacityProperty(), 0, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(1000),
            new KeyValue(contentHolder.translateXProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(JFXDialog.this.opacityProperty(), 1, Interpolator.EASE_BOTH)))
    );
    // reduce the number to increase the shifting , increase number to reduce shifting
    setCycleDuration(Duration.seconds(0.4));
    setDelay(Duration.seconds(0));
}
 
Example 9
Source File: Notifications.java    From yfiton with Apache License 2.0 6 votes vote down vote up
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay, Notifications notification) {
    KeyValue fadeOutBegin = new KeyValue(bar.opacityProperty(), 1.0);
    KeyValue fadeOutEnd = new KeyValue(bar.opacityProperty(), 0.0);

    KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
    KeyFrame kfEnd = new KeyFrame(Duration.millis(500), fadeOutEnd);

    Timeline timeline = new Timeline(kfBegin, kfEnd);
    timeline.setDelay(startDelay);
    timeline.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            hide(popup, p);
            notification.onHideAction.handle(e);
        }
    });

    return timeline;
}
 
Example 10
Source File: JFXButtonSkin.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
ButtonClickTransition(Node node, DropShadow shadowEffect) {
    super(node, new Timeline(
            new KeyFrame(Duration.ZERO,
                new KeyValue(shadowEffect.radiusProperty(),
                    JFXDepthManager.getShadowAt(2).radiusProperty().get(),
                    Interpolator.EASE_BOTH),
                new KeyValue(shadowEffect.spreadProperty(),
                    JFXDepthManager.getShadowAt(2).spreadProperty().get(),
                    Interpolator.EASE_BOTH),
                new KeyValue(shadowEffect.offsetXProperty(),
                    JFXDepthManager.getShadowAt(2).offsetXProperty().get(),
                    Interpolator.EASE_BOTH),
                new KeyValue(shadowEffect.offsetYProperty(),
                    JFXDepthManager.getShadowAt(2).offsetYProperty().get(),
                    Interpolator.EASE_BOTH)
            ),
            new KeyFrame(Duration.millis(1000),
                new KeyValue(shadowEffect.radiusProperty(),
                    JFXDepthManager.getShadowAt(5).radiusProperty().get(),
                    Interpolator.EASE_BOTH),
                new KeyValue(shadowEffect.spreadProperty(),
                    JFXDepthManager.getShadowAt(5).spreadProperty().get(),
                    Interpolator.EASE_BOTH),
                new KeyValue(shadowEffect.offsetXProperty(),
                    JFXDepthManager.getShadowAt(5).offsetXProperty().get(),
                    Interpolator.EASE_BOTH),
                new KeyValue(shadowEffect.offsetYProperty(),
                    JFXDepthManager.getShadowAt(5).offsetYProperty().get(),
                    Interpolator.EASE_BOTH)
            )
        )
    );
    // reduce the number to increase the shifting , increase number to reduce shifting
    setCycleDuration(Duration.seconds(0.2));
    setDelay(Duration.seconds(0));
}
 
Example 11
Source File: SlideCheckBoxSkin.java    From JFX8CustomControls with Apache License 2.0 5 votes vote down vote up
private Timeline getDeselectTimeline() {
    final KeyValue kvThumbStartTranslateDeselect = new KeyValue(thumb.translateXProperty(), 24);
    final KeyValue kvThumbEndTranslateDeselect   = new KeyValue(thumb.translateXProperty(), -24);

    final KeyValue kvMarkStartOpacityDeselect    = new KeyValue(markBox.opacityProperty(), 1);
    final KeyValue kvMarkEndOpacityDeselect      = new KeyValue(markBox.opacityProperty(), 0);

    final KeyValue kvMarkStartScaleXDeselect     = new KeyValue(markBox.scaleXProperty(), 1);
    final KeyValue kvMarkEndScaleXDeselect       = new KeyValue(markBox.scaleXProperty(), 0);

    final KeyValue kvMarkStartScaleYDeselect     = new KeyValue(markBox.scaleYProperty(), 1);
    final KeyValue kvMarkEndScaleYDeselect       = new KeyValue(markBox.scaleYProperty(), 0);

    final KeyValue kvCrossStartOpacityDeselect   = new KeyValue(crossBox.opacityProperty(), 0);
    final KeyValue kvCrossEndOpacityDeselect     = new KeyValue(crossBox.opacityProperty(), 1);

    final KeyValue kvCrossStartScaleXDeselect    = new KeyValue(crossBox.scaleXProperty(), 0);
    final KeyValue kvCrossEndScaleXDeselect      = new KeyValue(crossBox.scaleXProperty(), 1);

    final KeyValue kvCrossStartScaleYDeselect    = new KeyValue(crossBox.scaleYProperty(), 0);
    final KeyValue kvCrossEndScaleYDeselect      = new KeyValue(crossBox.scaleYProperty(), 1);

    final KeyValue kvCrossRotateStart            = new KeyValue(crossBox.rotateProperty(), 0);
    final KeyValue kvCrossRotateEnd              = new KeyValue(crossBox.rotateProperty(), 360);

    final KeyFrame kfStart       = new KeyFrame(Duration.ZERO, kvThumbStartTranslateDeselect,
                                                kvMarkStartOpacityDeselect, kvMarkStartScaleXDeselect, kvMarkStartScaleYDeselect,
                                                kvCrossStartOpacityDeselect, kvCrossStartScaleXDeselect, kvCrossStartScaleYDeselect);
    final KeyFrame kfEnd         = new KeyFrame(Duration.millis(180), kvThumbEndTranslateDeselect,
                                                kvMarkEndOpacityDeselect, kvMarkEndScaleXDeselect, kvMarkEndScaleYDeselect,
                                                kvCrossEndOpacityDeselect, kvCrossEndScaleXDeselect, kvCrossEndScaleYDeselect);
    final KeyFrame kfRotateStart = new KeyFrame(Duration.millis(250), kvCrossRotateStart);
    final KeyFrame kfRotateEnd   = new KeyFrame(Duration.millis(750), kvCrossRotateEnd);

    final Timeline timeline = new Timeline();
    timeline.getKeyFrames().setAll(kfStart, kfEnd, kfRotateStart, kfRotateEnd);
    timeline.setOnFinished(actionEvent -> crossBox.setRotate(0));
    return timeline;
}
 
Example 12
Source File: JFXSliderSkin.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private void initAnimation(Orientation orientation) {
    double thumbPos, thumbNewPos;
    DoubleProperty layoutProperty;

    if (orientation == Orientation.HORIZONTAL) {
        if (((JFXSlider) getSkinnable()).getIndicatorPosition() == IndicatorPosition.RIGHT) {
            thumbPos = thumb.getLayoutY() - thumb.getHeight();
            thumbNewPos = thumbPos - shifting;
        } else {
            double height = animatedThumb.prefHeight(animatedThumb.prefWidth(-1));
            thumbPos = thumb.getLayoutY() - height / 2;
            thumbNewPos = thumb.getLayoutY() - height - thumb.getHeight();
        }
        layoutProperty = animatedThumb.translateYProperty();
    } else {
        if (((JFXSlider) getSkinnable()).getIndicatorPosition() == IndicatorPosition.RIGHT) {
            thumbPos = thumb.getLayoutX() - thumb.getWidth();
            thumbNewPos = thumbPos - shifting;
        } else {
            double width = animatedThumb.prefWidth(-1);
            thumbPos = thumb.getLayoutX() - width / 2;
            thumbNewPos = thumb.getLayoutX() - width - thumb.getWidth();
        }
        layoutProperty = animatedThumb.translateXProperty();
    }

    clearAnimation();

    timeline = new Timeline(
        new KeyFrame(
            Duration.ZERO,
            new KeyValue(animatedThumb.scaleXProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(animatedThumb.scaleYProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(layoutProperty, thumbPos, Interpolator.EASE_BOTH)),
        new KeyFrame(
            Duration.seconds(0.2),
            new KeyValue(animatedThumb.scaleXProperty(), 1, Interpolator.EASE_BOTH),
            new KeyValue(animatedThumb.scaleYProperty(), 1, Interpolator.EASE_BOTH),
            new KeyValue(layoutProperty, thumbNewPos, Interpolator.EASE_BOTH)));
}
 
Example 13
Source File: InterpolatorSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public void changeInterpolator(Interpolator newinterpolator){
    Duration currenttime = Duration.ZERO;
    if (timeline!=null){
        currenttime = timeline.getCurrentTime();
        
        timeline.stop();
    }
    timeline = TimelineBuilder.create()
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .keyFrames(
                new KeyFrame(
                    Duration.ZERO,
                    new KeyValue(circle1.translateXProperty(), 0, Interpolator.LINEAR),
                    new KeyValue(circle2.translateXProperty(), 0, Interpolator.EASE_BOTH),
                    new KeyValue(circle3.translateXProperty(), 0, Interpolator.EASE_IN),
                    new KeyValue(circle4.translateXProperty(), 0, Interpolator.EASE_OUT),
                    new KeyValue(circle5.translateXProperty(), 0, newinterpolator)
            ),
                new KeyFrame(
                    Duration.seconds(4),
                    new KeyValue(circle1.translateXProperty(), 155, Interpolator.LINEAR),
                    new KeyValue(circle2.translateXProperty(), 155, Interpolator.EASE_BOTH),
                    new KeyValue(circle3.translateXProperty(), 155, Interpolator.EASE_IN),
                    new KeyValue(circle4.translateXProperty(), 155, Interpolator.EASE_OUT),
                    new KeyValue(circle5.translateXProperty(), 155, newinterpolator)
            )
                    )
            .build();
    
    timeline.playFrom(currenttime);
    
    
}
 
Example 14
Source File: InterpolatorSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public void changeInterpolator(Interpolator newinterpolator){
    Duration currenttime = Duration.ZERO;
    if (timeline!=null){
        currenttime = timeline.getCurrentTime();
        
        timeline.stop();
    }
    timeline = TimelineBuilder.create()
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .keyFrames(
                new KeyFrame(
                    Duration.ZERO,
                    new KeyValue(circle1.translateXProperty(), 0, Interpolator.LINEAR),
                    new KeyValue(circle2.translateXProperty(), 0, Interpolator.EASE_BOTH),
                    new KeyValue(circle3.translateXProperty(), 0, Interpolator.EASE_IN),
                    new KeyValue(circle4.translateXProperty(), 0, Interpolator.EASE_OUT),
                    new KeyValue(circle5.translateXProperty(), 0, newinterpolator)
            ),
                new KeyFrame(
                    Duration.seconds(4),
                    new KeyValue(circle1.translateXProperty(), 155, Interpolator.LINEAR),
                    new KeyValue(circle2.translateXProperty(), 155, Interpolator.EASE_BOTH),
                    new KeyValue(circle3.translateXProperty(), 155, Interpolator.EASE_IN),
                    new KeyValue(circle4.translateXProperty(), 155, Interpolator.EASE_OUT),
                    new KeyValue(circle5.translateXProperty(), 155, newinterpolator)
            )
                    )
            .build();
    
    timeline.playFrom(currenttime);
    
    
}
 
Example 15
Source File: ColorAnimationUtils.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds animated color properties to the given node that can be accessed from CSS.
 * 
 * @param node the node to be styled with animated colors
 * @param data a {@link AnimatedColor} object storing the animation parameters
 */
public static void animateColor(final Node node, final AnimatedColor data) {

    removeAnimation(node);

    final ObjectProperty<Color> baseColor = new SimpleObjectProperty<>();

    final KeyValue firstkeyValue = new KeyValue(baseColor, data.getFirstColor());
    final KeyValue secondKeyValue = new KeyValue(baseColor, data.getSecondColor());
    final KeyFrame firstKeyFrame = new KeyFrame(Duration.ZERO, firstkeyValue);
    final KeyFrame secondKeyFrame = new KeyFrame(data.getInterval(), secondKeyValue);
    final Timeline timeline = new Timeline(firstKeyFrame, secondKeyFrame);

    baseColor.addListener((v, o, n) -> {

        final int redValue = (int) (n.getRed() * 255);
        final int greenValue = (int) (n.getGreen() * 255);
        final int blueValue = (int) (n.getBlue() * 255);

        final String format = data.getProperty() + ": " + COLOR_FORMAT + ";";
        node.setStyle(String.format(format, redValue, greenValue, blueValue));
    });

    node.getProperties().put(TIMELINE_KEY, timeline);

    timeline.setAutoReverse(true);
    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.play();
}
 
Example 16
Source File: SlideCheckBoxSkin.java    From JFX8CustomControls with Apache License 2.0 4 votes vote down vote up
private Timeline getSelectTimeline() {
    final KeyValue kvThumbStartTranslateSelected = new KeyValue(thumb.translateXProperty(), -24, Interpolator.EASE_BOTH);
    final KeyValue kvThumbEndTranslateSelected   = new KeyValue(thumb.translateXProperty(), 24, Interpolator.EASE_BOTH);

    final KeyValue kvMarkStartOpacitySelected    = new KeyValue(markBox.opacityProperty(), 0, Interpolator.EASE_BOTH);
    final KeyValue kvMarkEndOpacitySelected      = new KeyValue(markBox.opacityProperty(), 1, Interpolator.EASE_BOTH);

    final KeyValue kvMarkStartScaleXSelected     = new KeyValue(markBox.scaleXProperty(), 0, Interpolator.EASE_BOTH);
    final KeyValue kvMarkEndScaleXSelected       = new KeyValue(markBox.scaleXProperty(), 1, Interpolator.EASE_BOTH);

    final KeyValue kvMarkStartScaleYSelected     = new KeyValue(markBox.scaleYProperty(), 0, Interpolator.EASE_BOTH);
    final KeyValue kvMarkEndScaleYSelected       = new KeyValue(markBox.scaleYProperty(), 1, Interpolator.EASE_BOTH);

    final KeyValue kvMarkStartScaleUpXSelected   = new KeyValue(markBox.scaleXProperty(), 1, Interpolator.EASE_BOTH);
    final KeyValue kvMarkEndScaleUpXSelected     = new KeyValue(markBox.scaleXProperty(), 1.5, Interpolator.EASE_BOTH);

    final KeyValue kvMarkStartScaleUpYSelected   = new KeyValue(markBox.scaleYProperty(), 1, Interpolator.EASE_BOTH);
    final KeyValue kvMarkEndScaleUpYSelected     = new KeyValue(markBox.scaleYProperty(), 1.5, Interpolator.EASE_BOTH);

    final KeyValue kvMarkStartScaleDownXSelected = new KeyValue(markBox.scaleXProperty(), 1.5, Interpolator.EASE_BOTH);
    final KeyValue kvMarkEndScaleDownXSelected   = new KeyValue(markBox.scaleXProperty(), 1, Interpolator.EASE_BOTH);

    final KeyValue kvMarkStartScaleDownYSelected = new KeyValue(markBox.scaleYProperty(), 1.5, Interpolator.EASE_BOTH);
    final KeyValue kvMarkEndScaleDownYSelected   = new KeyValue(markBox.scaleYProperty(), 1, Interpolator.EASE_BOTH);

    final KeyValue kvCrossStartOpacitySelected   = new KeyValue(crossBox.opacityProperty(), 1, Interpolator.EASE_BOTH);
    final KeyValue kvCrossEndOpacitySelected     = new KeyValue(crossBox.opacityProperty(), 0, Interpolator.EASE_BOTH);

    final KeyValue kvCrossStartScaleXSelected    = new KeyValue(crossBox.scaleXProperty(), 1, Interpolator.EASE_BOTH);
    final KeyValue kvCrossEndScaleXSelected      = new KeyValue(crossBox.scaleXProperty(), 0, Interpolator.EASE_BOTH);

    final KeyValue kvCrossStartScaleYSelected    = new KeyValue(crossBox.scaleYProperty(), 1, Interpolator.EASE_BOTH);
    final KeyValue kvCrossEndScaleYSelected      = new KeyValue(crossBox.scaleYProperty(), 0, Interpolator.EASE_BOTH);

    final KeyFrame kfStart = new KeyFrame(Duration.ZERO, kvThumbStartTranslateSelected,
                                          kvMarkStartOpacitySelected, kvMarkStartScaleXSelected, kvMarkStartScaleYSelected,
                                          kvCrossStartOpacitySelected, kvCrossStartScaleXSelected, kvCrossStartScaleYSelected);
    final KeyFrame kfEnd   = new KeyFrame(Duration.millis(180), kvThumbEndTranslateSelected,
                                          kvMarkEndOpacitySelected, kvMarkEndScaleXSelected, kvMarkEndScaleYSelected,
                                          kvCrossEndOpacitySelected, kvCrossEndScaleXSelected, kvCrossEndScaleYSelected);
    final KeyFrame kfScaleUpStart   = new KeyFrame(Duration.millis(250), kvMarkStartScaleUpXSelected, kvMarkStartScaleUpYSelected);
    final KeyFrame kfScaleUpEnd     = new KeyFrame(Duration.millis(350), kvMarkEndScaleUpXSelected, kvMarkEndScaleUpYSelected);
    final KeyFrame kfScaleDownStart = new KeyFrame(Duration.millis(350), kvMarkStartScaleDownXSelected, kvMarkStartScaleDownYSelected);
    final KeyFrame kfScaleDownEnd   = new KeyFrame(Duration.millis(500), kvMarkEndScaleDownXSelected, kvMarkEndScaleDownYSelected);

    final Timeline timeline = new Timeline();
    timeline.getKeyFrames().setAll(kfStart, kfEnd, kfScaleUpStart, kfScaleUpEnd, kfScaleDownStart, kfScaleDownEnd);
    return timeline;
}
 
Example 17
Source File: Board.java    From util4j with Apache License 2.0 4 votes vote down vote up
private void createScore() {
    Label lblTitle = new Label("fx2048");
    lblTitle.getStyleClass().addAll("game-label","game-title");
    Label lblSubtitle = new Label("FX");
    lblSubtitle.getStyleClass().addAll("game-label","game-subtitle");
    HBox hFill = new HBox();
    HBox.setHgrow(hFill, Priority.ALWAYS);
    hFill.setAlignment(Pos.CENTER);
    
    VBox vScores = new VBox();
    HBox hScores=new HBox(5);
    
    vScore.setAlignment(Pos.CENTER);
    vScore.getStyleClass().add("game-vbox");
    Label lblTit = new Label("分数");
    lblTit.getStyleClass().addAll("game-label","game-titScore");
    lblScore.getStyleClass().addAll("game-label","game-score");
    lblScore.textProperty().bind(gameScoreProperty.asString());
    vScore.getChildren().addAll(lblTit, lblScore);

    VBox vRecord = new VBox(-5);
    vRecord.setAlignment(Pos.CENTER);
    vRecord.getStyleClass().add("game-vbox");
    Label lblTitBest = new Label("最高分");
    lblTitBest.getStyleClass().addAll("game-label","game-titScore");
    lblBest.getStyleClass().addAll("game-label","game-score");
    lblBest.textProperty().bind(gameBestProperty.asString());
    vRecord.getChildren().addAll(lblTitBest, lblBest);
    hScores.getChildren().addAll(vScore,vRecord);
    VBox vFill = new VBox();
    VBox.setVgrow(vFill, Priority.ALWAYS);
    vScores.getChildren().addAll(hScores,vFill);
            
    hTop.getChildren().addAll(lblTitle, lblSubtitle, hFill,vScores);
    hTop.setMinSize(gridWidth, TOP_HEIGHT);
    hTop.setPrefSize(gridWidth, TOP_HEIGHT);
    hTop.setMaxSize(gridWidth, TOP_HEIGHT);

    vGame.getChildren().add(hTop);

    HBox hTime=new HBox();
    hTime.setMinSize(gridWidth, GAP_HEIGHT);
    hTime.setAlignment(Pos.BOTTOM_RIGHT);
    lblTime.getStyleClass().addAll("game-label","game-time");
    lblTime.textProperty().bind(clock);
    timer=new Timeline(new KeyFrame(Duration.ZERO, e->{
        clock.set(LocalTime.now().minusNanos(time.toNanoOfDay()).format(fmt));
    }),new KeyFrame(Duration.seconds(1)));
    timer.setCycleCount(Animation.INDEFINITE);
    hTime.getChildren().add(lblTime);
    
    vGame.getChildren().add(hTime);
    getChildren().add(vGame);
    
    lblPoints.getStyleClass().addAll("game-label","game-points");
    lblPoints.setAlignment(Pos.CENTER);
    lblPoints.setMinWidth(100);
    getChildren().add(lblPoints);
}
 
Example 18
Source File: Board.java    From fx2048 with GNU General Public License v3.0 4 votes vote down vote up
private void createScore() {
    var lblTitle = new Label("2048");
    lblTitle.getStyleClass().addAll("game-label", "game-title");

    var lblSubtitle = new Label("FX");
    lblSubtitle.getStyleClass().addAll("game-label", "game-subtitle");

    var hFill = new HBox();
    HBox.setHgrow(hFill, Priority.ALWAYS);
    hFill.setAlignment(Pos.CENTER);

    var vScores = new VBox();
    var hScores = new HBox(5);

    vScore.setAlignment(Pos.CENTER);
    vScore.getStyleClass().add("game-vbox");

    var lblTit = new Label("SCORE");
    lblTit.getStyleClass().addAll("game-label", "game-titScore");

    lblScore.getStyleClass().addAll("game-label", "game-score");
    lblScore.textProperty().bind(gameScoreProperty.asString());
    vScore.getChildren().addAll(lblTit, lblScore);

    var vRecord = new VBox(-5);
    vRecord.setAlignment(Pos.CENTER);
    vRecord.getStyleClass().add("game-vbox");

    var lblTitBest = new Label("BEST");
    lblTitBest.getStyleClass().addAll("game-label", "game-titScore");
    lblBest.getStyleClass().addAll("game-label", "game-score");
    lblBest.textProperty().bind(gameBestProperty.asString());
    vRecord.getChildren().addAll(lblTitBest, lblBest);
    hScores.getChildren().addAll(vScore, vRecord);

    var vFill = new VBox();
    VBox.setVgrow(vFill, Priority.ALWAYS);
    vScores.getChildren().addAll(hScores, vFill);

    hTop.getChildren().addAll(lblTitle, lblSubtitle, hFill, vScores);
    hTop.setMinSize(gridWidth, TOP_HEIGHT);
    hTop.setPrefSize(gridWidth, TOP_HEIGHT);
    hTop.setMaxSize(gridWidth, TOP_HEIGHT);

    vGame.getChildren().add(hTop);

    var hTime = new HBox();
    hTime.setMinSize(gridWidth, GAP_HEIGHT);
    hTime.setAlignment(Pos.BOTTOM_RIGHT);
    lblTime.getStyleClass().addAll("game-label", "game-time");
    lblTime.textProperty().bind(clock);
    timer = new Timeline(new KeyFrame(Duration.ZERO, e -> {
        clock.set(LocalTime.now().minusNanos(time.toNanoOfDay()).format(fmt));
    }), new KeyFrame(Duration.seconds(1)));
    timer.setCycleCount(Animation.INDEFINITE);
    hTime.getChildren().add(lblTime);

    vGame.getChildren().add(hTime);
    getChildren().add(vGame);

    lblPoints.getStyleClass().addAll("game-label", "game-points");
    lblPoints.setAlignment(Pos.CENTER);
    lblPoints.setMinWidth(100);
    getChildren().add(lblPoints);
}
 
Example 19
Source File: CircularProgressIndicator.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
private void initGraphics() {
    double center = PREFERRED_WIDTH * 0.5;
    double radius = PREFERRED_WIDTH * 0.45;
    circle = new Circle();
    circle.setCenterX(center);
    circle.setCenterY(center);
    circle.setRadius(radius);
    circle.getStyleClass().add("indicator");
    circle.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
    circle.setStrokeWidth(PREFERRED_WIDTH * 0.10526316);
    circle.setStrokeDashOffset(dashOffset.get());
    circle.getStrokeDashArray().setAll(dashArray_0.getValue(), 200d);

    arc = new Arc(center, center, radius, radius, 90, -360.0 * getProgress());
    arc.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
    arc.setStrokeWidth(PREFERRED_WIDTH * 0.1);
    arc.getStyleClass().add("indicator");

    indeterminatePane = new StackPane(circle);
    indeterminatePane.setVisible(false);

    progressPane      = new Pane(arc);
    progressPane.setVisible(Double.compare(getProgress(), 0.0) != 0);

    getChildren().setAll(progressPane, indeterminatePane);

    // Setup timeline animation
    KeyValue kvDashOffset_0    = new KeyValue(dashOffset, 0, Interpolator.EASE_BOTH);
    KeyValue kvDashOffset_50   = new KeyValue(dashOffset, -32, Interpolator.EASE_BOTH);
    KeyValue kvDashOffset_100  = new KeyValue(dashOffset, -64, Interpolator.EASE_BOTH);

    KeyValue kvDashArray_0_0   = new KeyValue(dashArray_0, 5, Interpolator.EASE_BOTH);
    KeyValue kvDashArray_0_50  = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);
    KeyValue kvDashArray_0_100 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);

    KeyValue kvRotate_0        = new KeyValue(circle.rotateProperty(), -10, Interpolator.LINEAR);
    KeyValue kvRotate_100      = new KeyValue(circle.rotateProperty(), 370, Interpolator.LINEAR);

    KeyFrame kf0               = new KeyFrame(Duration.ZERO, kvDashOffset_0, kvDashArray_0_0, kvRotate_0);
    KeyFrame kf1               = new KeyFrame(Duration.millis(1000), kvDashOffset_50, kvDashArray_0_50);
    KeyFrame kf2               = new KeyFrame(Duration.millis(1500), kvDashOffset_100, kvDashArray_0_100, kvRotate_100);

    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.getKeyFrames().setAll(kf0, kf1, kf2);

    // Setup additional pane rotation
    indeterminatePaneRotation = new RotateTransition();
    indeterminatePaneRotation.setNode(indeterminatePane);
    indeterminatePaneRotation.setFromAngle(0);
    indeterminatePaneRotation.setToAngle(-360);
    indeterminatePaneRotation.setInterpolator(Interpolator.LINEAR);
    indeterminatePaneRotation.setCycleCount(Timeline.INDEFINITE);
    indeterminatePaneRotation.setDuration(new Duration(4500));
}
 
Example 20
Source File: FadeAnimation.java    From JavaFX-Chat with GNU General Public License v3.0 4 votes vote down vote up
/**
 *
 * @return a constructed instance of a show fade animation
 */
private Timeline setupShowAnimation() {

    Timeline tl = new Timeline();

    //Sets opacity to 0.0 instantly which is pretty much invisible
    KeyValue kvOpacity = new KeyValue(stage.opacityProperty(), 0.0);
    KeyFrame frame1 = new KeyFrame(Duration.ZERO, kvOpacity);

    //Sets opacity to 1.0 (fully visible) over the time of 3000 milliseconds.
    KeyValue kvOpacity2 = new KeyValue(stage.opacityProperty(), 1.0);
    KeyFrame frame2 = new KeyFrame(Duration.millis(3000), kvOpacity2);

    tl.getKeyFrames().addAll(frame1, frame2);

    tl.setOnFinished(e -> trayIsShowing = true);

    return tl;
}