Java Code Examples for javafx.animation.TranslateTransition#setAutoReverse()

The following examples show how to use javafx.animation.TranslateTransition#setAutoReverse() . 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: TranslateTransitionSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TranslateTransitionSample() {
    super(400,40);
    Circle circle = new Circle(20, Color.CRIMSON);
    circle.setTranslateX(20);
    circle.setTranslateY(20);
    getChildren().add(circle);
    translateTransition = new TranslateTransition(Duration.seconds(4),circle);
    translateTransition.setFromX(20);
    translateTransition.setToX(380);
    translateTransition.setCycleCount(Timeline.INDEFINITE);
    translateTransition.setAutoReverse(true);        
    translateTransition = TranslateTransitionBuilder.create()
            .duration(Duration.seconds(4))
            .node(circle)
            .fromX(20)
            .toX(380)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
 
Example 2
Source File: TranslateTransitionSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TranslateTransitionSample() {
    super(400,40);
    Circle circle = new Circle(20, Color.CRIMSON);
    circle.setTranslateX(20);
    circle.setTranslateY(20);
    getChildren().add(circle);
    translateTransition = new TranslateTransition(Duration.seconds(4),circle);
    translateTransition.setFromX(20);
    translateTransition.setToX(380);
    translateTransition.setCycleCount(Timeline.INDEFINITE);
    translateTransition.setAutoReverse(true);        
    translateTransition = TranslateTransitionBuilder.create()
            .duration(Duration.seconds(4))
            .node(circle)
            .fromX(20)
            .toX(380)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
 
Example 3
Source File: MKXMenuApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Node createMiddleContent() {
    String title = "MKX Menu App";
    HBox letters = new HBox(0);
    letters.setAlignment(Pos.CENTER);
    for (int i = 0; i < title.length(); i++) {
        Text letter = new Text(title.charAt(i) + "");
        letter.setFont(FONT);
        letter.setFill(Color.WHITE);
        letters.getChildren().add(letter);

        TranslateTransition tt = new TranslateTransition(Duration.seconds(2), letter);
        tt.setDelay(Duration.millis(i * 50));
        tt.setToY(-25);
        tt.setAutoReverse(true);
        tt.setCycleCount(TranslateTransition.INDEFINITE);
        tt.play();
    }

    return letters;
}
 
Example 4
Source File: SlideShowController.java    From FXMaterialDesign with MIT License 5 votes vote down vote up
private void nextSlide(byte indexOfSlide) {
    lblPageNumber.setText(indexOfSlide + lblPageNumber.getText().substring(1));
    switch (indexOfSlide) {
        case 2:
            slide2.setVisible(true);
            TranslateTransition tt1 = new TranslateTransition(Duration.millis(800));
            tt1.setNode(slide1);
            tt1.setFromX(0.0);
            tt1.setToX(-384.0);
            tt1.setAutoReverse(false);
            tt1.play();
            
            tt1.setOnFinished(e -> {
                slide1.setVisible(false);
            });
            btnPrevious.setId("btn2");
            btnNext.setId("btn2");
            break;
        case 3:
            slide3.setVisible(true);
            TranslateTransition tt2 = new TranslateTransition(Duration.millis(800));
            tt2.setNode(slide2);
            tt2.setFromX(0.0);
            tt2.setToX(-384.0);
            tt2.setAutoReverse(false);
            tt2.play();
            
            tt2.setOnFinished(e -> {
                slide2.setVisible(false);
            });
            btnPrevious.setId("btn3");
            btnNext.setId("btn3");
            break;
            
    }
}
 
Example 5
Source File: SlideShowController.java    From FXMaterialDesign with MIT License 5 votes vote down vote up
private void previousSlide(byte indexOfSlide) {
    lblPageNumber.setText(indexOfSlide + lblPageNumber.getText().substring(1));
    switch (indexOfSlide) {
        case 1:
            slide1.setVisible(true);
            TranslateTransition tt1 = new TranslateTransition(Duration.millis(800));
            tt1.setNode(slide1);
            tt1.setFromX(-384.0);
            tt1.setToX(0.0);
            tt1.setAutoReverse(false);
            tt1.play();
            
            tt1.setOnFinished(e -> {
                slide2.setVisible(false);
                btnPrevious.setId("btn1");
                btnNext.setId("btn1");
            });
            break;
        case 2:
            slide2.setVisible(true);
            TranslateTransition tt2 = new TranslateTransition(Duration.millis(800));
            tt2.setNode(slide2);
            tt2.setFromX(-384.0);
            tt2.setToX(0.0);
            tt2.setAutoReverse(false);
            tt2.play();
            
            tt2.setOnFinished(e -> {
                slide3.setVisible(false);
                btnPrevious.setId("btn2");
                btnNext.setId("btn2");
            });
            break;
    }
}
 
Example 6
Source File: Tutorial.java    From FXTutorials with MIT License 4 votes vote down vote up
private Parent createContent() {
    Cube c = new Cube(1, Color.GREEN);
    c.setTranslateX(-1);
    c.setRotationAxis(Rotate.Y_AXIS);
    c.setRotate(45);

    Cube c2 = new Cube(1, Color.BLUE);
    c2.setTranslateX(1);
    c2.setRotationAxis(Rotate.Y_AXIS);
    c2.setRotate(45);

    Cube c3 = new Cube(1, Color.RED);
    c3.setRotationAxis(Rotate.Y_AXIS);
    c3.setRotate(45);

    camera = new PerspectiveCamera(true);
    translate = new Translate(0, 0, -10);
    rotate = new Rotate(0, new Point3D(0, 1, 0));
    camera.getTransforms().addAll(translate, rotate);

    PointLight light = new PointLight(Color.WHITE);
    light.setTranslateX(3);
    light.setTranslateZ(-5);

    TranslateTransition tt = new TranslateTransition(Duration.seconds(2), light);
    tt.setFromX(-3);
    tt.setToX(3);
    tt.setAutoReverse(true);
    tt.setCycleCount(Animation.INDEFINITE);

    AmbientLight globalLight = new AmbientLight(Color.WHITE.deriveColor(0, 1, 0.2, 1));


    worldRoot.getChildren().addAll(c, c2, c3, globalLight, light);

    SubScene subScene = new SubScene(worldRoot, 800, 600, true, SceneAntialiasing.BALANCED);
    subScene.setCamera(camera);

    tt.play();

    return new Group(new Rectangle(800, 600), subScene);
}