Java Code Examples for javafx.util.Duration#millis()

The following examples show how to use javafx.util.Duration#millis() . 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: Transferencia.java    From uip-pc2 with MIT License 6 votes vote down vote up
public void salir(MouseEvent mouseEvent) {
    Stage stage = (Stage) salir.getScene().getWindow();
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Login.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();
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
}
 
Example 2
Source File: HorizontalTransition.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
public HorizontalTransition(boolean leftDirection, Node contentContainer, Node overlay) {
    super(contentContainer, new Timeline(
        new KeyFrame(Duration.ZERO,
            new KeyValue(contentContainer.translateXProperty(),
                (contentContainer.getLayoutX() + contentContainer.getLayoutBounds().getMaxX())
                * (leftDirection? -1 : 1), Interpolator.LINEAR),
            new KeyValue(overlay.opacityProperty(), 0, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(1000),
            new KeyValue(overlay.opacityProperty(), 1, Interpolator.EASE_BOTH),
            new KeyValue(contentContainer.translateXProperty(), 0, Interpolator.EASE_OUT)
        )));
    // reduce the number to increase the shifting , increase number to reduce shifting
    setCycleDuration(Duration.seconds(0.4));
    setDelay(Duration.seconds(0));
}
 
Example 3
Source File: GameElimniationController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
protected void shake(int i1, int j1) {
    try {
        VBox vbox = chessBoard.get(i1 + "-" + j1);
        double x = vbox.getLayoutX();
        double y = vbox.getLayoutY();
        Path path = new Path();
        path.getElements().add(new LineTo(x - 20, y + 18));
        path.getElements().add(new LineTo(x + 20, y + 18));
        path.getElements().add(new LineTo(x - 20, y + 18));
        path.getElements().add(new LineTo(x + 20, y + 18));
        path.getElements().add(new LineTo(x, y));

        PathTransition pathTransition = new PathTransition(Duration.millis(200), path, vbox);
        pathTransition.setCycleCount(3);
        pathTransition.setAutoReverse(true);
        pathTransition.play();

    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
Example 4
Source File: MainController.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
public void readyToGoAnimation() {
    // Buttons slide in and clickable address appears simultaneously.
    TranslateTransition arrive = new TranslateTransition(Duration.millis(1200), controlsBox);
    arrive.setInterpolator(new ElasticInterpolator(EasingMode.EASE_OUT, 1, 2));
    arrive.setToY(0.0);
    FadeTransition reveal = new FadeTransition(Duration.millis(1200), addressControl);
    reveal.setToValue(1.0);
    ParallelTransition group = new ParallelTransition(arrive, reveal);
    group.setDelay(NotificationBarPane.ANIM_OUT_DURATION);
    group.setCycleCount(1);
    group.play();
}
 
Example 5
Source File: ClockPane.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
/** Construct a click with specified hour, minute, and second */
public ClockPane(int hour, int minute, int second) {
	this.hour = hour;
	this.minute = minute;
	this.second = second;
	paintClock();
	animation = new Timeline(
		new KeyFrame(Duration.millis(1000), e -> moveClock()));
	animation.setCycleCount(Timeline.INDEFINITE);
	animation.play();
}
 
Example 6
Source File: VolumeChart.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void dataItemAdded(XYChart.Series<Number, Number> series, int itemIndex, XYChart.Data<Number, Number> item) {
    Node volumeBar = createCandle(getData().indexOf(series), item, itemIndex);
    getPlotChildren().remove(volumeBar);

    if (shouldAnimate()) {
        volumeBar.setOpacity(0);
        getPlotChildren().add(volumeBar);
        FadeTransition ft = new FadeTransition(Duration.millis(500), volumeBar);
        ft.setToValue(1);
        ft.play();
    } else {
        getPlotChildren().add(volumeBar);
    }
}
 
Example 7
Source File: RadialMenu.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private Timeline createSimpleItemOpenTimeLine(final StackPane NODE, final double X, final double Y, final double DELAY) {
    KeyValue kvX1  = new KeyValue(NODE.translateXProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvY1  = new KeyValue(NODE.translateYProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvR1  = new KeyValue(NODE.rotateProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvO1  = new KeyValue(NODE.opacityProperty(), 0, Interpolator.EASE_OUT);

    KeyValue kvX2  = new KeyValue(NODE.translateXProperty(), 0.0);
    KeyValue kvY2  = new KeyValue(NODE.translateYProperty(), 0.0);

    KeyValue kvX3  = new KeyValue(NODE.translateXProperty(), 1.1 * X, Interpolator.EASE_IN);
    KeyValue kvY3  = new KeyValue(NODE.translateYProperty(), 1.1 * Y, Interpolator.EASE_IN);

    KeyValue kvX4  = new KeyValue(NODE.translateXProperty(), 0.97 * X, Interpolator.EASE_OUT);
    KeyValue kvY4  = new KeyValue(NODE.translateYProperty(), 0.97 * Y, Interpolator.EASE_OUT);
    KeyValue kvRO4 = new KeyValue(NODE.rotateProperty(), 360);
    KeyValue kvO4  = new KeyValue(NODE.opacityProperty(), 1.0, Interpolator.EASE_OUT);

    KeyValue kvX5  = new KeyValue(NODE.translateXProperty(), X);
    KeyValue kvY5  = new KeyValue(NODE.translateYProperty(), Y);

    KeyFrame kfO1  = new KeyFrame(Duration.millis(0), kvX1, kvY1, kvR1, kvO1);
    KeyFrame kfO2  = new KeyFrame(Duration.millis(50 + DELAY), kvX2, kvY2);
    KeyFrame kfO3  = new KeyFrame(Duration.millis(150 + DELAY), kvX3, kvY3);
    KeyFrame kfO4  = new KeyFrame(Duration.millis(300 + DELAY), kvX4, kvY4, kvRO4, kvO4);
    KeyFrame kfO5  = new KeyFrame(Duration.millis(400 + DELAY), kvX5, kvY5);

    return new Timeline(kfO1, kfO2, kfO3, kfO4, kfO5);
}
 
Example 8
Source File: Callout.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
protected void buildAnimation(Node head,
                            Line beginLeaderLine,
                            Line endLeaderLine,
                            HBox mainTitle,
                            Rectangle subTitleRect,
                            HBox subTitle) {

    // generate a sequence animation
    calloutAnimation = new SequentialTransition();

    // Allow animation to go in reverse
    calloutAnimation.setCycleCount(2);
    calloutAnimation.setAutoReverse(true);

    // Animation of head
    calloutAnimation.getChildren().add(buildHeadAnim(head));

    // Animation of the beginning leader line.
    calloutAnimation.getChildren().add(buildBeginLeaderLineAnim(beginLeaderLine));

    // Animation of the ending leader line.
    calloutAnimation.getChildren().add(buildEndLeaderLineAnim(endLeaderLine));

    // Animation of the main title
    calloutAnimation.getChildren().add(buildMainTitleAnim(mainTitle));

    // Animation of the subtitle rectangle
    calloutAnimation.getChildren().add(buildSubtitleRectAnim(mainTitle, subTitleRect));

    // Animation of the subtitle
    calloutAnimation.getChildren().add(buildSubTitleAnim(mainTitle, subTitle));

    Timeline pause = new Timeline(new KeyFrame(Duration.millis(getPauseTime()/2)));
    calloutAnimation.getChildren().add(pause);

}
 
Example 9
Source File: SystemClipboard.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public SystemClipboard() {
    clipboard = Clipboard.getSystemClipboard();
    Timeline monitorTask = new Timeline(new KeyFrame(Duration.millis(200), this));
    monitorTask.setCycleCount(Animation.INDEFINITE);
    monitorTask.play();
    prevData = null;
}
 
Example 10
Source File: MapPresenter.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void addPoint(MapPoint p, Node icon) {
    points.add(new Pair(p, icon));
    icon.setVisible(false);
    this.getChildren().add(icon);
    // required to layout first the node and be able to find its 
    // bounds
    PauseTransition pause = new PauseTransition(Duration.millis(100));
    pause.setOnFinished(f -> {
        markDirty();
        icon.setVisible(true);
    });
    pause.play();
}
 
Example 11
Source File: Exercise_20_05.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
public MultipleBallPane() {
	// Create an animation for moving the ball
	animation = new Timeline(
		new KeyFrame(Duration.millis(50), e -> moveBall()));
	animation.setCycleCount(Timeline.INDEFINITE);
	animation.play(); // Start animation
}
 
Example 12
Source File: DialogLoggerUtil.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * shows a message dialog just for a few given milliseconds
 *
 * @param parent
 * @param title
 * @param message
 * @param time
 */
public static void showMessageDialogForTime(String title, String message, long time) {
  Alert alert = new Alert(AlertType.INFORMATION, message);
  alert.setTitle(title);
  alert.show();
  Timeline idleTimer = new Timeline(new KeyFrame(Duration.millis(time), e -> alert.hide()));
  idleTimer.setCycleCount(1);
  idleTimer.play();
}
 
Example 13
Source File: DashboardController.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private void loadNode(Node node) {
	//System.out.println("loadNode()");
    insertPane.getChildren().clear();
    insertPane.getChildren().add((Node) node);

    FadeTransition ft = new FadeTransition(Duration.millis(1500));
    ft.setNode(node);
    ft.setFromValue(0.1);
    ft.setToValue(1);
    ft.setCycleCount(1);
    ft.setAutoReverse(false);
    ft.play();
}
 
Example 14
Source File: ScheduleListNode.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
public ScheduleListNode(Displayable displayable) {
    super(10);
    setAlignment(Pos.CENTER_LEFT);
    ImageView icon = displayable.getPreviewIcon();
    liveIcon = new ImageView(new Image("file:icons/recordingssettingsicon.png"));
    liveIcon.setFitHeight(10);
    liveIcon.setFitWidth(10);
    liveIcon.setVisible(false);
    getChildren().add(icon);
    getChildren().add(new Label(displayable.getPreviewText()));
    getChildren().add(liveIcon);

    if (displayable instanceof TextDisplayable || displayable instanceof TimerDisplayable) {
        themeButton = new Button("", new ImageView(new Image("file:icons/theme.png", 16, 16, false, true)));
        if (displayable instanceof TextDisplayable) {
            themeButton.setOnAction(new EditThemeScheduleActionHandler((TextDisplayable) displayable));
        } else {
            themeButton.setOnAction(new EditTimerThemeActionHandler((TimerDisplayable) displayable));
        }
        Utils.setToolbarButtonStyle(themeButton);
        Region spacer = new Region();
        HBox.setHgrow(spacer, Priority.ALWAYS);
        getChildren().add(spacer);
        getChildren().add(themeButton);
        themeButton.setOpacity(0);
        fade = new FadeTransition(Duration.millis(100), themeButton);
        setOnMouseEntered((event) -> {
            fade.stop();
            fade.setToValue(1);
            fade.play();
        });
        setOnMouseExited((event) -> {
            fade.stop();
            fade.setToValue(0);
            fade.play();
        });
    }
}
 
Example 15
Source File: HeatControlSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void fadeBack() {
    FadeTransition fadeInfoTextOut = new FadeTransition(Duration.millis(425), infoText);
    fadeInfoTextOut.setFromValue(1.0);
    fadeInfoTextOut.setToValue(0.0);
    
    FadeTransition fadeValueOut = new FadeTransition(Duration.millis(425), value);
    fadeValueOut.setFromValue(1.0);
    fadeValueOut.setToValue(0.0);

    PauseTransition pause = new PauseTransition(Duration.millis(50));

    FadeTransition fadeInfoTextIn = new FadeTransition(Duration.millis(425), infoText);
    fadeInfoTextIn.setFromValue(0.0);
    fadeInfoTextIn.setToValue(1.0);
    
    FadeTransition fadeValueIn = new FadeTransition(Duration.millis(425), value);
    fadeValueIn.setFromValue(0.0);
    fadeValueIn.setToValue(1.0);                
    
    ParallelTransition parallelIn = new ParallelTransition(fadeInfoTextIn, fadeValueIn);

    ParallelTransition parallelOut = new ParallelTransition(fadeInfoTextOut, fadeValueOut);
    parallelOut.setOnFinished(event -> {
        double currentValue = (valueIndicatorRotate.getAngle() + getSkinnable().getStartAngle() - 180) / angleStep + getSkinnable().getMinValue();
        value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", currentValue));
        value.setTranslateX((size - value.getLayoutBounds().getWidth()) * 0.5);
        if (getSkinnable().getTarget() < getSkinnable().getValue()) {
            getSkinnable().setInfoText("COOLING");
        } else if (getSkinnable().getTarget() > getSkinnable().getValue()) {
            getSkinnable().setInfoText("HEATING");
        }
        
        resizeText();
        drawTickMarks(ticks);
        userAction = false;
    });

    SequentialTransition sequence = new SequentialTransition(parallelOut, pause, parallelIn);
    sequence.play();
}
 
Example 16
Source File: JFXDrawer.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
public JFXDrawer() {
    this(Duration.millis(420));
}
 
Example 17
Source File: HamburgerBackArrowBasicTransition.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
private static Timeline createTimeline(JFXHamburger burger) {
    double burgerWidth = burger.getChildren().get(0).getLayoutBounds().getWidth();
    double burgerHeight = burger.getChildren().get(2).getBoundsInParent().getMaxY() - burger.getChildren()
        .get(0)
        .getBoundsInParent()
        .getMinY();

    double hypotenuse = Math.sqrt(Math.pow(burgerHeight / 2 - burger.getChildren()
                                                                  .get(0)
                                                                  .getLayoutBounds()
                                                                  .getHeight() / 2, 2) + Math.pow(burgerWidth / 2,
        2));
    double angle = Math.toDegrees(Math.asin((burgerHeight / 2 - burger.getChildren()
                                                                    .get(0)
                                                                    .getLayoutBounds()
                                                                    .getHeight() / 2) / hypotenuse));

    double burgerDiagonal = Math.sqrt(Math.pow(burger.getChildren().get(0).getLayoutBounds().getHeight(),
        2) + Math.pow(burger.getChildren()
                          .get(0)
                          .getBoundsInParent()
                          .getWidth() / 2, 2));
    double theta = (90 - angle) + Math.toDegrees(Math.atan((burger.getChildren()
                                                                .get(0)
                                                                .getLayoutBounds()
                                                                .getHeight()) / (burger.getChildren()
                                                                                     .get(0)
                                                                                     .getBoundsInParent()
                                                                                     .getWidth() / 2)));
    double hOffset = Math.cos(Math.toRadians(theta)) * burgerDiagonal / 2;
    double transY = burger.getChildren().get(0).getLayoutBounds().getHeight() / 2 + burger.getSpacing() - hOffset;
    double transX = burgerWidth / 2 - Math.sin(Math.toRadians(theta)) * (burgerDiagonal / 2);

    return new Timeline(
        new KeyFrame(
            Duration.ZERO,
            new KeyValue(burger.rotateProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(0).rotateProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(0).translateYProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(0).translateXProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(0).scaleXProperty(), 1, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(2).rotateProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(2).translateYProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(2).translateXProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(2).scaleXProperty(), 1, Interpolator.EASE_BOTH)

        ),
        new KeyFrame(Duration.millis(1000),
            new KeyValue(burger.rotateProperty(), 0, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(0).rotateProperty(), -angle, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(0).translateYProperty(), transY, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(0).translateXProperty(), -transX, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(0).scaleXProperty(), 0.5, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(2).rotateProperty(), angle, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(2).translateYProperty(), -transY, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(2).translateXProperty(), -transX, Interpolator.EASE_BOTH),
            new KeyValue(burger.getChildren().get(2).scaleXProperty(), 0.5, Interpolator.EASE_BOTH)
        )
    );
}
 
Example 18
Source File: DefaultConnectorSkin.java    From graph-editor with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates a new default connector skin instance.
 *
 * @param connector the {@link GConnector} the skin is being created for
 */
public DefaultConnectorSkin(final GConnector connector) {

    super(connector);

    performChecks();

    root.setManaged(false);
    root.resize(SIZE, SIZE);
    root.setPickOnBounds(false);

    polygon.setManaged(false);
    polygon.getStyleClass().addAll(STYLE_CLASS_BASE, connector.getType());

    drawTriangleConnector(connector.getType(), polygon);

    root.getChildren().add(polygon);

    animatedColorAllowed = new AnimatedColor(ALLOWED, Color.WHITE, Color.MEDIUMSEAGREEN, Duration.millis(500));
    animatedColorForbidden = new AnimatedColor(FORBIDDEN, Color.WHITE, Color.TOMATO, Duration.millis(500));
}
 
Example 19
Source File: App.java    From DeskChan with GNU Lesser General Public License v3.0 4 votes vote down vote up
DelayNotifier(String tag, long delay) {
	this.tag = tag;
	timeline = new Timeline(new KeyFrame(Duration.millis(delay), this));
	delayNotifiers.add(this);
	timeline.play();
}
 
Example 20
Source File: ValidationPane.java    From JFoenix with Apache License 2.0 2 votes vote down vote up
/**
 * creates error animation frames when moving from small -> large error container
 *
 * @return
 */
private KeyFrame createScaleToOneFrames() {
    return new KeyFrame(Duration.millis(100), new
        KeyValue(errorClipScale.yProperty(), 1, Interpolator.EASE_BOTH));
}