Java Code Examples for javafx.animation.TranslateTransition#setToX()
The following examples show how to use
javafx.animation.TranslateTransition#setToX() .
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 |
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 |
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: SpaceInvadersController.java From FXGLGames with MIT License | 6 votes |
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 4
Source File: SpaceInvadersController.java From FXGLGames with MIT License | 6 votes |
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 5
Source File: LoginFader.java From iliasDownloaderTool with GNU General Public License v2.0 | 6 votes |
private void fade(double c, GridPane login) { TranslateTransition t1 = new TranslateTransition(Duration.millis(500), dashboard.getActionBar()); t1.setByX(c); TranslateTransition t2 = new TranslateTransition(Duration.millis(500), login); t2.setByX(c); t2.setFromX(login.getLayoutX() - c); t2.setToX(login.getLayoutX()); p.getChildren().addAll(t1, t2); p.setInterpolator(new Interpolator() { @Override protected double curve(double t) { return Math.pow(t, 2); } }); p.play(); if (login.getOpacity() == 0) { login.setOpacity(1); } else { login.setOpacity(0); } }
Example 6
Source File: SlideShowController.java From FXMaterialDesign with MIT License | 5 votes |
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 7
Source File: SlideShowController.java From FXMaterialDesign with MIT License | 5 votes |
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 8
Source File: StepperTouchController.java From FXMaterialDesign with MIT License | 5 votes |
@FXML private void onAdd() { if(Integer.parseInt(txtCounter.getText()) == 9) return; TranslateTransition tt = new TranslateTransition(Duration.millis(500), paneCounter); tt.setToX(115); tt.play(); tt.setOnFinished(e -> { txtCounter.setText(String.valueOf(Integer.parseInt(txtCounter.getText()) + 1)); TranslateTransition tt2 = new TranslateTransition(Duration.millis(500), paneCounter); tt2.setToX(0); tt2.play(); }); }
Example 9
Source File: StepperTouchController.java From FXMaterialDesign with MIT License | 5 votes |
@FXML private void onSub() { if(Integer.parseInt(txtCounter.getText()) == 0) return; TranslateTransition tt = new TranslateTransition(Duration.millis(500), paneCounter); tt.setToX(-115); tt.play(); tt.setOnFinished(e -> { txtCounter.setText(String.valueOf(Integer.parseInt(txtCounter.getText()) - 1)); TranslateTransition tt2 = new TranslateTransition(Duration.millis(500), paneCounter); tt2.setToX(0); tt2.play(); }); }
Example 10
Source File: SlidingListTile.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Reset position of tile with smooth transition */ public void resetTilePosition() { TranslateTransition transition = new TranslateTransition(Duration.millis(300), tile); transition.setInterpolator(Interpolator.EASE_OUT); transition.setFromX(tile.getTranslateX()); transition.setToX(0); transition.playFromStart(); }
Example 11
Source File: BackgroundController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void initialize() { TranslateTransition translateTransition = new TranslateTransition(Duration.millis(10000), background1); translateTransition.setFromX(0); translateTransition.setToX(-1 * BACKGROUND_WIDTH); translateTransition.setInterpolator(Interpolator.LINEAR); TranslateTransition translateTransition2 = new TranslateTransition(Duration.millis(10000), background2); translateTransition2.setFromX(0); translateTransition2.setToX(-1 * BACKGROUND_WIDTH); translateTransition2.setInterpolator(Interpolator.LINEAR); parallelTransition = new ParallelTransition( translateTransition, translateTransition2 ); parallelTransition.setCycleCount(Animation.INDEFINITE); // // Sets the label of the Button based on the animation state // parallelTransition.statusProperty().addListener((obs, oldValue, newValue) -> { if( newValue == Animation.Status.RUNNING ) { btnControl.setText( "||" ); } else { btnControl.setText( ">" ); } }); }
Example 12
Source File: MainNode.java From helloiot with GNU General Public License v3.0 | 4 votes |
public void initialize() { if (appexitbutton) { exitbutton.setVisible(true); exitbutton.setGraphic(IconBuilder.create(IconFontGlyph.FA_SOLID_POWER_OFF, 18.0).styleClass("icon-fill").build()); exitbutton.setOnAction(ev -> { rootpane.getScene().getWindow().hide(); }); } else { exitbutton.setVisible(false); headerbox.getChildren().remove(exitbutton); exitbutton = null; } menubutton.setGraphic(IconBuilder.create(IconFontGlyph.FA_SOLID_BARS, 18.0).styleClass("icon-fill").build()); menubutton.setDisable(true); timeindicator = new TimeIndicator(resources.getString("clock.pattern")); indicators.getChildren().add(timeindicator.getNode()); listpagesgray.setBackground(new Background(new BackgroundFill(Color.gray(0.5, 0.75), CornerRadii.EMPTY, Insets.EMPTY))); FadeTransition ft = new FadeTransition(Duration.millis(300), scrollpages); ft.setFromValue(0.0); ft.setToValue(1.0); ft.setInterpolator(Interpolator.LINEAR); FadeTransition ft2 = new FadeTransition(Duration.millis(300), listpagesgray); ft2.setFromValue(0.0); ft2.setToValue(1.0); ft2.setInterpolator(Interpolator.LINEAR); TranslateTransition tt = new TranslateTransition(Duration.millis(300), scrollpages); tt.setFromX(-scrollpages.prefWidth(0)); tt.setToX(0.0); tt.setInterpolator(Interpolator.EASE_BOTH); TranslateTransition tt2 = new TranslateTransition(Duration.millis(300), appcontainer); tt2.setFromX(0.0); tt2.setToX(scrollpages.prefWidth(0)); tt2.setInterpolator(Interpolator.EASE_BOTH); listpagestransition = new ParallelTransition(ft, ft2, tt, tt2); listpagestransition.setRate(-1.0); listpagestransition.setOnFinished((ActionEvent actionEvent) -> { if (listpagestransition.getCurrentTime().equals(Duration.ZERO)) { scrollpages.setVisible(false); listpagesgray.setVisible(false); } }); }
Example 13
Source File: ImprovedBackgroundController.java From examples-javafx-repos1 with Apache License 2.0 | 4 votes |
@FXML public void initialize() { TranslateTransition background1Transition = new TranslateTransition(Duration.millis(8000), background1); background1Transition.setFromX(0); background1Transition.setToX(-1 * BACKGROUND_WIDTH); background1Transition.setInterpolator(Interpolator.LINEAR); TranslateTransition background2Transition = new TranslateTransition(Duration.millis(8000), background2); background2Transition.setFromX(0); background2Transition.setToX(-1 * BACKGROUND_WIDTH); background2Transition.setInterpolator(Interpolator.LINEAR); ParallelTransition backgroundWrapper = new ParallelTransition( background1Transition, background2Transition ); backgroundWrapper.setCycleCount(Animation.INDEFINITE); TranslateTransition clouds1Transition = new TranslateTransition(Duration.millis(20000), clouds1); clouds1Transition.setFromX(0); clouds1Transition.setToX(-1 * BACKGROUND_WIDTH); clouds1Transition.setInterpolator(Interpolator.LINEAR); TranslateTransition clouds2Transition = new TranslateTransition(Duration.millis(20000), clouds2); clouds2Transition.setFromX(0); clouds2Transition.setToX(-1 * BACKGROUND_WIDTH); clouds2Transition.setInterpolator(Interpolator.LINEAR); ParallelTransition cloudsWrapper = new ParallelTransition( clouds1Transition, clouds2Transition ); cloudsWrapper.setCycleCount(Animation.INDEFINITE); parallelTransition = new ParallelTransition( backgroundWrapper, cloudsWrapper ); parallelTransition.setCycleCount(Animation.INDEFINITE); // // Sets the label of the Button based on the animation state // parallelTransition.statusProperty().addListener((obs, oldValue, newValue) -> { if( newValue == Animation.Status.RUNNING ) { btnControl.setText( "||" ); } else { btnControl.setText( ">" ); } }); }
Example 14
Source File: Main.java From FXTutorials with MIT License | 4 votes |
public void show() { setVisible(true); TranslateTransition tt = new TranslateTransition(Duration.seconds(0.5), this); tt.setToX(0); tt.play(); }
Example 15
Source File: Main.java From FXTutorials with MIT License | 4 votes |
public void hide() { TranslateTransition tt = new TranslateTransition(Duration.seconds(0.5), this); tt.setToX(-300); tt.setOnFinished(event -> setVisible(false)); tt.play(); }
Example 16
Source File: Tutorial.java From FXTutorials with MIT License | 4 votes |
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); }