Java Code Examples for javafx.animation.RotateTransition#setDuration()

The following examples show how to use javafx.animation.RotateTransition#setDuration() . 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: RadialMenu.java    From Enzo with Apache License 2.0 6 votes vote down vote up
public void close() {
    if (State.CLOSED == getState()) return;

    setState(State.CLOSED);
    RotateTransition rotate = new RotateTransition();
    rotate.setNode(cross);
    rotate.setToAngle(0);
    rotate.setDuration(Duration.millis(200));
    rotate.setInterpolator(Interpolator.EASE_BOTH);
    rotate.play();
    closeTimeLines[closeTimeLines.length - 1].setOnFinished(actionEvent -> {
        FadeTransition buttonFadeOut = new FadeTransition();
        buttonFadeOut.setNode(mainMenuButton);
        buttonFadeOut.setDuration(Duration.millis(100));
        buttonFadeOut.setToValue(options.getButtonAlpha());
        buttonFadeOut.play();
        buttonFadeOut.setOnFinished(event -> {
            if (options.isButtonHideOnClose()) hide();
            fireMenuEvent(new MenuEvent(this, null, MenuEvent.MENU_CLOSE_FINISHED));
        });
    });
    for (int i = 0 ; i < closeTimeLines.length ; i++) {
        closeTimeLines[i].play();
    }
    fireMenuEvent(new MenuEvent(this, null, MenuEvent.MENU_CLOSE_STARTED));
}
 
Example 2
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 3
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 4
Source File: RadialMenu.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public void click(final MenuItem CLICKED_ITEM) {
    List<Transition> transitions = new ArrayList<>(items.size() * 2);
    for (Parent node : items.keySet()) {
        if (items.get(node).equals(CLICKED_ITEM)) {
            // Add enlarge transition to selected item
            ScaleTransition enlargeItem = new ScaleTransition(Duration.millis(300), node);
            enlargeItem.setToX(5.0);
            enlargeItem.setToY(5.0);
            transitions.add(enlargeItem);
        } else {
            // Add shrink transition to all other items
            ScaleTransition shrinkItem = new ScaleTransition(Duration.millis(300), node);
            shrinkItem.setToX(0.0);
            shrinkItem.setToY(0.0);
            transitions.add(shrinkItem);
        }
        // Add fade out transition to every node
        FadeTransition fadeOutItem = new FadeTransition(Duration.millis(300), node);
        fadeOutItem.setToValue(0.0);
        transitions.add(fadeOutItem);
    }

    // Add rotate and fade transition to main menu button
    if (options.isButtonHideOnSelect()) {
        RotateTransition rotateMainButton = new RotateTransition(Duration.millis(300), mainMenuButton);
        rotateMainButton.setToAngle(225);
        transitions.add(rotateMainButton);
        FadeTransition fadeOutMainButton = new FadeTransition(Duration.millis(300), mainMenuButton);
        fadeOutMainButton.setToValue(0.0);
        transitions.add(fadeOutMainButton);
        ScaleTransition shrinkMainButton = new ScaleTransition(Duration.millis(300), mainMenuButton);
        shrinkMainButton.setToX(0.0);
        shrinkMainButton.setToY(0.0);
        transitions.add(shrinkMainButton);
    } else {
        RotateTransition rotateBackMainButton = new RotateTransition();
        rotateBackMainButton.setNode(cross);
        rotateBackMainButton.setToAngle(0);
        rotateBackMainButton.setDuration(Duration.millis(200));
        rotateBackMainButton.setInterpolator(Interpolator.EASE_BOTH);
        transitions.add(rotateBackMainButton);
        FadeTransition mainButtonFadeOut = new FadeTransition();
        mainButtonFadeOut.setNode(mainMenuButton);
        mainButtonFadeOut.setDuration(Duration.millis(100));
        mainButtonFadeOut.setToValue(options.getButtonAlpha());
        transitions.add(mainButtonFadeOut);
    }

    // Play all transitions in parallel
    ParallelTransition selectTransition = new ParallelTransition();
    selectTransition.getChildren().addAll(transitions);
    selectTransition.play();

    // Set menu state back to closed
    setState(State.CLOSED);
    mainMenuButton.setOpen(false);
}