javafx.animation.SequentialTransition Java Examples

The following examples show how to use javafx.animation.SequentialTransition. 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: SpaceInvadersController.java    From FXGLGames with MIT License 6 votes vote down vote up
private Animation getAnimationLoseLife(Texture texture) {
    texture.setFitWidth(64);
    texture.setFitHeight(64);

    Viewport viewport = gameScene.getViewport();

    TranslateTransition tt = new TranslateTransition(Duration.seconds(0.66), texture);
    tt.setToX(viewport.getWidth() / 2 - texture.getFitWidth() / 2);
    tt.setToY(viewport.getHeight() / 2 - texture.getFitHeight() / 2);

    ScaleTransition st = new ScaleTransition(Duration.seconds(0.66), texture);
    st.setToX(0);
    st.setToY(0);

    return new SequentialTransition(tt, st);
}
 
Example #2
Source File: SpaceInvadersController.java    From FXGLGames with MIT License 6 votes vote down vote up
private Animation getAnimationLoseLife(Texture texture) {
    texture.setFitWidth(64);
    texture.setFitHeight(64);

    Viewport viewport = gameScene.getViewport();

    TranslateTransition tt = new TranslateTransition(Duration.seconds(0.66), texture);
    tt.setToX(viewport.getWidth() / 2 - texture.getFitWidth() / 2);
    tt.setToY(viewport.getHeight() / 2 - texture.getFitHeight() / 2);

    ScaleTransition st = new ScaleTransition(Duration.seconds(0.66), texture);
    st.setToX(0);
    st.setToY(0);

    return new SequentialTransition(tt, st);
}
 
Example #3
Source File: ChartLayoutAnimator.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
/**
 * Play a animation containing the given keyframes.
 *
 * @param animation The animation to play
 * @return A id reference to the animation that can be used to stop the animation if needed
 */
public Object animate(Animation animation) {
    SequentialTransition t = new SequentialTransition();
    t.getChildren().add(animation);
    t.setOnFinished(this);
    // start animation timer if needed
    if (activeTimeLines.isEmpty())
        start();
    // get id and add to map
    activeTimeLines.put(t, t);
    // play animation
    t.play();
    return t;

}
 
Example #4
Source File: GaugeSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void fadeBackToInteractive() {
    FadeTransition fadeUnitOut = new FadeTransition(Duration.millis(425), unit);
    fadeUnitOut.setFromValue(1.0);
    fadeUnitOut.setToValue(0.0);
    FadeTransition fadeValueOut = new FadeTransition(Duration.millis(425), value);
    fadeValueOut.setFromValue(1.0);
    fadeValueOut.setToValue(0.0);

    PauseTransition pause = new PauseTransition(Duration.millis(50));

    FadeTransition fadeUnitIn = new FadeTransition(Duration.millis(425), unit);
    fadeUnitIn.setFromValue(0.0);
    fadeUnitIn.setToValue(1.0);
    FadeTransition fadeValueIn = new FadeTransition(Duration.millis(425), value);
    fadeValueIn.setFromValue(0.0);
    fadeValueIn.setToValue(1.0);
    ParallelTransition parallelIn = new ParallelTransition(fadeUnitIn, fadeValueIn);

    ParallelTransition parallelOut = new ParallelTransition(fadeUnitOut, fadeValueOut);
    parallelOut.setOnFinished(event -> {
        unit.setText("Interactive");
        value.setText("");
        resizeText();
    });

    SequentialTransition sequence = new SequentialTransition(parallelOut, pause, parallelIn);
    sequence.play();
}
 
Example #5
Source File: RadialBargraphSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void fadeBackToInteractive() {
    FadeTransition fadeUnitOut = new FadeTransition(Duration.millis(425), unit);
    fadeUnitOut.setFromValue(1.0);
    fadeUnitOut.setToValue(0.0);
    FadeTransition fadeValueOut = new FadeTransition(Duration.millis(425), value);
    fadeValueOut.setFromValue(1.0);
    fadeValueOut.setToValue(0.0);

    PauseTransition pause = new PauseTransition(Duration.millis(50));

    FadeTransition fadeUnitIn = new FadeTransition(Duration.millis(425), unit);
    fadeUnitIn.setFromValue(0.0);
    fadeUnitIn.setToValue(1.0);
    FadeTransition fadeValueIn = new FadeTransition(Duration.millis(425), value);
    fadeValueIn.setFromValue(0.0);
    fadeValueIn.setToValue(1.0);
    ParallelTransition parallelIn = new ParallelTransition(fadeUnitIn, fadeValueIn);

    ParallelTransition parallelOut = new ParallelTransition(fadeUnitOut, fadeValueOut);
    parallelOut.setOnFinished(event -> {
        unit.setText("Interactive");
        value.setText("");
        resizeText();
    });

    SequentialTransition sequence = new SequentialTransition(parallelOut, pause, parallelIn);
    sequence.play();
}
 
Example #6
Source File: HeatControlSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void fadeBack() {
    FadeTransition fadeInfoTextOut = new FadeTransition(Duration.millis(425), infoText);
    fadeInfoTextOut.setFromValue(1.0);
    fadeInfoTextOut.setToValue(0.0);
    
    FadeTransition fadeValueOut = new FadeTransition(Duration.millis(425), value);
    fadeValueOut.setFromValue(1.0);
    fadeValueOut.setToValue(0.0);

    PauseTransition pause = new PauseTransition(Duration.millis(50));

    FadeTransition fadeInfoTextIn = new FadeTransition(Duration.millis(425), infoText);
    fadeInfoTextIn.setFromValue(0.0);
    fadeInfoTextIn.setToValue(1.0);
    
    FadeTransition fadeValueIn = new FadeTransition(Duration.millis(425), value);
    fadeValueIn.setFromValue(0.0);
    fadeValueIn.setToValue(1.0);                
    
    ParallelTransition parallelIn = new ParallelTransition(fadeInfoTextIn, fadeValueIn);

    ParallelTransition parallelOut = new ParallelTransition(fadeInfoTextOut, fadeValueOut);
    parallelOut.setOnFinished(event -> {
        double currentValue = (valueIndicatorRotate.getAngle() + getSkinnable().getStartAngle() - 180) / angleStep + getSkinnable().getMinValue();
        value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", currentValue));
        value.setTranslateX((size - value.getLayoutBounds().getWidth()) * 0.5);
        if (getSkinnable().getTarget() < getSkinnable().getValue()) {
            getSkinnable().setInfoText("COOLING");
        } else if (getSkinnable().getTarget() > getSkinnable().getValue()) {
            getSkinnable().setInfoText("HEATING");
        }
        
        resizeText();
        drawTickMarks(ticks);
        userAction = false;
    });

    SequentialTransition sequence = new SequentialTransition(parallelOut, pause, parallelIn);
    sequence.play();
}
 
Example #7
Source File: GameManager.java    From fx2048 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Animation that creates a pop effect when two tiles merge by increasing the
 * tile scale to 120% at the middle, and then going back to 100%
 *
 * @param tile to be animated
 * @return a sequential transition
 */
private SequentialTransition animateMergedTile(Tile tile) {
    final var scale0 = new ScaleTransition(ANIMATION_MERGED_TILE, tile);
    scale0.setToX(1.2);
    scale0.setToY(1.2);
    scale0.setInterpolator(Interpolator.EASE_IN);

    final var scale1 = new ScaleTransition(ANIMATION_MERGED_TILE, tile);
    scale1.setToX(1.0);
    scale1.setToY(1.0);
    scale1.setInterpolator(Interpolator.EASE_OUT);

    return new SequentialTransition(scale0, scale1);
}
 
Example #8
Source File: GameManager.java    From Game2048FX with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Animation that creates a pop effect when two tiles merge
 * by increasing the tile scale to 120% at the middle, and then going back to 100%
 * @param tile to be animated
 * @return a sequential transition
 */
private SequentialTransition animateMergedTile(Tile tile) {
    final ScaleTransition scale0 = new ScaleTransition(Duration.millis(80*timeFactor), tile);
    scale0.setToX(1.2);
    scale0.setToY(1.2);
    scale0.setInterpolator(Interpolator.EASE_IN);

    final ScaleTransition scale1 = new ScaleTransition(Duration.millis(80*timeFactor), tile);
    scale1.setToX(1.0);
    scale1.setToY(1.0);
    scale1.setInterpolator(Interpolator.EASE_OUT);

    return new SequentialTransition(scale0, scale1);
}
 
Example #9
Source File: ImageMosaicStep.java    From TweetwallFX with MIT License 5 votes vote down vote up
private Transition createReverseHighlightAndZoomTransition(final int column, final int row) {
    ImageView randomView = rects[column][row];
    randomView.toFront();
    ParallelTransition firstParallelTransition = new ParallelTransition();
    ParallelTransition secondParallelTransition = new ParallelTransition();

    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 5; j++) {
            if ((i == column) && (j == row)) {
                continue;
            }
            FadeTransition ft = new FadeTransition(Duration.seconds(1), rects[i][j]);
            ft.setFromValue(0.3);
            ft.setToValue(1.0);
            firstParallelTransition.getChildren().add(ft);
        }
    }

    double width = pane.getWidth() / 6.0 - 10;
    double height = pane.getHeight() / 5.0 - 8;

    final SizeTransition zoomBox = new SizeTransition(Duration.seconds(2.5), randomView.fitWidthProperty(), randomView.fitHeightProperty())
            .withWidth(randomView.getLayoutBounds().getWidth(), width)
            .withHeight(randomView.getLayoutBounds().getHeight(), height);
    final LocationTransition trans = new LocationTransition(Duration.seconds(2.5), randomView)
            .withX(randomView.getLayoutX(), bounds[column][row].getMinX())
            .withY(randomView.getLayoutY(), bounds[column][row].getMinY());
    secondParallelTransition.getChildren().addAll(trans, zoomBox);

    SequentialTransition seqT = new SequentialTransition();
    seqT.getChildren().addAll(secondParallelTransition, firstParallelTransition);

    secondParallelTransition.setOnFinished(event
            -> randomView.setEffect(null));

    return seqT;
}
 
Example #10
Source File: ImageMosaicStep.java    From TweetwallFX with MIT License 5 votes vote down vote up
private Transition createMosaicTransition(final List<ImageStore> imageStores) {
    final SequentialTransition fadeIn = new SequentialTransition();
    final List<FadeTransition> allFadeIns = new ArrayList<>();
    final double width = pane.getWidth() / 6.0 - 10;
    final double height = pane.getHeight() / 5.0 - 8;
    final List<ImageStore> distillingList = new ArrayList<>(imageStores);

    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 5; j++) {
            int index = RANDOM.nextInt(distillingList.size());
            ImageStore selectedImage = distillingList.remove(index);
            ImageView imageView = new ImageView(selectedImage.getImage());
            imageView.setCache(true);
            imageView.setCacheHint(CacheHint.SPEED);
            imageView.setFitWidth(width);
            imageView.setFitHeight(height);
            imageView.setEffect(new GaussianBlur(0));
            rects[i][j] = imageView;
            bounds[i][j] = new BoundingBox(i * (width + 10) + 5, j * (height + 8) + 4, width, height);
            rects[i][j].setOpacity(0);
            rects[i][j].setLayoutX(bounds[i][j].getMinX());
            rects[i][j].setLayoutY(bounds[i][j].getMinY());
            pane.getChildren().add(rects[i][j]);
            FadeTransition ft = new FadeTransition(Duration.seconds(0.3), imageView);
            ft.setToValue(1);
            allFadeIns.add(ft);
        }
    }
    Collections.shuffle(allFadeIns);
    fadeIn.getChildren().addAll(allFadeIns);
    return fadeIn;
}
 
Example #11
Source File: GameManager.java    From util4j with Apache License 2.0 5 votes vote down vote up
/**
 * Animation that creates a pop effect when two tiles merge
 * by increasing the tile scale to 120% at the middle, and then going back to 100% 
 * @param tile to be animated
 * @return a sequential transition 
 */
private SequentialTransition animateMergedTile(Tile tile) {
    final ScaleTransition scale0 = new ScaleTransition(ANIMATION_MERGED_TILE, tile);
    scale0.setToX(1.2);
    scale0.setToY(1.2);
    scale0.setInterpolator(Interpolator.EASE_IN);

    final ScaleTransition scale1 = new ScaleTransition(ANIMATION_MERGED_TILE, tile);
    scale1.setToX(1.0);
    scale1.setToY(1.0);
    scale1.setInterpolator(Interpolator.EASE_OUT);

    return new SequentialTransition(scale0, scale1);
}
 
Example #12
Source File: Splash.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Close the splash screen */
public void close()
{
    // Keep the splash for another 3 seconds
    // (so in case of fast startup it's at least shown 3 secs),
    // then fade out.
    final PauseTransition pause = new PauseTransition(Duration.seconds(3));
    final FadeTransition fade = new FadeTransition(Duration.seconds(1.5), stage.getScene().getRoot());
    fade.setFromValue(1.0);
    fade.setToValue(0);

    final SequentialTransition animation = new SequentialTransition(pause, fade);
    animation.setOnFinished(event -> stage.close());
    animation.play();
}
 
Example #13
Source File: FadeInCloudStep.java    From TweetwallFX with MIT License 4 votes vote down vote up
@Override
public void doStep(final MachineContext context) {
    List<Word> sortedWords = context.getDataProvider(TagCloudDataProvider.class).getWords();

    if (sortedWords.isEmpty()) {
        return;
    }

    WordleSkin wordleSkin = (WordleSkin) context.get("WordleSkin");
    List<Word> limitedWords = sortedWords.stream().limit(wordleSkin.getDisplayCloudTags()).collect(Collectors.toList());
    limitedWords.sort(Comparator.reverseOrder());

    Bounds layoutBounds = wordleSkin.getPane().getLayoutBounds();

    WordleLayout.Configuration configuration = new WordleLayout.Configuration(limitedWords, wordleSkin.getFont(), wordleSkin.getFontSizeMax(), layoutBounds);
    if (null != wordleSkin.getLogo()) {
        configuration.setBlockedAreaBounds(wordleSkin.getLogo().getBoundsInParent());
    }
    if (null != wordleSkin.getSecondLogo()) {
        configuration.setBlockedAreaBounds(wordleSkin.getSecondLogo().getBoundsInParent());
    }
    WordleLayout cloudWordleLayout = WordleLayout.createWordleLayout(configuration);
    Duration defaultDuration = Duration.seconds(1.5);

    List<Transition> fadeOutTransitions = new ArrayList<>();
    List<Transition> moveTransitions = new ArrayList<>();
    List<Transition> fadeInTransitions = new ArrayList<>();

    cloudWordleLayout.getWordLayoutInfo().entrySet().stream().forEach(entry -> {
        Word word = entry.getKey();
        Bounds bounds = entry.getValue();
        Text textNode = cloudWordleLayout.createTextNode(word);
        wordleSkin.word2TextMap.put(word, textNode);
        textNode.setLayoutX(bounds.getMinX() + layoutBounds.getWidth() / 2d);
        textNode.setLayoutY(bounds.getMinY() + layoutBounds.getHeight() / 2d + bounds.getHeight() / 2d);
        textNode.setOpacity(0);
        wordleSkin.getPane().getChildren().add(textNode);
        FadeTransition ft = new FadeTransition(defaultDuration, textNode);
        ft.setToValue(1);
        fadeInTransitions.add(ft);
    });

    ParallelTransition fadeOuts = new ParallelTransition();
    fadeOuts.getChildren().addAll(fadeOutTransitions);
    ParallelTransition moves = new ParallelTransition();
    moves.getChildren().addAll(moveTransitions);
    ParallelTransition fadeIns = new ParallelTransition();
    fadeIns.getChildren().addAll(fadeInTransitions);
    SequentialTransition morph = new SequentialTransition(fadeOuts, moves, fadeIns);

    morph.setOnFinished(e -> context.proceed());
    morph.play();
}
 
Example #14
Source File: MaterialDesignButton.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
private void createRippleEffect() {
        circleRipple = new Circle(0.1, rippleColor);
        circleRipple.setOpacity(0.0);
        // Optional box blur on ripple - smoother ripple effect
//        circleRipple.setEffect(new BoxBlur(3, 3, 2));

        // Fade effect bit longer to show edges on the end
        final FadeTransition fadeTransition = new FadeTransition(rippleDuration, circleRipple);
        fadeTransition.setInterpolator(Interpolator.EASE_OUT);
        fadeTransition.setFromValue(1.0);
        fadeTransition.setToValue(0.0);

        final Timeline scaleRippleTimeline = new Timeline();

        final SequentialTransition parallelTransition = new SequentialTransition();
        parallelTransition.getChildren().addAll(
                scaleRippleTimeline,
                fadeTransition
        );

        parallelTransition.setOnFinished(event1 -> {
            circleRipple.setOpacity(0.0);
            circleRipple.setRadius(0.1);
        });

        this.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> {
            parallelTransition.stop();
            parallelTransition.getOnFinished().handle(null);

            circleRipple.setCenterX(event.getX());
            circleRipple.setCenterY(event.getY());

            // Recalculate ripple size if size of button from last time was changed
            if (getWidth() != lastRippleWidth || getHeight() != lastRippleHeight)
            {
                lastRippleWidth = getWidth();
                lastRippleHeight = getHeight();

                rippleClip.setWidth(lastRippleWidth);
                rippleClip.setHeight(lastRippleHeight);

                try {
                    rippleClip.setArcHeight(this.getBackground().getFills().get(0).getRadii().getTopLeftHorizontalRadius());
                    rippleClip.setArcWidth(this.getBackground().getFills().get(0).getRadii().getTopLeftHorizontalRadius());
                    circleRipple.setClip(rippleClip);
                } catch (Exception e) {

                }

                // Getting 45% of longest button's length, because we want edge of ripple effect always visible
                double circleRippleRadius = Math.max(getHeight(), getWidth()) * 0.45;
                final KeyValue keyValue = new KeyValue(circleRipple.radiusProperty(), circleRippleRadius, Interpolator.EASE_OUT);
                final KeyFrame keyFrame = new KeyFrame(rippleDuration, keyValue);
                scaleRippleTimeline.getKeyFrames().clear();
                scaleRippleTimeline.getKeyFrames().add(keyFrame);
            }

            parallelTransition.playFromStart();
        });
    }
 
Example #15
Source File: MaterialDesignToggleButton.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
private void createRippleEffect() {
        circleRipple = new Circle(0.1, rippleColor);
        circleRipple.setOpacity(0.0);
        // Optional box blur on ripple - smoother ripple effect
//        circleRipple.setEffect(new BoxBlur(3, 3, 2));

        // Fade effect bit longer to show edges on the end
        final FadeTransition fadeTransition = new FadeTransition(rippleDuration, circleRipple);
        fadeTransition.setInterpolator(Interpolator.EASE_OUT);
        fadeTransition.setFromValue(1.0);
        fadeTransition.setToValue(0.0);

        final Timeline scaleRippleTimeline = new Timeline();

        final SequentialTransition parallelTransition = new SequentialTransition();
        parallelTransition.getChildren().addAll(
                scaleRippleTimeline,
                fadeTransition
        );

        parallelTransition.setOnFinished(event1 -> {
            circleRipple.setOpacity(0.0);
            circleRipple.setRadius(0.1);
        });

        this.addEventHandler(MouseEvent.MOUSE_EXITED, event -> {
        	this.setCursor(Cursor.DEFAULT);
        });

        this.addEventHandler(MouseEvent.MOUSE_ENTERED, event -> {
        	this.setCursor(Cursor.HAND);
        });


        this.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> {
            parallelTransition.stop();
            parallelTransition.getOnFinished().handle(null);

            circleRipple.setCenterX(event.getX());
            circleRipple.setCenterY(event.getY());

            // Recalculate ripple size if size of button from last time was changed
            if (getWidth() != lastRippleWidth || getHeight() != lastRippleHeight)
            {
                lastRippleWidth = getWidth();
                lastRippleHeight = getHeight();

                rippleClip.setWidth(lastRippleWidth);
                rippleClip.setHeight(lastRippleHeight);

                try {
                    rippleClip.setArcHeight(this.getBackground().getFills().get(0).getRadii().getTopLeftHorizontalRadius());
                    rippleClip.setArcWidth(this.getBackground().getFills().get(0).getRadii().getTopLeftHorizontalRadius());
                    circleRipple.setClip(rippleClip);
                } catch (Exception e) {

                }

                // Getting 45% of longest button's length, because we want edge of ripple effect always visible
                double circleRippleRadius = Math.max(getHeight(), getWidth()) * 0.45;
                final KeyValue keyValue = new KeyValue(circleRipple.radiusProperty(), circleRippleRadius, Interpolator.EASE_OUT);
                final KeyFrame keyFrame = new KeyFrame(rippleDuration, keyValue);
                scaleRippleTimeline.getKeyFrames().clear();
                scaleRippleTimeline.getKeyFrames().add(keyFrame);
            }

            parallelTransition.playFromStart();
        });
    }
 
Example #16
Source File: RippleEffect.java    From pmd-designer with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RippleEffect(ReadOnlyDoubleProperty containerWidth,
                    ReadOnlyDoubleProperty containerHeight,
                    Supplier<Background> containerBackground) {
    circleRipple = new Circle(0.1, rippleColor);
    circleRipple.setOpacity(0.0);
    // Optional box blur on ripple - smoother ripple effect
    //circleRipple.setEffect(new BoxBlur(3, 3, 2));
    // Fade effect bit longer to show edges on the end of animation
    final FadeTransition fadeTransition = new FadeTransition(rippleDuration, circleRipple);
    fadeTransition.setInterpolator(Interpolator.EASE_OUT);
    fadeTransition.setFromValue(1.0);
    fadeTransition.setToValue(0.0);
    final Timeline scaleRippleTimeline = new Timeline();
    final SequentialTransition parallelTransition = new SequentialTransition();
    parallelTransition.getChildren().addAll(
        scaleRippleTimeline,
        fadeTransition
    );
    // When ripple transition is finished then reset circleRipple to starting point
    parallelTransition.setOnFinished(event -> {
        circleRipple.setOpacity(0.0);
        circleRipple.setRadius(0.1);
    });
    this.handler = event -> {
        parallelTransition.stop();
        // Manually fire finish event
        parallelTransition.getOnFinished().handle(null);
        circleRipple.setCenterX(event.getX());
        circleRipple.setCenterY(event.getY());
        // Recalculate ripple size if size of button from last time was changed
        if (containerWidth.get() != lastRippleWidth || containerHeight.get() != lastRippleHeight) {
            lastRippleWidth = containerWidth.get();
            lastRippleHeight = containerHeight.get();
            rippleClip.setWidth(lastRippleWidth);
            rippleClip.setHeight(lastRippleHeight);
            try {
                rippleClip.setArcHeight(containerBackground.get().getFills().get(0).getRadii().getTopLeftHorizontalRadius());
                rippleClip.setArcWidth(containerBackground.get().getFills().get(0).getRadii().getTopLeftHorizontalRadius());
                circleRipple.setClip(rippleClip);
            } catch (Exception ignored) {
                // try block because of possible null of Background, fills ...
            }
            // Getting 45% of longest button's length, because we want edge of ripple effect always visible
            double circleRippleRadius = Math.max(containerHeight.get(), containerWidth.get()) * 0.45;
            final KeyValue keyValue = new KeyValue(circleRipple.radiusProperty(), circleRippleRadius, Interpolator.EASE_OUT);
            final KeyFrame keyFrame = new KeyFrame(rippleDuration, keyValue);
            scaleRippleTimeline.getKeyFrames().clear();
            scaleRippleTimeline.getKeyFrames().add(keyFrame);
        }
        parallelTransition.playFromStart();
    };
}
 
Example #17
Source File: FadeAnimation.java    From JavaFX-Chat with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Initializes a fade type animation on a stage
 * @param customStage The stage associate the fade animation with
 */
public FadeAnimation(CustomStage customStage) {

    this.stage = customStage;

    //It wouldn't allow me to play embedded animations so I had to create two separate
    //Instances so I could play sequentially and individually.

    showAnimation = setupShowAnimation();
    dismissAnimation = setupDismissAnimation();

    sq = new SequentialTransition(setupShowAnimation(), setupDismissAnimation());
}
 
Example #18
Source File: FarCry4Loading.java    From FXTutorials with MIT License 2 votes vote down vote up
public LoadingArc() {
    Arc arc = new Arc();

    arc.setCenterX(25);
    arc.setCenterY(25);
    arc.setRadiusX(25.0f);
    arc.setRadiusY(25.0f);
    arc.setLength(30.0f);
    arc.setStrokeWidth(5);

    Stop[] stops = new Stop[] { new Stop(0, Color.WHITE), new Stop(1, Color.BLUE)};
    LinearGradient lg1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);

    arc.setStroke(lg1);

    Rectangle rect = new Rectangle(50, 50);
    rect.setFill(null);
    rect.setStroke(Color.RED);

    getChildren().addAll(rect, arc);


    double time = 0.75;

    Rotate r = new Rotate(0, 25, 25);
    arc.getTransforms().add(r);
    //arc.getTransforms().add(new Scale(-1, 1, 25, 25));

    Timeline timeline = new Timeline();
    KeyFrame kf2 = new KeyFrame(Duration.seconds(time), new KeyValue(r.angleProperty(), 270));


    timeline.getKeyFrames().addAll(kf2);

    Timeline timeline3 = new Timeline(new KeyFrame(Duration.seconds(time), new KeyValue(r.angleProperty(), 360)));


    SequentialTransition st = new SequentialTransition(timeline, timeline3);
    st.setCycleCount(Timeline.INDEFINITE);
    st.setInterpolator(Interpolator.EASE_BOTH);
    st.play();

    //////////

    Timeline timeline2 = new Timeline();
    timeline2.setAutoReverse(true);
    timeline2.setCycleCount(Timeline.INDEFINITE);


    KeyFrame kf = new KeyFrame(Duration.seconds(time), new KeyValue(arc.lengthProperty(), 270, Interpolator.EASE_BOTH));

    timeline2.getKeyFrames().add(kf);
    timeline2.play();
}