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 Project: OEE-Designer   Author: point85   File: FlipTileSkin.java    License: MIT License 7 votes vote down vote up
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 #2
Source Project: PDF4Teachers   Author: ClementGre   File: ZoomOperator.java    License: Apache License 2.0 7 votes vote down vote up
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 Project: AnimateFX   Author: Typhon0   File: JackInTheBox.java    License: Apache License 2.0 7 votes vote down vote up
@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 #4
Source Project: marathonv5   Author: jalian-systems   File: RotateTransitionSample.java    License: Apache License 2.0 6 votes vote down vote up
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 #5
Source Project: yfiton   Author: yfiton   File: Notifications.java    License: Apache License 2.0 6 votes vote down vote up
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 #6
Source Project: arcgis-runtime-samples-java   Author: Esri   File: FormatCoordinatesSample.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 #7
Source Project: constellation   Author: constellation-app   File: TimelineChart.java    License: Apache License 2.0 6 votes vote down vote up
@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 #8
Source Project: FXGLGames   Author: AlmasB   File: BossComponent.java    License: MIT License 6 votes vote down vote up
@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 #9
Source Project: JavaFX-Tutorial-Codes   Author: afsalashyana   File: Scene2Controller.java    License: Apache License 2.0 6 votes vote down vote up
@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 #10
Source Project: paintera   Author: saalfeldlab   File: Viewer3DFX.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 #11
Source Project: marathonv5   Author: jalian-systems   File: FillTransitionSample.java    License: Apache License 2.0 6 votes vote down vote up
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 #12
Source Project: phoebus   Author: ControlSystemStudio   File: DisplayEditorApplication.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@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 Project: uip-pc2   Author: abdelgmartinezl   File: Resumen.java    License: MIT License 6 votes vote down vote up
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 Project: AnimateFX   Author: Typhon0   File: ZoomOutRight.java    License: Apache License 2.0 6 votes vote down vote up
@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 #15
Source Project: yfiton   Author: yfiton   File: DesktopNotification.java    License: Apache License 2.0 6 votes vote down vote up
@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 #16
Source Project: FXTutorials   Author: AlmasB   File: Main.java    License: MIT License 6 votes vote down vote up
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 #17
Source Project: Hostel-Management-System   Author: pranavjindal999   File: MainProgramSceneController.java    License: MIT License 6 votes vote down vote up
@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 #18
Source Project: bisq   Author: bisq-network   File: VolumeChart.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
@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 #19
Source Project: FXTutorials   Author: AlmasB   File: MidiApp.java    License: MIT License 6 votes vote down vote up
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 #20
Source Project: FXGLGames   Author: AlmasB   File: Level13.java    License: MIT License 6 votes vote down vote up
@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 #21
Source Project: Enzo   Author: HanSolo   File: RadialBargraphSkin.java    License: Apache License 2.0 6 votes vote down vote up
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 #22
Source Project: FXGLGames   Author: AlmasB   File: SpaceInvadersApp.java    License: MIT License 6 votes vote down vote up
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 #23
Source Project: FXGLGames   Author: AlmasB   File: BallComponent.java    License: MIT License 6 votes vote down vote up
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 #24
Source Project: oim-fx   Author: oimchat   File: FadeInLeftBigTransition.java    License: MIT License 6 votes vote down vote up
@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 #25
Source Project: marathonv5   Author: jalian-systems   File: StrokeTransitionSample.java    License: Apache License 2.0 6 votes vote down vote up
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 #26
Source Project: uip-pc2   Author: abdelgmartinezl   File: Movimientos.java    License: MIT License 6 votes vote down vote up
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 #27
Source Project: FXGLGames   Author: AlmasB   File: SpaceInvadersFactory.java    License: MIT License 6 votes vote down vote up
@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 #28
Source Project: OEE-Designer   Author: point85   File: SmoothedChart.java    License: MIT License 5 votes vote down vote up
public void setTooltipTimeout(final double TIMEOUT) {
    if (null == tooltipTimeout) {
        _tooltipTimeout = Helper.clamp(0, 10000, TIMEOUT);
        timeBeforeFadeOut.setDuration(Duration.millis(_tooltipTimeout));
    } else {
        tooltipTimeout.set(TIMEOUT);
    }
}
 
Example #29
Source Project: RadialFx   Author: MrLoNee   File: RadialGlobalMenu.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private Transition createOpacityTransition(final Node node,
    final double from, final double to) {
final FadeTransition fadeIn = FadeTransitionBuilder.create().node(node)
	.fromValue(from).toValue(to).duration(Duration.millis(200))
	.build();
backContainer.setOpacity(from);
return fadeIn;

   }
 
Example #30
Source Project: metastone   Author: demilich1   File: DamageNumber.java    License: GNU General Public License v2.0 5 votes vote down vote up
public DamageNumber(String text, GameToken parent, int successiveHits) {
	this.parent = parent;
	this.setAlignment(Pos.CENTER);

	ImageView image = new ImageView(IconFactory.getImageUrl("common/splash.png"));
	image.setFitWidth(96);
	image.setFitHeight(96);
	
	if (successiveHits > 0) {
		double xOffset = -48 * successiveHits;
		setTranslateX(xOffset);
	}

	Text textShape = new Text(text);
	textShape.setFill(Color.WHITE);
	textShape.setStyle("-fx-font-size: 22pt; -fx-font-family: \"System\";-fx-font-weight: 900;-fx-stroke: black;-fx-stroke-width: 2;");

	setCache(true);
	setCacheHint(CacheHint.SPEED);

	getChildren().add(image);
	getChildren().add(textShape);
	parent.getAnchor().getChildren().add(this);

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);

	PauseTransition animation = new PauseTransition(Duration.seconds(1.2));
	animation.setOnFinished(this::onComplete);
	animation.play();
}