Search in sources :

Example 46 with Timeline

use of javafx.animation.Timeline in project bitsquare by bitsquare.

the class Overlay method animateHide.

protected void animateHide(Runnable onFinishedHandler) {
    Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
    double duration = getDuration(200);
    Timeline timeline = new Timeline();
    ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
    if (type.animationType == AnimationType.SlideDownFromCenterTop) {
        double endY = -gridPane.getHeight();
        keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.translateYProperty(), -10, interpolator)));
        keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.translateYProperty(), endY, interpolator)));
        timeline.setOnFinished(e -> onFinishedHandler.run());
        timeline.play();
    } else if (type.animationType == AnimationType.ScaleFromCenter) {
        double endScale = 0.25;
        keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator)));
        keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), endScale, interpolator), new KeyValue(gridPane.scaleYProperty(), endScale, interpolator)));
    } else if (type.animationType == AnimationType.ScaleYFromCenter) {
        gridPane.setRotationAxis(Rotate.X_AXIS);
        gridPane.getScene().setCamera(new PerspectiveCamera());
        keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.rotateProperty(), 0, interpolator), new KeyValue(gridPane.opacityProperty(), 1, interpolator)));
        keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.rotateProperty(), -90, interpolator), new KeyValue(gridPane.opacityProperty(), 0, interpolator)));
    } else if (type.animationType == AnimationType.ScaleDownToCenter) {
        double endScale = 0.1;
        keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator)));
        keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), endScale, interpolator), new KeyValue(gridPane.scaleYProperty(), endScale, interpolator)));
    } else if (type.animationType == AnimationType.FadeInAtCenter) {
        keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator)));
        keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator)));
    }
    timeline.setOnFinished(e -> onFinishedHandler.run());
    timeline.play();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) Interpolator(javafx.animation.Interpolator) PerspectiveCamera(javafx.scene.PerspectiveCamera)

Example 47 with Timeline

use of javafx.animation.Timeline in project Gargoyle by callakrsos.

the class LettersPane method createRandomTimeLine.

private Timeline createRandomTimeLine(Node node) {
    // over 3 seconds move letter to random position and fade it out
    final Timeline timeline = new Timeline();
    timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            // we are done remove us from scene
            getChildren().remove(node);
        }
    }, new KeyValue(node.translateXProperty(), getRandom(0.0f, getWidth() - node.getBoundsInLocal().getWidth()), INTERPOLATOR), new KeyValue(node.translateYProperty(), getRandom(0.0f, getHeight() - node.getBoundsInLocal().getHeight()), INTERPOLATOR), new KeyValue(node.opacityProperty(), 0f)));
    return timeline;
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) ActionEvent(javafx.event.ActionEvent) KeyFrame(javafx.animation.KeyFrame) EventHandler(javafx.event.EventHandler)

Example 48 with Timeline

use of javafx.animation.Timeline in project Gargoyle by callakrsos.

the class LettersPane method createUpperTimeLine.

//	private Timeline createCurveTimeLine(Node node) {
//		// over 3 seconds move letter to random position and fade it out
//		final Timeline timeline = new Timeline();
//		timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
//			@Override
//			public void handle(ActionEvent event) {
//				// we are done remove us from scene
//				getChildren().remove(node);
//			}
//		}, new KeyValue(node.translateXProperty(), node.translateXProperty().get(), INTERPOLATOR),
//			new KeyValue(node.translateYProperty(), 100f, INTERPOLATOR), new KeyValue(node.opacityProperty(), 0f)));
//
//		new KeyFrame(Duration.millis(0.5), new KeyFrame(time, values))
//
//
//
//		return timeline;
//
//
//	}
private Timeline createUpperTimeLine(Node node) {
    // over 3 seconds move letter to random position and fade it out
    final Timeline timeline = new Timeline();
    timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            // we are done remove us from scene
            getChildren().remove(node);
        }
    }, new KeyValue(node.translateXProperty(), node.translateXProperty().get(), INTERPOLATOR), new KeyValue(node.translateYProperty(), 100f, INTERPOLATOR), new KeyValue(node.opacityProperty(), 0f)));
    return timeline;
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) ActionEvent(javafx.event.ActionEvent) KeyFrame(javafx.animation.KeyFrame) EventHandler(javafx.event.EventHandler)

Example 49 with Timeline

use of javafx.animation.Timeline in project arquivoProject by fader-azevedo.

the class CriarEstanteController method salvarEstante.

@FXML
private void salvarEstante() {
    if (txtCodigo.getText().isEmpty() || txtDescricao.getText().isEmpty()) {
        db.alertInfo("Por Favor, Preenche todos os campos");
        return;
    }
    Calendar cal = Calendar.getInstance();
    Estante e = new Estante(1, db.tratamento(txtCodigo.getText().trim()), db.tratamento(txtDescricao.getText().trim()), cal.getTime());
    db.salvar(e);
    lbMessage.setOpacity(1);
    Timeline times = new Timeline(new KeyFrame(Duration.millis(4000), ev -> {
        lbMessage.setOpacity(0);
    }));
    times.play();
    txtCodigo.setText("");
    txtDescricao.setText("");
    lista.setItems(db.listarCogigoEstante());
}
Also used : JFXTextArea(com.jfoenix.controls.JFXTextArea) JFXButton(com.jfoenix.controls.JFXButton) KeyFrame(javafx.animation.KeyFrame) Initializable(javafx.fxml.Initializable) Label(javafx.scene.control.Label) ListView(javafx.scene.control.ListView) URL(java.net.URL) Timeline(javafx.animation.Timeline) Estante(model.Estante) FXML(javafx.fxml.FXML) Duration(javafx.util.Duration) Calendar(java.util.Calendar) ResourceBundle(java.util.ResourceBundle) AnchorPane(javafx.scene.layout.AnchorPane) ObservableList(javafx.collections.ObservableList) JFXTextField(com.jfoenix.controls.JFXTextField) Timeline(javafx.animation.Timeline) Calendar(java.util.Calendar) KeyFrame(javafx.animation.KeyFrame) Estante(model.Estante) FXML(javafx.fxml.FXML)

Example 50 with Timeline

use of javafx.animation.Timeline in project arquivoProject by fader-azevedo.

the class ListaEstanteController method playThis.

private void playThis(JFXButton button) {
    Timeline timeline = new Timeline(new KeyFrame(Duration.millis(250), ev -> {
        clipRectNextPratieira.setHeight(pnCarregaPratileira.getHeight());
        if (clipRectNextPratieira.widthProperty().get() != 0) {
            Timeline timelineUp = new Timeline();
            final KeyValue kvUp1 = new KeyValue(clipRectNextPratieira.widthProperty(), 0);
            final KeyValue kvUp2 = new KeyValue(clipRectNextPratieira.translateXProperty(), pnCarregaPratileira.getWidth());
            final KeyValue kvUp4 = new KeyValue(pnCarregaPratileira.prefWidthProperty(), 0);
            final KeyValue kvUp3 = new KeyValue(pnCarregaPratileira.translateXProperty(), pnCarregaPratileira.getWidth());
            final KeyFrame kfUp = new KeyFrame(Duration.millis(1000), kvUp1, kvUp2, kvUp3, kvUp4);
            timelineUp.getKeyFrames().add(kfUp);
            timelineUp.play();
        } else {
            try {
                pnCarregaPratileira.toFront();
                FXMLLoader listPratView = new FXMLLoader();
                listPratView.load(getClass().getResource("/view/ListaPratileira.fxml").openStream());
                ListaPratileiraController lpController = listPratView.getController();
                lpController.removeClass();
                lpController.scrollBtnPratileira(button.getText());
                Tooltip toot = new Tooltip("Voltar para Estantes");
                // acao para volta nesse controller
                lpController.btnBack.setOnAction(ic -> {
                    this.playThis(button);
                });
                lpController.btnBack.setTooltip(toot);
                lpController.btnBack.setVisible(true);
                lpController.boxCaminho.setVisible(true);
                lpController.btnClosePratileira.setVisible(false);
                AnchorPane root = listPratView.getRoot();
                pnCarregaPratileira.getChildren().add(root);
                btnCloseEstante.toFront();
                Timeline timeDireita = new Timeline();
                final KeyValue kvDir1 = new KeyValue(clipRectNextPratieira.widthProperty(), pnCarregaPratileira.getWidth());
                final KeyValue kvDir2 = new KeyValue(clipRectNextPratieira.translateXProperty(), 0);
                final KeyValue kvDir4 = new KeyValue(pnCarregaPratileira.prefWidthProperty(), pnCarregaPratileira.getWidth());
                final KeyValue kvDir3 = new KeyValue(pnCarregaPratileira.translateXProperty(), 0);
                final KeyFrame kfDwn = new KeyFrame(Duration.millis(600), kvDir1, kvDir2, kvDir3, kvDir4);
                timeDireita.getKeyFrames().add(kfDwn);
                timeDireita.play();
            } catch (IOException ex) {
                Logger.getLogger(ListaEstanteController.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }));
    timeline.play();
}
Also used : EventHandler(javafx.event.EventHandler) JFXButton(com.jfoenix.controls.JFXButton) MaterialDesignIconView(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView) Pos(javafx.geometry.Pos) javafx.collections(javafx.collections) javafx.scene.layout(javafx.scene.layout) javafx.scene.control(javafx.scene.control) URL(java.net.URL) GroupBuilder(javafx.scene.GroupBuilder) MouseEvent(javafx.scene.input.MouseEvent) Session(org.hibernate.Session) Level(java.util.logging.Level) Calendar(java.util.Calendar) Insets(javafx.geometry.Insets) ResourceBundle(java.util.ResourceBundle) KeyValue(javafx.animation.KeyValue) JFXTextArea(com.jfoenix.controls.JFXTextArea) Orientation(javafx.geometry.Orientation) KeyFrame(javafx.animation.KeyFrame) Rectangle2D(javafx.geometry.Rectangle2D) FilteredList(javafx.collections.transformation.FilteredList) Font(javafx.scene.text.Font) Timeline(javafx.animation.Timeline) Rectangle(javafx.scene.shape.Rectangle) IOException(java.io.IOException) Logger(java.util.logging.Logger) Estante(model.Estante) List(java.util.List) ActionEvent(javafx.event.ActionEvent) Duration(javafx.util.Duration) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Stage(javafx.stage.Stage) Paint(javafx.scene.paint.Paint) javafx.fxml(javafx.fxml) MaterialDesignIcon(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon) ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) JFXTextField(com.jfoenix.controls.JFXTextField) Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) IOException(java.io.IOException)

Aggregations

Timeline (javafx.animation.Timeline)111 KeyFrame (javafx.animation.KeyFrame)107 KeyValue (javafx.animation.KeyValue)81 Duration (javafx.util.Duration)32 ActionEvent (javafx.event.ActionEvent)22 JFXButton (com.jfoenix.controls.JFXButton)20 IOException (java.io.IOException)19 URL (java.net.URL)19 ResourceBundle (java.util.ResourceBundle)19 FXML (javafx.fxml.FXML)19 Initializable (javafx.fxml.Initializable)18 FXMLLoader (javafx.fxml.FXMLLoader)17 Pane (javafx.scene.layout.Pane)17 AnchorPane (javafx.scene.layout.AnchorPane)16 Level (java.util.logging.Level)15 Logger (java.util.logging.Logger)15 MouseEvent (javafx.scene.input.MouseEvent)14 Rotate (javafx.scene.transform.Rotate)14 JFXTextField (com.jfoenix.controls.JFXTextField)12 Interpolator (javafx.animation.Interpolator)12