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

The following examples show how to use javafx.animation.RotateTransition#play() . 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: FarCry4Loading.java    From FXTutorials with MIT License 6 votes vote down vote up
public LoadingCircle() {
    Circle circle = new Circle(20);
    circle.setFill(null);
    circle.setStroke(Color.WHITE);
    circle.setStrokeWidth(2);

    Rectangle rect = new Rectangle(20, 20);

    Shape shape = Shape.subtract(circle, rect);
    shape.setFill(Color.WHITE);

    getChildren().add(shape);

    animation = new RotateTransition(Duration.seconds(2.5), this);
    animation.setByAngle(-360);
    animation.setInterpolator(Interpolator.LINEAR);
    animation.setCycleCount(Animation.INDEFINITE);
    animation.play();
}
 
Example 2
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 3
Source File: DataViewerSample.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private static Pane getDemoPane() {
    final Rectangle rect = new Rectangle(-130, -40, 80, 80);
    rect.setFill(Color.BLUE);
    final Circle circle = new Circle(0, 0, 40);
    circle.setFill(Color.GREEN);
    final Polygon triangle = new Polygon(60, -40, 120, 0, 50, 40);
    triangle.setFill(Color.RED);

    final Group group = new Group(rect, circle, triangle);
    group.setTranslateX(300);
    group.setTranslateY(200);

    final RotateTransition rotateTransition = new RotateTransition(Duration.millis(4000), group);
    rotateTransition.setByAngle(3.0 * 360);
    rotateTransition.setCycleCount(Animation.INDEFINITE);
    rotateTransition.setAutoReverse(true);
    rotateTransition.play();

    final RotateTransition rotateTransition1 = new RotateTransition(Duration.millis(1000), rect);
    rotateTransition1.setByAngle(360);
    rotateTransition1.setCycleCount(Animation.INDEFINITE);
    rotateTransition1.setAutoReverse(false);
    rotateTransition1.play();

    final RotateTransition rotateTransition2 = new RotateTransition(Duration.millis(1000), triangle);
    rotateTransition2.setByAngle(360);
    rotateTransition2.setCycleCount(Animation.INDEFINITE);
    rotateTransition2.setAutoReverse(false);
    rotateTransition2.play();
    group.setManaged(true);

    HBox.setHgrow(group, Priority.ALWAYS);
    final HBox box = new HBox(group);
    VBox.setVgrow(box, Priority.ALWAYS);
    box.setId("demoPane");
    return box;
}
 
Example 4
Source File: GameView.java    From CrazyAlpha with GNU General Public License v2.0 5 votes vote down vote up
public static void makeRotateTransition(Node node, int mills, double byAngle) {
    RotateTransition rt = new RotateTransition(Duration.millis(mills));
    rt.setByAngle(byAngle);
    rt.setCycleCount(Animation.INDEFINITE);
    rt.setNode(node);
    rt.play();
}
 
Example 5
Source File: GameView.java    From CrazyAlpha with GNU General Public License v2.0 5 votes vote down vote up
public static void makeRotateTransition(Node node, int mills, double fromAngle, double toAngle, boolean autoReverse) {
    RotateTransition rt = new RotateTransition(Duration.millis(mills));
    rt.setFromAngle(fromAngle);
    rt.setToAngle(toAngle);
    rt.setAutoReverse(autoReverse);
    rt.setCycleCount(Animation.INDEFINITE);
    rt.setNode(node);
    rt.play();
}
 
Example 6
Source File: FXMLController.java    From JavaFX-Tutorial-Codes with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the controller class.
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    RotateTransition transition = new RotateTransition(Duration.seconds(5), arc1);
    transition.setAxis(new Point3D(50, 50, 0));
    transition.setByAngle(200);
    transition.play();
}
 
Example 7
Source File: Dialogs.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
private static void setRotate(Shape s, boolean reverse, double angle, int duration) {
    RotateTransition r = new RotateTransition(Duration.seconds(duration), s);
    r.setAutoReverse(reverse);
    r.setDelay(Duration.ZERO);
    r.setRate(3.0);
    r.setCycleCount(RotateTransition.INDEFINITE);
    r.setByAngle(angle);
    r.play();
}
 
Example 8
Source File: SpinningGlobe.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void rotateGlobe() {
 rt = new RotateTransition(Duration.seconds(OrbitInfo.SOLAR_DAY/500D), globe.getWorld());
    //rt.setByAngle(360);
    rt.setInterpolator(Interpolator.LINEAR);
    rt.setCycleCount(Animation.INDEFINITE);
    rt.setAxis(Rotate.Y_AXIS);
    rt.setFromAngle(360);
    rt.setToAngle(0);
    rt.play();
}
 
Example 9
Source File: Dice.java    From FXTutorials with MIT License 5 votes vote down vote up
public void roll() {
    RotateTransition rt = new RotateTransition(Duration.seconds(1), this);
    rt.setFromAngle(0);
    rt.setToAngle(360);
    rt.setOnFinished(event -> {
        valueProperty.set((int)(Math.random() * (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE);
    });
    rt.play();
}
 
Example 10
Source File: HangmanMain.java    From FXTutorials with MIT License 5 votes vote down vote up
public void show() {
    RotateTransition rt = new RotateTransition(Duration.seconds(1), bg);
    rt.setAxis(Rotate.Y_AXIS);
    rt.setToAngle(180);
    rt.setOnFinished(event -> text.setVisible(true));
    rt.play();
}
 
Example 11
Source File: DockCommandsBox.java    From AnchorFX with GNU Lesser General Public License v3.0 5 votes vote down vote up
void notifyCloseAction() {
    if (isMenuOpen) {
        isMenuOpen = false;

        RotateTransition rotate = new RotateTransition(Duration.seconds(0.2), menuButton.getGraphic());
        rotate.setToAngle(0);
        rotate.play();

        hideAction.run();
    }
}
 
Example 12
Source File: DockCommandsBox.java    From AnchorFX with GNU Lesser General Public License v3.0 5 votes vote down vote up
void notifyOpenAction() {
    RotateTransition rotate = new RotateTransition(Duration.seconds(0.2), menuButton.getGraphic());
    rotate.setToAngle(90);
    rotate.play();

    openAction.run();
}
 
Example 13
Source File: Simple3DSphereApp.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public Parent createContent() throws Exception {

        Image dImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-d.jpg").toExternalForm());
        Image nImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-n.jpg").toExternalForm());
        Image sImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-s.jpg").toExternalForm());
        Image siImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-l.jpg").toExternalForm());

        material = new PhongMaterial();
        material.setDiffuseColor(Color.WHITE);
        material.diffuseMapProperty().bind(
                Bindings.when(diffuseMap).then(dImage).otherwise((Image) null));
        material.setSpecularColor(Color.TRANSPARENT);
        material.specularMapProperty().bind(
                Bindings.when(specularMap).then(sImage).otherwise((Image) null));
        material.bumpMapProperty().bind(
                Bindings.when(bumpMap).then(nImage).otherwise((Image) null));
        material.selfIlluminationMapProperty().bind(
                Bindings.when(selfIlluminationMap).then(siImage).otherwise((Image) null));

        earth = new Sphere(5);
        earth.setMaterial(material);
        earth.setRotationAxis(Rotate.Y_AXIS);


        // Create and position camera
        PerspectiveCamera camera = new PerspectiveCamera(true);
        camera.getTransforms().addAll(
                new Rotate(-20, Rotate.Y_AXIS),
                new Rotate(-20, Rotate.X_AXIS),
                new Translate(0, 0, -20));

        sun = new PointLight(Color.rgb(255, 243, 234));
        sun.translateXProperty().bind(sunDistance.multiply(-0.82));
        sun.translateYProperty().bind(sunDistance.multiply(-0.41));
        sun.translateZProperty().bind(sunDistance.multiply(-0.41));
        sun.lightOnProperty().bind(sunLight);

        AmbientLight ambient = new AmbientLight(Color.rgb(1, 1, 1));

        // Build the Scene Graph
        Group root = new Group();
        root.getChildren().add(camera);
        root.getChildren().add(earth);
        root.getChildren().add(sun);
        root.getChildren().add(ambient);

        RotateTransition rt = new RotateTransition(Duration.seconds(24), earth);
        rt.setByAngle(360);
        rt.setInterpolator(Interpolator.LINEAR);
        rt.setCycleCount(Animation.INDEFINITE);
        rt.play();

        // Use a SubScene
        SubScene subScene = new SubScene(root, 400, 300, true, SceneAntialiasing.BALANCED);
        subScene.setFill(Color.TRANSPARENT);
        subScene.setCamera(camera);

        return new Group(subScene);
    }