当前位置: 首页>>代码示例>>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;未经允许,请勿转载。