Search in sources :

Example 6 with ParallelTransition

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

the class JFXMasonryPane method layoutChildren.

/**
 * {@inheritDoc}
 */
@Override
protected void layoutChildren() {
    performingLayout = true;
    int col, row;
    col = (int) Math.floor((getWidth() + getHSpacing() - snappedLeftInset() - snappedRightInset()) / (getCellWidth() + getHSpacing()));
    col = getLimitColumn() != -1 && col > getLimitColumn() ? getLimitColumn() : col;
    if (matrix != null && col == matrix[0].length) {
        performingLayout = false;
        return;
    }
    // (int) Math.floor(this.getHeight() / (cellH + 2*vSpacing));
    row = getLimitRow();
    matrix = new int[row][col];
    double minWidth = -1;
    double minHeight = -1;
    List<BoundingBox> newBoxes;
    List<Region> managedChildren = getManagedChildren();
    // filter Region nodes
    for (int i = 0; i < managedChildren.size(); i++) {
        if (!(managedChildren.get(i) instanceof Region)) {
            managedChildren.remove(i);
            i--;
        }
    }
    // get bounding boxes layout
    newBoxes = layoutMode.get().fillGrid(matrix, managedChildren, getCellWidth(), getCellHeight(), row, col, getHSpacing(), getVSpacing());
    if (newBoxes == null) {
        performingLayout = false;
        return;
    }
    HashMap<Node, BoundingBox> oldBoxes = boundingBoxes;
    if (dirtyBoxes) {
        boundingBoxes = new HashMap<>();
    }
    for (int i = 0; i < managedChildren.size() && i < newBoxes.size(); i++) {
        final Region child = managedChildren.get(i);
        final BoundingBox boundingBox = newBoxes.get(i);
        if (!(child instanceof GridPane)) {
            double blockX;
            double blockY;
            double blockWidth;
            double blockHeight;
            if (boundingBox != null) {
                blockX = boundingBox.getMinY() * getCellWidth() + boundingBox.getMinY() * getHSpacing() + snappedLeftInset();
                blockY = boundingBox.getMinX() * getCellHeight() + boundingBox.getMinX() * getVSpacing() + snappedTopInset();
                blockWidth = boundingBox.getWidth() * getCellWidth() + (boundingBox.getWidth() - 1) * getHSpacing();
                blockHeight = boundingBox.getHeight() * getCellHeight() + (boundingBox.getHeight() - 1) * getVSpacing();
            } else {
                blockX = child.getLayoutX();
                blockY = child.getLayoutY();
                blockWidth = -1;
                blockHeight = -1;
            }
            if (animationMap == null) {
                // init static children
                child.setPrefSize(blockWidth, blockHeight);
                child.resizeRelocate(blockX, blockY, blockWidth, blockHeight);
            } else {
                BoundingBox oldBoundingBox = oldBoxes.get(child);
                if (oldBoundingBox == null || (!oldBoundingBox.equals(boundingBox) && dirtyBoxes)) {
                    // handle new children
                    child.setOpacity(0);
                    child.setPrefSize(blockWidth, blockHeight);
                    child.resizeRelocate(blockX, blockY, blockWidth, blockHeight);
                }
                if (boundingBox != null) {
                    // handle children repositioning
                    if (child.getWidth() != blockWidth || child.getHeight() != blockHeight) {
                        child.setOpacity(0);
                        child.setPrefSize(blockWidth, blockHeight);
                        child.resizeRelocate(blockX, blockY, blockWidth, blockHeight);
                    }
                    final KeyFrame keyFrame = new KeyFrame(Duration.millis(2000), new KeyValue(child.opacityProperty(), 1, Interpolator.LINEAR), new KeyValue(child.layoutXProperty(), blockX, Interpolator.LINEAR), new KeyValue(child.layoutYProperty(), blockY, Interpolator.LINEAR));
                    animationMap.put(child, new CachedTransition(child, new Timeline(keyFrame)) {

                        {
                            setCycleDuration(Duration.seconds(0.320));
                            setDelay(Duration.seconds(0));
                            setOnFinished((finish) -> {
                                child.setLayoutX(blockX);
                                child.setLayoutY(blockY);
                                child.setOpacity(1);
                            });
                        }
                    });
                } else {
                    // handle children is being hidden ( cause it can't fit in the pane )
                    final KeyFrame keyFrame = new KeyFrame(Duration.millis(2000), new KeyValue(child.opacityProperty(), 0, Interpolator.LINEAR), new KeyValue(child.layoutXProperty(), blockX, Interpolator.LINEAR), new KeyValue(child.layoutYProperty(), blockY, Interpolator.LINEAR));
                    animationMap.put(child, new CachedTransition(child, new Timeline(keyFrame)) {

                        {
                            setCycleDuration(Duration.seconds(0.320));
                            setDelay(Duration.seconds(0));
                            setOnFinished((finish) -> {
                                child.setLayoutX(blockX);
                                child.setLayoutY(blockY);
                                child.setOpacity(0);
                            });
                        }
                    });
                }
            }
            // update bounding box
            boundingBoxes.put(child, boundingBox);
            if (boundingBox != null) {
                if (blockX + blockWidth > minWidth) {
                    minWidth = blockX + blockWidth;
                }
                if (blockY + blockHeight > minHeight) {
                    minHeight = blockY + blockHeight;
                }
            }
        }
    }
    if (minHeight != -1) {
        minHeight += snappedBottomInset();
        setPrefHeight(minHeight);
    }
    if (animationMap == null) {
        animationMap = new HashMap<>();
    }
    trans.stop();
    ParallelTransition newTransition = new ParallelTransition();
    newTransition.getChildren().addAll(animationMap.values());
    newTransition.play();
    trans = newTransition;
    dirtyBoxes = false;
    performingLayout = false;
}
Also used : KeyFrame(javafx.animation.KeyFrame) ObjectProperty(javafx.beans.property.ObjectProperty) BoundingBox(javafx.geometry.BoundingBox) Node(javafx.scene.Node) Timeline(javafx.animation.Timeline) DoubleProperty(javafx.beans.property.DoubleProperty) HashMap(java.util.HashMap) IntegerProperty(javafx.beans.property.IntegerProperty) Transition(javafx.animation.Transition) ArrayList(java.util.ArrayList) ParallelTransition(javafx.animation.ParallelTransition) CachedTransition(com.jfoenix.transitions.CachedTransition) Duration(javafx.util.Duration) List(java.util.List) Region(javafx.scene.layout.Region) Interpolator(javafx.animation.Interpolator) ListChangeListener(javafx.collections.ListChangeListener) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) WeakListChangeListener(javafx.collections.WeakListChangeListener) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) KeyValue(javafx.animation.KeyValue) GridPane(javafx.scene.layout.GridPane) Pane(javafx.scene.layout.Pane) GridPane(javafx.scene.layout.GridPane) KeyValue(javafx.animation.KeyValue) Node(javafx.scene.Node) Timeline(javafx.animation.Timeline) BoundingBox(javafx.geometry.BoundingBox) Region(javafx.scene.layout.Region) KeyFrame(javafx.animation.KeyFrame) CachedTransition(com.jfoenix.transitions.CachedTransition) ParallelTransition(javafx.animation.ParallelTransition)

Example 7 with ParallelTransition

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

the class JFXAutoCompletePopupSkin method animate.

public void animate() {
    updateListHeight();
    if (showTransition == null || showTransition.getStatus().equals(Status.STOPPED)) {
        if (scale == null) {
            scale = new Scale(1, 0);
            pane.getTransforms().add(scale);
        }
        scale.setY(0);
        suggestionList.setOpacity(0);
        scale.setPivotX(pane.getLayoutBounds().getWidth() / 2);
        showTransition = new Timeline(new KeyFrame(Duration.millis(120), new KeyValue(scale.yProperty(), 1, Interpolator.EASE_BOTH)));
        showTransition.setOnFinished((finish) -> {
            Group vf = (Group) suggestionList.lookup(".sheet");
            ParallelTransition trans = new ParallelTransition();
            for (int i = 0; i < vf.getChildren().size(); i++) {
                ListCell<T> cell = (ListCell<T>) vf.getChildren().get(i);
                int index = cell.getIndex();
                if (index > -1) {
                    cell.setOpacity(0);
                    cell.setTranslateY(-suggestionList.getFixedCellSize() / 8);
                    Timeline f = new Timeline(new KeyFrame(Duration.millis(120), end -> {
                        cell.setOpacity(1);
                        cell.setTranslateY(0);
                    }, new KeyValue(cell.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(cell.translateYProperty(), 0, Interpolator.EASE_BOTH)));
                    f.setDelay(Duration.millis(index * 20));
                    trans.getChildren().add(f);
                }
            }
            suggestionList.setOpacity(1);
            trans.play();
        });
        showTransition.play();
    }
}
Also used : KeyFrame(javafx.animation.KeyFrame) MouseButton(javafx.scene.input.MouseButton) ListView(javafx.scene.control.ListView) Status(javafx.animation.Animation.Status) ListCell(javafx.scene.control.ListCell) Node(javafx.scene.Node) JFXAutoCompletePopup(com.jfoenix.controls.JFXAutoCompletePopup) Timeline(javafx.animation.Timeline) StackPane(javafx.scene.layout.StackPane) Group(javafx.scene.Group) Skin(javafx.scene.control.Skin) InvalidationListener(javafx.beans.InvalidationListener) ParallelTransition(javafx.animation.ParallelTransition) Duration(javafx.util.Duration) Interpolator(javafx.animation.Interpolator) Scale(javafx.scene.transform.Scale) JFXAutoCompleteEvent(com.jfoenix.controls.events.JFXAutoCompleteEvent) KeyValue(javafx.animation.KeyValue) Group(javafx.scene.Group) Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) ListCell(javafx.scene.control.ListCell) KeyFrame(javafx.animation.KeyFrame) Scale(javafx.scene.transform.Scale) ParallelTransition(javafx.animation.ParallelTransition)

Example 8 with ParallelTransition

use of javafx.animation.ParallelTransition in project Malai by arnobl.

the class DnDHelpAnimation method createTransition.

@Override
public Transition createTransition() {
    ell = new Ellipse(x1, y1, size, size);
    text = new Text(textPress);
    text.xProperty().bind(ell.centerXProperty().add(ell.getRadiusX()));
    text.yProperty().bind(ell.centerYProperty().subtract(ell.getRadiusY()));
    ell.setFill(Color.LIGHTGRAY);
    ell.setEffect(new DropShadow(20d, Color.BLACK));
    helpPane.getChildren().add(ell);
    helpPane.getChildren().add(text);
    ell.setVisible(false);
    text.setVisible(false);
    ell.setFocusTraversable(false);
    ell.setMouseTransparent(true);
    text.setFocusTraversable(false);
    text.setMouseTransparent(true);
    final SequentialTransition mainTrans = new SequentialTransition();
    final ParallelTransition parallelTransition = new ParallelTransition(new Timeline(new KeyFrame(duration, new KeyValue(ell.centerXProperty(), x2))), new Timeline(new KeyFrame(duration, new KeyValue(ell.centerYProperty(), y2))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(text.visibleProperty(), Boolean.TRUE))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(ell.visibleProperty(), Boolean.TRUE))));
    mainTrans.getChildren().add(new PauseTransition(Duration.seconds(1.5)));
    mainTrans.getChildren().add(new ParallelTransition(new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusXProperty(), size / 2d))), new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusYProperty(), size / 2d)))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(100d), new KeyValue(text.textProperty(), textDrag))));
    mainTrans.getChildren().add(parallelTransition);
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(100d), new KeyValue(text.textProperty(), textRelease))));
    mainTrans.getChildren().add(new ParallelTransition(new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusXProperty(), size))), new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusYProperty(), size)))));
    mainTrans.getChildren().add(new PauseTransition(Duration.seconds(1.5)));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(text.visibleProperty(), Boolean.FALSE))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(ell.visibleProperty(), Boolean.FALSE))));
    transition = mainTrans;
    return transition;
}
Also used : Ellipse(javafx.scene.shape.Ellipse) Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) SequentialTransition(javafx.animation.SequentialTransition) KeyFrame(javafx.animation.KeyFrame) Text(javafx.scene.text.Text) PauseTransition(javafx.animation.PauseTransition) DropShadow(javafx.scene.effect.DropShadow) ParallelTransition(javafx.animation.ParallelTransition)

Example 9 with ParallelTransition

use of javafx.animation.ParallelTransition in project tilesfx by HanSolo.

the class StockTileSkin method handleCurrentValue.

@Override
protected void handleCurrentValue(final double VALUE) {
    low = Statistics.getMin(dataList);
    high = Statistics.getMax(dataList);
    if (Helper.equals(low, high)) {
        low = minValue;
        high = maxValue;
    }
    range = high - low;
    double minX = graphBounds.getX();
    double maxX = minX + graphBounds.getWidth();
    double minY = graphBounds.getY();
    double maxY = minY + graphBounds.getHeight();
    double stepX = graphBounds.getWidth() / (noOfDatapoints - 1);
    double stepY = graphBounds.getHeight() / range;
    double referenceValue = tile.getReferenceValue();
    if (!dataList.isEmpty()) {
        MoveTo begin = (MoveTo) pathElements.get(0);
        begin.setX(minX);
        begin.setY(maxY - Math.abs(low - dataList.get(0)) * stepY);
        for (int i = 1; i < (noOfDatapoints - 1); i++) {
            LineTo lineTo = (LineTo) pathElements.get(i);
            lineTo.setX(minX + i * stepX);
            lineTo.setY(maxY - Math.abs(low - dataList.get(i)) * stepY);
        }
        LineTo end = (LineTo) pathElements.get(noOfDatapoints - 1);
        end.setX(maxX);
        end.setY(maxY - Math.abs(low - dataList.get(noOfDatapoints - 1)) * stepY);
        dot.setCenterX(maxX);
        dot.setCenterY(end.getY());
        updateState(VALUE, referenceValue);
        referenceLine.setStartY(maxY - Math.abs(low - referenceValue) * stepY);
        referenceLine.setEndY(maxY - Math.abs(low - referenceValue) * stepY);
        changeText.setText(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (VALUE - referenceValue)));
        changePercentageText.setText(new StringBuilder().append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (VALUE / referenceValue * 100.0) - 100.0)).append("\u0025").toString());
        RotateTransition rotateTransition = new RotateTransition(Duration.millis(200), triangle);
        rotateTransition.setFromAngle(triangle.getRotate());
        rotateTransition.setToAngle(state.angle);
        FillTransition fillIndicatorTransition = new FillTransition(Duration.millis(200), triangle);
        fillIndicatorTransition.setFromValue((Color) triangle.getFill());
        fillIndicatorTransition.setToValue(state.color);
        FillTransition fillReferenceTransition = new FillTransition(Duration.millis(200), changePercentageText);
        fillReferenceTransition.setFromValue((Color) triangle.getFill());
        fillReferenceTransition.setToValue(state.color);
        ParallelTransition parallelTransition = new ParallelTransition(rotateTransition, fillIndicatorTransition, fillReferenceTransition);
        parallelTransition.play();
    }
    valueText.setText(String.format(locale, formatString, VALUE));
    highText.setText(String.format(locale, formatString, high));
    lowText.setText(String.format(locale, formatString, low));
    if (!tile.isTextVisible() && null != movingAverage.getTimeSpan()) {
        timeSpanText.setText(createTimeSpanText());
        text.setText(timeFormatter.format(movingAverage.getLastEntry().getTimestampAsDateTime(tile.getZoneId())));
    }
    resizeDynamicText();
}
Also used : MoveTo(javafx.scene.shape.MoveTo) LineTo(javafx.scene.shape.LineTo) FillTransition(javafx.animation.FillTransition) RotateTransition(javafx.animation.RotateTransition) ParallelTransition(javafx.animation.ParallelTransition)

Example 10 with ParallelTransition

use of javafx.animation.ParallelTransition in project tilesfx by HanSolo.

the class HighLowTileSkin method handleCurrentValue.

@Override
protected void handleCurrentValue(final double VALUE) {
    double deviation = calculateDeviation(VALUE);
    updateState(deviation);
    valueText.setText(String.format(locale, formatString, VALUE));
    deviationText.setText(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", deviation));
    RotateTransition rotateTransition = new RotateTransition(Duration.millis(200), triangle);
    rotateTransition.setFromAngle(triangle.getRotate());
    rotateTransition.setToAngle(state.angle);
    FillTransition fillIndicatorTransition = new FillTransition(Duration.millis(200), triangle);
    fillIndicatorTransition.setFromValue((Color) triangle.getFill());
    fillIndicatorTransition.setToValue(state.color);
    FillTransition fillReferenceTransition = new FillTransition(Duration.millis(200), deviationText);
    fillReferenceTransition.setFromValue((Color) triangle.getFill());
    fillReferenceTransition.setToValue(state.color);
    FillTransition fillReferenceUnitTransition = new FillTransition(Duration.millis(200), deviationUnitText);
    fillReferenceUnitTransition.setFromValue((Color) triangle.getFill());
    fillReferenceUnitTransition.setToValue(state.color);
    ParallelTransition parallelTransition = new ParallelTransition(rotateTransition, fillIndicatorTransition, fillReferenceTransition, fillReferenceUnitTransition);
    parallelTransition.play();
}
Also used : FillTransition(javafx.animation.FillTransition) RotateTransition(javafx.animation.RotateTransition) ParallelTransition(javafx.animation.ParallelTransition)

Aggregations

ParallelTransition (javafx.animation.ParallelTransition)11 KeyFrame (javafx.animation.KeyFrame)5 KeyValue (javafx.animation.KeyValue)5 SequentialTransition (javafx.animation.SequentialTransition)5 Timeline (javafx.animation.Timeline)5 FadeTransition (javafx.animation.FadeTransition)4 PauseTransition (javafx.animation.PauseTransition)4 Duration (javafx.util.Duration)4 ArrayList (java.util.ArrayList)3 Interpolator (javafx.animation.Interpolator)3 RotateTransition (javafx.animation.RotateTransition)3 HashMap (java.util.HashMap)2 List (java.util.List)2 FillTransition (javafx.animation.FillTransition)2 ScaleTransition (javafx.animation.ScaleTransition)2 Transition (javafx.animation.Transition)2 Group (javafx.scene.Group)2 Node (javafx.scene.Node)2 JFXAutoCompletePopup (com.jfoenix.controls.JFXAutoCompletePopup)1 JFXAutoCompleteEvent (com.jfoenix.controls.events.JFXAutoCompleteEvent)1