/** * 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 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); }
private boolean delayConditionMet() { if (mouseUpDuration == null) { return false; } return options.getDelay() <= mouseUpDuration.elapsedMillis(); }
while (duration.elapsedMillis() < TIME_SLICE) { boolean executedSomeTask = false; for (int i = 0; i < length; i++) {
int cumulativeElapsedMillis = duration.elapsedMillis(); state.setElapsedMillis(cumulativeElapsedMillis - lastElapsedMillis); lastElapsedMillis = cumulativeElapsedMillis;
void add(String name) { events.put(name, duration.elapsedMillis()); }
/** * 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())); } } }
/** * 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++) {
while (duration.elapsedMillis() < TIME_SLICE) { boolean executedSomeTask = false; for (int i = 0; i < length; i++) {
while (duration.elapsedMillis() < TIME_SLICE) { boolean executedSomeTask = false; for (int i = 0; i < length; i++) {
int cumulativeElapsedMillis = duration.elapsedMillis(); state.setElapsedMillis(cumulativeElapsedMillis - lastElapsedMillis); lastElapsedMillis = cumulativeElapsedMillis;
int cumulativeElapsedMillis = duration.elapsedMillis(); state.setElapsedMillis(cumulativeElapsedMillis - lastElapsedMillis); lastElapsedMillis = cumulativeElapsedMillis;