Example usage for javafx.animation ScaleTransition ScaleTransition

List of usage examples for javafx.animation ScaleTransition ScaleTransition

Introduction

In this page you can find the example usage for javafx.animation ScaleTransition ScaleTransition.

Prototype

public ScaleTransition(Duration duration, Node node) 

Source Link

Document

The constructor of ScaleTransition

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 200);
    stage.setScene(scene);/* www.j  a va  2  s. com*/

    Rectangle rect = new Rectangle(100, 40, 100, 100);
    rect.setArcHeight(50);
    rect.setArcWidth(50);
    rect.setFill(Color.VIOLET);

    ScaleTransition st = new ScaleTransition(Duration.millis(2000), rect);
    st.setByX(1.5f);
    st.setByY(1.5f);
    st.setAutoReverse(true);

    st.play();

    root.getChildren().add(rect);

    stage.show();

}

From source file:org.noroomattheinn.visibletesla.LocationController.java

private Animation animateBlip() {
    final Circle core = new Circle(572, 360, 5);
    final Circle blip = new Circle(572, 360, 5);
    final Circle outline = new Circle(572, 360, 5);
    Duration blipTime = Duration.seconds(1.5);
    Duration interBlipTime = Duration.seconds(0.5);

    core.setFill(Color.BLUE);/*from  www  .j  a  va 2s.  c  o  m*/
    blip.setFill(Color.LIGHTBLUE);
    outline.setFill(Color.TRANSPARENT);
    outline.setStroke(Color.DARKBLUE);
    outline.setStrokeWidth(0.25);

    root.getChildren().addAll(blip, core, outline);

    FadeTransition fadeBlip = new FadeTransition(blipTime, blip);
    fadeBlip.setFromValue(0.8);
    fadeBlip.setToValue(0.0);

    ScaleTransition scaleBlip = new ScaleTransition(blipTime, blip);
    scaleBlip.setFromX(1);
    scaleBlip.setToX(4);
    scaleBlip.setFromY(1);
    scaleBlip.setToY(4);

    FadeTransition fadeOutline = new FadeTransition(blipTime, outline);
    fadeOutline.setFromValue(1.0);
    fadeOutline.setToValue(0.0);

    ScaleTransition scaleOutline = new ScaleTransition(blipTime, outline);
    scaleOutline.setFromX(1);
    scaleOutline.setToX(4);
    scaleOutline.setFromY(1);
    scaleOutline.setToY(4);

    SequentialTransition sequence = new SequentialTransition(
            new ParallelTransition(fadeBlip, scaleBlip, scaleOutline, fadeOutline),
            new PauseTransition(interBlipTime));
    sequence.setCycleCount(Timeline.INDEFINITE);
    sequence.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent t) {
            core.setVisible(false);
            blip.setVisible(false);
            outline.setVisible(false);
        }
    });

    sequence.play();
    return sequence;
}