javafx.util.Duration Java Examples
The following examples show how to use
javafx.util.Duration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JackInTheBox.java From AnimateFX with Apache License 2.0 | 7 votes |
@Override void initTimeline() { Rotate rotate = new Rotate(30, getNode().getBoundsInParent().getWidth() / 2, getNode().getBoundsInParent().getHeight()); getNode().getTransforms().add(rotate); setTimeline(new Timeline( new KeyFrame(Duration.millis(0), new KeyValue(rotate.angleProperty(), 30, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleXProperty(), 0.1, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleYProperty(), 0.1, AnimateFXInterpolator.EASE), new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) ), new KeyFrame(Duration.millis(500), new KeyValue(rotate.angleProperty(), -10, AnimateFXInterpolator.EASE) ), new KeyFrame(Duration.millis(700), new KeyValue(rotate.angleProperty(), 3, AnimateFXInterpolator.EASE) ), new KeyFrame(Duration.millis(1000), new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), new KeyValue(rotate.angleProperty(), 0, AnimateFXInterpolator.EASE), new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) ) )); }
Example #2
Source File: ZoomOperator.java From PDF4Teachers with Apache License 2.0 | 7 votes |
public void scrollDown(int factor, boolean removeTransition){ if(!isPlaying){ aimTranslateY = pane.getTranslateY(); aimTranslateX = pane.getTranslateX(); aimScale = pane.getScaleX(); } double newTranslateY = aimTranslateY - factor; if(newTranslateY - getPaneShiftY() < -getScrollableHeight()) newTranslateY = -getScrollableHeight() + getPaneShiftY(); aimTranslateY = newTranslateY; if(Main.settings.isZoomAnimations() && factor > 25 && !removeTransition){ timeline.getKeyFrames().clear(); timeline.getKeyFrames().addAll( new KeyFrame(Duration.millis(200), new KeyValue(pane.translateYProperty(), aimTranslateY)) ); timeline.stop(); isPlaying = true; timeline.play(); }else{ pane.setTranslateY(aimTranslateY); } }
Example #3
Source File: FlipTileSkin.java From OEE-Designer with MIT License | 7 votes |
private void flipForward() { timeline.stop(); flap.setCache(true); flap.setCacheHint(CacheHint.ROTATE); //flap.setCacheHint(CacheHint.SPEED); currentSelectionIndex++; if (currentSelectionIndex >= characters.size()) { currentSelectionIndex = 0; } nextSelectionIndex = currentSelectionIndex + 1; if (nextSelectionIndex >= characters.size()) { nextSelectionIndex = 0; } KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0)); //KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.EASE_IN); KeyFrame keyFrame = new KeyFrame(Duration.millis(tile.getFlipTimeInMS()), keyValueFlap); timeline.getKeyFrames().setAll(keyFrame); timeline.play(); }
Example #4
Source File: SpaceInvadersFactory.java From FXGLGames with MIT License | 6 votes |
@Spawns("Explosion") public Entity newExplosion(SpawnData data) { play("explosion.wav"); var texture = texture("explosion.png", 80 * 16, 80).toAnimatedTexture(16, Duration.seconds(0.5)); var e = entityBuilder() .at(data.getX() - 40, data.getY() - 40) // we want a smaller texture, 80x80 // it has 16 frames, hence 80 * 16 .view(texture.loop()) .build(); texture.setOnCycleFinished(() -> e.removeFromWorld()); return e; }
Example #5
Source File: FillTransitionSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public FillTransitionSample() { super(100,100); Rectangle rect = new Rectangle(0, 0, 100, 100); rect.setArcHeight(20); rect.setArcWidth(20); rect.setFill(Color.DODGERBLUE); getChildren().add(rect); fillTransition = FillTransitionBuilder.create() .duration(Duration.seconds(3)) .shape(rect) .fromValue(Color.RED) .toValue(Color.DODGERBLUE) .cycleCount(Timeline.INDEFINITE) .autoReverse(true) .build(); }
Example #6
Source File: Notifications.java From yfiton with Apache License 2.0 | 6 votes |
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay, Notifications notification) { KeyValue fadeOutBegin = new KeyValue(bar.opacityProperty(), 1.0); KeyValue fadeOutEnd = new KeyValue(bar.opacityProperty(), 0.0); KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin); KeyFrame kfEnd = new KeyFrame(Duration.millis(500), fadeOutEnd); Timeline timeline = new Timeline(kfBegin, kfEnd); timeline.setDelay(startDelay); timeline.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { hide(popup, p); notification.onHideAction.handle(e); } }); return timeline; }
Example #7
Source File: BossComponent.java From FXGLGames with MIT License | 6 votes |
@Override public void die() { Entity enemy = getEntity(); enemy.getComponent(CollidableComponent.class).setValue(false); enemy.setUpdateEnabled(false); for (int i = 0; i < 5; i++) { runOnce(() -> { spawn("Explosion", enemy.getCenter().add(FXGLMath.randomPoint2D().multiply(70))); }, Duration.seconds(0.25 * i)); } runOnce(() -> { enemy.removeFromWorld(); getEventBus().fireEvent(new GameEvent(GameEvent.ENEMY_KILLED)); }, Duration.seconds(1.8)); }
Example #8
Source File: Viewer3DFX.java From paintera with GNU General Public License v2.0 | 6 votes |
public void setAffine(final Affine affine, final Duration duration) { if (duration.toMillis() == 0.0) { setAffine(affine); return; } final Timeline timeline = new Timeline(60.0); timeline.setCycleCount(1); timeline.setAutoReverse(false); final Affine currentState = new Affine(); getAffine(currentState); final DoubleProperty progressProperty = new SimpleDoubleProperty(0.0); final SimilarityTransformInterpolator interpolator = new SimilarityTransformInterpolator( Transforms.fromTransformFX(currentState), Transforms.fromTransformFX(affine) ); progressProperty.addListener((obs, oldv, newv) -> setAffine(Transforms.toTransformFX(interpolator.interpolateAt(newv.doubleValue())))); final KeyValue kv = new KeyValue(progressProperty, 1.0, Interpolator.EASE_BOTH); timeline.getKeyFrames().add(new KeyFrame(duration, kv)); timeline.play(); }
Example #9
Source File: FormatCoordinatesSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 6 votes |
/** * Shows a callout at the specified location with different coordinate formats in the callout. * * @param location coordinate to show coordinate formats for */ private void showCalloutWithLocationCoordinates(Point location) { Callout callout = mapView.getCallout(); callout.setTitle("Location:"); String latLonDecimalDegrees = CoordinateFormatter.toLatitudeLongitude(location, CoordinateFormatter .LatitudeLongitudeFormat.DECIMAL_DEGREES, 4); String latLonDegMinSec = CoordinateFormatter.toLatitudeLongitude(location, CoordinateFormatter .LatitudeLongitudeFormat.DEGREES_MINUTES_SECONDS, 1); String utm = CoordinateFormatter.toUtm(location, CoordinateFormatter.UtmConversionMode.LATITUDE_BAND_INDICATORS, true); String usng = CoordinateFormatter.toUsng(location, 4, true); callout.setDetail( "Decimal Degrees: " + latLonDecimalDegrees + "\n" + "Degrees, Minutes, Seconds: " + latLonDegMinSec + "\n" + "UTM: " + utm + "\n" + "USNG: " + usng + "\n" ); mapView.getCallout().showCalloutAt(location, new Duration(500)); }
Example #10
Source File: TimelineChart.java From constellation with Apache License 2.0 | 6 votes |
@Override protected void seriesRemoved(final Series<Number, Number> series) { final Node child = series.getNode(); if (shouldAnimate()) { // fade out old item: final FadeTransition ft = new FadeTransition(Duration.millis(500), child); ft.setToValue(0); ft.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent actionEvent) { getPlotChildren().clear(); } }); ft.play(); } else { getPlotChildren().clear(); } }
Example #11
Source File: Scene2Controller.java From JavaFX-Tutorial-Codes with Apache License 2.0 | 6 votes |
@FXML private void loadThird(ActionEvent event) throws IOException { Parent root = FXMLLoader.load(getClass().getResource("/javafx/scene/transition/scene3/scene3.fxml")); Scene scene = button.getScene(); root.translateXProperty().set(scene.getWidth()); StackPane parentContainer = (StackPane) button.getScene().getRoot(); parentContainer.getChildren().add(root); Timeline timeline = new Timeline(); KeyValue kv = new KeyValue(root.translateXProperty(), 0, Interpolator.EASE_IN); KeyFrame kf = new KeyFrame(Duration.seconds(1), kv); timeline.getKeyFrames().add(kf); timeline.setOnFinished(t -> { parentContainer.getChildren().remove(container); }); timeline.play(); }
Example #12
Source File: DisplayEditorApplication.java From phoebus with Eclipse Public License 1.0 | 6 votes |
@Override public DisplayEditorInstance create() { if (!AuthorizationService.hasAuthorization("edit_display")) { // User does not have a permission to start editor final Alert alert = new Alert(Alert.AlertType.WARNING); DialogHelper.positionDialog(alert, DockPane.getActiveDockPane(), -200, -100); alert.initOwner(DockPane.getActiveDockPane().getScene().getWindow()); alert.setResizable(true); alert.setTitle(DISPLAY_NAME); alert.setHeaderText(Messages.DisplayApplicationMissingRight); // Autohide in some seconds, also to handle the situation after // startup without edit_display rights but opening editor from memento PauseTransition wait = new PauseTransition(Duration.seconds(7)); wait.setOnFinished((e) -> { Button btn = (Button)alert.getDialogPane().lookupButton(ButtonType.OK); btn.fire(); }); wait.play(); alert.showAndWait(); return null; } return new DisplayEditorInstance(this); }
Example #13
Source File: Resumen.java From uip-pc2 with MIT License | 6 votes |
public void ver(ActionEvent actionEvent) { Stage stage = (Stage) movimientos.getScene().getWindow(); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Movimientos.fxml")); Parent root = null; try { root = fxmlLoader.load(); } catch (Exception e) { Alert alerta = new Alert(Alert.AlertType.ERROR); alerta.setTitle("Error de AplicaciĆ³n"); alerta.setContentText("Llama al lapecillo de sistemas."); alerta.showAndWait(); Platform.exit(); } FadeTransition ft = new FadeTransition(Duration.millis(1500), root); ft.setFromValue(0.0); ft.setToValue(1.0); ft.play(); Movimientos controller = fxmlLoader.<Movimientos>getController(); controller.cargar_movimientos(cuenta.getText()); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); }
Example #14
Source File: MainScene.java From mars-sim with GNU General Public License v3.0 | 6 votes |
/** * Creates and starts the earth timer */ public void startEarthTimer() { // Set up earth time text update timeLabeltimer = new Timeline(new KeyFrame(Duration.millis(TIME_DELAY), ae -> updateTimeLabels())); // Note: Infinite Timeline might result in a memory leak if not stopped // properly. // All the objects with animated properties would not be garbage collected. timeLabeltimer.setCycleCount(javafx.animation.Animation.INDEFINITE); timeLabeltimer.play(); }
Example #15
Source File: ZoomOutRight.java From AnimateFX with Apache License 2.0 | 6 votes |
@Override void initTimeline() { setTimeline(new Timeline( new KeyFrame(Duration.millis(0), new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE), new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) ), new KeyFrame(Duration.millis(400), new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), new KeyValue(getNode().translateXProperty(), -42, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleXProperty(), 0.475, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleYProperty(), 0.475, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleZProperty(), 0.475, AnimateFXInterpolator.EASE) ), new KeyFrame(Duration.millis(1100), new KeyValue(getNode().translateXProperty(), 2000, AnimateFXInterpolator.EASE), new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleXProperty(), 0.1, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleYProperty(), 0.1, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleZProperty(), 0.1, AnimateFXInterpolator.EASE) ) )); }
Example #16
Source File: DesktopNotification.java From yfiton with Apache License 2.0 | 6 votes |
@Override public void start(Stage primaryStage) { Map<String, String> parameters = getParameters().getNamed(); primaryStage.initStyle(StageStyle.TRANSPARENT); Scene scene = new Scene(new VBox(), 1, 1); scene.setFill(null); primaryStage.setScene(scene); primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("/yfiton-icon.png"))); primaryStage.show(); Notifications.create() .darkStyle() .graphic(new ImageView(Notifications.class.getResource("/" + parameters.get("type") + ".png").toExternalForm())) .hideAfter(Duration.seconds(Integer.parseInt(parameters.get("hideAfter")))) .onHideAction(event -> System.exit(0)) .position(Pos.valueOf(parameters.get("position"))) .text(parameters.get("message")) .show(); }
Example #17
Source File: Main.java From FXTutorials with MIT License | 6 votes |
public LoadingBar() { Circle outer = new Circle(50); outer.setFill(null); outer.setStroke(Color.BLACK); Circle inner = new Circle(5); inner.setTranslateY(-50); rt = new RotateTransition(Duration.seconds(2), this); rt.setToAngle(360); rt.setInterpolator(Interpolator.LINEAR); rt.setCycleCount(RotateTransition.INDEFINITE); getChildren().addAll(outer, inner); setVisible(false); }
Example #18
Source File: MainProgramSceneController.java From Hostel-Management-System with MIT License | 6 votes |
@FXML private void shirnkDetailsAction(ActionEvent event) { if ("Cancel".equals(StudentDetailController.editCancelButton.getText())) { StudentDetailController.editCancelButtonAction(event); } final Animation animation = new Transition() { { setCycleDuration(Duration.millis(800)); } @Override protected void interpolate(double frac) { SplitPaneMain.setDividerPosition(0, SplitPaneMain.getDividerPositions()[0]-frac); } }; animation.play(); }
Example #19
Source File: VolumeChart.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void dataItemRemoved(XYChart.Data<Number, Number> item, XYChart.Series<Number, Number> series) { final Node node = item.getNode(); if (shouldAnimate()) { FadeTransition ft = new FadeTransition(Duration.millis(500), node); ft.setToValue(0); ft.setOnFinished((ActionEvent actionEvent) -> { getPlotChildren().remove(node); removeDataItemFromDisplay(series, item); }); ft.play(); } else { getPlotChildren().remove(node); removeDataItemFromDisplay(series, item); } }
Example #20
Source File: MidiApp.java From FXTutorials with MIT License | 6 votes |
private void onKeyPress(KeyCode key) { root.getChildren() .stream() .map(view -> (NoteView) view) .filter(view -> view.note.key.equals(key)) .forEach(view -> { FillTransition ft = new FillTransition( Duration.seconds(0.15), view.bg, Color.WHITE, Color.BLACK ); ft.setCycleCount(2); ft.setAutoReverse(true); ft.play(); channel.noteOn(view.note.number, 90); }); }
Example #21
Source File: Level13.java From FXGLGames with MIT License | 6 votes |
@Override public void init() { double t = 0; for (int y = 0; y < ENEMY_ROWS; y++) { for (int x = 0; x < ENEMIES_PER_ROW; x++) { Entity enemy = spawnEnemy(random(0, getAppWidth() - 100), random(0, getAppHeight() / 2.0)); var a = animationBuilder() .repeatInfinitely() .autoReverse(true) .delay(Duration.seconds(t)) .duration(Duration.seconds(1.0)) .scale(enemy) .from(new Point2D(1.0, 1.0)) .to(new Point2D(0.0, 0.0)) .build(); animations.add(a); a.start(); t += 0.3; } } }
Example #22
Source File: RadialBargraphSkin.java From Enzo with Apache License 2.0 | 6 votes |
private void setBar() { double range = (getSkinnable().getMaxValue() - getSkinnable().getMinValue()); double angleRange = getSkinnable().getAngleRange(); angleStep = angleRange / range; double targetAngle = getSkinnable().getValue() * angleStep; if (getSkinnable().isAnimated()) { timeline.stop(); final KeyValue KEY_VALUE = new KeyValue(angle, targetAngle, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0)); final KeyFrame KEY_FRAME = new KeyFrame(Duration.millis(getSkinnable().getAnimationDuration()), KEY_VALUE); timeline.getKeyFrames().setAll(KEY_FRAME); timeline.play(); } else { angle.set(targetAngle); } }
Example #23
Source File: SpaceInvadersApp.java From FXGLGames with MIT License | 6 votes |
private void nextLevel() { getInput().setProcessInput(false); if (geti("level") > 0) { cleanupLevel(); } set("enemiesKilled", 0); inc("level", +1); if (geti("level") > levels.size()) { showGameOver(); return; } playInCutscene(() -> { spawn("LevelInfo"); runOnce(this::initLevel, Duration.seconds(LEVEL_START_DELAY)); play(Asset.SOUND_NEW_LEVEL); }); }
Example #24
Source File: BallComponent.java From FXGLGames with MIT License | 6 votes |
private void applyZombie() { byType(BreakoutType.BRICK).stream() .filter(brick -> brick.getPropertyOptional("markedByZombie").isEmpty()) .findAny() .ifPresent(brick -> { brick.setProperty("markedByZombie", true); var rect = new Rectangle(brick.getWidth(), brick.getHeight(), null); rect.setStroke(Color.YELLOW); brick.getViewComponent().addChild(rect); spawn("zombie", brick.getPosition().subtract(65, 65)); runOnce(() -> { if (brick.isActive()) brick.call("onHit"); }, Duration.seconds(1.0)); }); }
Example #25
Source File: FadeInLeftBigTransition.java From oim-fx with MIT License | 6 votes |
@Override protected void starting() { double startX = -node.localToScene(0, 0).getX() -node.getBoundsInParent().getWidth(); timeline = TimelineBuilder.create() .keyFrames( new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(node.translateXProperty(), startX, WEB_EASE) ), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(node.translateXProperty(), 0, WEB_EASE) ) ) .build(); super.starting(); }
Example #26
Source File: StrokeTransitionSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public StrokeTransitionSample() { super(150,150); Rectangle rect = new Rectangle(0, 0, 150, 150); rect.setArcHeight(20); rect.setArcWidth(20); rect.setFill(null); rect.setStroke(Color.DODGERBLUE); rect.setStrokeWidth(10); getChildren().add(rect); strokeTransition = StrokeTransitionBuilder.create() .duration(Duration.seconds(3)) .shape(rect) .fromValue(Color.RED) .toValue(Color.DODGERBLUE) .cycleCount(Timeline.INDEFINITE) .autoReverse(true) .build(); }
Example #27
Source File: Movimientos.java From uip-pc2 with MIT License | 6 votes |
public void atras(MouseEvent mouseEvent) { Stage stage = (Stage) atras.getScene().getWindow(); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Resumen.fxml")); Parent root = null; try { root = fxmlLoader.load(); } catch (Exception e) { Alert alerta = new Alert(Alert.AlertType.ERROR); alerta.setTitle("Error de AplicaciĆ³n"); alerta.setContentText("Llama al lapecillo de sistemas."); alerta.showAndWait(); Platform.exit(); } FadeTransition ft = new FadeTransition(Duration.millis(1500), root); ft.setFromValue(0.0); ft.setToValue(1.0); ft.play(); Resumen controller = fxmlLoader.<Resumen>getController(); controller.setCuenta(); controller.setSaldo(); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); }
Example #28
Source File: RotateTransitionSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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(); }
Example #29
Source File: InfoPopup.java From charts with Apache License 2.0 | 5 votes |
private void init() { setAutoFix(true); fadeIn = new FadeTransition(Duration.millis(200), hBox); fadeIn.setFromValue(0); fadeIn.setToValue(0.75); fadeOut = new FadeTransition(Duration.millis(200), hBox); fadeOut.setFromValue(0.75); fadeOut.setToValue(0.0); fadeOut.setOnFinished(e -> hide()); delay = new PauseTransition(Duration.millis(_timeout)); delay.setOnFinished(e -> animatedHide()); }
Example #30
Source File: AdvancedStockLineChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public AdvancedStockLineChartSample() { getChildren().add(createChart()); // create timeline to add new data every 60th of second animation = new Timeline(); animation.getKeyFrames().add(new KeyFrame(Duration.millis(1000/60), new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { // 6 minutes data per frame for(int count=0; count < 6; count++) { nextTime(); plotTime(); } } })); animation.setCycleCount(Animation.INDEFINITE); }