@Override public void run() { assert (!isExecuting()); setExecutionTimerPending(false); doExecuteCommands(Duration.currentTimeMillis()); } };
/** * Iterate over all animations and update them. */ private void updateAnimations() { // Copy the animation requests to avoid concurrent modifications. AnimationHandleImpl[] curAnimations = new AnimationHandleImpl[animationRequests.size()]; curAnimations = animationRequests.toArray(curAnimations); // Iterate over the animation requests. Duration duration = new Duration(); for (AnimationHandleImpl requestId : curAnimations) { // Remove the current request. animationRequests.remove(requestId); // Execute the callback. requestId.getCallback().execute(duration.getStartMillis()); } // Reschedule the timer if there are more animation requests. if (animationRequests.size() > 0) { /* * In order to achieve as close to 60fps as possible, we calculate the new * delay based on the execution time of this method. The delay will be * less than 16ms, assuming this method takes more than 1ms to complete. */ timer.schedule(Math.max(MIN_FRAME_DELAY, DEFAULT_FRAME_DELAY - duration.elapsedMillis())); } } }
/** * Returns the number of milliseconds that have elapsed since this object was * created. */ public int elapsedMillis() { return uncheckedConversion(currentTimeMillis() - start); }
/** Returns the time (mm:ss) that have elapsed since this timer was created. */ private String getElapsedTime() { final int elapsedSec = duration.elapsedMillis() / 1000; final int minutesPart = elapsedSec / 60; final int secondsPart = elapsedSec - minutesPart * 60; return (minutesPart < 10 ? "0" + minutesPart : minutesPart) + ":" + (secondsPart < 10 ? "0" + secondsPart : secondsPart); }
/** * there for testing */ Duration createDuration() { return new Duration(); }
private boolean delayConditionMet() { if (mouseUpDuration == null) { return false; } return options.getDelay() <= mouseUpDuration.elapsedMillis(); }
/** * there for testing */ Duration createDuration() { return new Duration(); }
@Override public boolean execute() { double currentTime = Duration.currentTimeMillis(); Iterator<TemporalPoint> iter = touchPositionsDuringMomentum.iterator(); while (iter.hasNext()) { TemporalPoint point = iter.next(); if (currentTime - point.getTime() >= TIME_THRESHOLD) { iter.remove(); } } return !touchPositionsDuringMomentum.isEmpty(); } }
/** * Returns the number of milliseconds that have elapsed since this object was * created. */ public int elapsedMillis() { return uncheckedConversion(currentTimeMillis() - start); }
/** * Iterate over all animations and update them. */ private void updateAnimations() { // Copy the animation requests to avoid concurrent modifications. AnimationHandleImpl[] curAnimations = new AnimationHandleImpl[animationRequests.size()]; curAnimations = animationRequests.toArray(curAnimations); // Iterate over the animation requests. Duration duration = new Duration(); for (AnimationHandleImpl requestId : curAnimations) { // Remove the current request. animationRequests.remove(requestId); // Execute the callback. requestId.getCallback().execute(duration.getStartMillis()); } // Reschedule the timer if there are more animation requests. if (animationRequests.size() > 0) { /* * In order to achieve as close to 60fps as possible, we calculate the new * delay based on the execution time of this method. The delay will be * less than 16ms, assuming this method takes more than 1ms to complete. */ timer.schedule(Math.max(MIN_FRAME_DELAY, DEFAULT_FRAME_DELAY - duration.elapsedMillis())); } } }
while (duration.elapsedMillis() < TIME_SLICE) { boolean executedSomeTask = false; for (int i = 0; i < length; i++) {
/** * there for testing */ Duration createDuration() { return new Duration(); }
/** * Immediately run this animation. If the animation is already running, it * will be canceled first. * <p> * If the element is not <code>null</code>, the {@link #onUpdate(double)} * method might be called only if the element may be visible (generally left * at the appreciation of the browser). Otherwise, it will be called * unconditionally. * * @param duration the duration of the animation in milliseconds * @param element the element that visually bounds the entire animation */ public void run(int duration, Element element) { run(duration, Duration.currentTimeMillis(), element); }
/** * Returns the number of milliseconds that have elapsed since this object was * created. */ public int elapsedMillis() { return uncheckedConversion(currentTimeMillis() - start); }
/** * Iterate over all animations and update them. */ private void updateAnimations() { // Copy the animation requests to avoid concurrent modifications. AnimationHandleImpl[] curAnimations = new AnimationHandleImpl[animationRequests.size()]; curAnimations = animationRequests.toArray(curAnimations); // Iterate over the animation requests. Duration duration = new Duration(); for (AnimationHandleImpl requestId : curAnimations) { // Remove the current request. animationRequests.remove(requestId); // Execute the callback. requestId.getCallback().execute(duration.getStartMillis()); } // Reschedule the timer if there are more animation requests. if (animationRequests.size() > 0) { /* * In order to achieve as close to 60fps as possible, we calculate the new * delay based on the execution time of this method. The delay will be * less than 16ms, assuming this method takes more than 1ms to complete. */ timer.schedule(Math.max(MIN_FRAME_DELAY, DEFAULT_FRAME_DELAY - duration.elapsedMillis())); } } }
int cumulativeElapsedMillis = duration.elapsedMillis(); state.setElapsedMillis(cumulativeElapsedMillis - lastElapsedMillis); lastElapsedMillis = cumulativeElapsedMillis;
/** * there for testing */ Duration createDuration() { return new Duration(); }
@Override public void onBrowserEvent(Event event) { // Align the scrollbars with the content. if (Event.ONSCROLL == event.getTypeInt()) { double curTime = Duration.currentTimeMillis(); if (curTime > ignoreContentUntil) { ignoreScrollbarsUntil = curTime + IGNORE_SCROLL_TIMEOUT; maybeUpdateScrollbarPositions(); } } super.onBrowserEvent(event); }
/** * Returns the number of milliseconds that have elapsed since this object was * created. */ public int elapsedMillis() { return uncheckedConversion(currentTimeMillis() - start); }
void add(String name) { events.put(name, duration.elapsedMillis()); }