Search in sources :

Example 16 with PauseTransition

use of javafx.animation.PauseTransition in project JFoenix by jfoenixadmin.

the class JFXNodeUtils method addPressAndHoldHandler.

public static void addPressAndHoldHandler(Node node, Duration holdTime, EventHandler<MouseEvent> handler) {
    Wrapper<MouseEvent> eventWrapper = new Wrapper<>();
    PauseTransition holdTimer = new PauseTransition(holdTime);
    holdTimer.setOnFinished(event -> handler.handle(eventWrapper.content));
    node.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> {
        eventWrapper.content = event;
        holdTimer.playFromStart();
    });
    node.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> holdTimer.stop());
    node.addEventHandler(MouseEvent.DRAG_DETECTED, event -> holdTimer.stop());
}
Also used : MouseEvent(javafx.scene.input.MouseEvent) PauseTransition(javafx.animation.PauseTransition)

Example 17 with PauseTransition

use of javafx.animation.PauseTransition in project Malai by arnobl.

the class DnDHelpAnimation method createTransition.

@Override
public Transition createTransition() {
    ell = new Ellipse(x1, y1, size, size);
    text = new Text(textPress);
    text.xProperty().bind(ell.centerXProperty().add(ell.getRadiusX()));
    text.yProperty().bind(ell.centerYProperty().subtract(ell.getRadiusY()));
    ell.setFill(Color.LIGHTGRAY);
    ell.setEffect(new DropShadow(20d, Color.BLACK));
    helpPane.getChildren().add(ell);
    helpPane.getChildren().add(text);
    ell.setVisible(false);
    text.setVisible(false);
    ell.setFocusTraversable(false);
    ell.setMouseTransparent(true);
    text.setFocusTraversable(false);
    text.setMouseTransparent(true);
    final SequentialTransition mainTrans = new SequentialTransition();
    final ParallelTransition parallelTransition = new ParallelTransition(new Timeline(new KeyFrame(duration, new KeyValue(ell.centerXProperty(), x2))), new Timeline(new KeyFrame(duration, new KeyValue(ell.centerYProperty(), y2))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(text.visibleProperty(), Boolean.TRUE))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(ell.visibleProperty(), Boolean.TRUE))));
    mainTrans.getChildren().add(new PauseTransition(Duration.seconds(1.5)));
    mainTrans.getChildren().add(new ParallelTransition(new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusXProperty(), size / 2d))), new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusYProperty(), size / 2d)))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(100d), new KeyValue(text.textProperty(), textDrag))));
    mainTrans.getChildren().add(parallelTransition);
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(100d), new KeyValue(text.textProperty(), textRelease))));
    mainTrans.getChildren().add(new ParallelTransition(new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusXProperty(), size))), new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusYProperty(), size)))));
    mainTrans.getChildren().add(new PauseTransition(Duration.seconds(1.5)));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(text.visibleProperty(), Boolean.FALSE))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(ell.visibleProperty(), Boolean.FALSE))));
    transition = mainTrans;
    return transition;
}
Also used : Ellipse(javafx.scene.shape.Ellipse) Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) SequentialTransition(javafx.animation.SequentialTransition) KeyFrame(javafx.animation.KeyFrame) Text(javafx.scene.text.Text) PauseTransition(javafx.animation.PauseTransition) DropShadow(javafx.scene.effect.DropShadow) ParallelTransition(javafx.animation.ParallelTransition)

Aggregations

PauseTransition (javafx.animation.PauseTransition)17 MouseEvent (javafx.scene.input.MouseEvent)7 SequentialTransition (javafx.animation.SequentialTransition)6 EventHandler (javafx.event.EventHandler)6 Duration (javafx.util.Duration)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 FadeTransition (javafx.animation.FadeTransition)5 ActionEvent (javafx.event.ActionEvent)5 Node (javafx.scene.Node)5 Color (javafx.scene.paint.Color)5 Locale (java.util.Locale)4 ParallelTransition (javafx.animation.ParallelTransition)4 Event (javafx.event.Event)4 EventType (javafx.event.EventType)4 Background (javafx.scene.layout.Background)4 BackgroundFill (javafx.scene.layout.BackgroundFill)4 Region (javafx.scene.layout.Region)4 Paint (javafx.scene.paint.Paint)4 UnmodifiableListSet (com.sun.javafx.collections.UnmodifiableListSet)3