private ParallelTransition createFadeTransition(final ImageView iv, final Image img) { FadeTransition fadeOutTransition = new FadeTransition(Duration.seconds(.25), iv); fadeOutTransition.setFromValue(1.0); fadeOutTransition.setToValue(0.0); fadeOutTransition.setOnFinished( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { iv.setImage(img); } }); FadeTransition fadeInTransition = new FadeTransition(Duration.seconds(.25), iv); fadeInTransition.setFromValue(0.0); fadeInTransition.setToValue(1.0); /* * FadeTransition fadeFlyCare = FadeOutTransition(ivFlyCard); */ ParallelTransition parallelTransition = new ParallelTransition(); parallelTransition.getChildren().addAll(fadeOutTransition, fadeInTransition); return parallelTransition; }
private void snapshotTweet(final Parent tweetContainer) throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); // render the chart in an offscreen scene (scene is used to allow css processing) and snapshot // it to an image. // the snapshot is done in runlater as it must occur on the javafx application thread. Platform.runLater( () -> { // animation obsFadeOutWords.stream().forEach(w -> parallelWords.getChildren().add(fadeOut(w))); obsFadeInWords.stream().forEach(w -> parallelTexts.getChildren().add(fadeIn(w))); sequential.setOnFinished( e -> { parallelWords.getChildren().clear(); parallelTexts.getChildren().clear(); latch.countDown(); }); sequential.play(); }); latch.await(); }
private SequentialTransition createTransition( final Point2D pntStartPoint, final Point2D pntEndPoint, ImageView imView) { imView = new ImageView( new Image(getClass().getResourceAsStream("/res/img/b1fh.png"), 75, 75, true, true)); imView.setX(pntStartPoint.getX()); imView.setY(pntStartPoint.getY() - 30); APMainScreen.getChildren().add(imView); TranslateTransition translateTransition = new TranslateTransition(Duration.millis(300), imView); translateTransition.setFromX(0); translateTransition.setToX(pntEndPoint.getX() - pntStartPoint.getX()); translateTransition.setFromY(0); translateTransition.setToY(pntEndPoint.getY() - pntStartPoint.getY()); translateTransition.setCycleCount(1); translateTransition.setAutoReverse(false); int rnd = randInt(1, 3); RotateTransition rotateTransition = new RotateTransition(Duration.millis(150), imView); rotateTransition.setByAngle(90F); rotateTransition.setCycleCount(rnd); rotateTransition.setAutoReverse(false); ParallelTransition parallelTransition = new ParallelTransition(); parallelTransition.getChildren().addAll(translateTransition, rotateTransition); SequentialTransition seqTrans = new SequentialTransition(); seqTrans.getChildren().addAll(parallelTransition); final ImageView ivRemove = imView; seqTrans.setOnFinished( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { APMainScreen.getChildren().remove(ivRemove); } }); return seqTrans; }
private ParallelTransition createTransition( final ImageView iv, final ImageView ivStart, final Image img) { FadeTransition fadeOutTransition = new FadeTransition(Duration.seconds(.25), iv); fadeOutTransition.setFromValue(1.0); fadeOutTransition.setToValue(0.0); fadeOutTransition.setOnFinished( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { iv.setImage(img); ; } }); FadeTransition fadeInTransition = new FadeTransition(Duration.seconds(.25), iv); fadeInTransition.setFromValue(0.0); fadeInTransition.setToValue(1.0); /* TranslateTransition translateTransition = new TranslateTransition(Duration.millis(500), ivStart); translateTransition.setFromX(0); translateTransition.setToX(ivX - ivStartX1); translateTransition.setFromY(0); translateTransition.setToY(ivY - ivStartY1); translateTransition.setCycleCount(2); translateTransition.setAutoReverse(false); */ // RotateTransition rotateTransition = new RotateTransition(Duration.millis(150), ivStart); // rotateTransition.setByAngle(90f); // rotateTransition.setCycleCount(1); // rotateTransition.setAutoReverse(false); ParallelTransition parallelTransition = new ParallelTransition(); parallelTransition.getChildren().addAll(fadeOutTransition, fadeInTransition); return parallelTransition; }