List of usage examples for javafx.util Duration millis
double millis
To view the source code for javafx.util Duration millis.
Click Source Link
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Sample"); stage.setWidth(300);/*from www. j a v a 2 s .c o m*/ stage.setHeight(190); VBox vbox = new VBox(); vbox.setLayoutX(20); vbox.setLayoutY(20); final String content = "Lorem ipsum"; final Text text = new Text(10, 20, ""); final Animation animation = new Transition() { { setCycleDuration(Duration.millis(2000)); } protected void interpolate(double frac) { final int length = content.length(); final int n = Math.round(length * (float) frac); text.setText(content.substring(0, n)); } }; animation.play(); vbox.getChildren().add(text); vbox.setSpacing(10); ((Group) scene.getRoot()).getChildren().add(vbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle(""); Group root = new Group(); Scene scene = new Scene(root, 300, 250, Color.WHITE); Group g = new Group(); DropShadow ds = new DropShadow(); ds.setOffsetY(3.0);/*from ww w .jav a 2 s . c o m*/ ds.setColor(Color.color(0.4, 0.4, 0.4)); Ellipse ellipse = new Ellipse(); ellipse.setCenterX(50.0f); ellipse.setCenterY(50.0f); ellipse.setRadiusX(50.0f); ellipse.setRadiusY(25.0f); ellipse.setEffect(ds); FillTransition ft = new FillTransition(Duration.millis(3000), ellipse, Color.RED, Color.BLUE); ft.setAutoReverse(true); ft.play(); g.getChildren().add(ellipse); root.getChildren().add(g); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle(""); Group root = new Group(); Scene scene = new Scene(root, 300, 250, Color.WHITE); Group g = new Group(); DropShadow ds = new DropShadow(); ds.setOffsetY(3.0);/*from w w w . j a va 2s . c o m*/ ds.setColor(Color.color(0.4, 0.4, 0.4)); Ellipse ellipse = new Ellipse(); ellipse.setCenterX(50.0f); ellipse.setCenterY(50.0f); ellipse.setRadiusX(50.0f); ellipse.setRadiusY(25.0f); ellipse.setEffect(ds); FadeTransition ft = new FadeTransition(Duration.millis(3000), ellipse); ft.setFromValue(1.0); ft.setToValue(0.3); ft.setAutoReverse(true); ft.play(); g.getChildren().add(ellipse); root.getChildren().add(g); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { final NumberAxis xAxis = new NumberAxis(); final CategoryAxis yAxis = new CategoryAxis(); final BarChart<Number, String> bc = new BarChart<Number, String>(xAxis, yAxis); bc.setTitle("Summary"); xAxis.setLabel("Value"); xAxis.setTickLabelRotation(90);//w w w . java 2s . co m yAxis.setLabel("Item"); XYChart.Series series1 = new XYChart.Series(); series1.setName("2003"); series1.getData().add(new XYChart.Data(2, itemA)); series1.getData().add(new XYChart.Data(20, itemB)); series1.getData().add(new XYChart.Data(10, itemC)); XYChart.Series series2 = new XYChart.Series(); series2.setName("2004"); series2.getData().add(new XYChart.Data(50, itemA)); series2.getData().add(new XYChart.Data(41, itemB)); series2.getData().add(new XYChart.Data(45, itemC)); XYChart.Series series3 = new XYChart.Series(); series3.setName("2005"); series3.getData().add(new XYChart.Data(45, itemA)); series3.getData().add(new XYChart.Data(44, itemB)); series3.getData().add(new XYChart.Data(18, itemC)); Timeline tl = new Timeline(); tl.getKeyFrames().add(new KeyFrame(Duration.millis(500), new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { for (XYChart.Series<Number, String> series : bc.getData()) { for (XYChart.Data<Number, String> data : series.getData()) { data.setXValue(Math.random() * 100); } } } })); tl.setCycleCount(Animation.INDEFINITE); tl.play(); Scene scene = new Scene(bc, 800, 600); bc.getData().addAll(series1, series2, series3); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { final Label markerText = new Label(); StackPane.setAlignment(markerText, Pos.TOP_CENTER); String workingDir = System.getProperty("user.dir"); final File f = new File(workingDir, "../media/omgrobots.flv"); final Media m = new Media(f.toURI().toString()); final ObservableMap<String, Duration> markers = m.getMarkers(); markers.put("Robot Finds Wall", Duration.millis(3100)); markers.put("Then Finds the Green Line", Duration.millis(5600)); markers.put("Robot Grabs Sled", Duration.millis(8000)); markers.put("And Heads for Home", Duration.millis(11500)); final MediaPlayer mp = new MediaPlayer(m); mp.setOnMarker(new EventHandler<MediaMarkerEvent>() { @Override/*from w w w.j a v a 2s.co m*/ public void handle(final MediaMarkerEvent event) { Platform.runLater(new Runnable() { @Override public void run() { markerText.setText(event.getMarker().getKey()); } }); } }); final MediaView mv = new MediaView(mp); final StackPane root = new StackPane(); root.getChildren().addAll(mv, markerText); root.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { mp.seek(Duration.ZERO); markerText.setText(""); } }); final Scene scene = new Scene(root, 960, 540); final URL stylesheet = getClass().getResource("media.css"); scene.getStylesheets().add(stylesheet.toString()); primaryStage.setScene(scene); primaryStage.setTitle("Video Player 2"); primaryStage.show(); mp.play(); }
From source file:projavafx.videoplayer3.VideoPlayer3.java
@Override public void start(Stage primaryStage) { final Label message = new Label("I \u2764 Robots"); message.setVisible(false);//from ww w . j a v a2 s. com String workingDir = System.getProperty("user.dir"); final File f = new File(workingDir, "../media/omgrobots.flv"); final Media m = new Media(f.toURI().toString()); m.getMarkers().put("Split", Duration.millis(3000)); m.getMarkers().put("Join", Duration.millis(9000)); final MediaPlayer mp = new MediaPlayer(m); final MediaView mv1 = new MediaView(mp); mv1.setViewport(new Rectangle2D(0, 0, 960 / 2, 540)); StackPane.setAlignment(mv1, Pos.CENTER_LEFT); final MediaView mv2 = new MediaView(mp); mv2.setViewport(new Rectangle2D(960 / 2, 0, 960 / 2, 540)); StackPane.setAlignment(mv2, Pos.CENTER_RIGHT); StackPane root = new StackPane(); root.getChildren().addAll(message, mv1, mv2); root.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { mp.seek(Duration.ZERO); message.setVisible(false); } }); final Scene scene = new Scene(root, 960, 540); final URL stylesheet = getClass().getResource("media.css"); scene.getStylesheets().add(stylesheet.toString()); primaryStage.setScene(scene); primaryStage.setTitle("Video Player 3"); primaryStage.show(); mp.setOnMarker(new EventHandler<MediaMarkerEvent>() { @Override public void handle(final MediaMarkerEvent event) { Platform.runLater(new Runnable() { @Override public void run() { if (event.getMarker().getKey().equals("Split")) { message.setVisible(true); buildSplitTransition(mv1, mv2).play(); } else { buildJoinTransition(mv1, mv2).play(); } } }); } }); mp.play(); }
From source file:com.toyota.carservice.controller.SwitchController.java
@FXML private void btnLoginOnAction(ActionEvent event) { ApplicationContext ctx = config.getInstance().getApplicationContext(); UserDaoJdbcImpl userDaoImpl = ctx.getBean(UserDaoJdbcImpl.class); // if(userDaoImpl.check(txtUsername.getText(), txtPassword.getText())>0){ if (Boolean.TRUE) { paneMenu.toFront();//from w ww .j av a 2s . c o m paneMenu.setOpacity(1); paneLogin.setOpacity(0); lblClose.toFront(); } else { new FadeInTransition(lblConfirmation).playFrom(Duration.millis(15)); } }
From source file:Main.java
@Override public void start(Stage stage) { Group p = new Group(); Scene scene = new Scene(p); stage.setScene(scene);/*from w w w .j av a2s . co m*/ stage.setWidth(500); stage.setHeight(500); p.setTranslateX(80); p.setTranslateY(80); //create a circle with effect final Circle circle = new Circle(20, Color.rgb(156, 216, 255)); circle.setEffect(new Lighting()); //create a text inside a circle final Text text = new Text(i.toString()); text.setStroke(Color.BLACK); //create a layout for circle with text inside final StackPane stack = new StackPane(); stack.getChildren().addAll(circle, text); stack.setLayoutX(30); stack.setLayoutY(30); p.getChildren().add(stack); stage.show(); //create a timeline for moving the circle timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //You can add a specific action when each frame is started. timer = new AnimationTimer() { @Override public void handle(long l) { text.setText(i.toString()); i++; } }; //create a keyValue with factory: scaling the circle 2times KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2); KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2); //create a keyFrame, the keyValue is reached at time 2s Duration duration = Duration.millis(2000); //one can add a specific action when the keyframe is reached EventHandler onFinished = new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { stack.setTranslateX(java.lang.Math.random() * 200 - 100); //reset counter i = 0; } }; KeyFrame keyFrame = new KeyFrame(duration, onFinished, keyValueX, keyValueY); //add the keyframe to the timeline timeline.getKeyFrames().add(keyFrame); timeline.play(); timer.start(); }
From source file:projavafx.videoplayer3.VideoPlayer3.java
private ParallelTransition buildJoinTransition(Node one, Node two) { return ParallelTransitionBuilder.create().children( TranslateTransitionBuilder.create().duration(Duration.millis(1000)).node(one).byX(200).build(), TranslateTransitionBuilder.create().duration(Duration.millis(1000)).node(two).byX(-200).build()) .build();//from ww w . j ava 2s .c o m }
From source file:projavafx.videoplayer3.VideoPlayer3.java
private ParallelTransition buildSplitTransition(Node one, Node two) { return ParallelTransitionBuilder.create().children( TranslateTransitionBuilder.create().duration(Duration.millis(1000)).node(one).byX(-200).build(), TranslateTransitionBuilder.create().duration(Duration.millis(1000)).node(two).byX(200).build()) .build();/* w ww . jav a 2 s. c o m*/ }