當前位置: 首頁>>代碼示例>>Java>>正文


Java Duration類代碼示例

本文整理匯總了Java中javafx.util.Duration的典型用法代碼示例。如果您正苦於以下問題:Java Duration類的具體用法?Java Duration怎麽用?Java Duration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Duration類屬於javafx.util包,在下文中一共展示了Duration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ActionTextPane

import javafx.util.Duration; //導入依賴的package包/類
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);

    }
 
開發者ID:jdesive,項目名稱:textmd,代碼行數:19,代碼來源:ActionTextPane.java

示例2: makeText

import javafx.util.Duration; //導入依賴的package包/類
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();
}
 
開發者ID:nwg-piotr,項目名稱:EistReturns,代碼行數:38,代碼來源:Utils.java

示例3: seriesRemoved

import javafx.util.Duration; //導入依賴的package包/類
@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);
        }
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:22,代碼來源:AdvCandleStickChartSample.java

示例4: bindUpdates

import javafx.util.Duration; //導入依賴的package包/類
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();
}
 
開發者ID:de-sach,項目名稱:BatpackJava,代碼行數:17,代碼來源:batteryMonitorLayoutController.java

示例5: initialProperty

import javafx.util.Duration; //導入依賴的package包/類
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;
}
 
開發者ID:GoSuji,項目名稱:Suji,代碼行數:23,代碼來源:GoTimer.java

示例6: makeFadeOut

import javafx.util.Duration; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:tadeuespindolapalermo,項目名稱:ShowMilhaoPOOJava,代碼行數:25,代碼來源:ControllerLayoutPrincipal.java

示例7: initialize

import javafx.util.Duration; //導入依賴的package包/類
@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()));
}
 
開發者ID:ProgrammingLife2017,項目名稱:hygene,代碼行數:25,代碼來源:GraphNavigationController.java

示例8: addContinuousPressHandler

import javafx.util.Duration; //導入依賴的package包/類
/**
 * 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());
}
 
開發者ID:ProgrammingLife2017,項目名稱:hygene,代碼行數:26,代碼來源:GraphNavigationController.java

示例9: initializeExerciseTimer

import javafx.util.Duration; //導入依賴的package包/類
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();
        }
    });
}
 
開發者ID:Naoghuman,項目名稱:ABC-List,代碼行數:19,代碼來源:ExercisePresenter.java

示例10: startSnakeGame

import javafx.util.Duration; //導入依賴的package包/類
/**
 * 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();
	}
}
 
開發者ID:sanijablan,項目名稱:M426_Scrum,代碼行數:30,代碼來源:SnakeGameGUI.java

示例11: updateValues

import javafx.util.Duration; //導入依賴的package包/類
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));
            }
        });
    }
}
 
開發者ID:hendrikebbers,項目名稱:ExtremeGuiMakeover,代碼行數:22,代碼來源:MediaControl.java

示例12: starting

import javafx.util.Duration; //導入依賴的package包/類
@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);
}
 
開發者ID:EricCanull,項目名稱:fxexperience2,代碼行數:18,代碼來源:RotateInUpRightTransition.java

示例13: initialize

import javafx.util.Duration; //導入依賴的package包/類
@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));
}
 
開發者ID:TheRedSpy15,項目名稱:The-Trail,代碼行數:24,代碼來源:TravelController.java

示例14: PulseTransition

import javafx.util.Duration; //導入依賴的package包/類
/**
 * 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));
}
 
開發者ID:EricCanull,項目名稱:fxexperience2,代碼行數:27,代碼來源:PulseTransition.java

示例15: start

import javafx.util.Duration; //導入依賴的package包/類
@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();
}
 
開發者ID:lttng,項目名稱:lttng-scope,代碼行數:21,代碼來源:FadeTransitionEx.java


注:本文中的javafx.util.Duration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。