javafx.animation.TranslateTransition Java Examples

The following examples show how to use javafx.animation.TranslateTransition. 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: AndroidKeyboardService.java    From attach with GNU General Public License v3.0 7 votes vote down vote up
private static void adjustPosition(Node node, Parent parent, double kh) {
    if (node == null || node.getScene() == null || node.getScene().getWindow() == null) {
        return;
    }
    double tTot = node.getScene().getHeight();
    double ty = node.getLocalToSceneTransform().getTy() + node.getBoundsInParent().getHeight() + 2;
    double y = 1;
    Parent root = parent == null ? node.getScene().getRoot() : parent;
    if (ty > tTot - kh) {
        y = tTot - ty - kh;
    } else if (kh == 0 && root.getTranslateY() != 0) {
        y = 0;
    }
    if (y <= 0) {
        if (debug) {
            LOG.log(Level.INFO, String.format("Moving %s %.2f pixels", root, y));
        }
        final TranslateTransition transition = new TranslateTransition(Duration.millis(100), root);
        transition.setFromY(root.getTranslateY());
        transition.setToY(y);
        transition.setInterpolator(Interpolator.EASE_OUT);
        transition.playFromStart();
    }
}
 
Example #2
Source File: IOSKeyboardService.java    From attach with GNU General Public License v3.0 6 votes vote down vote up
private static void adjustPosition(Node node, Parent parent, double kh) {
    if (node == null || node.getScene() == null || node.getScene().getWindow() == null) {
        return;
    }
    double tTot = node.getScene().getHeight();
    double ty = node.getLocalToSceneTransform().getTy() + node.getBoundsInParent().getHeight() + 2;
    double y = 1;
    Parent root = parent == null ? node.getScene().getRoot() : parent;
    if (ty > tTot - kh) {
        y = tTot - ty - kh;
    } else if (kh == 0 && root.getTranslateY() != 0) {
        y = 0;
    }
    if (y <= 0) {
        if (debug) {
            LOG.log(Level.INFO, String.format("Moving %s %.2f pixels", root, y));
        }
        final TranslateTransition transition = new TranslateTransition(Duration.millis(100), root);
        transition.setFromY(root.getTranslateY());
        transition.setToY(y);
        transition.setInterpolator(Interpolator.EASE_OUT);
        transition.playFromStart();
    }
}
 
Example #3
Source File: LoginFader.java    From iliasDownloaderTool with GNU General Public License v2.0 6 votes vote down vote up
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 #4
Source File: MKXMenuApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Node createRightContent() {
    String title = "Please Subscribe :)";
    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);
        letter.setOpacity(0);
        letters.getChildren().add(letter);

        FadeTransition ft = new FadeTransition(Duration.seconds(2), letter);
        ft.setDelay(Duration.millis(i * 50));
        ft.setToValue(1);
        ft.setAutoReverse(true);
        ft.setCycleCount(TranslateTransition.INDEFINITE);
        ft.play();
    }

    return letters;
}
 
Example #5
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 #6
Source File: GameDevMath.java    From FXTutorials with MIT License 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    Scene scene = new Scene(createContent());
    scene.setOnMouseClicked(event -> {
        player.setTranslateX(event.getSceneX());
        player.setTranslateY(event.getSceneY());

        Point2D vector = player.getPoint().subtract(enemy.getPoint());

        vectorView.setVector(vector);

        PointView bullet = new PointView(enemy.getPoint());
        root.getChildren().add(bullet);

        TranslateTransition tt = new TranslateTransition(Duration.seconds(3), bullet);
        tt.setByX(vector.getX());
        tt.setByY(vector.getY());
        tt.setAutoReverse(true);
        tt.setCycleCount(2);
        tt.setOnFinished(e -> root.getChildren().remove(bullet));
        tt.play();
    });

    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example #7
Source File: HealingNumber.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public HealingNumber(String text, GameToken parent) {
	this.parent = parent;

	setText(text);
	setFill(Color.GREEN);
	setStyle("-fx-font-size: 28pt; -fx-font-family: \"System\";-fx-font-weight: bolder;-fx-stroke: black;-fx-stroke-width: 2;");

	setCache(true);
	setCacheHint(CacheHint.SPEED);

	parent.getAnchor().getChildren().add(this);

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
	TranslateTransition animation = new TranslateTransition(Duration.seconds(0.5), this);
	animation.setToY(-30);
	animation.setOnFinished(this::onComplete);
	animation.play();
}
 
Example #8
Source File: SpaceInvadersController.java    From FXGLGames with MIT License 6 votes vote down vote up
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 #9
Source File: LaunchScreeenController.java    From FakeImageDetection with GNU General Public License v3.0 6 votes vote down vote up
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 #10
Source File: SpaceInvadersController.java    From FXGLGames with MIT License 6 votes vote down vote up
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 #11
Source File: Toast.java    From ApkToolPlus with Apache License 2.0 6 votes vote down vote up
public Toast show(StackPane ui, long duration){
        Platform.runLater(() -> {
            ui.getChildren().add(label);
            StackPane.setAlignment(label, Pos.BOTTOM_CENTER); // 从下方居中往中间移动
            TranslateTransition tt = new TranslateTransition(Duration.millis(200), label);
            tt.setByY(-(ui.getHeight()/2));
            tt.setCycleCount(1);
            tt.setAutoReverse(false);
            tt.setOnFinished(event -> {
//                LogUtils.d("toast animation finish.");
                Timer timer = new Timer();
                timer.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        if(label.getParent() != null){
                            Platform.runLater(() -> ui.getChildren().remove(label));
                            timer.cancel();
                        }
                    }
                },duration);
            });
            tt.play();
        });
        return this;
    }
 
Example #12
Source File: ToggleSwitchSkin.java    From mdict-java with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructor for all ToggleSwitchSkin instances.
 *
 * @param control The ToggleSwitch for which this Skin should attach to.
 */
public ToggleSwitchSkin(ToggleSwitch control) {
    super(control);

    thumb = new StackPane();
    thumbArea = new StackPane();
    label = new Label();
    labelContainer = new StackPane();
    transition = new TranslateTransition(Duration.millis(getThumbMoveAnimationTime()), thumb);

    label.textProperty().bind(control.textProperty());
    getChildren().addAll(labelContainer, thumbArea, thumb);
    labelContainer.getChildren().addAll(label);
    StackPane.setAlignment(label, Pos.CENTER_LEFT);

    thumb.getStyleClass().setAll("thumb");
    thumbArea.getStyleClass().setAll("thumb-area");

    thumbArea.setOnMouseReleased(event -> mousePressedOnToggleSwitch(control));
    thumb.setOnMouseReleased(event -> mousePressedOnToggleSwitch(control));
    control.selectedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue.booleanValue() != oldValue.booleanValue())
            selectedStateChanged();
    });
}
 
Example #13
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 #14
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 #15
Source File: ThreeDOM.java    From scenic-view with GNU General Public License v3.0 6 votes vote down vote up
private Tile3D nodeToTile3D(SVNode node2D, double factor2d3d, double depth) {

        Tile3D tile = new Tile3D(currentRoot2D, factor2d3d, node2D, depth, THICKNESS, this, iThreeDOM);

        if (initialParallelTransition != null && depth > 1) {
            TranslateTransition translateTransition = new TranslateTransition(Duration.seconds(2));
            translateTransition.setInterpolator(Interpolator.EASE_OUT);
            translateTransition.setNode(tile);
            // Take into account slider's value
            translateTransition.setToZ(-depth * spaceSlider.getValue());
            initialParallelTransition.getChildren().add(translateTransition);
        } else {
            tile.setTranslateZ(-depth * spaceSlider.getValue());
        }

        return tile;
    }
 
Example #16
Source File: MainController.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
public void readyToGoAnimation() {
    // Buttons slide in and clickable address appears simultaneously.
    TranslateTransition arrive = new TranslateTransition(Duration.millis(1200), controlsBox);
    arrive.setInterpolator(new ElasticInterpolator(EasingMode.EASE_OUT, 1, 2));
    arrive.setToY(0.0);
    FadeTransition reveal = new FadeTransition(Duration.millis(1200), addressControl);
    reveal.setToValue(1.0);
    ParallelTransition group = new ParallelTransition(arrive, reveal);
    group.setDelay(NotificationBarPane.ANIM_OUT_DURATION);
    group.setCycleCount(1);
    group.play();
}
 
Example #17
Source File: IconSwitchSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.5 * PREFERRED_HEIGHT)); // "OpenSans"
    font = Font.font("Open Sans", 0.5 * PREFERRED_HEIGHT);

    background = new Region();
    background.getStyleClass().setAll("background");
    background.setStyle("-switch-color: " + Util.colorToCss((Color) getSkinnable().getSwitchColor()) + ";");

    symbol = getSkinnable().getSymbol();
    symbol.setMouseTransparent(true);

    text = new Label(getSkinnable().getText());
    text.setTextAlignment(TextAlignment.CENTER);
    text.setAlignment(Pos.CENTER);
    text.setTextFill(getSkinnable().getSymbolColor());
    text.setFont(font);

    thumb = new Region();
    thumb.getStyleClass().setAll("thumb");
    thumb.setStyle("-thumb-color: " + Util.colorToCss((Color) getSkinnable().getThumbColor()) + ";");
    thumb.setMouseTransparent(true);

    pane = new Pane(background, symbol, text, thumb);
    pane.getStyleClass().setAll("icon-switch");

    moveToDeselected = new TranslateTransition(Duration.millis(180), thumb);
    moveToSelected = new TranslateTransition(Duration.millis(180), thumb);

    // Add all nodes
    getChildren().setAll(pane);
}
 
Example #18
Source File: OnOffSwitchSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.5 * PREFERRED_HEIGHT)); // "OpenSans"
    font = Font.font("Open Sans", 0.5 * PREFERRED_HEIGHT);

    background = new Region();
    background.getStyleClass().setAll("background");
    background.setStyle("-switch-color: " + Util.colorToCss((Color) getSkinnable().getSwitchColor()) + ";");

    selectedText  = new Text("1");
    selectedText.setFont(font);
    selectedText.getStyleClass().setAll("selected-text");
    selectedText.setStyle("-text-color-on: " + Util.colorToCss((Color) getSkinnable().getTextColorOn()) + ";");

    deselectedText = new Text("0");
    deselectedText.setFont(font);
    deselectedText.getStyleClass().setAll("deselected-text");
    deselectedText.setStyle("-text-color-off: " + Util.colorToCss((Color) getSkinnable().getTextColorOff()) + ";");

    thumb = new Region();
    thumb.getStyleClass().setAll("thumb");
    thumb.setMouseTransparent(true);
    thumb.setStyle("-thumb-color: " + Util.colorToCss((Color) getSkinnable().getThumbColor()) + ";");

    pane = new Pane(background, selectedText, deselectedText, thumb);
    pane.getStyleClass().setAll("on-off-switch");

    moveToDeselected = new TranslateTransition(Duration.millis(180), thumb);
    moveToSelected = new TranslateTransition(Duration.millis(180), thumb);

    // Add all nodes
    getChildren().setAll(pane);
}
 
Example #19
Source File: Workbench.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
/**
 * Handles the initial animation of an overlay.
 *
 * <p>An overlay will have a default size of {@code 0}, when it is <b>first being shown</b> by
 * {@link WorkbenchPresenter#showOverlay(Region, boolean)}, because it has not been added to the
 * scene graph or a layout pass has not been performed yet. This means the animation won't be
 * played by {@link WorkbenchPresenter#showOverlay(Region, boolean)} as well.<br>
 * For this reason, we wait for the {@link WorkbenchOverlay} to be initialized and then initially
 * set the coordinates of the overlay to be outside of the {@link Scene}, followed by playing the
 * initial starting animation.<br>
 * Any subsequent calls which show this {@code workbenchOverlay} again will <b>not</b> cause this
 * to trigger again, as the {@link Event} of {@link WorkbenchOverlay#onInitializedProperty()}
 * will only be fired once, since calling {@link Workbench#hideOverlay(Region)} only makes the
 * overlays not visible, which means the nodes remain with their size already initialized in the
 * scene graph.
 *
 * @param workbenchOverlay for which to prepare the initial animation handler for
 * @param side from which the sliding animation should originate
 */
private void addInitialAnimationHandler(WorkbenchOverlay workbenchOverlay, Side side) {
  Region overlay = workbenchOverlay.getOverlay();
  // prepare values for setting the listener
  ReadOnlyDoubleProperty size =
      side.isVertical() ? overlay.widthProperty() : overlay.heightProperty();
  //                       LEFT or RIGHT side          TOP or BOTTOM side

  // make sure this code only gets run the first time the overlay has been shown and
  // rendered in the scene graph, to ensure the overlay has a size for the calculations
  workbenchOverlay.setOnInitialized(event -> {
    // prepare variables
    TranslateTransition start = workbenchOverlay.getAnimationStart();
    TranslateTransition end = workbenchOverlay.getAnimationEnd();
    DoubleExpression hiddenCoordinate = DoubleBinding.doubleExpression(size);
    if (Side.LEFT.equals(side) || Side.TOP.equals(side)) {
      hiddenCoordinate = hiddenCoordinate.negate(); // make coordinates in hidden state negative
    }

    if (side.isVertical()) { // LEFT or RIGHT => X
      overlay.setTranslateX(hiddenCoordinate.get()); // initial position
      start.setToX(0);
      if (!end.toXProperty().isBound()) {
        end.toXProperty().bind(hiddenCoordinate);
      }
    }
    if (side.isHorizontal()) { // TOP or BOTTOM => Y
      overlay.setTranslateY(hiddenCoordinate.get()); // initial position
      start.setToY(0);
      if (!end.toYProperty().isBound()) {
        end.toYProperty().bind(hiddenCoordinate);
      }
    }

    start.play();
  });
}
 
Example #20
Source File: MKXMenuApp.java    From FXTutorials with MIT License 5 votes vote down vote up
private Node createLeftContent() {
    final Text inbox = new Text("You have " + messages + " new message(-s)");
    inbox.setFill(Color.WHITE);

    bgThread.scheduleAtFixedRate(() -> {
        Platform.runLater(() -> {
            TranslateTransition tt = new TranslateTransition(Duration.seconds(0.5), inbox);
            tt.setToY(150);

            FadeTransition ft = new FadeTransition(Duration.seconds(0.5), inbox);
            ft.setToValue(0);

            ParallelTransition pt = new ParallelTransition(tt, ft);
            pt.setOnFinished(e -> {
                inbox.setTranslateY(-150);
                inbox.setText("You have " + ++messages + " new message(-s)");

                TranslateTransition tt2 = new TranslateTransition(Duration.seconds(0.5), inbox);
                tt2.setToY(0);

                FadeTransition ft2 = new FadeTransition(Duration.seconds(0.5), inbox);
                ft2.setToValue(1);

                ParallelTransition pt2 = new ParallelTransition(tt2, ft2);
                pt2.play();
            });
            pt.play();
        });
    }, 2, 5, TimeUnit.SECONDS);

    return inbox;
}
 
Example #21
Source File: Connect4App.java    From FXTutorials with MIT License 5 votes vote down vote up
private void placeDisc(Disc disc, int column) {
    int row = ROWS - 1;
    do {
        if (!getDisc(column, row).isPresent())
            break;

        row--;
    } while (row >= 0);

    if (row < 0)
        return;

    grid[column][row] = disc;
    discRoot.getChildren().add(disc);
    disc.setTranslateX(column * (TILE_SIZE + 5) + TILE_SIZE / 4);

    final int currentRow = row;

    TranslateTransition animation = new TranslateTransition(Duration.seconds(0.5), disc);
    animation.setToY(row * (TILE_SIZE + 5) + TILE_SIZE / 4);
    animation.setOnFinished(e -> {
        if (gameEnded(column, currentRow)) {
            gameOver();
        }

        redMove = !redMove;
    });
    animation.play();
}
 
Example #22
Source File: Workbench.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private TranslateTransition slideOut(Region overlay) {
  TranslateTransition close = new TranslateTransition(
      new Duration(ANIMATION_DURATION_DRAWER_CLOSE), overlay);
  close.setOnFinished(event -> {
    overlay.setVisible(false);
    LOGGER.trace(
        "Overlay LayoutX: " + overlay.getLayoutX() + " TranslateX: " + overlay.getTranslateX());
  });
  return close;
}
 
Example #23
Source File: WorkbenchOverlay.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes a new <b>animated</b> overlay.
 *
 * @param overlay to be shown as the main content node
 * @param glassPane to be shown in the background of the overlay
 * @param animationStart animation that should be played when the overlay is being shown
 * @param animationEnd animation that should be played when the overlay is being hidden
 */
public WorkbenchOverlay(Region overlay, GlassPane glassPane,
                        TranslateTransition animationStart, TranslateTransition animationEnd) {
  this.overlay = overlay;
  this.glassPane = glassPane;
  this.animationStart = animationStart;
  this.animationEnd = animationEnd;

  setupInitializedListeners(overlay);
}
 
Example #24
Source File: BackgroundController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@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 #25
Source File: AnimatedTableRow.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private TranslateTransition createAndConfigureAnimation(
		final TableView<Person> sourceTable,
		final TableView<Person> destinationTable,
		final Pane commonTableAncestor, final TableRow<Person> row,
		final ImageView imageView, final Point2D animationStartPoint,
		Point2D animationEndPoint) {
	final TranslateTransition transition = new TranslateTransition(ANIMATION_DURATION, imageView);
	// At end of animation, actually move data, and remove animated image
	transition.setOnFinished(createAnimationFinishedHandler(sourceTable, destinationTable, commonTableAncestor, row.getItem(), imageView));
	// configure transition
	transition.setByX(animationEndPoint.getX() - animationStartPoint.getX()); // absolute translation, computed from coords relative to Scene
	transition.setByY(animationEndPoint.getY() - animationStartPoint.getY()); // absolute translation, computed from coords relative to Scene
	return transition;
}
 
Example #26
Source File: MainController.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
public void readyToGoAnimation() {
    // Buttons slide in and clickable address appears simultaneously.
    TranslateTransition arrive = new TranslateTransition(Duration.millis(1200), controlsBox);
    arrive.setInterpolator(new ElasticInterpolator(EasingMode.EASE_OUT, 1, 2));
    arrive.setToY(0.0);
    FadeTransition reveal = new FadeTransition(Duration.millis(1200), addressControl);
    reveal.setToValue(1.0);
    ParallelTransition group = new ParallelTransition(arrive, reveal);
    group.setDelay(NotificationBarPane.ANIM_OUT_DURATION);
    group.setCycleCount(1);
    group.play();
}
 
Example #27
Source File: SlidingListTile.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 #28
Source File: NeuralnetInterfaceController.java    From FakeImageDetection with GNU General Public License v3.0 5 votes vote down vote up
private void removeBannersandDescs() {
    TranslateTransition tChristopher = new TranslateTransition(Duration.millis(1000), christopher);
    TranslateTransition tDescription = new TranslateTransition(Duration.millis(1000), description);
    tChristopher.setToY(-500);
    tDescription.setToY(-500);
    ParallelTransition pt = new ParallelTransition(tChristopher, tDescription);
    pt.play();

}
 
Example #29
Source File: LaunchScreeenController.java    From FakeImageDetection with GNU General Public License v3.0 5 votes vote down vote up
private void removeBannersandDescs() {
    TranslateTransition tChristopher = new TranslateTransition(Duration.millis(duration), christopher);
    TranslateTransition tDescription = new TranslateTransition(Duration.millis(duration), description);
    tChristopher.setToY(-200);
    tDescription.setToY(1000);
    ParallelTransition pt = new ParallelTransition(tChristopher, tDescription);
    pt.play();

}
 
Example #30
Source File: StepperTouchController.java    From FXMaterialDesign with MIT License 5 votes vote down vote up
@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();
    });
}