Java 类javafx.util.Duration 实例源码

项目:textmd    文件:ActionTextPane.java   
public ActionTextPane() {

        actionText = new Label("Test");
        graphic = new ImageView(new Image("assets/icons/editor_action_info_icon.png"));
        actionText.setGraphic(graphic);
        actionText.setTextFill(Utils.getDefaultTextColor());
        actionText.setAlignment(Pos.CENTER);
        actionText.setPadding(new Insets(0, 0, 0, 5));
        getChildren().add(actionText);
        setAlignment(Pos.CENTER);

        ft = new FadeTransition(Duration.millis(500), graphic);
        ft.setFromValue(1.0);
        ft.setToValue(0.0);
        ft.setAutoReverse(true);
        ft.setCycleCount(4);

    }
项目: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();
}
项目: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();
}
项目:Suji    文件:GoTimer.java   
public ObjectProperty<Duration> initialProperty() {
    if ( initial == null ) {
        initial = new ObjectPropertyBase<Duration>(Duration.seconds(1)) {
            @Override
            public void invalidated() {
                refreshIndicator();
            }

            @Override
            public Object getBean() {
                return GoTimer.this;
            }

            @Override
            public String getName() {
                return "initial";
            }
        };
    }

    return initial;
}
项目:ShowMilhaoPOOJava    文件:ControllerLayoutPrincipal.java   
/**
 * Método que inicia a view Inicial (MENU) e aplica estilos CSS nos botões   
 */
@Autor("Divino Matheus")
   private void makeFadeOut(String path) {

    FadeTransition fadeTransition = new FadeTransition();
    fadeTransition.setDuration(Duration.millis(250));
    fadeTransition.setNode(rootPane);
    fadeTransition.setFromValue(1);
    fadeTransition.setToValue(0);
    fadeTransition.setOnFinished(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            try {
                loadScreenPlay(path);
            } catch (IOException ex) {
                Logger.getLogger(ControllerLayoutInicial.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });     
    fadeTransition.play();
}
项目:hygene    文件:GraphNavigationController.java   
@Override
public void initialize(final URL location, final ResourceBundle resources) {
    graphNavigationButtons.visibleProperty().bind(graphDimensionsCalculator.getGraphProperty().isNotNull());
    graphNavigationButtons.managedProperty().bind(graphDimensionsCalculator.getGraphProperty().isNotNull());


    addContinuousPressHandler(goLeft, Duration.millis(GO_RIGHT_LEFT_INTERVAL),
            event -> goLeftAction(new ActionEvent()));

    addContinuousPressHandler(goRight, Duration.millis(GO_RIGHT_LEFT_INTERVAL),
            event -> goRightAction(new ActionEvent()));

    addContinuousPressHandler(goLeftLarge, Duration.millis(GO_RIGHT_LEFT_INTERVAL_LARGE),
            event -> goLeftLargeAction(new ActionEvent()));

    addContinuousPressHandler(goRightLarge, Duration.millis(GO_RIGHT_LEFT_INTERVAL_LARGE),
            event -> goRightLargeAction(new ActionEvent()));

    addContinuousPressHandler(zoomIn, Duration.millis(ZOOM_IN_OUT_INTERVAL), event ->
            zoomInAction(new ActionEvent()));

    addContinuousPressHandler(zoomOut, Duration.millis(ZOOM_IN_OUT_INTERVAL), event ->
            zoomOutAction(new ActionEvent()));
}
项目:hygene    文件:GraphNavigationController.java   
/**
 * Add an event handler to a node will trigger continuously trigger at a given interval while the button is
 * being pressed.
 *
 * @param node     the {@link Node}
 * @param holdTime interval time
 * @param handler  the handler
 */
private void addContinuousPressHandler(final Node node, final Duration holdTime,
                                       final EventHandler<MouseEvent> handler) {
    final Wrapper<MouseEvent> eventWrapper = new Wrapper<>();

    final PauseTransition holdTimer = new PauseTransition(holdTime);
    holdTimer.setOnFinished(event -> {
        handler.handle(eventWrapper.content);
        holdTimer.playFromStart();
    });

    node.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> {
        eventWrapper.content = event;
        holdTimer.playFromStart();
    });
    node.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> holdTimer.stop());
    node.addEventHandler(MouseEvent.DRAG_DETECTED, event -> holdTimer.stop());
}
项目:ABC-List    文件:ExercisePresenter.java   
private void initializeExerciseTimer() {
    LoggerFacade.getDefault().info(this.getClass(), "Initialize [Exercise] timer"); // NOI18N

    ptExerciseTimer.setAutoReverse(false);
    ptExerciseTimer.setDelay(Duration.millis(125.0d));
    ptExerciseTimer.setDuration(Duration.seconds(1.0d));
    ptExerciseTimer.setOnFinished(value -> {
        --exerciseTime;
        this.onActionShowTime(exerciseTime);

        if (exerciseTime > 0) {
            ptExerciseTimer.playFromStart();
        }
        else {
            this.onActionExerciseIsReady();
        }
    });
}
项目:M426_Scrum    文件:SnakeGameGUI.java   
/**
 * Starts the timeline for the snake game and monitors the snake action
 */
private void startSnakeGame() {
    hasGameStarted = true;
    paused = false;
    timeline = new Timeline(new KeyFrame(Duration.ZERO, new EventHandler() {
        @Override
        public void handle(Event event) {
            if (pressedDir != null) {
                snake.setNewDirection(pressedDir);
            }
            snake.move();
            if (snake.snakeReachedFruit(fruit)) {
                snakeEatsFruit();
            }
            if (snake.isGameOver()) {
                timeline.stop();
                createGameOverPane();
            }
            repaintPane();
        }
    }), new KeyFrame(Duration.millis(speed)));

    if (snake.isSnakeAlive()) {
        timeline.setCycleCount(Timeline.INDEFINITE);
        timeline.play();
    }
}
项目:ExtremeGuiMakeover    文件:MediaControl.java   
protected void updateValues() {
    if (playTime != null && timeSlider != null && volumeSlider != null) {
        Platform.runLater(() -> {
            MediaPlayer mp = getMediaPlayer();

            Duration currentTime = mp.getCurrentTime();
            playTime.setText(formatTime(currentTime, duration));
            timeSlider.setDisable(duration.isUnknown());
            if (!timeSlider.isDisabled()
                    && duration.greaterThan(Duration.ZERO)
                    && !timeSlider.isValueChanging()) {
                timeSlider.setValue(currentTime.divide(duration).toMillis()
                        * 100.0);
            }
            if (!volumeSlider.isValueChanging()) {
                volumeSlider.setValue((int) Math.round(mp.getVolume()
                        * 100));
            }
        });
    }
}
项目:fxexperience2    文件:RotateInUpRightTransition.java   
@Override protected void starting() {
    super.starting();
    rotate = new Rotate(0,
            node.getBoundsInLocal().getWidth(),
            node.getBoundsInLocal().getHeight());
  timeline = new Timeline(
            new KeyFrame(Duration.millis(0),    
                new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                new KeyValue(rotate.angleProperty(), -90, WEB_EASE)
            ),
            new KeyFrame(Duration.millis(1000),    
                new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                new KeyValue(rotate.angleProperty(), 0, WEB_EASE)
            )
        );
    node.getTransforms().add(rotate);
}
项目:The-Trail    文件:TravelController.java   
@FXML
public void initialize(){

    Main.checkFullScreen();

    Main.getAlertWindow().setOnCloseRequest(e -> spriteImage.setImage(new Image(Gang.getCarSpriteURL())));

    // updating labels
    distanceLabel.setText("To go: "+ Gang.getDistance() +"Mi");
    conditionsLabel.setText("Condition: "+ Gang.getHealthConditions());
    daysLabel.setText("Days: "+ Gang.getDays());
    statusLabel.setText("Status: Resting");

    // setting up how the animation will work
    drivingTransition = new TranslateTransition();
    drivingTransition.setDuration(Duration.seconds(animationDuration));
    drivingTransition.setToX(Main.getMainWindow().getWidth() - 850);
    drivingTransition.setNode(sprite);
    drivingTransition.setCycleCount(Animation.INDEFINITE);

    // fixes the bug with thread not ending when stage was closed
    Main.getMainWindow().setOnCloseRequest(e -> Gang.setMoving(false));
}
项目:fxexperience2    文件:PulseTransition.java   
/**
 * Create new PulseTransition
 * 
 * @param node The node to affect
 */
public PulseTransition(final Node node) {
    super(
        node,
      new Timeline(
                new KeyFrame(Duration.millis(0), 
                    new KeyValue(node.scaleXProperty(), 1, WEB_EASE),
                    new KeyValue(node.scaleYProperty(), 1, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(500), 
                    new KeyValue(node.scaleXProperty(), 1.1, WEB_EASE),
                    new KeyValue(node.scaleYProperty(), 1.1, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(1000), 
                    new KeyValue(node.scaleXProperty(), 1, WEB_EASE),
                    new KeyValue(node.scaleYProperty(), 1, WEB_EASE)
                )
            )
        );
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
项目:lttng-scope    文件:FadeTransitionEx.java   
@Override
public void start(Stage primaryStage) {
    if (primaryStage == null) {
        return;
    }

  Group group = new Group();
  Rectangle rect = new Rectangle(20,20,200,200);

  FadeTransition ft = new FadeTransition(Duration.millis(5000), rect);
  ft.setFromValue(1.0);
  ft.setToValue(0.0);
  ft.play();

  group.getChildren().add(rect);

  Scene scene = new Scene(group, 300, 200);
  primaryStage.setScene(scene);
  primaryStage.show();
}
项目: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();
}
项目: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();
}
项目:xpanderfx    文件:MainFXMLDocumentController.java   
/**
 * Animation for key pressed.
 * @param b 
 */
private void keyPressedAnimation(Button b) {
    ScaleTransition st = new ScaleTransition(Duration.seconds(.2), b);
    st.setFromX(.8);
    st.setFromY(.8);
    st.setToX(1.6);
    st.setToY(1.6);
    st.play();
    st.setOnFinished(e -> {
        if(!b.isHover()) {
            ScaleTransition st2 = new ScaleTransition(Duration.seconds(.09), b);
            st2.setToX(1);
            st2.setToY(1);
            st2.play();
        }
    });

    FadeTransition ft = new FadeTransition(Duration.seconds(.2), b);
    ft.setFromValue(.2);
    ft.setToValue(1);
    ft.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();
    }
}
项目:marathonv5    文件:Ensemble2.java   
/**
 * Show the given node as a floating dialog over the whole application, with 
 * the rest of the application dimmed out and blocked from mouse events.
 * 
 * @param message 
 */
public void showModalMessage(Node message) {
    modalDimmer.getChildren().add(message);
    modalDimmer.setOpacity(0);
    modalDimmer.setVisible(true);
    modalDimmer.setCache(true);
    TimelineBuilder.create().keyFrames(
        new KeyFrame(Duration.seconds(1), 
            new EventHandler<ActionEvent>() {
                public void handle(ActionEvent t) {
                    modalDimmer.setCache(false);
                }
            },
            new KeyValue(modalDimmer.opacityProperty(),1, Interpolator.EASE_BOTH)
    )).build().play();
}
项目:marathonv5    文件:AdvCandleStickChartSample.java   
@Override protected void dataItemAdded(Series<Number, Number> series, int itemIndex, Data<Number, Number> item) {
    Node candle = createCandle(getData().indexOf(series), item, itemIndex);
    if (shouldAnimate()) {
        candle.setOpacity(0);
        getPlotChildren().add(candle);
        // fade in new candle
        FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
        ft.setToValue(1);
        ft.play();
    } else {
        getPlotChildren().add(candle);
    }
    // always draw average line on top
    if (series.getNode() != null) {
        series.getNode().toFront();
    }
}
项目:marathonv5    文件:AdvCandleStickChartSample.java   
@Override protected void seriesRemoved(Series<Number, Number> series) {
    // remove all candle nodes
    for (XYChart.Data<Number, Number> d : series.getData()) {
        final Node candle = d.getNode();
        if (shouldAnimate()) {
            // fade out old candle
            FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
            ft.setToValue(0);
            ft.setOnFinished(new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent actionEvent) {
                    getPlotChildren().remove(candle);
                }
            });
            ft.play();
        } else {
            getPlotChildren().remove(candle);
        }
    }
}
项目: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();
}
项目:marathonv5    文件:ScaleTransitionSample.java   
public ScaleTransitionSample() {
    super(150,150);
    Rectangle rect = new Rectangle(50, 50, 50, 50);
    rect.setArcHeight(15);
    rect.setArcWidth(15);
    rect.setFill(Color.ORANGE);
    getChildren().add(rect);
    scaleTransition = ScaleTransitionBuilder.create()
            .node(rect)
            .duration(Duration.seconds(4))
            .toX(3)
            .toY(3)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
项目:marathonv5    文件:OverlayMediaPlayer.java   
protected void updateValues() {
    if (playTime != null && timeSlider != null && volumeSlider != null && duration != null) {
        Platform.runLater(new Runnable() {
            public void run() {
                Duration currentTime = mp.getCurrentTime();
                playTime.setText(formatTime(currentTime, duration));
                timeSlider.setDisable(duration.isUnknown());
                if (!timeSlider.isDisabled() && duration.greaterThan(Duration.ZERO) && !timeSlider.isValueChanging()) {
                    timeSlider.setValue(currentTime.divide(duration).toMillis() * 100.0);
                }
                if (!volumeSlider.isValueChanging()) {
                    volumeSlider.setValue((int) Math.round(mp.getVolume() * 100));
                }
            }
        });
    }
}
项目:ShowMilhaoPOOJava    文件:ControllerLayoutInicial.java   
/**  
 * Método para efeito de transição de saída  
 */ 
private void makeFadeOut(String path) {
    FadeTransition fadeTransition = new FadeTransition();
    fadeTransition.setDuration(Duration.millis(250));
    fadeTransition.setNode(rootPane);
    fadeTransition.setFromValue(1);
    fadeTransition.setToValue(0);
    fadeTransition.setOnFinished(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            try {
                loadScreenPlay(path);
            } catch (IOException ex) {
                Logger.getLogger(ControllerLayoutInicial.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });     
    fadeTransition.play();
}
项目:marathonv5    文件:AdvancedMedia.java   
protected void updateValues() {
    if (playTime != null && timeSlider != null && volumeSlider != null && duration != null) {
        Platform.runLater(new Runnable() {
            public void run() {
                Duration currentTime = mp.getCurrentTime();
                playTime.setText(formatTime(currentTime, duration));
                timeSlider.setDisable(duration.isUnknown());
                if (!timeSlider.isDisabled() && duration.greaterThan(Duration.ZERO) && !timeSlider.isValueChanging()) {
                    timeSlider.setValue(currentTime.divide(duration).toMillis() * 100.0);
                }
                if (!volumeSlider.isValueChanging()) {
                    volumeSlider.setValue((int) Math.round(mp.getVolume() * 100));
                }
            }
        });
    }
}
项目:GazePlay    文件:Bravo.java   
private ScaleTransition createScaleTransition() {
    ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(zoomInDuration), this);
    scaleTransition.setInterpolator(Interpolator.LINEAR);

    // scale to the actual height of the scene
    // so that the image takes the full height of the scene when it is fully scaled
    double scaleRatio = (1 / pictureInitialHeightToSceneHeightRatio) / (1 / pictureFinalHeightToSceneHeightRatio)
            - 1d;
    scaleTransition.setByX(scaleRatio);
    scaleTransition.setByY(scaleRatio);

    scaleTransition.setCycleCount(zoomInAndOutCyclesCount);
    scaleTransition.setAutoReverse(true);
    scaleTransition.setOnFinished(actionEvent -> log.debug("finished scaleTransition"));
    return scaleTransition;
}
项目: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();
    }
}
项目: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);
    }
}
项目: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;
}
项目: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();
}
项目:marathonv5    文件:LiveDataFetcher.java   
public void regionOrProductChanged() {
    cancel();
    boolean regionChanged = updateRegionAndProductSelection();
    if (regionChanged) {
        // pause the data updating to wait for animation to finish
        PauseTransition delay = new PauseTransition(Duration.millis(1500));
        delay.setOnFinished(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent t) {
                restart();
            }
        });
        delay.play();
    } else {
        restart();
    }
}
项目:qupath-tracking-extension    文件:ExtendedViewTrackerPlayback.java   
public ExtendedViewTrackerPlayback(QuPathViewer viewer) {
    this.viewer = viewer;
    this.playing = new SimpleBooleanProperty(false);
    this.timeline = new Timeline(
            new KeyFrame(Duration.ZERO,
                    actionEvent -> ExtendedViewTrackerPlayback.this.handleUpdate(),
                    new KeyValue[0]), new KeyFrame(Duration.millis(50.0D)));
    this.timeline.setCycleCount(-1);
    this.playing.addListener((v, o, n) -> {
        if (n) {
            this.doStartPlayback();
        } else {
            this.doStopPlayback();
        }

    });
}
项目:octoBubbles    文件:GraphController.java   
void zoomPane(double newZoom) {
    double scale = newZoom / 100;

    final Timeline timeline = new Timeline();
    final KeyValue kv1 = new KeyValue(aDrawPane.scaleXProperty(), scale);
    final KeyValue kv2 = new KeyValue(aDrawPane.scaleYProperty(), scale);
    final KeyFrame kf = new KeyFrame(Duration.millis(100), kv1, kv2);
    timeline.getKeyFrames().add(kf);
    timeline.play();
}
项目:fxexperience2    文件:FadeOutUpTransition.java   
/**
 * Create new FadeOutUpTransition
 * 
 * @param node The node to affect
 */
public FadeOutUpTransition(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));
}
项目: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    文件:SwingTransition.java   
/**
 * Create new SwingTransition
 * 
 * @param node The node to affect
 */
public SwingTransition(final Node node) {
    super(
        node,
      new Timeline(
                new KeyFrame(Duration.millis(0), new KeyValue(node.rotateProperty(), 0, WEB_EASE)),
                new KeyFrame(Duration.millis(200), new KeyValue(node.rotateProperty(), 15, WEB_EASE)),
                new KeyFrame(Duration.millis(400), new KeyValue(node.rotateProperty(), -10, WEB_EASE)),
                new KeyFrame(Duration.millis(600), new KeyValue(node.rotateProperty(), 5, WEB_EASE)),
                new KeyFrame(Duration.millis(800), new KeyValue(node.rotateProperty(), -5, WEB_EASE)),
                new KeyFrame(Duration.millis(1000), new KeyValue(node.rotateProperty(), 0, WEB_EASE))
            )
        );
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
项目:marathonv5    文件:RotateTransitionSample.java   
public RotateTransitionSample() {
    super(140,140);

    Rectangle rect = new Rectangle(20, 20, 100, 100);
    rect.setArcHeight(20);
    rect.setArcWidth(20);
    rect.setFill(Color.ORANGE);
    getChildren().add(rect);

    rotateTransition = RotateTransitionBuilder.create()
            .node(rect)
            .duration(Duration.seconds(4))
            .fromAngle(0)
            .toAngle(720)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
项目:fx-media-catalog    文件:FxMediaCatalog.java   
private void bindContentProgressClick(MediaPlayer aMediaPlayer, ProgressBar aContentProgress) {
    if (null == aMediaPlayer || null == aContentProgress) return;
    final Media media = aMediaPlayer.getMedia();
    if (null == media) return;
    unbindContentProgressClick(aContentProgress);
    aContentProgress.setOnMouseClicked((e) -> {
        final Duration d = media.getDuration();
        final Duration newPosition = d.divide(aContentProgress.getWidth()).multiply(e.getX());
        aMediaPlayer.seek(newPosition);
       });
}
项目:fxexperience2    文件:FadeInUpBigTransition.java   
@Override protected void starting() {
    double startY = node.getScene().getHeight() - node.localToScene(0, 0).getY();
        timeline = new Timeline(
                new KeyFrame(Duration.millis(0),    
                    new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                    new KeyValue(node.translateYProperty(), startY, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(1000),    
                    new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                    new KeyValue(node.translateYProperty(), 0, WEB_EASE)
                )
            );
    super.starting();
}