List of usage examples for javafx.animation Animation INDEFINITE
int INDEFINITE
To view the source code for javafx.animation Animation INDEFINITE.
Click Source Link
From source file:Main.java
private void addBouncyBall(final Scene scene) { final Circle ball = new Circle(100, 100, 20); final Group root = (Group) scene.getRoot(); root.getChildren().add(ball);//from ww w . j a v a 2s. c o m Timeline tl = new Timeline(); tl.setCycleCount(Animation.INDEFINITE); KeyFrame moveBall = new KeyFrame(Duration.seconds(.0200), new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { double xMin = ball.getBoundsInParent().getMinX(); double yMin = ball.getBoundsInParent().getMinY(); double xMax = ball.getBoundsInParent().getMaxX(); double yMax = ball.getBoundsInParent().getMaxY(); if (xMin < 0 || xMax > scene.getWidth()) { dx = dx * -1; } if (yMin < 0 || yMax > scene.getHeight()) { dy = dy * -1; } ball.setTranslateX(ball.getTranslateX() + dx); ball.setTranslateY(ball.getTranslateY() + dy); } }); tl.getKeyFrames().add(moveBall); tl.play(); }
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);//from ww w . j a v a2 s . c om 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:org.pdfsam.ui.selection.LoadingStatusIndicator.java
public LoadingStatusIndicator(PdfDocumentDescriptorProvider descriptorProvider, String ownerModule) { requireNotNull(descriptorProvider,/*from w w w . j a va 2 s. co m*/ "Cannot create LoadingStatusIndicator with a null PdfDocumentDescriptorProvider"); this.ownerModule = defaultString(ownerModule); this.popup = new PasswordFieldPopup(getOwnerModule()); this.descriptorProvider = descriptorProvider; this.addEventFilter(MouseEvent.MOUSE_CLICKED, (e) -> { if (loadingStatus.get() == ENCRYPTED) { showPasswordRequest(); } else if (loadingStatus.get() == WITH_ERRORS) { eventStudio().broadcast(new ShowStageRequest(), "LogStage"); } }); loadingStatus.addListener((o, oldVal, newVal) -> updateIndicator(newVal)); this.getStyleClass().addAll("encryption-status"); this.icon.setText(""); icon.setTextAlignment(TextAlignment.CENTER); icon.setAlignment(Pos.CENTER); this.setGraphic(icon); rotate.setByAngle(360); rotate.setCycleCount(Animation.INDEFINITE); rotate.setInterpolator(Interpolator.LINEAR); }
From source file:org.sociotech.unui.javafx.engine2d.AbstractWorld.java
private void initEventLoop() { final Duration fps = Duration.millis(1000 / (float) 60); final KeyFrame eventLoop = new KeyFrame(fps, new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { // destroy entities on list getEntityManager().destroy(); updateEntities();//from ww w .j a va2 s.co m updateFps(); onPostUpdate(m_fps); } }); // Create Loop TimelineBuilder builder = TimelineBuilder.create(); builder.cycleCount(Animation.INDEFINITE); builder.keyFrames(eventLoop); m_eventLoop = builder.build(); }