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());
}
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;
}
Aggregations