Java Code Examples for javafx.animation.Timeline#stop()
The following examples show how to use
javafx.animation.Timeline#stop() .
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: ColorAnimationUtils.java From graph-editor with Eclipse Public License 1.0 | 5 votes |
/** * Removes an animated color from this node, if one has been set on it. */ public static void removeAnimation(final Node node) { // Stopping the timeline should allow object properties that depend on it to be garbage collected. if (node.getProperties().get(TIMELINE_KEY) instanceof Timeline) { final Timeline timeline = (Timeline) node.getProperties().get(TIMELINE_KEY); timeline.stop(); } }
Example 2
Source File: Clock.java From Medusa with Apache License 2.0 | 4 votes |
private void init(final ZonedDateTime TIME) { time = new ObjectPropertyBase<ZonedDateTime>(TIME) { @Override protected void invalidated() { if (!isRunning() && isAnimated()) { long animationDuration = getAnimationDuration(); timeline.stop(); final KeyValue KEY_VALUE = new KeyValue(currentTime, TIME.toEpochSecond()); final KeyFrame KEY_FRAME = new KeyFrame(javafx.util.Duration.millis(animationDuration), KEY_VALUE); timeline.getKeyFrames().setAll(KEY_FRAME); timeline.setOnFinished(e -> fireUpdateEvent(FINISHED_EVENT)); timeline.play(); } else { currentTime.set(TIME.toEpochSecond()); fireUpdateEvent(FINISHED_EVENT); } } @Override public Object getBean() { return Clock.this; } @Override public String getName() { return "time"; } }; currentTime = new LongPropertyBase(time.get().toEpochSecond()) { @Override protected void invalidated() {} @Override public Object getBean() { return Clock.this; } @Override public String getName() { return "currentTime"; } }; zoneId = time.get().getZone(); timeline = new Timeline(); timeline.setOnFinished(e -> fireUpdateEvent(FINISHED_EVENT)); updateInterval = LONG_INTERVAL; _checkSectionsForValue = false; _checkAreasForValue = false; sections = FXCollections.observableArrayList(); _secondsVisible = false; _highlightSections = false; areas = FXCollections.observableArrayList(); _areasVisible = false; _highlightAreas = false; _text = ""; _discreteSeconds = true; _discreteMinutes = true; _discreteHours = false; _secondsVisible = false; _titleVisible = false; _textVisible = false; _dateVisible = false; _dayVisible = false; _nightMode = false; _running = false; _autoNightMode = false; _backgroundPaint = Color.TRANSPARENT; _borderPaint = Color.TRANSPARENT; _borderWidth = 1; _foregroundPaint = Color.TRANSPARENT; _titleColor = DARK_COLOR; _textColor = DARK_COLOR; _dateColor = DARK_COLOR; _hourTickMarkColor = DARK_COLOR; _minuteTickMarkColor = DARK_COLOR; _tickLabelColor = DARK_COLOR; _alarmColor = DARK_COLOR; _hourTickMarksVisible = true; _minuteTickMarksVisible = true; _tickLabelsVisible = true; _hourColor = DARK_COLOR; _minuteColor = DARK_COLOR; _secondColor = DARK_COLOR; _knobColor = DARK_COLOR; _lcdDesign = LcdDesign.STANDARD; _alarmsEnabled = false; _alarmsVisible = false; alarms = FXCollections.observableArrayList(); alarmsToRemove = new ArrayList<>(); _lcdCrystalEnabled = false; _shadowsEnabled = false; _lcdFont = LcdFont.DIGITAL_BOLD; _locale = Locale.US; _tickLabelLocation = TickLabelLocation.INSIDE; _animated = false; animationDuration = 10000; _customFontEnabled = false; _customFont = Fonts.robotoRegular(12); }
Example 3
Source File: JFXScrollPane.java From JFoenix with Apache License 2.0 | 4 votes |
private static void customScrolling(ScrollPane scrollPane, DoubleProperty scrollDriection, Function<Bounds, Double> sizeFunc) { final double[] frictions = {0.99, 0.1, 0.05, 0.04, 0.03, 0.02, 0.01, 0.04, 0.01, 0.008, 0.008, 0.008, 0.008, 0.0006, 0.0005, 0.00003, 0.00001}; final double[] pushes = {1}; final double[] derivatives = new double[frictions.length]; Timeline timeline = new Timeline(); final EventHandler<MouseEvent> dragHandler = event -> timeline.stop(); final EventHandler<ScrollEvent> scrollHandler = event -> { if (event.getEventType() == ScrollEvent.SCROLL) { int direction = event.getDeltaY() > 0 ? -1 : 1; for (int i = 0; i < pushes.length; i++) { derivatives[i] += direction * pushes[i]; } if (timeline.getStatus() == Animation.Status.STOPPED) { timeline.play(); } event.consume(); } }; if (scrollPane.getContent().getParent() != null) { scrollPane.getContent().getParent().addEventHandler(MouseEvent.DRAG_DETECTED, dragHandler); scrollPane.getContent().getParent().addEventHandler(ScrollEvent.ANY, scrollHandler); } scrollPane.getContent().parentProperty().addListener((o,oldVal, newVal)->{ if (oldVal != null) { oldVal.removeEventHandler(MouseEvent.DRAG_DETECTED, dragHandler); oldVal.removeEventHandler(ScrollEvent.ANY, scrollHandler); } if (newVal != null) { newVal.addEventHandler(MouseEvent.DRAG_DETECTED, dragHandler); newVal.addEventHandler(ScrollEvent.ANY, scrollHandler); } }); timeline.getKeyFrames().add(new KeyFrame(Duration.millis(3), (event) -> { for (int i = 0; i < derivatives.length; i++) { derivatives[i] *= frictions[i]; } for (int i = 1; i < derivatives.length; i++) { derivatives[i] += derivatives[i - 1]; } double dy = derivatives[derivatives.length - 1]; double size = sizeFunc.apply(scrollPane.getContent().getLayoutBounds()); scrollDriection.set(Math.min(Math.max(scrollDriection.get() + dy / size, 0), 1)); if (Math.abs(dy) < 0.001) { timeline.stop(); } })); timeline.setCycleCount(Animation.INDEFINITE); }
Example 4
Source File: AutoScrollHandler.java From phoebus with Eclipse Public License 1.0 | 3 votes |
/** * Stop and clear the {@link Timeline} object. */ public void canceTimeline() { Timeline timeline = autoScrollTimeline.getAndSet(null); if ( timeline != null ) { timeline.stop(); } }