Search in sources :

Example 41 with KeyValue

use of javafx.animation.KeyValue 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 42 with KeyValue

use of javafx.animation.KeyValue 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 43 with KeyValue

use of javafx.animation.KeyValue 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)

Example 44 with KeyValue

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

the class ListaPastaController method playThis.

private void playThis(JFXButton button) {
    Timeline timeline = new Timeline(new KeyFrame(Duration.millis(250), ev -> {
        clipRectNextDocument.setHeight(pnCarregaDocumentos.getHeight());
        if (clipRectNextDocument.widthProperty().get() != 0) {
            Timeline timelineUp = new Timeline();
            final KeyValue kvUp1 = new KeyValue(clipRectNextDocument.widthProperty(), 0);
            final KeyValue kvUp2 = new KeyValue(clipRectNextDocument.translateXProperty(), pnCarregaDocumentos.getWidth());
            final KeyValue kvUp4 = new KeyValue(pnCarregaDocumentos.prefWidthProperty(), 0);
            final KeyValue kvUp3 = new KeyValue(pnCarregaDocumentos.translateXProperty(), pnCarregaDocumentos.getWidth());
            final KeyFrame kfUp = new KeyFrame(Duration.millis(1000), kvUp1, kvUp2, kvUp3, kvUp4);
            timelineUp.getKeyFrames().add(kfUp);
            timelineUp.play();
        } else {
            try {
                if (b == true) {
                    Pasta past = (Pasta) db.getEstOrPratOrPastByCodigo(button.getText(), Pasta.class);
                    Pratileira prat = (Pratileira) db.buscarPorId(Pratileira.class, past.getPratileira());
                    codigoPratileiraLb.setText(prat.getCodigo());
                    Estante es = (Estante) db.buscarPorId(Estante.class, prat.getEstante());
                    codigoEstanteLb.setText(es.getCodigo());
                }
                clipRectNextDocument.setHeight(pnCarregaDocumentos.getHeight());
                pnCarregaDocumentos.toFront();
                FXMLLoader fxmlLoader = new FXMLLoader();
                fxmlLoader.load(getClass().getResource("/view/ListaDocumento.fxml").openStream());
                ListaDocumentoController lDocController = fxmlLoader.getController();
                lDocController.btnBack.setOnAction(xs -> {
                    this.playThis(button);
                });
                lDocController.scrollBtnPauta(codigoEstanteLb.getText(), codigoPratileiraLb.getText(), button.getText());
                lDocController.removeClass();
                lDocController.boxCaminho.setVisible(true);
                lDocController.btnBack.setVisible(true);
                lDocController.btnCloseDoc.setVisible(false);
                clipRectNextDocument.toFront();
                AnchorPane root = fxmlLoader.getRoot();
                pnCarregaDocumentos.getChildren().clear();
                pnCarregaDocumentos.getChildren().add(root);
                Timeline timeDireita = new Timeline();
                final KeyValue kvDwn1 = new KeyValue(clipRectNextDocument.widthProperty(), pnCarregaDocumentos.getWidth());
                final KeyValue kvDwn2 = new KeyValue(clipRectNextDocument.translateXProperty(), 0);
                final KeyValue kvDwn4 = new KeyValue(pnCarregaDocumentos.prefWidthProperty(), pnCarregaDocumentos.getWidth());
                final KeyValue kvDwn3 = new KeyValue(pnCarregaDocumentos.translateXProperty(), 0);
                final KeyFrame kfDwn = new KeyFrame(Duration.millis(600), kvDwn1, kvDwn2, kvDwn3, kvDwn4);
                timeDireita.getKeyFrames().add(kfDwn);
                timeDireita.play();
            } catch (Exception ex) {
                Logger.getLogger(ListaDocumentoController.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }));
    timeline.play();
}
Also used : JFXButton(com.jfoenix.controls.JFXButton) MaterialDesignIconView(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView) Initializable(javafx.fxml.Initializable) URL(java.net.URL) SQLQuery(org.hibernate.SQLQuery) Session(org.hibernate.Session) Pratileira(model.Pratileira) Level(java.util.logging.Level) Insets(javafx.geometry.Insets) ScrollPane(javafx.scene.control.ScrollPane) ResourceBundle(java.util.ResourceBundle) Pasta(model.Pasta) FXMLLoader(javafx.fxml.FXMLLoader) KeyValue(javafx.animation.KeyValue) GridPane(javafx.scene.layout.GridPane) OctIconView(de.jensd.fx.glyphs.octicons.OctIconView) Pane(javafx.scene.layout.Pane) HBox(javafx.scene.layout.HBox) KeyFrame(javafx.animation.KeyFrame) Label(javafx.scene.control.Label) OctIcon(de.jensd.fx.glyphs.octicons.OctIcon) Timeline(javafx.animation.Timeline) Rectangle(javafx.scene.shape.Rectangle) IOException(java.io.IOException) Logger(java.util.logging.Logger) Estante(model.Estante) FXML(javafx.fxml.FXML) List(java.util.List) Duration(javafx.util.Duration) AnchorPane(javafx.scene.layout.AnchorPane) Paint(javafx.scene.paint.Paint) MaterialDesignIcon(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon) ContentDisplay(javafx.scene.control.ContentDisplay) Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) Pratileira(model.Pratileira) KeyFrame(javafx.animation.KeyFrame) Pasta(model.Pasta) FXMLLoader(javafx.fxml.FXMLLoader) AnchorPane(javafx.scene.layout.AnchorPane) IOException(java.io.IOException) Estante(model.Estante)

Example 45 with KeyValue

use of javafx.animation.KeyValue in project JFoenix by jfoenixadmin.

the class JFXListCell method updateItem.

/**
	 * {@inheritDoc}
	 */
@Override
public void updateItem(T item, boolean empty) {
    super.updateItem(item, empty);
    if (empty) {
        setText(null);
        setGraphic(null);
        // remove empty (Trailing cells)
        setMouseTransparent(true);
        setStyle("-fx-background-color:TRANSPARENT;");
    } else {
        if (item != null) {
            // if cell is not a trailing cell then show it
            setStyle(null);
            setMouseTransparent(false);
            Node currentNode = getGraphic();
            Node newNode;
            if ((item instanceof Region || item instanceof Control))
                newNode = (Node) item;
            else
                newNode = new Label(item.toString());
            boolean isJFXListView = getListView() instanceof JFXListView;
            // show cell tooltip if its toggled in JFXListView
            if (isJFXListView && ((JFXListView<?>) getListView()).isShowTooltip() && newNode instanceof Label) {
                setTooltip(new Tooltip(((Label) newNode).getText()));
            }
            if (currentNode == null || !currentNode.equals(newNode)) {
                // clear nodes
                cellContent = newNode;
                cellRippler.rippler.cacheRippleClip(false);
                // RIPPLER ITEM : in case if the list item has its own rippler bind the list rippler and item rippler properties
                if (newNode instanceof JFXRippler) {
                    // build cell container from exisiting rippler
                    cellRippler.ripplerFillProperty().bind(((JFXRippler) newNode).ripplerFillProperty());
                    cellRippler.maskTypeProperty().bind(((JFXRippler) newNode).maskTypeProperty());
                    cellRippler.positionProperty().bind(((JFXRippler) newNode).positionProperty());
                    cellContent = ((JFXRippler) newNode).getControl();
                } else // SUBLIST ITEM : build the Cell node as sublist the sublist
                if (newNode instanceof JFXListView<?>) {
                    // add the sublist to the parent and style the cell as sublist item
                    ((JFXListView<?>) getListView()).addSublist((JFXListView<?>) newNode, this.getIndex());
                    this.getStyleClass().add("sublist-item");
                    if (this.getPadding() != null)
                        this.setPadding(new Insets(this.getPadding().getTop(), 0, this.getPadding().getBottom(), 0));
                    // First build the group item used to expand / hide the sublist
                    StackPane groupNode = new StackPane();
                    groupNode.getStyleClass().add("sublist-header");
                    SVGGlyph dropIcon = new SVGGlyph(0, "ANGLE_RIGHT", "M340 548.571q0 7.429-5.714 13.143l-266.286 266.286q-5.714 5.714-13.143 5.714t-13.143-5.714l-28.571-28.571q-5.714-5.714-5.714-13.143t5.714-13.143l224.571-224.571-224.571-224.571q-5.714-5.714-5.714-13.143t5.714-13.143l28.571-28.571q5.714-5.714 13.143-5.714t13.143 5.714l266.286 266.286q5.714 5.714 5.714 13.143z", Color.BLACK);
                    dropIcon.setStyle("-fx-min-width:0.4em;-fx-max-width:0.4em;-fx-min-height:0.6em;-fx-max-height:0.6em;");
                    dropIcon.getStyleClass().add("drop-icon");
                    /*
						 *  alignment of the group node can be changed using the following css selector
						 *  .jfx-list-view .sublist-header{ }
						 */
                    groupNode.getChildren().setAll(((JFXListView<?>) newNode).getGroupnode(), dropIcon);
                    // the margin is needed when rotating the angle
                    StackPane.setMargin(dropIcon, new Insets(0, 19, 0, 0));
                    StackPane.setAlignment(dropIcon, Pos.CENTER_RIGHT);
                    // Second build the sublist container
                    StackPane sublistContainer = new StackPane();
                    sublistContainer.setMinHeight(0);
                    sublistContainer.setMaxHeight(0);
                    sublistContainer.getChildren().setAll(newNode);
                    sublistContainer.setTranslateY(this.snappedBottomInset());
                    sublistContainer.setOpacity(0);
                    StackPane.setMargin(newNode, new Insets(-1, -1, 0, -1));
                    //						sublistContainer.heightProperty().addListener((o,oldVal,newVal)->{
                    //							// store the hieght of the sublist and resize it to 0 to make it hidden
                    //							if(subListHeight == -1){
                    //								subListHeight = newVal.doubleValue() + this.snappedBottomInset()/2;
                    //								//								totalSubListsHeight += subListHeight;
                    //								// set the parent list 
                    //								Platform.runLater(()->{
                    //									sublistContainer.setMinHeight(0);
                    //									sublistContainer.setPrefHeight(0);
                    //									sublistContainer.setMaxHeight(0);
                    //									//									double currentHeight = ((JFXListView<T>)getListView()).getHeight();
                    //									// FIXME : THIS SHOULD ONLY CALLED ONCE ( NOW ITS BEING CALLED FOR EVERY SUBLIST)
                    //									//									updateListViewHeight(currentHeight - totalSubListsHeight);
                    //								});	
                    //							}
                    //						});
                    // Third, create container of group title and the sublist
                    VBox contentHolder = new VBox();
                    contentHolder.getChildren().setAll(groupNode, sublistContainer);
                    contentHolder.getStyleClass().add("sublist-container");
                    VBox.setVgrow(groupNode, Priority.ALWAYS);
                    cellContent = contentHolder;
                    cellRippler.ripplerPane.addEventHandler(MouseEvent.ANY, (e) -> e.consume());
                    contentHolder.addEventHandler(MouseEvent.ANY, (e) -> {
                        if (!e.isConsumed()) {
                            cellRippler.ripplerPane.fireEvent(e);
                            e.consume();
                        }
                    });
                    cellRippler.ripplerPane.addEventHandler(MouseEvent.MOUSE_CLICKED, (e) -> {
                        if (!e.isConsumed()) {
                            e.consume();
                            contentHolder.fireEvent(e);
                        }
                    });
                    // cache rippler clip in subnodes						
                    cellRippler.rippler.cacheRippleClip(true);
                    this.setOnMouseClicked((e) -> e.consume());
                    // Finally, add sublist animation						
                    contentHolder.setOnMouseClicked((click) -> {
                        click.consume();
                        // stop the animation or change the list height 
                        if (expandAnimation != null && expandAnimation.getStatus().equals(Status.RUNNING))
                            expandAnimation.stop();
                        // invert the expand property 
                        expandedProperty.set(!expandedProperty.get());
                        double newAnimatedHeight = ((Region) newNode).prefHeight(-1) * (expandedProperty.get() ? 1 : -1);
                        double newHeight = expandedProperty.get() ? this.getHeight() + newAnimatedHeight : this.prefHeight(-1);
                        // animate showing/hiding the sublist
                        double contentHeight = expandedProperty.get() ? newAnimatedHeight : 0;
                        if (expandedProperty.get()) {
                            updateClipHeight(newHeight);
                            getListView().setPrefHeight(getListView().getHeight() + newAnimatedHeight + animatedHeight);
                        }
                        // update the animated height
                        animatedHeight = newAnimatedHeight;
                        int opacity = expandedProperty.get() ? 1 : 0;
                        expandAnimation = new Timeline(new KeyFrame(Duration.millis(320), new KeyValue(sublistContainer.minHeightProperty(), contentHeight, Interpolator.EASE_BOTH), new KeyValue(sublistContainer.maxHeightProperty(), contentHeight, Interpolator.EASE_BOTH), new KeyValue(sublistContainer.opacityProperty(), opacity, Interpolator.EASE_BOTH)));
                        if (!expandedProperty.get()) {
                            expandAnimation.setOnFinished((finish) -> {
                                updateClipHeight(newHeight);
                                getListView().setPrefHeight(getListView().getHeight() + newAnimatedHeight);
                                animatedHeight = 0;
                            });
                        }
                        expandAnimation.play();
                    });
                    // animate arrow
                    expandedProperty.addListener((o, oldVal, newVal) -> {
                        if (newVal)
                            new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(dropIcon.rotateProperty(), 90, Interpolator.EASE_BOTH))).play();
                        else
                            new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(dropIcon.rotateProperty(), 0, Interpolator.EASE_BOTH))).play();
                    });
                }
                ((Region) cellContent).setMaxHeight(((Region) cellContent).prefHeight(-1));
                setGraphic(cellContent);
                setText(null);
            }
        }
    }
}
Also used : Pos(javafx.geometry.Pos) ListCell(javafx.scene.control.ListCell) Control(javafx.scene.control.Control) MouseEvent(javafx.scene.input.MouseEvent) StackPane(javafx.scene.layout.StackPane) VBox(javafx.scene.layout.VBox) Insets(javafx.geometry.Insets) KeyValue(javafx.animation.KeyValue) Tooltip(javafx.scene.control.Tooltip) Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) Label(javafx.scene.control.Label) Status(javafx.animation.Animation.Status) Node(javafx.scene.Node) Timeline(javafx.animation.Timeline) Rectangle(javafx.scene.shape.Rectangle) SVGGlyph(com.jfoenix.svg.SVGGlyph) Platform(javafx.application.Platform) Priority(javafx.scene.layout.Priority) BooleanProperty(javafx.beans.property.BooleanProperty) Duration(javafx.util.Duration) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Region(javafx.scene.layout.Region) Interpolator(javafx.animation.Interpolator) Shape(javafx.scene.shape.Shape) Insets(javafx.geometry.Insets) KeyValue(javafx.animation.KeyValue) Node(javafx.scene.Node) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) Control(javafx.scene.control.Control) Timeline(javafx.animation.Timeline) SVGGlyph(com.jfoenix.svg.SVGGlyph) Region(javafx.scene.layout.Region) KeyFrame(javafx.animation.KeyFrame) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane)

Aggregations

KeyValue (javafx.animation.KeyValue)85 KeyFrame (javafx.animation.KeyFrame)83 Timeline (javafx.animation.Timeline)82 Interpolator (javafx.animation.Interpolator)12 Rotate (javafx.scene.transform.Rotate)12 Duration (javafx.util.Duration)12 Insets (javafx.geometry.Insets)11 MouseEvent (javafx.scene.input.MouseEvent)10 PerspectiveCamera (javafx.scene.PerspectiveCamera)9 ArrayList (java.util.ArrayList)8 Scene (javafx.scene.Scene)7 Label (javafx.scene.control.Label)7 Rectangle (javafx.scene.shape.Rectangle)7 ActionEvent (javafx.event.ActionEvent)6 EventHandler (javafx.event.EventHandler)6 Group (javafx.scene.Group)6 Node (javafx.scene.Node)6 KeyCode (javafx.scene.input.KeyCode)6 VBox (javafx.scene.layout.VBox)6 JFXButton (com.jfoenix.controls.JFXButton)5