private void onActionSimulateGameMode(EGameMode gameMode) { DebugConsole.getDefault().debug(this.getClass(), "On Action simulate GameMode: " + gameMode.toString()); // NOI18N final SequentialTransition st = new SequentialTransition(); st.setDelay(Duration.millis(125.0d)); final PauseTransition ptStopGameMode = this.onActionStopGameMode(); st.getChildren().add(ptStopGameMode); final FadeTransition ftHideGameInformations = this.onActionHideGameInformations(); st.getChildren().add(ftHideGameInformations); final FadeTransition ftShowGameInformations = this.onActionShowGameInformations(gameMode); st.getChildren().add(ftShowGameInformations); final PauseTransition ptStartGameMode = this.onActionStartGameMode(gameMode); st.getChildren().add(ptStartGameMode); st.playFromStart(); }
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); }
public CardBox(final Card... CARDS) { super(CARDS); cards = FXCollections.observableArrayList(); cards.addAll(CARDS); firstTime = true; open = new BooleanPropertyBase(false) { @Override protected void invalidated() { handleState(get()); } @Override public Object getBean() { return CardBox.this; } @Override public String getName() { return "open"; } }; cardHandler = e -> handleCardSelect((Card) e.getSource()); selectedCard = cards.size() == 0 ? null : cards.get(cards.size() - 1); openTransition = new ParallelTransition(); closeTransition = new SequentialTransition(); initGraphics(); registerListeners(); }
public void showNotification(String text) { labelNotification.setText(text); labelNotification.setStyle("-fx-text-fill: #FFFFFF; -fx-font-size: 16; -fx-font-weight: bold; -fx-background-color: " + ConvertTo.toRGBHexWithoutOpacity(Colors.BACKGROUND_NOTIFICATION)); FadeTransition fadeIn = new FadeTransition(Duration.millis(200), labelNotification); fadeIn.setFromValue(0.0); fadeIn.setToValue(1.0); FadeTransition fadeOut = new FadeTransition(Duration.millis(400), labelNotification); fadeOut.setFromValue(1.0); fadeOut.setToValue(0.0); fadeOut.setDelay(Duration.millis(3000)); fadeOut.play(); SequentialTransition seqT = new SequentialTransition(fadeIn, fadeOut); seqT.play(); seqT.setOnFinished((a) -> { labelNotification.setStyle("-fx-text-fill: #FFFFFF; -fx-font-size: 16; -fx-font-weight: bold; -fx-background-color: transparent;"); }); }
@Override protected void initController(boolean initialize) { stage.initStyle(StageStyle.TRANSPARENT); FadeTransition ft = new FadeTransition(Duration.millis(500), getStage().getScene().getRoot()); ft.setFromValue(0.0); ft.setToValue(1.0); PauseTransition pt = new PauseTransition(Duration.millis(2000)); FadeTransition ft2 = new FadeTransition(Duration.millis(1000), getRoot()); ft2.setFromValue(1.0); ft2.setToValue(0.0); SequentialTransition st = new SequentialTransition(ft, pt, ft2); st.onFinishedProperty().set(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { closeWindow(); new LobbyController(SplashController.this).showWindow(); } }); st.playFromStart(); }
@Override public void stopWorking(Object key, String endMessage) { Platform.runLater(() -> { if (endMessage == null) { FadeTransition fade = new FadeTransition(Duration.seconds(1)); fade.setFromValue(1); fade.setToValue(0); fade.setOnFinished(event -> { statusLabel.opacityProperty().set(1); statusLabel.setText(null); }); SequentialTransition st = new SequentialTransition(statusLabel, new PauseTransition(Duration.seconds(5)), fade); st.play(); } else { statusLabel.setText(endMessage); workList.addWorkData(key, endMessage); stopWorking(key, null); } workIndicator.setVisible(false); }); }
@Override public void downloadOccured(String url) { Label download = new Label(url); download.getStyleClass().add("download"); downloads.getChildren().add(download); Timeline tlStayShown = new Timeline(); KeyValue kvStayOpaque = new KeyValue(download.opacityProperty(), 1); KeyFrame kfStayOpaque = new KeyFrame(Duration.millis(2000), kvStayOpaque); tlStayShown.getKeyFrames().add(kfStayOpaque); Timeline tlDisappear = new Timeline(); KeyValue kvDisappear = new KeyValue(download.opacityProperty(), 0); KeyFrame kfDisappear = new KeyFrame(Duration.millis(500), kvDisappear); tlDisappear.getKeyFrames().add(kfDisappear); SequentialTransition sequential = new SequentialTransition(tlStayShown, tlDisappear); sequential.setOnFinished((ae) -> downloads.getChildren().remove(download)); sequential.play(); }
@Override public Object eval(Environment env) { final Object c = ((ASTree) condition()).eval(env); if (c instanceof Integer) { final Sprite sprite = env.getSprite(); SequentialTransition st = env.getSequentialTransition(); TranslateTransition tt = new TranslateTransition(Duration.millis(10), sprite); tt.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { sprite.setSpriteCostume((int) c); } }); st.getChildren().add(tt); } return c; }
@Override public Object eval(Environment env) { Sprite sprite = env.getSprite(); SequentialTransition st = env.getSequentialTransition(); ScaleTransition t = new ScaleTransition(); int fromDirection = sprite.getDirection(); t.setFromX(fromDirection); int toDirection = fromDirection * -1; t.setToX(toDirection); t.setNode(sprite); st.getChildren().add(t); sprite.setDirection(toDirection); return null; }
@Override public Object eval(Environment env) { Object c = ((ASTree) condition()).eval(env); if (c instanceof Integer) { Sprite sprite = env.getSprite(); SequentialTransition st = env.getSequentialTransition(); System.out.println(env.getSpeed()); TranslateTransition tt = new TranslateTransition(Duration.millis(env.getSpeed()), sprite); double x = sprite.moveBy((Integer) c); tt.setByX(x); env.setX(sprite.getX() + env.getX() + x); st.getChildren().add(tt); } return c; }
@Override public Object eval(Environment env) { final Object c = ((ASTree) condition()).eval(env); final Sprite sprite = env.getSprite(); SequentialTransition st = env.getSequentialTransition(); TranslateTransition tt = new TranslateTransition(Duration.millis(10), sprite); tt.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { sprite.setSpeechBubble(c.toString()); } }); st.getChildren().add(tt); return c; }
/** * Animation that creates a pop effect when two tiles merge * by increasing the tile scale to 120% at the middle, and then going back to 100% * @param tile to be animated * @return a sequential transition */ private SequentialTransition animateMergedTile(Tile tile) { final ScaleTransition scale0 = new ScaleTransition(ANIMATION_MERGED_TILE, tile); scale0.setToX(1.2); scale0.setToY(1.2); scale0.setInterpolator(Interpolator.EASE_IN); final ScaleTransition scale1 = new ScaleTransition(ANIMATION_MERGED_TILE, tile); scale1.setToX(1.0); scale1.setToY(1.0); scale1.setInterpolator(Interpolator.EASE_OUT); return new SequentialTransition(scale0, scale1); }
private void enter() { this.removeEventHandler(MouseEvent.MOUSE_ENTERED, enterEvent); hand.fireEvent(new net.gazeplay.games.creampie.event.TouchEvent(getCenterX(), getCenterY())); Timeline timeline = new Timeline(); Timeline timeline2 = new Timeline(); timeline.getKeyFrames() .add(new KeyFrame(new Duration(2000), new KeyValue(radiusProperty(), getInitialRadius() * 1.6))); timeline.getKeyFrames() .add(new KeyFrame(new Duration(2000), new KeyValue(rotateProperty(), getRotate() + (360 * 3)))); timeline.getKeyFrames().add(new KeyFrame(new Duration(2000), new KeyValue(visibleProperty(), false))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(radiusProperty(), radius))); Position newPosition = randomPositionGenerator.newRandomPosition(getInitialRadius()); timeline2.getKeyFrames() .add(new KeyFrame(new Duration(1), new KeyValue(centerXProperty(), newPosition.getX()))); timeline2.getKeyFrames() .add(new KeyFrame(new Duration(1), new KeyValue(centerYProperty(), newPosition.getY()))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(fillProperty(), new ImagePattern(pickRandomImage(availableImages), 0, 0, 1, 1, true)))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(rotateProperty(), 0))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1000), new KeyValue(visibleProperty(), true))); SequentialTransition sequence = new SequentialTransition(timeline, timeline2); sequence.play(); sequence.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { anniOff = true; stats.start(); } }); }
private void touch(TouchEvent te) { recomputePosition(); Timeline timeline = new Timeline(); Timeline timeline2 = new Timeline(); timeline.getKeyFrames().add(new KeyFrame(new Duration(200), new KeyValue(hand.heightProperty(), size))); timeline.getKeyFrames().add(new KeyFrame(new Duration(200), new KeyValue(hand.widthProperty(), size))); timeline.getKeyFrames() .add(new KeyFrame(new Duration(2000), new KeyValue(pie.translateXProperty(), te.x - maxSize))); timeline.getKeyFrames() .add(new KeyFrame(new Duration(2000), new KeyValue(pie.translateYProperty(), te.y - maxSize))); timeline.getKeyFrames().add(new KeyFrame(new Duration(2000), new KeyValue(pie.heightProperty(), maxSize * 2))); timeline.getKeyFrames().add(new KeyFrame(new Duration(2000), new KeyValue(pie.widthProperty(), maxSize * 2))); timeline.getKeyFrames() .add(new KeyFrame(new Duration(2000), new KeyValue(pie.rotateProperty(), pie.getRotate() + 360))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(hand.heightProperty(), maxSize))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(hand.widthProperty(), maxSize))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(pie.heightProperty(), size))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(pie.widthProperty(), size))); timeline2.getKeyFrames() .add(new KeyFrame(new Duration(1), new KeyValue(hand.translateXProperty(), handTranslateX))); timeline2.getKeyFrames() .add(new KeyFrame(new Duration(1), new KeyValue(hand.translateYProperty(), handTranslateY))); timeline2.getKeyFrames() .add(new KeyFrame(new Duration(1), new KeyValue(pie.translateXProperty(), pieTranslateX))); timeline2.getKeyFrames() .add(new KeyFrame(new Duration(1), new KeyValue(pie.translateYProperty(), pieTranslateY))); SequentialTransition sequence = new SequentialTransition(timeline, timeline2); sequence.play(); Utils.playSound("data/creampie/sounds/missile.mp3"); }
protected AbstractAnimation(CustomStage stage) { this.stage = stage; showAnimation = setupShowAnimation(); dismissAnimation = setupDismissAnimation(); sq = new SequentialTransition(setupShowAnimation(), setupDismissAnimation()); }
private Animation makeAnimation (Node agent, int x, int y, int z) { // create something to follow Path path = new Path(); path.getElements().addAll(new MoveTo(x, y), new VLineTo(z)); // create an animation where the shape follows a path PathTransition pt = new PathTransition(Duration.millis(4000), path, agent); // put them together in order return new SequentialTransition(agent, pt); }
private void fadeBack() { FadeTransition fadeInfoTextOut = new FadeTransition(Duration.millis(425), infoText); fadeInfoTextOut.setFromValue(1.0); fadeInfoTextOut.setToValue(0.0); FadeTransition fadeValueOut = new FadeTransition(Duration.millis(425), value); fadeValueOut.setFromValue(1.0); fadeValueOut.setToValue(0.0); PauseTransition pause = new PauseTransition(Duration.millis(50)); FadeTransition fadeInfoTextIn = new FadeTransition(Duration.millis(425), infoText); fadeInfoTextIn.setFromValue(0.0); fadeInfoTextIn.setToValue(1.0); FadeTransition fadeValueIn = new FadeTransition(Duration.millis(425), value); fadeValueIn.setFromValue(0.0); fadeValueIn.setToValue(1.0); ParallelTransition parallelIn = new ParallelTransition(fadeInfoTextIn, fadeValueIn); ParallelTransition parallelOut = new ParallelTransition(fadeInfoTextOut, fadeValueOut); parallelOut.setOnFinished(event -> { double currentValue = (valueIndicatorRotate.getAngle() + getSkinnable().getStartAngle() - 180) / angleStep + getSkinnable().getMinValue(); value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", currentValue)); value.setTranslateX((size - value.getLayoutBounds().getWidth()) * 0.5); if (getSkinnable().getTarget() < getSkinnable().getValue()) { getSkinnable().setInfoText("COOLING"); } else if (getSkinnable().getTarget() > getSkinnable().getValue()) { getSkinnable().setInfoText("HEATING"); } resizeText(); drawTickMarks(ticks); userAction = false; }); SequentialTransition sequence = new SequentialTransition(parallelOut, pause, parallelIn); sequence.play(); }
private void fadeBackToInteractive() { FadeTransition fadeUnitOut = new FadeTransition(Duration.millis(425), unit); fadeUnitOut.setFromValue(1.0); fadeUnitOut.setToValue(0.0); FadeTransition fadeValueOut = new FadeTransition(Duration.millis(425), value); fadeValueOut.setFromValue(1.0); fadeValueOut.setToValue(0.0); PauseTransition pause = new PauseTransition(Duration.millis(50)); FadeTransition fadeUnitIn = new FadeTransition(Duration.millis(425), unit); fadeUnitIn.setFromValue(0.0); fadeUnitIn.setToValue(1.0); FadeTransition fadeValueIn = new FadeTransition(Duration.millis(425), value); fadeValueIn.setFromValue(0.0); fadeValueIn.setToValue(1.0); ParallelTransition parallelIn = new ParallelTransition(fadeUnitIn, fadeValueIn); ParallelTransition parallelOut = new ParallelTransition(fadeUnitOut, fadeValueOut); parallelOut.setOnFinished(event -> { unit.setText("Interactive"); value.setText(""); resizeText(); }); SequentialTransition sequence = new SequentialTransition(parallelOut, pause, parallelIn); sequence.play(); }
private Transition createMosaicTransition(final List<ImageStore> imageStores) { SequentialTransition fadeIn = new SequentialTransition(); List<FadeTransition> allFadeIns = new ArrayList<>(); double width = pane.getWidth() / 6.0 - 10; double height = pane.getHeight() / 5.0 - 8; List<ImageStore> distillingList = new LinkedList<>(imageStores); for (int i = 0; i < 6; i++) { for (int j = 0; j < 5; j++) { int index = RANDOM.nextInt(distillingList.size()); ImageStore selectedImage = distillingList.remove(index); ImageView imageView = new ImageView(selectedImage.getImage()); imageView.setCache(true); imageView.setCacheHint(CacheHint.SPEED); imageView.setFitWidth(width); imageView.setFitHeight(height); imageView.setEffect(new GaussianBlur(0)); rects[i][j] = imageView; bounds[i][j] = new BoundingBox(i * (width + 10) + 5, j * (height + 8) + 4, width, height); rects[i][j].setOpacity(0); rects[i][j].setLayoutX(bounds[i][j].getMinX()); rects[i][j].setLayoutY(bounds[i][j].getMinY()); pane.getChildren().add(rects[i][j]); FadeTransition ft = new FadeTransition(Duration.seconds(0.3), imageView); ft.setToValue(1); allFadeIns.add(ft); } } Collections.shuffle(allFadeIns); fadeIn.getChildren().addAll(allFadeIns); return fadeIn; }
/** * Animation that creates a pop effect when two tiles merge * by increasing the tile scale to 120% at the middle, and then going back to 100% * @param tile to be animated * @return a sequential transition */ private SequentialTransition animateMergedTile(Tile tile) { final ScaleTransition scale0 = new ScaleTransition(Duration.millis(80), tile); scale0.setToX(1.2); scale0.setToY(1.2); scale0.setInterpolator(Interpolator.EASE_IN); final ScaleTransition scale1 = new ScaleTransition(Duration.millis(80), tile); scale1.setToX(1.0); scale1.setToY(1.0); scale1.setInterpolator(Interpolator.EASE_OUT); return new SequentialTransition(scale0, scale1); }
@Override public void start(Stage stage) { primaryStage = stage; setUpPrimaryStage(); intialiseLogger(); fadeOut(parent); SequentialTransition seqTransition = new SequentialTransition (new PauseTransition(Duration.millis(1500))); seqTransition.setOnFinished(event -> transitToMainScene()); seqTransition.play(); }
@Override public void start(Stage stage) { primaryStage = stage; setUpPrimaryStage(); intialiseLogger(); fadeOut(parent); SequentialTransition seqTransition = new SequentialTransition (new PauseTransition(Duration.millis(1500))); seqTransition.setOnFinished(event -> transitToMainScene(parent)); seqTransition.play(); }
public SequentialTransition getSequentialTransition() { SequentialTransition seqTrans = new SequentialTransition(); for (ExpressionEntry entry : this.expressionEntries) { LinkedList<Point2D> points = getPoints(entry); PathTransition pathTrans = new PathTransition(); pathTrans.setDuration(Duration.seconds(getPathDistance(points) / speed)); pathTrans.setPath(getPath(points)); pathTrans.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT); pathTrans.setInterpolator(Interpolator.LINEAR); seqTrans.getChildren().add(pathTrans); } return seqTrans; }
@Override protected Object call() throws Exception { String code = getCode(); Lexer lexer = new Lexer(new LangReader(code)); JointryParser parser = new JointryParser(); Environment env = new Environment(); env.setSprite(sprite); env.setSpeed(speed); st = new SequentialTransition(); env.setSequentialTransition(st); Object retval = null; try { while (lexer.peek(0) != Token.EOF) { ASTree t = parser.parse(lexer); if (!(t instanceof NullStmnt)) { retval = t.eval(env); } } } catch (ParseException ex) { Logger.getLogger(BackStageController.class.getName()).log(Level.SEVERE, null, ex); } st.play(); return retval; }
@Override public Object eval(Environment env) { Object c = ((ASTree) condition()).eval(env); if (c instanceof Integer) { Sprite sprite = env.getSprite(); SequentialTransition st = env.getSequentialTransition(); RotateTransition rt = new RotateTransition(Duration.millis(env.getSpeed()), sprite); rt.setByAngle((Integer) c); rt.setAutoReverse(true); st.getChildren().add(rt); } return c; }
@Override public Object eval(Environment env) { Object c = ((ASTree) condition()).eval(env); Integer sleep_time = (Integer) c; SequentialTransition st = env.getSequentialTransition(); PauseTransition pt = new PauseTransition(Duration.millis(sleep_time * 100)); st.getChildren().add(pt); return this; }
@FXML private void startButtonPressed(ActionEvent event) { // transition that changes a shape's fill FillTransition fillTransition = new FillTransition(Duration.seconds(1)); fillTransition.setToValue(Color.CYAN); fillTransition.setCycleCount(2); // each even cycle plays transition in reverse to restore original fillTransition.setAutoReverse(true); // transition that changes a shape's stroke over time StrokeTransition strokeTransition = new StrokeTransition(Duration.seconds(1)); strokeTransition.setToValue(Color.BLUE); strokeTransition.setCycleCount(2); strokeTransition.setAutoReverse(true); // parallelizes multiple transitions ParallelTransition parallelTransition = new ParallelTransition(fillTransition, strokeTransition); // transition that changes a node's opacity over time FadeTransition fadeTransition = new FadeTransition(Duration.seconds(1)); fadeTransition.setFromValue(1.0); // opaque fadeTransition.setToValue(0.0); // transparent fadeTransition.setCycleCount(2); fadeTransition.setAutoReverse(true); // transition that rotates a node RotateTransition rotateTransition = new RotateTransition(Duration.seconds(1)); rotateTransition.setByAngle(360.0); rotateTransition.setCycleCount(2); rotateTransition.setInterpolator(Interpolator.EASE_BOTH); rotateTransition.setAutoReverse(true); // transition that moves a node along a Path Path path = new Path(new MoveTo(45, 45), new LineTo(45, 0), new LineTo(90, 0), new LineTo(90, 90), new LineTo(0, 90)); PathTransition translateTransition = new PathTransition(Duration.seconds(2), path); translateTransition.setCycleCount(2); translateTransition.setInterpolator(Interpolator.EASE_IN); translateTransition.setAutoReverse(true); // transition that scales a shape to make it larger or smaller ScaleTransition scaleTransition = new ScaleTransition(Duration.seconds(1)); scaleTransition.setByX(0.75); scaleTransition.setByY(0.75); scaleTransition.setCycleCount(2); scaleTransition.setInterpolator(Interpolator.EASE_OUT); scaleTransition.setAutoReverse(true); // transition that applies a sequence of transitions to a node SequentialTransition sequentialTransition = new SequentialTransition (rectangle, parallelTransition, fadeTransition, rotateTransition, translateTransition, scaleTransition); sequentialTransition.play(); // play the transition }
@Override protected void initGraphics() { super.initGraphics(); chartEventListener = e -> handleData(); chartDataListener = c -> { while (c.next()) { if (c.wasAdded()) { c.getAddedSubList().forEach(addedItem -> addedItem.addChartDataEventListener(chartEventListener)); } else if (c.wasRemoved()) { c.getRemoved().forEach(removedItem -> removedItem.removeChartDataEventListener(chartEventListener)); } } handleData(); }; clickHandler = e -> select(e); endOfTransformationHandler = e -> selectorTooltip.hide(); smoothing = tile.isSmoothing(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); fillClip = new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT); strokeClip = new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT); points = new ArrayList<>(); fillPath = new Path(); fillPath.setStroke(null); fillPath.setClip(fillClip); strokePath = new Path(); strokePath.setFill(null); strokePath.setStroke(tile.getBarColor()); strokePath.setClip(strokeClip); strokePath.setMouseTransparent(true); Helper.enableNode(fillPath, ChartType.AREA == tile.getChartType()); canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); canvas.setMouseTransparent(true); ctx = canvas.getGraphicsContext2D(); dataPointsVisible = tile.getDataPointsVisible(); valueText = new Text(String.format(locale, formatString, ((tile.getValue() - minValue) / range * 100))); valueText.setFill(tile.getValueColor()); valueText.setTextOrigin(VPos.BASELINE); Helper.enableNode(valueText, tile.isValueVisible()); unitText = new Text(" " + tile.getUnit()); unitText.setFill(tile.getUnitColor()); unitText.setTextOrigin(VPos.BASELINE); Helper.enableNode(unitText, !tile.getUnit().isEmpty()); valueUnitFlow = new TextFlow(valueText, unitText); valueUnitFlow.setTextAlignment(TextAlignment.RIGHT); selector = new Circle(); selectorTooltip = new Tooltip(""); selectorTooltip.setWidth(60); selectorTooltip.setHeight(48); Tooltip.install(selector, selectorTooltip); FadeTransition fadeIn = new FadeTransition(Duration.millis(100), selector); fadeIn.setFromValue(0); fadeIn.setToValue(1); FadeTransition fadeOut = new FadeTransition(Duration.millis(100), selector); fadeOut.setFromValue(1); fadeOut.setToValue(0); fadeInFadeOut = new SequentialTransition(fadeIn, new PauseTransition(Duration.millis(3000)), fadeOut); handleData(); getPane().getChildren().addAll(titleText, fillPath, strokePath, canvas, valueUnitFlow, selector); }
private void createRippleEffect() { circleRipple = new Circle(0.1, rippleColor); circleRipple.setOpacity(0.0); // Optional box blur on ripple - smoother ripple effect // circleRipple.setEffect(new BoxBlur(3, 3, 2)); // Fade effect bit longer to show edges on the end final FadeTransition fadeTransition = new FadeTransition(rippleDuration, circleRipple); fadeTransition.setInterpolator(Interpolator.EASE_OUT); fadeTransition.setFromValue(1.0); fadeTransition.setToValue(0.0); final Timeline scaleRippleTimeline = new Timeline(); final SequentialTransition parallelTransition = new SequentialTransition(); parallelTransition.getChildren().addAll( scaleRippleTimeline, fadeTransition ); parallelTransition.setOnFinished(event1 -> { circleRipple.setOpacity(0.0); circleRipple.setRadius(0.1); }); this.addEventHandler(MouseEvent.MOUSE_EXITED, event -> { this.setCursor(Cursor.DEFAULT); }); this.addEventHandler(MouseEvent.MOUSE_ENTERED, event -> { this.setCursor(Cursor.HAND); }); this.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> { parallelTransition.stop(); parallelTransition.getOnFinished().handle(null); circleRipple.setCenterX(event.getX()); circleRipple.setCenterY(event.getY()); // Recalculate ripple size if size of button from last time was changed if (getWidth() != lastRippleWidth || getHeight() != lastRippleHeight) { lastRippleWidth = getWidth(); lastRippleHeight = getHeight(); rippleClip.setWidth(lastRippleWidth); rippleClip.setHeight(lastRippleHeight); try { rippleClip.setArcHeight(this.getBackground().getFills().get(0).getRadii().getTopLeftHorizontalRadius()); rippleClip.setArcWidth(this.getBackground().getFills().get(0).getRadii().getTopLeftHorizontalRadius()); circleRipple.setClip(rippleClip); } catch (Exception e) { } // Getting 45% of longest button's length, because we want edge of ripple effect always visible double circleRippleRadius = Math.max(getHeight(), getWidth()) * 0.45; final KeyValue keyValue = new KeyValue(circleRipple.radiusProperty(), circleRippleRadius, Interpolator.EASE_OUT); final KeyFrame keyFrame = new KeyFrame(rippleDuration, keyValue); scaleRippleTimeline.getKeyFrames().clear(); scaleRippleTimeline.getKeyFrames().add(keyFrame); } parallelTransition.playFromStart(); }); }
private void createRippleEffect() { circleRipple = new Circle(0.1, rippleColor); circleRipple.setOpacity(0.0); // Optional box blur on ripple - smoother ripple effect // circleRipple.setEffect(new BoxBlur(3, 3, 2)); // Fade effect bit longer to show edges on the end final FadeTransition fadeTransition = new FadeTransition(rippleDuration, circleRipple); fadeTransition.setInterpolator(Interpolator.EASE_OUT); fadeTransition.setFromValue(1.0); fadeTransition.setToValue(0.0); final Timeline scaleRippleTimeline = new Timeline(); final SequentialTransition parallelTransition = new SequentialTransition(); parallelTransition.getChildren().addAll( scaleRippleTimeline, fadeTransition ); parallelTransition.setOnFinished(event1 -> { circleRipple.setOpacity(0.0); circleRipple.setRadius(0.1); }); this.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> { parallelTransition.stop(); parallelTransition.getOnFinished().handle(null); circleRipple.setCenterX(event.getX()); circleRipple.setCenterY(event.getY()); // Recalculate ripple size if size of button from last time was changed if (getWidth() != lastRippleWidth || getHeight() != lastRippleHeight) { lastRippleWidth = getWidth(); lastRippleHeight = getHeight(); rippleClip.setWidth(lastRippleWidth); rippleClip.setHeight(lastRippleHeight); try { rippleClip.setArcHeight(this.getBackground().getFills().get(0).getRadii().getTopLeftHorizontalRadius()); rippleClip.setArcWidth(this.getBackground().getFills().get(0).getRadii().getTopLeftHorizontalRadius()); circleRipple.setClip(rippleClip); } catch (Exception e) { } // Getting 45% of longest button's length, because we want edge of ripple effect always visible double circleRippleRadius = Math.max(getHeight(), getWidth()) * 0.45; final KeyValue keyValue = new KeyValue(circleRipple.radiusProperty(), circleRippleRadius, Interpolator.EASE_OUT); final KeyFrame keyFrame = new KeyFrame(rippleDuration, keyValue); scaleRippleTimeline.getKeyFrames().clear(); scaleRippleTimeline.getKeyFrames().add(keyFrame); } parallelTransition.playFromStart(); }); }
private static void fadeTransicao(FadeTransition fadeOut, FadeTransition fadeIn){ SequentialTransition transicao = new SequentialTransition(fadeOut, fadeIn); transicao.play(); }
@Override public void doStep(final MachineContext context) { List<Word> sortedWords = context.getDataProvider(TagCloudDataProvider.class).getWords(); if (sortedWords.isEmpty()) { return; } WordleSkin wordleSkin = (WordleSkin) context.get("WordleSkin"); List<Word> limitedWords = sortedWords.stream().limit(wordleSkin.getDisplayCloudTags()).collect(Collectors.toList()); limitedWords.sort(Comparator.reverseOrder()); Bounds layoutBounds = wordleSkin.getPane().getLayoutBounds(); WordleLayout.Configuration configuration = new WordleLayout.Configuration(limitedWords, wordleSkin.getFont(), wordleSkin.getFontSizeMin(), wordleSkin.getFontSizeMax(), layoutBounds); if (null != wordleSkin.getLogo()) { configuration.setBlockedAreaBounds(wordleSkin.getLogo().getBoundsInParent()); } if (null != wordleSkin.getSecondLogo()) { configuration.setBlockedAreaBounds(wordleSkin.getSecondLogo().getBoundsInParent()); } WordleLayout cloudWordleLayout = WordleLayout.createWordleLayout(configuration); Duration defaultDuration = Duration.seconds(1.5); List<Transition> fadeOutTransitions = new ArrayList<>(); List<Transition> moveTransitions = new ArrayList<>(); List<Transition> fadeInTransitions = new ArrayList<>(); cloudWordleLayout.getWordLayoutInfo().entrySet().stream().forEach(entry -> { Word word = entry.getKey(); Bounds bounds = entry.getValue(); Text textNode = cloudWordleLayout.createTextNode(word); wordleSkin.word2TextMap.put(word, textNode); textNode.setLayoutX(bounds.getMinX() + layoutBounds.getWidth() / 2d); textNode.setLayoutY(bounds.getMinY() + layoutBounds.getHeight() / 2d + bounds.getHeight() / 2d); textNode.setOpacity(0); wordleSkin.getPane().getChildren().add(textNode); FadeTransition ft = new FadeTransition(defaultDuration, textNode); ft.setToValue(1); fadeInTransitions.add(ft); }); ParallelTransition fadeOuts = new ParallelTransition(); fadeOuts.getChildren().addAll(fadeOutTransitions); ParallelTransition moves = new ParallelTransition(); moves.getChildren().addAll(moveTransitions); ParallelTransition fadeIns = new ParallelTransition(); fadeIns.getChildren().addAll(fadeInTransitions); SequentialTransition morph = new SequentialTransition(fadeOuts, moves, fadeIns); morph.setOnFinished(e -> context.proceed()); morph.play(); }