javafx.animation.ScaleTransition Java Examples
The following examples show how to use
javafx.animation.ScaleTransition.
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: 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 #2
Source File: LaunchScreeenController.java From FakeImageDetection with GNU General Public License v3.0 | 6 votes |
private void animate() { TranslateTransition tt = new TranslateTransition(Duration.millis(duration), load_image_button); TranslateTransition tLogo = new TranslateTransition(Duration.millis(duration), christopher); TranslateTransition tDesc = new TranslateTransition(Duration.millis(duration), description); ScaleTransition st = new ScaleTransition(Duration.millis(duration), load_image_button); st.setToX(3); st.setToY(3); tt.setByY(-180f); tLogo.setToY(50); tDesc.setToY(500); buttonParallelTransition = new ParallelTransition(load_image_button, st, tt, tLogo, tDesc); buttonParallelTransition.play(); buttonParallelTransition.setOnFinished((e) -> { load_image_button.setOpacity(1); }); }
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: NeuralnetInterfaceController.java From FakeImageDetection with GNU General Public License v3.0 | 5 votes |
private void startAnimation() { navigation_button.setText("Applying ELA on Image"); float animationExtension = 1.2f; bulgingTransition = new ScaleTransition(Duration.millis(2000), navigation_button); bulgingTransition.setToX(animationExtension); bulgingTransition.setToY(animationExtension); bulgingTransition.autoReverseProperty().setValue(true); bulgingTransition.setCycleCount(bulgingTransition.INDEFINITE); bulgingTransition.play(); }
Example #5
Source File: FXUtils.java From TerasologyLauncher with Apache License 2.0 | 5 votes |
/** * Creates a {@link javafx.animation.ScaleTransition} with the given factor for the specified node element. * * @param factor the scaling factor * @param node the target node * @return a transition object */ static ScaleTransition createScaleTransition(final double factor, final Node node) { final ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(200), node); scaleTransition.setFromX(node.getScaleX()); scaleTransition.setFromY(node.getScaleY()); scaleTransition.setToX(factor); scaleTransition.setToY(factor); return scaleTransition; }
Example #6
Source File: GameManager.java From fx2048 with GNU General Public License v3.0 | 5 votes |
/** * 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 var scale0 = new ScaleTransition(ANIMATION_MERGED_TILE, tile); scale0.setToX(1.2); scale0.setToY(1.2); scale0.setInterpolator(Interpolator.EASE_IN); final var 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); }
Example #7
Source File: GameManager.java From fx2048 with GNU General Public License v3.0 | 5 votes |
/** * Animation that creates a fade in effect when a tile is added to the game by * increasing the tile scale from 0 to 100% * * @param tile to be animated * @return a scale transition */ private ScaleTransition animateNewlyAddedTile(Tile tile) { final var scaleTransition = new ScaleTransition(ANIMATION_NEWLY_ADDED_TILE, tile); scaleTransition.setToX(1.0); scaleTransition.setToY(1.0); scaleTransition.setInterpolator(Interpolator.EASE_OUT); scaleTransition.setOnFinished(e -> { // after last movement on full grid, check if there are movements available if (this.gameGrid.values().parallelStream().noneMatch(Objects::isNull) && mergeMovementsAvailable() == 0) { board.setGameOver(true); } }); return scaleTransition; }
Example #8
Source File: GameManager.java From Game2048FX with GNU General Public License v3.0 | 5 votes |
/** * 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*timeFactor), tile); scale0.setToX(1.2); scale0.setToY(1.2); scale0.setInterpolator(Interpolator.EASE_IN); final ScaleTransition scale1 = new ScaleTransition(Duration.millis(80*timeFactor), tile); scale1.setToX(1.0); scale1.setToY(1.0); scale1.setInterpolator(Interpolator.EASE_OUT); return new SequentialTransition(scale0, scale1); }
Example #9
Source File: GameManager.java From Game2048FX with GNU General Public License v3.0 | 5 votes |
/** * Animation that creates a fade in effect when a tile is added to the game * by increasing the tile scale from 0 to 100% * @param tile to be animated * @return a scale transition */ private ScaleTransition animateNewlyAddedTile(Tile tile) { final ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(125*timeFactor), tile); scaleTransition.setToX(1.0); scaleTransition.setToY(1.0); scaleTransition.setInterpolator(Interpolator.EASE_OUT); return scaleTransition; }
Example #10
Source File: GameManager.java From Game2048FX with GNU General Public License v3.0 | 5 votes |
/** * Adds a tile of random value to a random location with a proper animation * * @param randomLocation */ private ScaleTransition addAndAnimateRandomTile(Location randomLocation) { Tile tile = board.addRandomTile(randomLocation); gameGrid.put(tile.getLocation(), tile); return animateNewlyAddedTile(tile); }
Example #11
Source File: JoustToken.java From metastone with GNU General Public License v2.0 | 5 votes |
public JoustToken(GameBoardView boardView, Card card, boolean up, boolean won) { Window parent = boardView.getScene().getWindow(); this.cardToken = new CardTooltip(); popup = new Popup(); popup.getContent().setAll(cardToken); popup.setX(parent.getX() + 600); popup.show(parent); int offsetY = up ? -200 : 100; popup.setY(parent.getY() + parent.getHeight() * 0.5 - cardToken.getHeight() * 0.5 + offsetY); cardToken.setCard(card); NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED); FadeTransition animation = new FadeTransition(Duration.seconds(1.0), cardToken); animation.setDelay(Duration.seconds(1f)); animation.setOnFinished(this::onComplete); animation.setFromValue(1); animation.setToValue(0); animation.play(); if (won) { ScaleTransition scaleAnimation = new ScaleTransition(Duration.seconds(0.5f), cardToken); scaleAnimation.setByX(0.1); scaleAnimation.setByY(0.1); scaleAnimation.setCycleCount(2); scaleAnimation.setAutoReverse(true); scaleAnimation.play(); } }
Example #12
Source File: GameView.java From CrazyAlpha with GNU General Public License v2.0 | 5 votes |
public static void makeScaleTransition(Node node, int millis, double byX, double byY) { ScaleTransition st = new ScaleTransition(Duration.millis(millis)); st.setByX(byX); st.setByY(byY); st.setCycleCount(Animation.INDEFINITE); st.setAutoReverse(true); st.setNode(node); st.play(); }
Example #13
Source File: LaunchScreeenController.java From FakeImageDetection with GNU General Public License v3.0 | 5 votes |
private void startSimpleMetaDataAnimation() { float animationExtension = 3.25f; bulgingTransition = new ScaleTransition(Duration.millis(1000), load_image_button); bulgingTransition.setToX(animationExtension); bulgingTransition.setToY(animationExtension); bulgingTransition.autoReverseProperty().setValue(true); bulgingTransition.setCycleCount(2); bulgingTransition.play(); load_image_button.setFont(Font.font("Roboto", FontWeight.NORMAL, 8)); load_image_button.setText("Checking Metadata.."); }
Example #14
Source File: GameManager.java From util4j with Apache License 2.0 | 5 votes |
/** * 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); }
Example #15
Source File: GameManager.java From util4j with Apache License 2.0 | 5 votes |
/** * Animation that creates a fade in effect when a tile is added to the game * by increasing the tile scale from 0 to 100% * @param tile to be animated * @return a scale transition */ private ScaleTransition animateNewlyAddedTile(Tile tile) { final ScaleTransition scaleTransition = new ScaleTransition(ANIMATION_NEWLY_ADDED_TILE, tile); scaleTransition.setToX(1.0); scaleTransition.setToY(1.0); scaleTransition.setInterpolator(Interpolator.EASE_OUT); scaleTransition.setOnFinished(e -> { // after last movement on full grid, check if there are movements available if (this.gameGrid.values().parallelStream().noneMatch(Objects::isNull) && mergeMovementsAvailable() == 0 ) { board.setGameOver(true); } }); return scaleTransition; }
Example #16
Source File: InternalWindow.java From desktoppanefx with Apache License 2.0 | 5 votes |
private ScaleTransition hideWindow() { ScaleTransition st = new ScaleTransition(Duration.millis(100), this); st.setToX(0); st.setToY(0); st.setByX(1); st.setByY(1); st.setCycleCount(1); return st; }
Example #17
Source File: InternalWindow.java From desktoppanefx with Apache License 2.0 | 5 votes |
public void closeWindow() { InternalWindowEvent event = new InternalWindowEvent(this, InternalWindowEvent.WINDOW_CLOSE_REQUEST); fireEvent(event); if (event.isConsumed()) { return; } if (isDetached()) { fireEvent(new InternalWindowEvent(this, InternalWindowEvent.WINDOW_HIDING)); detachedWindow.close(); detachedWindow = null; fireEvent(new InternalWindowEvent(this, InternalWindowEvent.WINDOW_HIDDEN)); } else { ScaleTransition st = hideWindow(); st.setOnFinished(t -> { if (desktopPane != null) { desktopPane.removeInternalWindow(this); } closed.setValue(true); fireEvent(new InternalWindowEvent(this, InternalWindowEvent.WINDOW_HIDDEN)); }); fireEvent(new InternalWindowEvent(this, InternalWindowEvent.WINDOW_HIDING)); st.play(); } }
Example #18
Source File: LaunchScreeenController.java From FakeImageDetection with GNU General Public License v3.0 | 4 votes |
private void loadMetaDataCheck() { startSimpleMetaDataAnimation(); MetadataProcessor processor = new MetadataProcessor(processingFile); bulgingTransition.setOnFinished((e) -> { TranslateTransition tt = new TranslateTransition(Duration.millis(duration - 500), load_image_button); ScaleTransition st = new ScaleTransition(Duration.millis(duration - 500), load_image_button); st.setToX(1); st.setToY(1); tt.setToX(-150f); tt.setToY(80f); Timeline timeline = new Timeline(); timeline.setCycleCount(1); KeyValue keyValueX = new KeyValue(load_image_button.prefWidthProperty(), 400); KeyValue keyValueY = new KeyValue(load_image_button.prefHeightProperty(), 50); KeyFrame keyFrame = new KeyFrame(Duration.millis(duration - 500), keyValueX, keyValueY); timeline.getKeyFrames().add(keyFrame); ParallelTransition pt = new ParallelTransition(load_image_button, st, tt, timeline); pt.play(); pt.setOnFinished((e1) -> { loadMetadataResult(); load_image_button.setText("Test On AI"); load_image_button.setFont(Font.font("Roboto", FontWeight.BOLD, 20)); homeIcon.setVisible(true); // Neural Network Entry load_image_button.setOnMouseClicked((e2) -> { System.out.println("Loading NN........"); try { anchorPane.getChildren().clear(); StackPane pane = FXMLLoader.load(getClass().getResource("/resources/fxml/neuralinterface.fxml")); anchorPane.getChildren().setAll(pane); } catch (IOException ex) { Logger.getLogger(MetadataResultController.class.getName()).log(Level.SEVERE, null, ex); } }); }); }); }
Example #19
Source File: EmojiSelectorController.java From ChatRoom-JavaFX with Apache License 2.0 | 4 votes |
/** * 创建emoji节点stackpane,并给其添加事件监听器 * @param emoji * @return */ private Node addEmojiNodeListener(Emoji emoji) { // 是否需要光标设置 Node stackPane = EmojiDisplayer.createEmojiNode(emoji, 32, 3); if (stackPane instanceof StackPane) { // 设置光标手势 stackPane.setCursor(Cursor.HAND); ScaleTransition st = new ScaleTransition(Duration.millis(90), stackPane); // 设置提示 Tooltip tooltip = new Tooltip(emoji.getShortname()); Tooltip.install(stackPane, tooltip); // 设置光标的触发事件 stackPane.setOnMouseEntered(e -> { // stackPane.setStyle("-fx-background-color: #a6a6a6; // -fx-background-radius: 3;"); stackPane.setEffect(new DropShadow()); st.setToX(1.2); st.setToY(1.2); st.playFromStart(); if (searchTextField.getText().isEmpty()) searchTextField.setPromptText(emoji.getShortname()); }); // 设置光标的离开事件 stackPane.setOnMouseExited(e -> { // stackPane.setStyle(""); stackPane.setEffect(null); st.setToX(1.); st.setToY(1.); st.playFromStart(); }); // 设置光标的点击事件 stackPane.setOnMouseClicked(e -> { // 获得emoji简称 String shortname = emoji.getShortname(); chatController.getMessageBoxTextArea().appendText(shortname); // 关闭emoji选择器 if (getLocalStage().isShowing()) { closeLocalStage(); } }); } return stackPane; }
Example #20
Source File: RadialMenu.java From Enzo with Apache License 2.0 | 4 votes |
public void click(final MenuItem CLICKED_ITEM) { List<Transition> transitions = new ArrayList<>(items.size() * 2); for (Parent node : items.keySet()) { if (items.get(node).equals(CLICKED_ITEM)) { // Add enlarge transition to selected item ScaleTransition enlargeItem = new ScaleTransition(Duration.millis(300), node); enlargeItem.setToX(5.0); enlargeItem.setToY(5.0); transitions.add(enlargeItem); } else { // Add shrink transition to all other items ScaleTransition shrinkItem = new ScaleTransition(Duration.millis(300), node); shrinkItem.setToX(0.0); shrinkItem.setToY(0.0); transitions.add(shrinkItem); } // Add fade out transition to every node FadeTransition fadeOutItem = new FadeTransition(Duration.millis(300), node); fadeOutItem.setToValue(0.0); transitions.add(fadeOutItem); } // Add rotate and fade transition to main menu button if (options.isButtonHideOnSelect()) { RotateTransition rotateMainButton = new RotateTransition(Duration.millis(300), mainMenuButton); rotateMainButton.setToAngle(225); transitions.add(rotateMainButton); FadeTransition fadeOutMainButton = new FadeTransition(Duration.millis(300), mainMenuButton); fadeOutMainButton.setToValue(0.0); transitions.add(fadeOutMainButton); ScaleTransition shrinkMainButton = new ScaleTransition(Duration.millis(300), mainMenuButton); shrinkMainButton.setToX(0.0); shrinkMainButton.setToY(0.0); transitions.add(shrinkMainButton); } else { RotateTransition rotateBackMainButton = new RotateTransition(); rotateBackMainButton.setNode(cross); rotateBackMainButton.setToAngle(0); rotateBackMainButton.setDuration(Duration.millis(200)); rotateBackMainButton.setInterpolator(Interpolator.EASE_BOTH); transitions.add(rotateBackMainButton); FadeTransition mainButtonFadeOut = new FadeTransition(); mainButtonFadeOut.setNode(mainMenuButton); mainButtonFadeOut.setDuration(Duration.millis(100)); mainButtonFadeOut.setToValue(options.getButtonAlpha()); transitions.add(mainButtonFadeOut); } // Play all transitions in parallel ParallelTransition selectTransition = new ParallelTransition(); selectTransition.getChildren().addAll(transitions); selectTransition.play(); // Set menu state back to closed setState(State.CLOSED); mainMenuButton.setOpen(false); }