Java 类javafx.animation.Interpolator 实例源码

项目:incubator-netbeans    文件:TimelineInterpolator.java   
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(root, 250, 90));

    //create circles by method createMovingCircle listed below
    Circle circle1 = createMovingCircle(Interpolator.LINEAR); //default interpolator
    circle1.setOpacity(0.7);
    Circle circle2 = createMovingCircle(Interpolator.EASE_BOTH); //circle slows down when reached both ends of trajectory
    circle2.setOpacity(0.45);
    Circle circle3 = createMovingCircle(Interpolator.EASE_IN);
    Circle circle4 = createMovingCircle(Interpolator.EASE_OUT);
    Circle circle5 = createMovingCircle(Interpolator.SPLINE(0.5, 0.1, 0.1, 0.5)); //one can define own behaviour of interpolator by spline method

    root.getChildren().addAll(
            circle1,
            circle2,
            circle3,
            circle4,
            circle5
    );
}
项目:phone-simulator    文件:USSDGUIController.java   
private Timeline startAnimateForm300() {
    Timeline tml = new Timeline(
            new KeyFrame(Duration.ZERO, new KeyValue(pnlContent.maxHeightProperty(), 70)),
            new KeyFrame(Duration.seconds(0.4), new KeyValue(pnlContent.maxHeightProperty(), 300, Interpolator.EASE_BOTH)));
    tml.setOnFinished((ActionEvent event) -> {
        pnlForm.setVisible(true);
        txtSend.requestFocus();
    });
    return tml;
}
项目:phone-simulator    文件:USSDGUIController.java   
private Timeline startAnimateForm130() {
    Timeline tml = new Timeline(
            new KeyFrame(Duration.ZERO, new KeyValue(pnlContent.maxHeightProperty(), 70)),
            new KeyFrame(Duration.seconds(0.4), new KeyValue(pnlContent.maxHeightProperty(), 130, Interpolator.EASE_BOTH)));
    tml.setOnFinished((ActionEvent event) -> {

        pnlForm.setVisible(false);
        pnlMessage.setVisible(true);
    });

    return tml;
}
项目:incubator-netbeans    文件:TimelineInterpolator.java   
private Circle createMovingCircle(Interpolator interpolator) {
    //create a transparent circle
    Circle circle = new Circle(45,45, 40,  Color.web("1c89f4"));
    circle.setOpacity(0);
    //add effect
    circle.setEffect(new Lighting());

    //create a timeline for moving the circle

    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);

    //create a keyValue for horizontal translation of circle to the position 155px with given interpolator
    KeyValue keyValue = new KeyValue(circle.translateXProperty(), 155, interpolator);

    //create a keyFrame with duration 4s
    KeyFrame keyFrame = new KeyFrame(Duration.seconds(4), keyValue);

    //add the keyframe to the timeline
    timeline.getKeyFrames().add(keyFrame);

    return circle;
}
项目:dynamo    文件:LevelBarSkin.java   
private void updatePointer() {
    currentValueText.setText(formatCurrentValue(getSkinnable().getCurrentValue(), getSkinnable().getDecimals()));
    currentValueText.setFont(Font.font("Digital-7", width * CURRENT_VALUE_FONT_SIZE_FACTOR));
    currentValueText.setTextOrigin(VPos.TOP);
    currentValueText.setTextAlignment(TextAlignment.RIGHT);

    currentValuePointer.getStyleClass().clear();
    currentValuePointer.getStyleClass().setAll("normal-current-value-pointer");
    currentValuePointer.setPrefSize(currentValueText.getLayoutBounds().getWidth()*1.10, currentValueText.getLayoutBounds().getHeight()*1.10);
    currentValuePointerGroup.setTranslateX((width/2 + barWidth/2) - currentValuePointerGroup.getLayoutBounds().getWidth());

    final double newPosition =  getSkinnable().getCurrentValue() < getSkinnable().getMinValue() ? height - (currentValuePointerGroup.getLayoutBounds().getHeight() * 0.5) :
                                getSkinnable().getCurrentValue() > getSkinnable().getMaxValue() ? height - barHeight - (currentValuePointerGroup.getLayoutBounds().getHeight() * 0.5) :
                                height - (currentValuePointerGroup.getLayoutBounds().getHeight() * 0.5) - (barHeight * (getSkinnable().getCurrentValue()-getSkinnable().getMinValue()) / (getSkinnable().getMaxValue()-getSkinnable().getMinValue()));

    if(getSkinnable().getAnimated()){
        timeline.stop();
        final KeyValue KEY_VALUE = new KeyValue(currentValuePointerGroup.translateYProperty(), newPosition, Interpolator.EASE_BOTH);
        final KeyFrame KEY_FRAME = new KeyFrame(Duration.millis(getSkinnable().getAnimationDuration()), KEY_VALUE);
        timeline.getKeyFrames().setAll(KEY_FRAME);
        timeline.play();
    }else {
        currentValuePointerGroup.setTranslateY(newPosition);
    }
}
项目:util4j    文件:GameManager.java   
/**
 * Animation that moves the tile from its previous location to a new location 
 * @param tile to be animated
 * @param newLocation new location of the tile
 * @return a timeline 
 */
private Timeline animateExistingTile(Tile tile, Location newLocation) {
    Timeline timeline = new Timeline();
    KeyValue kvX = new KeyValue(tile.layoutXProperty(),
            newLocation.getLayoutX(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);
    KeyValue kvY = new KeyValue(tile.layoutYProperty(),
            newLocation.getLayoutY(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);

    KeyFrame kfX = new KeyFrame(ANIMATION_EXISTING_TILE, kvX);
    KeyFrame kfY = new KeyFrame(ANIMATION_EXISTING_TILE, kvY);

    timeline.getKeyFrames().add(kfX);
    timeline.getKeyFrames().add(kfY);

    return timeline;
}
项目:MultiAxisCharts    文件:MultiAxisLineChart.java   
private Timeline createDataRemoveTimeline(final Data<X, Y> item, final Node symbol, final Series<X, Y> series) {
    Timeline t = new Timeline();
    // save data values in case the same data item gets added immediately.
    XYValueMap.put(item, ((Number) item.getYValue()).doubleValue());

    t.getKeyFrames()
            .addAll(new KeyFrame(Duration.ZERO, new KeyValue(item.currentYProperty(), item.getCurrentY()),
                    new KeyValue(item.currentXProperty(), item.getCurrentX())),
                    new KeyFrame(Duration.millis(500), actionEvent -> {
                        if (symbol != null)
                            getPlotChildren().remove(symbol);
                        removeDataItemFromDisplay(series, item);
                        XYValueMap.clear();
                    }, new KeyValue(item.currentYProperty(), item.getYValue(), Interpolator.EASE_BOTH),
                            new KeyValue(item.currentXProperty(), item.getXValue(), Interpolator.EASE_BOTH)));
    return t;
}
项目:MultiAxisCharts    文件:MultiAxisBarChart.java   
private void animateDataAdd(Data<X, Y> item, Node bar) {
    double barVal;
    if (orientation == Orientation.VERTICAL) {
        barVal = ((Number) item.getYValue()).doubleValue();
        if (barVal < 0) {
            bar.getStyleClass().add(NEGATIVE_STYLE);
        }
        item.setCurrentY(getY1Axis().toRealValue((barVal < 0) ? -bottomPos : bottomPos));
        getPlotChildren().add(bar);
        item.setYValue(getY1Axis().toRealValue(barVal));
        animate(new KeyFrame(Duration.ZERO, new KeyValue(item.currentYProperty(), item.getCurrentY())),
                new KeyFrame(Duration.millis(700),
                        new KeyValue(item.currentYProperty(), item.getYValue(), Interpolator.EASE_BOTH)));
    } else {
        barVal = ((Number) item.getXValue()).doubleValue();
        if (barVal < 0) {
            bar.getStyleClass().add(NEGATIVE_STYLE);
        }
        item.setCurrentX(getXAxis().toRealValue((barVal < 0) ? -bottomPos : bottomPos));
        getPlotChildren().add(bar);
        item.setXValue(getXAxis().toRealValue(barVal));
        animate(new KeyFrame(Duration.ZERO, new KeyValue(item.currentXProperty(), item.getCurrentX())),
                new KeyFrame(Duration.millis(700),
                        new KeyValue(item.currentXProperty(), item.getXValue(), Interpolator.EASE_BOTH)));
    }
}
项目:GazePlay    文件:Bubble.java   
private void moveCircle(Circle C) {

        double centerX = (scene.getWidth() - maxRadius) * Math.random() + maxRadius;
        double centerY = scene.getHeight();

        C.setCenterX(centerX);
        //C.setTranslateY((scene.getHeight() - maxRadius) * Math.random() + maxRadius);
        C.setCenterY(centerY);
        double radius = (maxRadius - minRadius) * Math.random() + minRadius;
        C.setFill(new Color(Math.random(), Math.random(), Math.random(), 1));
        C.setRadius(radius);

        Timeline timeline = new Timeline();

        double timelength = ((maxTimeLength - minTimeLength) * Math.random() + minTimeLength) * 1000;

        timeline.getKeyFrames().add(new KeyFrame(new Duration(timelength), new KeyValue(C.centerYProperty(), 0 - maxRadius, Interpolator.EASE_IN)));

       /* SequentialTransition sequence = new SequentialTransition();

        for(int i = 0; i < 10; i++) {
            sequence.getChildren().add(new KeyFrame(new Duration(timelength / 10), new KeyValue(C.centerXProperty(), centerX - 100)));
            sequence.getChildren().add(new KeyFrame(new Duration(timelength / 10), new KeyValue(C.centerXProperty(), centerX + 100)));
        }*/

        timeline.play();

        timeline.setOnFinished(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent actionEvent) {

                //moveCircle(C);
                newCircle();
            }
        });
    }
项目:fxexperience2    文件:FlipTransition.java   
/**
 * Create new FlipTransition
 *
 * @param node The node to affect
 */
public FlipTransition(final Node node) {
    super(node, new Timeline(
            new KeyFrame(Duration.millis(0),
                    new KeyValue(node.rotateProperty(), 0, Interpolator.EASE_OUT),
                    new KeyValue(node.translateZProperty(), 0, Interpolator.EASE_OUT)),
            new KeyFrame(Duration.millis(400),
                    new KeyValue(node.translateZProperty(), -150, Interpolator.EASE_OUT),
                    new KeyValue(node.rotateProperty(), -170, Interpolator.EASE_OUT)),
            new KeyFrame(Duration.millis(500),
                    new KeyValue(node.translateZProperty(), -150, Interpolator.EASE_IN),
                    new KeyValue(node.rotateProperty(), -190, Interpolator.EASE_IN),
                    new KeyValue(node.scaleXProperty(), 1, Interpolator.EASE_IN),
                    new KeyValue(node.scaleYProperty(), 1, Interpolator.EASE_IN)),
            new KeyFrame(Duration.millis(800),
                    new KeyValue(node.translateZProperty(), 0, Interpolator.EASE_IN),
                    new KeyValue(node.rotateProperty(), -360, Interpolator.EASE_IN),
                    new KeyValue(node.scaleXProperty(), 0.95, Interpolator.EASE_IN),
                    new KeyValue(node.scaleYProperty(), 0.95, Interpolator.EASE_IN)),
            new KeyFrame(Duration.millis(1000),
                    new KeyValue(node.scaleXProperty(), 1, Interpolator.EASE_IN),
                    new KeyValue(node.scaleYProperty(), 1, Interpolator.EASE_IN))));
    this.flipNode = node;
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
项目:recruitervision    文件:SlideAnimation.java   
@Override
protected Timeline setupShowAnimation() {
    Timeline tl = new Timeline();

    // Sets the x location of the tray off the screen
    double offScreenX = stage.getOffScreenBounds().getX();
    KeyValue kvX = new KeyValue(stage.xLocationProperty(), offScreenX);
    KeyFrame frame1 = new KeyFrame(Duration.ZERO, kvX);

    // Animates the Tray onto the screen and interpolates at a tangent for 300 millis
    Interpolator interpolator = Interpolator.TANGENT(Duration.millis(300), 50);
    KeyValue kvInter = new KeyValue(stage.xLocationProperty(), stage.getBottomRight().getX(), interpolator);
    KeyFrame frame2 = new KeyFrame(Duration.millis(1300), kvInter);

    // Sets opacity to 0 instantly
    KeyValue kvOpacity = new KeyValue(stage.opacityProperty(), 0.0);
    KeyFrame frame3 = new KeyFrame(Duration.ZERO, kvOpacity);

    // Increases the opacity to fully visible whilst moving in the space of 1000 millis
    KeyValue kvOpacity2 = new KeyValue(stage.opacityProperty(), 1.0);
    KeyFrame frame4 = new KeyFrame(Duration.millis(1000), kvOpacity2);

    tl.getKeyFrames().addAll(frame1, frame2, frame3, frame4);

    tl.setOnFinished(e -> trayIsShowing = true);

    return tl;
}
项目:recruitervision    文件:SlideAnimation.java   
@Override
protected Timeline setupDismissAnimation() {
    Timeline tl = new Timeline();

    double offScreenX = stage.getOffScreenBounds().getX();
    Interpolator interpolator = Interpolator.TANGENT(Duration.millis(300), 50);
    double trayPadding = 3;

    // The destination X location for the stage. Which is off the users screen
    // Since the tray has some padding, we want to hide that too
    KeyValue kvX = new KeyValue(stage.xLocationProperty(), offScreenX + trayPadding, interpolator);
    KeyFrame frame1 = new KeyFrame(Duration.millis(1400), kvX);

    // Change the opacity level to 0.4 over the duration of 2000 millis
    KeyValue kvOpacity = new KeyValue(stage.opacityProperty(), 0.4);
    KeyFrame frame2 = new KeyFrame(Duration.millis(2000), kvOpacity);

    tl.getKeyFrames().addAll(frame1, frame2);

    tl.setOnFinished(e -> {
        trayIsShowing = false;
        stage.close();
        stage.setLocation(stage.getBottomRight());
    });

    return tl;
}
项目:Drones-Simulator    文件:SpriteAnimation.java   
/**
 * Creates an animation that will run for indefinite time.
 * Use setCycleCount(1) to run animation only once. Remember to remove the imageView afterwards.
 *
 * @param imageView - the imageview of the sprite
 * @param duration - How long should one animation cycle take
 * @param count - Number of frames
 * @param columns - Number of colums the sprite has
 * @param offsetX - Offset x
 * @param offsetY - Offset y
 * @param width - Width of each frame
 * @param height - Height of each frame
 */
public SpriteAnimation(
        ImageView imageView,
        Duration duration,
        int count, int columns,
        int offsetX, int offsetY,
        int width, int height
) {
    this.imageView = imageView;
    this.count = count;
    this.columns = columns;
    this.offsetX = offsetX;
    this.offsetY = offsetY;
    this.width = width;
    this.height = height;
    setCycleDuration(duration);
    setCycleCount(Animation.INDEFINITE);
    setInterpolator(Interpolator.LINEAR);
    this.imageView.setViewport(new Rectangle2D(offsetX, offsetY, width, height));

}
项目:H-Uppaal    文件:NailPresentation.java   
private void initializeShakeAnimation() {
    final Interpolator interpolator = Interpolator.SPLINE(0.645, 0.045, 0.355, 1);

    final double startX = controller.root.getTranslateX();
    final KeyValue kv1 = new KeyValue(controller.root.translateXProperty(), startX - 3, interpolator);
    final KeyValue kv2 = new KeyValue(controller.root.translateXProperty(), startX + 3, interpolator);
    final KeyValue kv3 = new KeyValue(controller.root.translateXProperty(), startX, interpolator);

    final KeyFrame kf1 = new KeyFrame(millis(50), kv1);
    final KeyFrame kf2 = new KeyFrame(millis(100), kv2);
    final KeyFrame kf3 = new KeyFrame(millis(150), kv1);
    final KeyFrame kf4 = new KeyFrame(millis(200), kv2);
    final KeyFrame kf5 = new KeyFrame(millis(250), kv3);

    shakeAnimation.getKeyFrames().addAll(kf1, kf2, kf3, kf4, kf5);
}
项目:H-Uppaal    文件:HUPPAALController.java   
public void collapseMessagesIfNotCollapsed() {
    final Transition collapse = new Transition() {
        double height = tabPaneContainer.getMaxHeight();

        {
            setInterpolator(Interpolator.SPLINE(0.645, 0.045, 0.355, 1));
            setCycleDuration(Duration.millis(200));
        }

        @Override
        protected void interpolate(final double frac) {
            tabPaneContainer.setMaxHeight(((height - 35) * (1 - frac)) + 35);
        }
    };

    if (tabPaneContainer.getMaxHeight() > 35) {
        collapse.play();
    }
}
项目:H-Uppaal    文件:HUPPAALController.java   
@FXML
public void collapseMessagesClicked() {
    final Transition collapse = new Transition() {
        double height = tabPaneContainer.getMaxHeight();

        {
            setInterpolator(Interpolator.SPLINE(0.645, 0.045, 0.355, 1));
            setCycleDuration(Duration.millis(200));
        }

        @Override
        protected void interpolate(final double frac) {
            tabPaneContainer.setMaxHeight(((height - 35) * (1 - frac)) + 35);
        }
    };

    if (tabPaneContainer.getMaxHeight() > 35) {
        collapse.play();
    } else {
        expandMessagesContainer.play();
    }
}
项目:GestureFX    文件:GesturePane.java   
private void animateValue(double from,
                          double to,
                          Duration duration,
                          Interpolator interpolator, DoubleConsumer consumer,
                          EventHandler<ActionEvent> l) {
    timeline.stop();
    timeline.getKeyFrames().clear();
    KeyValue keyValue = new KeyValue(new WritableValue<Double>() {
        @Override
        public Double getValue() {
            return from;
        }
        @Override
        public void setValue(Double value) {
            consumer.accept(value);
        }
    }, to, interpolator == null ? Interpolator.LINEAR : interpolator);
    timeline.getKeyFrames().add(new KeyFrame(duration, keyValue));
    timeline.setOnFinished(l);
    timeline.play();
}
项目:charts    文件:ChartItem.java   
public void setValue(final double VALUE) {
    if (null == value) {
        if (isAnimated()) {
            oldValue = _value;
            _value   = VALUE;
            timeline.stop();
            KeyValue kv1 = new KeyValue(currentValue, oldValue, Interpolator.EASE_BOTH);
            KeyValue kv2 = new KeyValue(currentValue, VALUE, Interpolator.EASE_BOTH);
            KeyFrame kf1 = new KeyFrame(Duration.ZERO, kv1);
            KeyFrame kf2 = new KeyFrame(Duration.millis(animationDuration), kv2);
            timeline.getKeyFrames().setAll(kf1, kf2);
            timeline.play();
        } else {
            oldValue = _value;
            _value = VALUE;
            fireItemEvent(FINISHED_EVENT);
        }
    } else {
        value.set(VALUE);
    }
}
项目:tilesfx    文件:FlipTileSkin.java   
private void flipForward() {
    timeline.stop();

    flap.setCache(true);
    flap.setCacheHint(CacheHint.ROTATE);
    //flap.setCacheHint(CacheHint.SPEED);

    currentSelectionIndex++;
    if (currentSelectionIndex >= characters.size()) {
        currentSelectionIndex = 0;
    }
    nextSelectionIndex = currentSelectionIndex + 1;
    if (nextSelectionIndex >= characters.size()) {
        nextSelectionIndex = 0;
    }
    KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
    //KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.EASE_IN);
    KeyFrame keyFrame     = new KeyFrame(Duration.millis(tile.getFlipTimeInMS()), keyValueFlap);
    timeline.getKeyFrames().setAll(keyFrame);
    timeline.play();
}
项目:ics4u    文件:SpriteAnimation.java   
public SpriteAnimation(
    ImageView imageView,
    Duration duration,
    int count, int columns,
    int offsetX, int offsetY,
    int width, int height) {
    this.imageView = imageView;
    this.count = count;
    this.columns = columns;
    this.offsetX = offsetX;
    this.offsetY = offsetY;
    this.width = width;
    this.height = height;
    setCycleDuration(duration);
    setInterpolator(Interpolator.LINEAR);
}
项目:Incubator    文件:FlipPanel.java   
public void flipToFront() {
    if (Double.compare(rotate.getAngle(), 0) == 0) return;
    KeyValue kvStart = new KeyValue(rotate.angleProperty(), 180, Interpolator.EASE_IN);
    KeyValue kvStop  = new KeyValue(rotate.angleProperty(), 0, Interpolator.EASE_OUT);
    KeyFrame kfStart = new KeyFrame(Duration.ZERO, kvStart);
    KeyFrame kfStop  = new KeyFrame(Duration.millis(flipTime), kvStop);
    flipToFront.getKeyFrames().setAll(kfStart, kfStop);

    front.setCache(true);
    front.setCacheHint(CacheHint.ROTATE);
    back.setCache(true);
    back.setCacheHint(CacheHint.ROTATE);

    flipToFront.setOnFinished(event -> {
        front.setCache(false);
        back.setCache(false);
        fireEvent(new FlipEvent(FlipPanel.this, FlipPanel.this, FlipEvent.FLIP_TO_FRONT_FINISHED));
    });
    flipToFront.play();
}
项目:Incubator    文件:FlipPanel.java   
public void flipToBack() {
    if (Double.compare(rotate.getAngle(), 180) == 0) return;
    KeyValue kvStart = new KeyValue(rotate.angleProperty(), 0, Interpolator.EASE_IN);
    KeyValue kvStop  = new KeyValue(rotate.angleProperty(), 180, Interpolator.EASE_OUT);
    KeyFrame kfStart = new KeyFrame(Duration.ZERO, kvStart);
    KeyFrame kfStop  = new KeyFrame(Duration.millis(flipTime), kvStop);
    flipToBack.getKeyFrames().setAll(kfStart, kfStop);

    front.setCache(true);
    front.setCacheHint(CacheHint.ROTATE);
    back.setCache(true);
    back.setCacheHint(CacheHint.ROTATE);

    flipToBack.setOnFinished(event -> {
        front.setCache(false);
        back.setCache(false);
        fireEvent(new FlipEvent(FlipPanel.this, FlipPanel.this, FlipEvent.FLIP_TO_BACK_FINISHED));
    });
    flipToBack.play();
}
项目:cryptwallet    文件:NotificationBarPane.java   
protected void animate(Number target) {
    if (timeline != null) {
        timeline.stop();
        timeline = null;
    }
    Duration duration;
    Interpolator interpolator;
    if (target.intValue() > 0) {
        interpolator = new ElasticInterpolator(EasingMode.EASE_OUT, 1, 2);
        duration = ANIM_IN_DURATION;
    } else {
        interpolator = Interpolator.EASE_OUT;
        duration = ANIM_OUT_DURATION;
    }
    KeyFrame kf = new KeyFrame(duration, new KeyValue(bar.prefHeightProperty(), target, interpolator));
    timeline = new Timeline(kf);
    timeline.setOnFinished(x -> timeline = null);
    timeline.play();
}
项目:photometric-data-retriever    文件:SpriteAnimation.java   
public SpriteAnimation(
        ImageView imageView,
        Duration duration,
        int count,   int columns,
        int offsetX, int offsetY,
        int width,   int height) {
    this.imageView = imageView;
    this.count     = count;
    this.columns   = columns;
    this.offsetX   = offsetX;
    this.offsetY   = offsetY;
    this.width     = width;
    this.height    = height;
    setCycleDuration(duration);
    setInterpolator(Interpolator.LINEAR);
}
项目:MoodFX    文件:BtnSkin.java   
private void initGraphics() {
    font = Font.font(0.4 * PREFERRED_HEIGHT);

    text = new Text(getSkinnable().getText());
    text.setFont(font);
    text.setFill(getSkinnable().getTextColor());

    thumb = new Rectangle();
    thumb.setFill(getSkinnable().getThumbColor());
    thumb.setOpacity(0.0);
    thumb.setMouseTransparent(true);

    pressed  = new FadeTransition(Duration.millis(100), thumb);
    pressed.setInterpolator(Interpolator.EASE_IN);
    pressed.setFromValue(0.0);
    pressed.setToValue(0.8);

    released = new FadeTransition(Duration.millis(250), thumb);
    released.setInterpolator(Interpolator.EASE_OUT);
    released.setFromValue(0.8);
    released.setToValue(0.0);

    pane = new Pane(thumb, text);

    getChildren().setAll(pane);
}
项目:Forum-Notifier    文件:ParticleAnimation.java   
private void animate(Circle particle, Path path) {
    Random randGen = new Random();

    PathTransition pathTransition = new PathTransition(Duration.seconds(path.getElements().size() * (randGen.nextInt(30) + 30)), path, particle);
    pathTransition.setInterpolator(Interpolator.EASE_OUT);

    ScaleTransition scaleTransition = new ScaleTransition(Duration.seconds(3f), particle);
    scaleTransition.setToX(10f);
    scaleTransition.setToY(10f);
    scaleTransition.setInterpolator(Interpolator.EASE_OUT);

    FadeTransition fadeTransition = new FadeTransition(Duration.seconds(6f), particle);
    fadeTransition.setToValue(0.7);
    fadeTransition.setInterpolator(Interpolator.EASE_OUT);

    pathTransition.play();
    scaleTransition.play();
    fadeTransition.play();
}
项目:Retrospector    文件:RollOver.java   
private Timeline createAnimation() {
    return new Timeline(
            new KeyFrame(Duration.millis(0), new KeyValue(angle, HALF_PIE)),
            new KeyFrame(Duration.millis(ANIMATION_DURATION / 2), new KeyValue(angle, 0, Interpolator.EASE_IN)),
            new KeyFrame(Duration.millis(ANIMATION_DURATION / 2), new EventHandler<ActionEvent>() {

                @Override
                public void handle(final ActionEvent arg0) {
                    // TODO -- Do they another way or API to do this?
                    flippedProperty.set(flippedProperty.not().get());
                }
            }),
            new KeyFrame(Duration.millis(ANIMATION_DURATION / 2), new KeyValue(angle, PIE)),
            new KeyFrame(Duration.millis(ANIMATION_DURATION), new KeyValue(angle, HALF_PIE, Interpolator.EASE_OUT))
    );
}
项目:openjfx-8u-dev-tests    文件:AnimationApp.java   
@Override
public Node drawNode() {
    Pane p = pre();

    //create a timeline for moving the circle
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);

    keyValue1 = new KeyValue(circle.translateXProperty(), 300);
    keyValue2 = new KeyValue(circle.translateYProperty(), 200, Interpolator.EASE_BOTH);
    keyValue3 = new KeyValue(circle.visibleProperty(), true);

    KeyFrame keyFrame1 = new KeyFrame(duration, keyValue1);
    timeline.getKeyFrames().add(keyFrame1);

    KeyFrame keyFrame2 = new KeyFrame(duration, cuepointName2, keyValue2);
    timeline.getKeyFrames().add(keyFrame2);

    KeyFrame keyFrame3 = new KeyFrame(duration, cuepointName, keyValue3);
    timeline.getKeyFrames().add(keyFrame3);

    return p;
}
项目:openjfx-8u-dev-tests    文件:AnimationApp.java   
@Override
public Node drawNode() {
    Pane p = pre();

    //create a timeline for moving the circle
    timeline.setCycleCount(1);
    timeline.setAutoReverse(true);

    keyValue1 = new KeyValue(circle.translateXProperty(), 300, Interpolator.EASE_OUT);
    keyValue2 = new KeyValue(circle.translateYProperty(), 200, Interpolator.EASE_IN);
    AnimationBooleanInterpolator boolInterp = new AnimationBooleanInterpolator();
    keyValue3 = new KeyValue(circle.visibleProperty(), false, boolInterp);

    KeyFrame keyFrame1 = new KeyFrame(duration, onFinish, keyValue1 , keyValue2);
    timeline.getKeyFrames().add(keyFrame1);

    KeyFrame keyFrame3 = new KeyFrame(duration, keyValue3);
    timeline.getKeyFrames().add(keyFrame3);

    return p;
}
项目:dialplate    文件:DialPlate.java   
private void handleDial(final MouseEvent EVENT, final double MAX_ANGLE, final int NUMBER) {
    final EventType TYPE = EVENT.getEventType();

    if (MouseEvent.MOUSE_DRAGGED == TYPE) {
        Point2D point = sceneToLocal(EVENT.getSceneX(), EVENT.getSceneY());
        touchRotate(point.getX(), point.getY(), MAX_ANGLE);
    } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
        KeyValue kv0 = new KeyValue(plateRotate.angleProperty(), currentAngle, Interpolator.EASE_BOTH);
        KeyValue kv1 = new KeyValue(plateRotate.angleProperty(), 0, Interpolator.EASE_BOTH);
        KeyFrame kf0 = new KeyFrame(Duration.ZERO, kv0);
        KeyFrame kf1 = new KeyFrame(Duration.millis(2 * MAX_ANGLE), kv1);
        timeline.getKeyFrames().setAll(kf0, kf1);
        timeline.play();
        timeline.setOnFinished(e -> {
            currentAngle = 0;
            plateRotate.setAngle(currentAngle);
            fireEvent(new DialEvent(DialEvent.NUMBER_DIALED, NUMBER));
        });
    }
}
项目:Sprint-JavaFX-Animation    文件:Controller.java   
/**
 * Gets the next interpolator from the 9 SprintInterpolators. Each time it is run,
 * the function will return the next interpolator from the list
 * @return The next SprintInterpolator
 */
public Interpolator getInterpolator() {
    if (interpolatorIndex > 9) {
        interpolatorIndex = 1;
    }
    int num = interpolatorIndex;
    interpolatorIndex++;
    switch (num) {
        case 1: return SprintInterpolators.BACK;
        case 2: return SprintInterpolators.BOUNCE;
        case 3: return SprintInterpolators.CIRCULAR;
        case 4: return SprintInterpolators.CUBIC;
        case 5: return SprintInterpolators.ELASTIC;
        case 6: return SprintInterpolators.EXPONENTIAL;
        case 7: return SprintInterpolators.QUADRATIC;
        case 8: return SprintInterpolators.QUINTIC;
        case 9: return SprintInterpolators.SINE;
        default: return SprintInterpolators.BOUNCE;
    }
}
项目:rapidminer-studio    文件:BrowserPopup.java   
public void closeWithReason(String reason) {
    // Store the reason
    reasonQueue.offer(reason);
    if (!closed.compareAndSet(false, true)) {
        return;
    }
    // Slide out & dispose
    Platform.runLater(() -> {
        if (webView != null) {
            ImageView imageView = new ImageView(webView.snapshot(null, null));
            animatedPane.getChildren().set(0, imageView);
            dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
        }
        TranslateTransition slideOut = new TranslateTransition(Duration.millis(TRANSLATION_MS), animatedPane);
        slideOut.setInterpolator(Interpolator.EASE_IN);
        slideOut.setByX(translationDistance);
        slideOut.setOnFinished(e -> dispose());
        slideOut.play();
    });
}
项目:FXGL    文件:Particle.java   
@Override
public void reset() {
    image = null;
    startPosition.setZero();
    position.setZero();
    velocity.setZero();
    acceleration.setZero();
    radius.setZero();
    scale.setZero();
    startColor = Color.TRANSPARENT;
    endColor = Color.TRANSPARENT;
    blendMode = BlendMode.SRC_OVER;
    initialLife = 0;
    life = 0;
    interpolator = Interpolator.LINEAR;

    control = null;
}
项目:FXImgurUploader    文件:SplitFlapSkin.java   
public void flipForward() {
    timeline.stop();
    flap.setCacheShape(true);
    flap.setCache(true);
    flap.setCacheHint(CacheHint.ROTATE);
    //flap.setCacheHint(CacheHint.SPEED);
    currentSelectionIndex++;
    if (currentSelectionIndex >= selectedSet.size()) {
        currentSelectionIndex = 0;
    }
    nextSelectionIndex = currentSelectionIndex + 1;
    if (nextSelectionIndex >= selectedSet.size()) {
        nextSelectionIndex = 0;
    }
    //keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
    keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.EASE_IN);
    keyFrame     = new KeyFrame(Duration.millis(getSkinnable().getFlipTime()), keyValueFlap);
    timeline.getKeyFrames().setAll(keyFrame);
    timeline.play();
}
项目:FXImgurUploader    文件:RadialBargraphSkin.java   
private void setBar() {
    double range       = (getSkinnable().getMaxValue() - getSkinnable().getMinValue());
    double angleRange  = getSkinnable().getAngleRange();
    angleStep          = angleRange / range;
    double targetAngle = getSkinnable().getValue() * angleStep;

    if (getSkinnable().isAnimated()) {
        timeline.stop();
        final KeyValue KEY_VALUE = new KeyValue(angle, targetAngle, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
        final KeyFrame KEY_FRAME = new KeyFrame(Duration.millis(getSkinnable().getAnimationDuration()), KEY_VALUE);
        timeline.getKeyFrames().setAll(KEY_FRAME);
        timeline.play();
    } else {
        angle.set(targetAngle);
    }
}
项目:FXImgurUploader    文件:GaugeSkin.java   
private void rotateNeedle() {
    double range       = (getSkinnable().getMaxValue() - getSkinnable().getMinValue());
    double angleRange  = getSkinnable().getAngleRange();
    angleStep          = angleRange / range;
    double targetAngle = needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue()) * angleStep;

    if (getSkinnable().isAnimated()) {
        timeline.stop();
        //double animationDuration = (getSkinnable().getAnimationDuration() / (getSkinnable().getMaxValue() - getSkinnable().getMinValue())) * Math.abs(getSkinnable().getValue() - getSkinnable().getOldValue());
        final KeyValue KEY_VALUE = new KeyValue(needleRotate.angleProperty(), targetAngle, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
        final KeyFrame KEY_FRAME = new KeyFrame(Duration.millis(getSkinnable().getAnimationDuration()), KEY_VALUE);
        timeline.getKeyFrames().setAll(KEY_FRAME);
        timeline.play();
    } else {
        needleRotate.setAngle(targetAngle);
    }
}
项目:FXImgurUploader    文件:RadialMenu.java   
public void close() {
    if (State.CLOSED == getState()) return;

    setState(State.CLOSED);
    RotateTransition rotate = new RotateTransition();
    rotate.setNode(cross);
    rotate.setToAngle(0);
    rotate.setDuration(Duration.millis(200));
    rotate.setInterpolator(Interpolator.EASE_BOTH);
    rotate.play();
    closeTimeLines[closeTimeLines.length - 1].setOnFinished(actionEvent -> {
        FadeTransition buttonFadeOut = new FadeTransition();
        buttonFadeOut.setNode(mainMenuButton);
        buttonFadeOut.setDuration(Duration.millis(100));
        buttonFadeOut.setToValue(options.getButtonAlpha());
        buttonFadeOut.play();
        buttonFadeOut.setOnFinished(event -> {
            if (options.isButtonHideOnClose()) hide();
            fireMenuEvent(new MenuEvent(this, null, MenuEvent.MENU_CLOSE_FINISHED));
        });
    });
    for (int i = 0 ; i < closeTimeLines.length ; i++) {
        closeTimeLines[i].play();
    }
    fireMenuEvent(new MenuEvent(this, null, MenuEvent.MENU_CLOSE_STARTED));
}
项目:JCardGamesFX    文件:KlondikeMouseUtil.java   
/**
 * Animates card movements.
 *
 * @param card     The card view to animate.
 * @param sourceX  Source X coordinate of the card view.
 * @param sourceY  Source Y coordinate of the card view.
 * @param targetX  Destination X coordinate of the card view.
 * @param targetY  Destination Y coordinate of the card view.
 * @param duration The duration of the animation.
 * @param doAfter  The action to perform after the animation has been completed.
 */
private void animateCardMovement(
    CardView card, double sourceX, double sourceY,
    double targetX, double targetY, Duration duration,
    EventHandler<ActionEvent> doAfter) {

  Path path = new Path();
  path.getElements().add(new MoveToAbs(card, sourceX, sourceY));
  path.getElements().add(new LineToAbs(card, targetX, targetY));

  PathTransition pathTransition =
      new PathTransition(duration, path, card);
  pathTransition.setInterpolator(Interpolator.EASE_IN);
  pathTransition.setOnFinished(doAfter);

  Timeline blurReset = new Timeline();
  KeyValue bx = new KeyValue(card.getDropShadow().offsetXProperty(), 0, Interpolator.EASE_IN);
  KeyValue by = new KeyValue(card.getDropShadow().offsetYProperty(), 0, Interpolator.EASE_IN);
  KeyValue br = new KeyValue(card.getDropShadow().radiusProperty(), 2, Interpolator.EASE_IN);
  KeyFrame bKeyFrame = new KeyFrame(duration, bx, by, br);
  blurReset.getKeyFrames().add(bKeyFrame);

  ParallelTransition pt = new ParallelTransition(card, pathTransition, blurReset);
  pt.play();
}
项目:JFoenix    文件:JFXSpinnerSkin.java   
private KeyFrame[] getKeyFrames(double angle, double duration, Paint color) {
    KeyFrame[] frames = new KeyFrame[4];
    frames[0] = new KeyFrame(Duration.seconds(duration),
        new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR),
        new KeyValue(arc.startAngleProperty(),
            angle + 45 + control.getStartingAngle(),
            Interpolator.LINEAR));
    frames[1] = new KeyFrame(Duration.seconds(duration + 0.4),
        new KeyValue(arc.lengthProperty(), 250, Interpolator.LINEAR),
        new KeyValue(arc.startAngleProperty(),
            angle + 90 + control.getStartingAngle(),
            Interpolator.LINEAR));
    frames[2] = new KeyFrame(Duration.seconds(duration + 0.7),
        new KeyValue(arc.lengthProperty(), 250, Interpolator.LINEAR),
        new KeyValue(arc.startAngleProperty(),
            angle + 135 + control.getStartingAngle(),
            Interpolator.LINEAR));
    frames[3] = new KeyFrame(Duration.seconds(duration + 1.1),
        new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR),
        new KeyValue(arc.startAngleProperty(),
            angle + 435 + control.getStartingAngle(),
            Interpolator.LINEAR),
        new KeyValue(arc.strokeProperty(), color, Interpolator.EASE_BOTH));
    return frames;
}
项目:JFoenix    文件:JFXColorPickerSkin.java   
private void updateColor() {
    final ColorPicker colorPicker = (ColorPicker) getSkinnable();
    // update picker box color
    Circle colorCircle = new Circle();
    colorCircle.setFill(colorPicker.getValue());
    colorCircle.setLayoutX(colorBox.getWidth() / 4);
    colorCircle.setLayoutY(colorBox.getHeight() / 2);
    colorBox.getChildren().add(colorCircle);
    Timeline animateColor = new Timeline(new KeyFrame(Duration.millis(240),
        new KeyValue(colorCircle.radiusProperty(),
            200,
            Interpolator.EASE_BOTH)));
    animateColor.setOnFinished((finish) -> {
        JFXNodeUtils.updateBackground(colorBox.getBackground(), colorBox, colorCircle.getFill());
        colorBox.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(JFXNodeUtils.colorToHex(colorPicker.getValue()));
    } else {
        displayNode.setText("");
    }
}