Java 类javafx.animation.KeyFrame 实例源码

项目:boomer-tuner    文件:Player.java   
private void playCrossfade(final List<? extends Playable> items, final int index) {
    MediaPlayer oldPlayer = currentPlayer;
    final double currentVolume = oldPlayer.getVolume();
    oldPlayer.volumeProperty().unbind();
    playQueue = new ArrayList<>(items);
    currentIndex = index;

    MediaPlayer newPlayer = new MediaPlayer(new Media(playQueue.get(currentIndex).getUri().toString()));
    newPlayer.setVolume(0);
    newPlayer.play();
    Timeline crossfade = new Timeline(new KeyFrame(Duration.seconds(CROSSFADE_DURATION),
            new KeyValue(oldPlayer.volumeProperty(), 0),
            new KeyValue(newPlayer.volumeProperty(), currentVolume)));
    crossfade.setOnFinished(event -> {
        oldPlayer.stop();
        setCurrentPlayer(newPlayer);
    });
    crossfade.play();
}
项目:incubator-netbeans    文件:KeyStrokeMotion.java   
private void createLetter(String c) {
    final Text letter = new Text(c);
    letter.setFill(Color.BLACK);
    letter.setFont(FONT_DEFAULT);
    letter.setTextOrigin(VPos.TOP);
    letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2);
    letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2);
    getChildren().add(letter);
    // 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(letter);
                }
            },
            new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR),
            new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR),
            new KeyValue(letter.opacityProperty(), 0f)
    ));
    timeline.play();
}
项目:marathonv5    文件:KeyStrokeMotion.java   
private void createLetter(String c) {
    final Text letter = new Text(c);
    letter.setFill(Color.BLACK);
    letter.setFont(FONT_DEFAULT);
    letter.setTextOrigin(VPos.TOP);
    letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2);
    letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2);
    getChildren().add(letter);
    // 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(letter);
                }
            },
            new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR),
            new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR),
            new KeyValue(letter.opacityProperty(), 0f)
    ));
    timeline.play();
}
项目:CapsLock    文件:OverLayWindow.java   
void Exe(int i) {
    if(i==1) {
        warnmesse="プレイ開始から5分経過しました\n混雑している場合は次の人に\n交代してください";
        fontsize=25;
    }else if(i==2) {
        warnmesse="プレイ開始から10分経過しました\n混雑している場合は次の人に\n交代してください";
        fontsize=25;
    }else if(i==-1) {
        warnmesse="user timer is reset";
        fontsize=35;
    }

    final Stage primaryStage = new Stage(StageStyle.TRANSPARENT);
    primaryStage.initModality(Modality.NONE);
    final StackPane root = new StackPane();

    final Scene scene = new Scene(root, 350, 140);
    scene.setFill(null);

    final Label label = new Label(warnmesse);
    label.setFont(new Font("Arial", fontsize));
    BorderPane borderPane = new BorderPane();
    borderPane.setCenter(label);
    borderPane.setStyle("-fx-background-radius: 10;-fx-background-color: rgba(0,0,0,0.3);");

    root.getChildren().add(borderPane);

    final Rectangle2D d = Screen.getPrimary().getVisualBounds();
    primaryStage.setScene(scene);
    primaryStage.setAlwaysOnTop(true);
    primaryStage.setX(d.getWidth()-350);
    primaryStage.setY(d.getHeight()-300);

    primaryStage.show();

    final Timeline timer = new Timeline(new KeyFrame(Duration.seconds(CLOSE_SECONDS), (ActionEvent event) -> primaryStage.close()));
    timer.setCycleCount(Timeline.INDEFINITE);
    timer.play();
}
项目:BatpackJava    文件:batteryMonitorLayoutController.java   
private void bindUpdates() {
    final KeyFrame oneFrame = new KeyFrame(Duration.seconds(1), (ActionEvent evt) -> {
        if (this.batpack != null) {
            this.batpack = BatteryMonitorSystem.getBatpack();
            //System.out.println("layout: battery pack module 5 cell 5 voltage: " + batpack.getModules().get(4).getBatteryCells().get(4).getVoltageAsString());
            checkConnection();
            updateModules();
            updateTotalVoltage();
            updateMaxTemperature();
            updateCriticalValues();
        }

    });
    Timeline timer = TimelineBuilder.create().cycleCount(Animation.INDEFINITE).keyFrames(oneFrame).build();
    timer.playFromStart();
}
项目:octoBubbles    文件:GraphController.java   
void ensureVisible(double x, double y) {
    ScrollPane scrollPane = diagramController.getScrollPane();

    double xScroll = (x - scrollPane.getWidth() / 2) / (8000 - scrollPane.getWidth());
    double yScroll = (y - scrollPane.getHeight() / 2) / (8000 - scrollPane.getHeight());

    final Timeline timeline = new Timeline();
    final KeyValue kv1 = new KeyValue(scrollPane.hvalueProperty(), xScroll);
    final KeyValue kv2 = new KeyValue(scrollPane.vvalueProperty(), yScroll);
    final KeyFrame kf = new KeyFrame(Duration.millis(100), kv1, kv2);
    timeline.getKeyFrames().add(kf);
    timeline.play();

    aScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    aScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
}
项目:EistReturns    文件:Utils.java   
private static void makeText(Stage ownerStage, String toastMsg, int toastDelay) {
    Stage toastStage = new Stage();
    toastStage.initOwner(ownerStage);
    toastStage.setResizable(false);
    toastStage.initStyle(StageStyle.TRANSPARENT);

    Text text = new Text(toastMsg);
    text.setFont(Font.font("Verdana", 20));
    text.setFill(Color.BLACK);

    StackPane root = new StackPane(text);
    root.setStyle("-fx-background-radius: 20; -fx-background-color: rgba(255, 255, 255, 0.9); -fx-padding: 20px;");
    root.setOpacity(0);

    Scene scene = new Scene(root);
    scene.setFill(Color.TRANSPARENT);
    toastStage.setScene(scene);
    toastStage.show();

    Timeline fadeInTimeline = new Timeline();
    KeyFrame fadeInKey1 = new KeyFrame(Duration.millis(200), new KeyValue(toastStage.getScene().getRoot().opacityProperty(), 1));
    fadeInTimeline.getKeyFrames().add(fadeInKey1);
    fadeInTimeline.setOnFinished((ae) -> new Thread(() -> {
        try {
            Thread.sleep(toastDelay);
        } catch (InterruptedException e) {

            e.printStackTrace();
        }
        Timeline fadeOutTimeline = new Timeline();
        KeyFrame fadeOutKey1 = new KeyFrame(Duration.millis(500), new KeyValue(toastStage.getScene().getRoot().opacityProperty(), 0));
        fadeOutTimeline.getKeyFrames().add(fadeOutKey1);
        fadeOutTimeline.setOnFinished((aeb) -> toastStage.close());
        fadeOutTimeline.play();
    }).start());
    fadeInTimeline.play();
}
项目:fxexperience2    文件:FadeOutDownTransition.java   
/**
 * Create new FadeOutDownTransition
 * 
 * @param node The node to affect
 */
public FadeOutDownTransition(final Node node) {
    super(
        node,
            new Timeline(
                new KeyFrame(Duration.millis(0),    
                    new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                    new KeyValue(node.translateYProperty(), 0, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(1000),    
                    new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                    new KeyValue(node.translateYProperty(), 20, WEB_EASE)
                )
            )
        );
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
项目: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;
}
项目:fx-animation-editor    文件:DragBehavior.java   
private void startPanAnimation(double velocity, Timeline timeline, DoubleProperty animatedPan, DoubleProperty pan) {
    if (isRunning(timeline)) {
        return;
    }
    double durationInMillis = 1e10;
    double distance = velocity * durationInMillis;
    animatedPan.set(pan.get());
    KeyValue keyValue = new KeyValue(animatedPan, animatedPan.get() - distance);
    KeyFrame keyFrame = new KeyFrame(Duration.millis(durationInMillis), keyValue);
    timeline.getKeyFrames().setAll(keyFrame);
    timeline.playFromStart();
}
项目:fxexperience2    文件:FadeOutRightTransition.java   
/**
 * Create new FadeOutRightTransition
 * 
 * @param node The node to affect
 */
public FadeOutRightTransition(final Node node) {
    super(
        node,
        new Timeline(
                new KeyFrame(Duration.millis(0),    
                    new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                    new KeyValue(node.translateXProperty(), 0, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(1000),    
                    new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                    new KeyValue(node.translateXProperty(), 20, WEB_EASE)
                )
            )
        );
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
项目:incubator-netbeans    文件:ChartAdvancedStockLine.java   
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));
    root.getChildren().add(createChart());
    // create timeline to add new data every 60th of second
    animation = new Timeline();
    animation.getKeyFrames().add(new KeyFrame(Duration.millis(1000/60), new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent actionEvent) {
            // 6 minutes data per frame
            for(int count=0; count < 6; count++) {
                nextTime();
                plotTime();
            }
        }
    }));
    animation.setCycleCount(Animation.INDEFINITE);
}
项目:textmd    文件:EditorPane.java   
public void createSyncTimer(int duration) {
    covertTask = new Timeline(new KeyFrame(javafx.util.Duration.seconds(duration), (event2) -> {
        timer.start();
        String html = markdownParser.convertToHTML(editor.getText());
        webEngine.loadContent(html);
        currentHtml = html;
        covertTask.stop();
        editorToolBar.setActionText("Refreshed view successfully in " + timer.end() + "ms");
    }));
}
项目:Mafia-TCoS-CS319-Group2A    文件:CrimeScene.java   
@FXML
void commitCrime(ActionEvent event) {

    crimeBtn.setDisable(true);

    JFXRadioButton selectedRadio = (JFXRadioButton) group.getSelectedToggle();
    String extractedCrime = selectedRadio.getText();
    /*
    Extract the selected crime from the selected radio button's text or bindIt and pass it to the GameEngine. */
    GameEngine.game().isSuccessful(extractedCrime);

    Timeline timeline = new Timeline();
    for (int i = 0; i <= seconds; i++) {
        final int timeRemaining = seconds - i;
        KeyFrame frame = new KeyFrame(Duration.seconds(i),
                e -> {
                    crimeBtn.setDisable(true);
                    crimeBtn.setText("Wait " + timeRemaining + " sec..");
                });
        timeline.getKeyFrames().add(frame);
    }
    timeline.setOnFinished(e -> {
        crimeBtn.setText("Commit!");
        crimeBtn.setDisable(false);
        refresh();
        seconds += 5;
    });
    timeline.play();
}
项目:marathonv5    文件:DataAppPreloader.java   
@Override public void start(Stage stage) throws Exception {
    preloaderStage = stage;
    preloaderStage.setScene(preloaderScene);
    preloaderStage.show();

    if (DEMO_MODE) {
        final DoubleProperty prog = new SimpleDoubleProperty(0){
            @Override protected void invalidated() {
                handleProgressNotification(new ProgressNotification(get()));
            }
        };
        Timeline t = new Timeline();
        t.getKeyFrames().add(new KeyFrame(Duration.seconds(20), new KeyValue(prog, 1)));
        t.play();
    }
}
项目:marathonv5    文件:DataAppPreloader.java   
@Override public void handleStateChangeNotification(StateChangeNotification evt) {
    if (evt.getType() == StateChangeNotification.Type.BEFORE_INIT) {
        // check if download was crazy fast and restart progress
        if ((System.currentTimeMillis() - startDownload) < 500) {
            raceTrack.setProgress(0);
        }
        // we have finished downloading application, now we are running application
        // init() method, as we have no way of calculating real progress 
        // simplate pretend progress here
        simulatorTimeline = new Timeline();
        simulatorTimeline.getKeyFrames().add( 
                new KeyFrame(Duration.seconds(3), 
                        new KeyValue(raceTrack.progressProperty(),1)
                )
        );
        simulatorTimeline.play();
    }
}
项目: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;
}
项目:marathonv5    文件:DataAppPreloader.java   
@Override public void start(Stage stage) throws Exception {
    preloaderStage = stage;
    preloaderStage.setScene(preloaderScene);
    preloaderStage.show();

    if (DEMO_MODE) {
        final DoubleProperty prog = new SimpleDoubleProperty(0){
            @Override protected void invalidated() {
                handleProgressNotification(new ProgressNotification(get()));
            }
        };
        Timeline t = new Timeline();
        t.getKeyFrames().add(new KeyFrame(Duration.seconds(20), new KeyValue(prog, 1)));
        t.play();
    }
}
项目:marathonv5    文件:TimelineSample.java   
public TimelineSample() {
    super(280,120);

    //create a circle
    final Circle circle = new Circle(25,25, 20,  Color.web("1c89f4"));
    circle.setEffect(new Lighting());

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

    //one can start/pause/stop/play animation by
    //timeline.play();
    //timeline.pause();
    //timeline.stop();
    //timeline.playFromStart();

    //add the following keyframes to the timeline
    timeline.getKeyFrames().addAll
        (new KeyFrame(Duration.ZERO,
                      new KeyValue(circle.translateXProperty(), 0)),
         new KeyFrame(new Duration(4000),
                      new KeyValue(circle.translateXProperty(), 205)));


    getChildren().add(createNavigation());
    getChildren().add(circle);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Timeline rate", timeline.rateProperty(), -4d, 4d)
            //TODO it is possible to do it for integer?
    );
    // END REMOVE ME
}
项目:recruitervision    文件:FadeAnimation.java   
@Override
protected Timeline setupDismissAnimation() {
    Timeline tl = new Timeline();

    // At this stage the opacity is already at 1.0

    // Lowers the opacity to 0.0 within 2000 milliseconds
    KeyValue kv1 = new KeyValue(stage.opacityProperty(), 0.0);
    KeyFrame kf1 = new KeyFrame(Duration.millis(2000), kv1);

    tl.getKeyFrames().addAll(kf1);

    // Action to be performed when the animation has finished
    tl.setOnFinished(e -> {
        trayIsShowing = false;
        stage.close();
        stage.setLocation(stage.getBottomRight());
    });

    return tl;
}
项目:GameAuthoringEnvironment    文件:GameEngine.java   
private void initializeTimeline () {
    Timeline timeline = getTimeline();
    Duration frameDuration = Duration.seconds(1.0d / FPS);
    KeyFrame repeatedFrame = new KeyFrame(frameDuration, e -> step(frameDuration));
    timeline.getKeyFrames().add(repeatedFrame);
    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.play();
}
项目:netTanks    文件:Framework.java   
public Framework(int width, int height) {

        this.setWidth(width);
        this.setHeight(height);
        random = new Random();
        bullets = new ArrayList<>();
        tanks = new ArrayList<>();
        mines = new ArrayList<>();
        pickUps = new ArrayList<>();
        hud = new HUD(this);

        canvas = new Canvas(width, height);
        gc = canvas.getGraphicsContext2D();
        canvas.setWidth(width);
        canvas.setHeight(height);
        this.getChildren().add(canvas);

        //Create Game Loop
        gameloop = new Timeline(new KeyFrame(
                Duration.millis(16.666666666667),
                ae -> update()));
        gameloop.setCycleCount(Timeline.INDEFINITE);

        //Set SCALE to current scale of Canvas
        SCALE = this.getScaleX();

        //Make the Canvas register keystrokes
        this.addEventFilter(MouseEvent.ANY, (e) -> this.requestFocus());

        //Set Inputs
        setKeyInput();
        setMouseInput();
    }
项目:atbash-octopus    文件:InfoDialog.java   
public void showDialog() {
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setTitle("Feedback Dialog");
    alert.setHeaderText("Confirmation of action");
    alert.setContentText(message);

    alert.show();
    Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), event -> alert.hide()));
    idlestage.setCycleCount(1);
    idlestage.play();
}
项目: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);
    }
}
项目:fxexperience2    文件:BounceInLeftTransition.java   
@Override
protected void starting() {
    double startX = -node.localToScene(0, 0).getX() - node.getBoundsInParent().getWidth();
    timeline = new Timeline();
    timeline.getKeyFrames().add(
            new KeyFrame(Duration.millis(0),
                    new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                    new KeyValue(node.translateXProperty(), startX, WEB_EASE)
            ));
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(600),
            new KeyValue(node.opacityProperty(), 1, WEB_EASE),
            new KeyValue(node.translateXProperty(), 30, WEB_EASE)
    ));
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(800),
            new KeyValue(node.translateXProperty(), -10, WEB_EASE)
    ));
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(1000),
            new KeyValue(node.translateXProperty(), 0, WEB_EASE)
    )
    );
    super.starting();
}
项目:util4j    文件:Board.java   
public void animateScore() {
    if(gameMovePoints.get()==0){
        return;
    }

    final Timeline timeline = new Timeline();
    lblPoints.setText("+" + gameMovePoints.getValue().toString());
    lblPoints.setOpacity(1);
    double posX=vScore.localToScene(vScore.getWidth()/2d,0).getX();
    lblPoints.setTranslateX(0);
    lblPoints.setTranslateX(lblPoints.sceneToLocal(posX, 0).getX()-lblPoints.getWidth()/2d);
    lblPoints.setLayoutY(20);
    final KeyValue kvO = new KeyValue(lblPoints.opacityProperty(), 0);
    final KeyValue kvY = new KeyValue(lblPoints.layoutYProperty(), 100);

    Duration animationDuration = Duration.millis(600);
    final KeyFrame kfO = new KeyFrame(animationDuration, kvO);
    final KeyFrame kfY = new KeyFrame(animationDuration, kvY);

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

    timeline.play();
}
项目: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;
}
项目:fxexperience2    文件:FlipInYTransition.java   
/**
 * Create new FlipInYTransition
 *
 * @param node The node to affect
 */
public FlipInYTransition(final Node node) {
    super(
            node,
            new Timeline(
                    new KeyFrame(Duration.millis(0),
                            new KeyValue(node.rotateProperty(), -90, WEB_EASE),
                            new KeyValue(node.opacityProperty(), 0, WEB_EASE)
                    ),
                    new KeyFrame(Duration.millis(400),
                            new KeyValue(node.rotateProperty(), 10, WEB_EASE)
                    ),
                    new KeyFrame(Duration.millis(700),
                            new KeyValue(node.rotateProperty(), -10, WEB_EASE)
                    ),
                    new KeyFrame(Duration.millis(1000),
                            new KeyValue(node.rotateProperty(), 0, WEB_EASE),
                            new KeyValue(node.opacityProperty(), 1, WEB_EASE)
                    )
            )
    );
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
项目: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;
}
项目: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);
}
项目: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);
    }
}
项目: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();
            }
        });
    }
项目:GazePlay    文件:LightningSimulator.java   
private void periodicallyStrikeRandomNodes(TilePane field) {
    Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(0), event -> strikeRandomNode(field)),
            new KeyFrame(Duration.seconds(2)));

    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.play();
}
项目:GazePlay    文件:Metronome.java   
public Metronome() {
    // création du fond du métronome
    ImageView fond_metronome = new ImageView(
            new Image(Metronome.class.getResourceAsStream("images/metronome.png")));
    fond_metronome.setFitHeight(40);
    fond_metronome.setPreserveRatio(true);

    // création de l'aiguille du métronome
    ImageView aiguille = new ImageView(new Image(Metronome.class.getResourceAsStream("images/aiguille.png")));
    aiguille.setFitHeight(32);
    aiguille.setPreserveRatio(true);
    aiguille.setTranslateX(16);
    aiguille.setTranslateY(2);

    // on applique une transformation à l'aiguille
    Rotate rotation = new Rotate(0, 3, 29);
    aiguille.getTransforms().add(rotation);

    // création de l'animation de l'aiguille
    Timeline timeline = new Timeline();
    timeline.getKeyFrames().addAll(new KeyFrame(Duration.ZERO, new KeyValue(rotation.angleProperty(), 45)),
            new KeyFrame(new Duration(1000), new KeyValue(rotation.angleProperty(), -45)));
    timeline.setAutoReverse(true);
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.play();

    this.getChildren().add(fond_metronome);
    this.getChildren().add(aiguille);
    this.setTranslateX(400);
    this.setTranslateY(200);
}
项目:fxexperience2    文件:FlipOutYTransition.java   
/**
 * Create new FlipOutYTransition
 * 
 * @param node The node to affect
 */
public FlipOutYTransition(final Node node) {
    super(
        node,
     new Timeline(
                new KeyFrame(Duration.millis(0), 
                    new KeyValue(node.rotateProperty(), 0, WEB_EASE),
                    new KeyValue(node.opacityProperty(), 1, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(1000), 
                    new KeyValue(node.rotateProperty(), -90, WEB_EASE),
                    new KeyValue(node.opacityProperty(), 0, WEB_EASE)
                )
            )
        );
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
项目:fxexperience2    文件:FlipInXTransition.java   
/**
 * Create new FlipInXTransition
 * 
 * @param node The node to affect
 */
public FlipInXTransition(final Node node) {
    super(
        node,
   new Timeline(
                new KeyFrame(Duration.millis(0), 
                    new KeyValue(node.rotateProperty(), -90, WEB_EASE),
                    new KeyValue(node.opacityProperty(), 0, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(400), 
                    new KeyValue(node.rotateProperty(), 10, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(700), 
                    new KeyValue(node.rotateProperty(), -10, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(1000), 
                    new KeyValue(node.rotateProperty(), 0, WEB_EASE),
                    new KeyValue(node.opacityProperty(), 1, WEB_EASE)
                )
            )
        );
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
项目:fxexperience2    文件:BounceInDownTransition.java   
@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();
}
项目:fxexperience2    文件:FlipOutXTransition.java   
/**
 * Create new FlipOutXTransition
 * 
 * @param node The node to affect
 */
public FlipOutXTransition(final Node node) {
    super(
        node,
       new Timeline(
                new KeyFrame(Duration.millis(0), 
                    new KeyValue(node.rotateProperty(), 0, WEB_EASE),
                    new KeyValue(node.opacityProperty(), 1, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(1000), 
                    new KeyValue(node.rotateProperty(), -90, WEB_EASE),
                    new KeyValue(node.opacityProperty(), 0, WEB_EASE)
                )
            )
        );
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
项目:fxexperience2    文件:BounceOutLeftTransition.java   
@Override
protected void starting() {
    double endX = -node.localToScene(0, 0).getX() - node.getBoundsInParent().getWidth();
    timeline = new Timeline(
            new KeyFrame(Duration.millis(0),
                    new KeyValue(node.translateXProperty(), 0, WEB_EASE)
            ),
            new KeyFrame(Duration.millis(200),
                    new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                    new KeyValue(node.translateXProperty(), 20, WEB_EASE)
            ),
            new KeyFrame(Duration.millis(1000),
                    new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                    new KeyValue(node.translateXProperty(), endX, WEB_EASE)
            )
    );
    super.starting();
}