use of javafx.animation.PauseTransition in project tilesfx by HanSolo.
the class SmoothedChart method init.
// ******************** Initialization ************************************
private void init() {
_smoothed = true;
_chartType = ChartType.LINE;
_subDivisions = 16;
_snapToTicks = false;
_selectorFillColor = Color.WHITE;
_selectorStrokeColor = Color.RED;
_selectorSize = 10;
_decimals = 2;
_interactive = true;
_tooltipTimeout = 2000;
formatString = "%.2f";
strokePaths = new ArrayList<>();
clickHandler = e -> select(e);
endOfTransformationHandler = e -> selectorTooltip.hide();
seriesListener = change -> {
while (change.next()) {
if (change.wasAdded()) {
change.getAddedSubList().forEach(addedItem -> {
final Series<X, Y> series = addedItem;
final Path strokePath = (Path) ((Group) series.getNode()).getChildren().get(1);
final Path fillPath = (Path) ((Group) series.getNode()).getChildren().get(0);
fillPath.addEventHandler(MouseEvent.MOUSE_PRESSED, clickHandler);
strokePath.addEventHandler(MouseEvent.MOUSE_PRESSED, clickHandler);
strokePaths.add(strokePath);
series.getData().forEach(data -> data.YValueProperty().addListener(o -> layoutPlotChildren()));
});
} else if (change.wasRemoved()) {
change.getRemoved().forEach(removedItem -> {
final Series<X, Y> series = removedItem;
final Path strokePath = (Path) ((Group) series.getNode()).getChildren().get(1);
final Path fillPath = (Path) ((Group) series.getNode()).getChildren().get(0);
fillPath.removeEventHandler(MouseEvent.MOUSE_PRESSED, clickHandler);
strokePath.removeEventHandler(MouseEvent.MOUSE_PRESSED, clickHandler);
strokePaths.remove(strokePath);
});
}
}
};
// Add selector to chart
selector = new Circle();
selector.setFill(_selectorFillColor);
selector.setStroke(_selectorStrokeColor);
selector.setOpacity(0);
selectorTooltip = new Tooltip("");
Tooltip.install(selector, selectorTooltip);
FadeTransition fadeIn = new FadeTransition(Duration.millis(100), selector);
fadeIn.setFromValue(0);
fadeIn.setToValue(1);
timeBeforeFadeOut = new PauseTransition(Duration.millis(_tooltipTimeout));
FadeTransition fadeOut = new FadeTransition(Duration.millis(100), selector);
fadeOut.setFromValue(1);
fadeOut.setToValue(0);
fadeInFadeOut = new SequentialTransition(fadeIn, timeBeforeFadeOut, fadeOut);
fadeInFadeOut.setOnFinished(endOfTransformationHandler);
chartPlotBackground = getChartPlotBackground();
chartPlotBackground.widthProperty().addListener(o -> resizeSelector());
chartPlotBackground.heightProperty().addListener(o -> resizeSelector());
chartPlotBackground.layoutYProperty().addListener(o -> resizeSelector());
Path horizontalGridLines = getHorizontalGridLines();
if (null != horizontalGridLines) {
horizontalGridLines.setMouseTransparent(true);
}
Path verticalGridLines = getVerticalGridLines();
if (null != verticalGridLines) {
verticalGridLines.setMouseTransparent(true);
}
getChartChildren().addAll(selector);
}
use of javafx.animation.PauseTransition in project JFoenix by jfoenixadmin.
the class JFXSnackbar method close.
public void close() {
if (openAnimation != null) {
openAnimation.stop();
}
if (this.isVisible()) {
if (pauseTransition != null) {
pauseTransition.stop();
pauseTransition = null;
}
Timeline closeAnimation = new Timeline(new KeyFrame(Duration.ZERO, e -> this.toFront(), new KeyValue(this.opacityProperty(), 1, easeInterpolator), new KeyValue(this.translateYProperty(), 0, easeInterpolator)), new KeyFrame(Duration.millis(290), new KeyValue(this.visibleProperty(), true, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(300), e -> this.toBack(), new KeyValue(this.visibleProperty(), false, Interpolator.EASE_BOTH), new KeyValue(this.translateYProperty(), this.getLayoutBounds().getHeight(), easeInterpolator), new KeyValue(this.opacityProperty(), 0, easeInterpolator)));
closeAnimation.setCycleCount(1);
closeAnimation.setOnFinished(e -> {
resetPseudoClass();
processSnackbar();
});
closeAnimation.play();
}
}
use of javafx.animation.PauseTransition in project JFoenix by jfoenixadmin.
the class JFXNodeUtils method addDelayedPropertyInvalidationListener.
public static <T> InvalidationListener addDelayedPropertyInvalidationListener(ObservableValue<T> property, Duration delayTime, Consumer<T> justInTimeConsumer, Consumer<T> delayedConsumer) {
Wrapper<T> eventWrapper = new Wrapper<>();
PauseTransition holdTimer = new PauseTransition(delayTime);
holdTimer.setOnFinished(event -> delayedConsumer.accept(eventWrapper.content));
final InvalidationListener invalidationListener = observable -> {
eventWrapper.content = property.getValue();
justInTimeConsumer.accept(eventWrapper.content);
holdTimer.playFromStart();
};
property.addListener(invalidationListener);
return invalidationListener;
}
use of javafx.animation.PauseTransition in project JFoenix by jfoenixadmin.
the class JFXNodeUtils method addPressAndHoldFilter.
public static void addPressAndHoldFilter(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.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> {
eventWrapper.content = event;
holdTimer.playFromStart();
});
node.addEventFilter(MouseEvent.MOUSE_RELEASED, event -> holdTimer.stop());
node.addEventFilter(MouseEvent.DRAG_DETECTED, event -> holdTimer.stop());
}
use of javafx.animation.PauseTransition in project JFoenix by jfoenixadmin.
the class JFXNodeUtils method addDelayedPropertyInvalidationListener.
public static <T> InvalidationListener addDelayedPropertyInvalidationListener(ObservableValue<T> property, Duration delayTime, BiConsumer<T, InvalidationListener> consumer) {
Wrapper<T> eventWrapper = new Wrapper<>();
PauseTransition holdTimer = new PauseTransition(delayTime);
final InvalidationListener invalidationListener = observable -> {
eventWrapper.content = property.getValue();
holdTimer.playFromStart();
};
holdTimer.setOnFinished(event -> consumer.accept(eventWrapper.content, invalidationListener));
property.addListener(invalidationListener);
return invalidationListener;
}
Aggregations