Search in sources :

Example 11 with Timeline

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

the class JFXCustomColorPicker method preAnimate.

public void preAnimate() {
    double x = curves.get(0).getStartX();
    double y = curves.get(0).getStartY();
    curves.get(0).setStartX(centerX);
    curves.get(0).setStartY(centerY);
    double x1 = curves.get(1).getStartX();
    double y1 = curves.get(1).getStartY();
    curves.get(1).setStartX(centerX);
    curves.get(1).setStartY(centerY);
    double cx1 = curves.get(0).getControlX1();
    double cy1 = curves.get(0).getControlY1();
    curves.get(0).setControlX1(centerX + radius);
    curves.get(0).setControlY1(centerY + radius / 2);
    showAnimation = new CachedTransition(this, new Timeline(new KeyFrame(Duration.millis(1000), new KeyValue(curves.get(0).startXProperty(), x, Interpolator.EASE_BOTH), new KeyValue(curves.get(0).startYProperty(), y, Interpolator.EASE_BOTH), new KeyValue(curves.get(1).startXProperty(), x1, Interpolator.EASE_BOTH), new KeyValue(curves.get(1).startYProperty(), y1, Interpolator.EASE_BOTH), new KeyValue(curves.get(0).controlX1Property(), cx1, Interpolator.EASE_BOTH), new KeyValue(curves.get(0).controlY1Property(), cy1, Interpolator.EASE_BOTH)))) {

        {
            setCycleDuration(Duration.millis(240));
            setDelay(Duration.millis(0));
        }
    };
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) CachedTransition(com.jfoenix.transitions.CachedTransition)

Example 12 with Timeline

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

the class JFXColorPickerSkin method updateColor.

private void updateColor() {
    final ColorPicker colorPicker = (ColorPicker) getSkinnable();
    // update picker box color
    Circle ColorCircle = new Circle();
    ColorCircle.setFill(colorPicker.getValue());
    ColorCircle.setLayoutX(pickerColorBox.getWidth() / 4);
    ColorCircle.setLayoutY(pickerColorBox.getHeight() / 2);
    pickerColorBox.getChildren().add(ColorCircle);
    Timeline animateColor = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(ColorCircle.radiusProperty(), 200, Interpolator.EASE_BOTH)));
    animateColor.setOnFinished((finish) -> {
        pickerColorBox.setBackground(new Background(new BackgroundFill(ColorCircle.getFill(), pickerColorBox.getBackground().getFills().get(0).getRadii(), pickerColorBox.getBackground().getFills().get(0).getInsets())));
        pickerColorBox.getChildren().remove(ColorCircle);
    });
    animateColor.play();
    // update label color
    displayNode.setTextFill(colorPicker.getValue().grayscale().getRed() < 0.5 ? Color.valueOf("rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)"));
    if (colorLabelVisible.get())
        displayNode.setText(colorDisplayName(colorPicker.getValue()));
    else
        displayNode.setText("");
}
Also used : Circle(javafx.scene.shape.Circle) Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) ColorPicker(javafx.scene.control.ColorPicker) KeyFrame(javafx.animation.KeyFrame)

Example 13 with Timeline

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

the class JFXSpinner method layoutChildren.

/**
	 * {@inheritDoc}
	 */
@Override
protected void layoutChildren() {
    if (!initialized) {
        super.layoutChildren();
        initialColor = (Color) arc.getStroke();
        if (initialColor == null) {
            arc.setStroke(blueColor);
        }
        KeyFrame[] blueFrame = getKeyFrames(0, 0, initialColor == null ? blueColor : initialColor);
        KeyFrame[] redFrame = getKeyFrames(450, 1.4, initialColor == null ? redColor : initialColor);
        KeyFrame[] yellowFrame = getKeyFrames(900, 2.8, initialColor == null ? yellowColor : initialColor);
        KeyFrame[] greenFrame = getKeyFrames(1350, 4.2, initialColor == null ? greenColor : initialColor);
        KeyFrame endingFrame = new KeyFrame(Duration.seconds(5.6), new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR), new KeyValue(arc.startAngleProperty(), 1845 + getStartingAngle(), Interpolator.LINEAR));
        if (timeline != null)
            timeline.stop();
        timeline = new Timeline(blueFrame[0], blueFrame[1], blueFrame[2], blueFrame[3], redFrame[0], redFrame[1], redFrame[2], redFrame[3], yellowFrame[0], yellowFrame[1], yellowFrame[2], yellowFrame[3], greenFrame[0], greenFrame[1], greenFrame[2], greenFrame[3], endingFrame);
        timeline.setCycleCount(Timeline.INDEFINITE);
        timeline.setRate(1);
        timeline.play();
        initialized = true;
    }
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 14 with Timeline

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

the class AnimatedFlowContainer method setViewContext.

@Override
public <U> void setViewContext(ViewContext<U> context) {
    updatePlaceholder(context.getRootNode());
    if (animation != null) {
        animation.stop();
    }
    animation = new Timeline();
    animation.getKeyFrames().addAll(animationProducer.apply(this));
    animation.getKeyFrames().add(new KeyFrame(duration, (e) -> clearPlaceholder()));
    animation.play();
}
Also used : Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) FlowContainer(io.datafx.controller.flow.FlowContainer) Node(javafx.scene.Node) Timeline(javafx.animation.Timeline) WritableImage(javafx.scene.image.WritableImage) ViewContext(io.datafx.controller.context.ViewContext) SnapshotParameters(javafx.scene.SnapshotParameters) StackPane(javafx.scene.layout.StackPane) Function(java.util.function.Function) Duration(javafx.util.Duration) List(java.util.List) ImageView(javafx.scene.image.ImageView) ContainerAnimations(io.datafx.controller.flow.container.ContainerAnimations) Image(javafx.scene.image.Image) Timeline(javafx.animation.Timeline) KeyFrame(javafx.animation.KeyFrame)

Example 15 with Timeline

use of javafx.animation.Timeline in project fxexperience2 by EricCanull.

the class BounceInDownTransition method starting.

@Override
protected void starting() {
    double startY = -node.localToScene(0, 0).getY() - node.getBoundsInParent().getHeight();
    timeline = new Timeline();
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(node.translateYProperty(), startY, WEB_EASE)));
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(600), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(node.translateYProperty(), 30, WEB_EASE)));
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(800), new KeyValue(node.translateYProperty(), -10, WEB_EASE)));
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(1000), new KeyValue(node.translateYProperty(), 0, WEB_EASE)));
    super.starting();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Aggregations

Timeline (javafx.animation.Timeline)91 KeyFrame (javafx.animation.KeyFrame)87 KeyValue (javafx.animation.KeyValue)77 Rotate (javafx.scene.transform.Rotate)14 MouseEvent (javafx.scene.input.MouseEvent)13 Duration (javafx.util.Duration)13 Interpolator (javafx.animation.Interpolator)12 Insets (javafx.geometry.Insets)9 PerspectiveCamera (javafx.scene.PerspectiveCamera)9 Scene (javafx.scene.Scene)8 ActionEvent (javafx.event.ActionEvent)7 Group (javafx.scene.Group)7 Node (javafx.scene.Node)7 KeyCode (javafx.scene.input.KeyCode)7 Color (javafx.scene.paint.Color)7 AnimationTimer (javafx.animation.AnimationTimer)6 EventHandler (javafx.event.EventHandler)6 Label (javafx.scene.control.Label)6 Rectangle (javafx.scene.shape.Rectangle)6 ArrayList (java.util.ArrayList)5