/** * Starts the animator. */ public void start() { if (_listenerList != null) { AnimatorListener[] listeners = getAnimatorListeners(); for (AnimatorListener listener : listeners) { listener.animationStarts(_source); } } startTimer(); _currentStep = 0; }
/** * Interrupts the animator. The counter is not reset in this case. */ public void interrupt() { stopTimer(); }
public void actionPerformed(ActionEvent e) { if (_source != null) { if (_listenerList != null) { AnimatorListener[] listeners = getAnimatorListeners(); for (AnimatorListener listener : listeners) { listener.animationFrame(_source, _totalSteps, _currentStep); } } _currentStep++; if (_totalSteps != -1 && _currentStep > _totalSteps) { stop(); if (_listenerList != null) { AnimatorListener[] listeners = getAnimatorListeners(); for (AnimatorListener listener : listeners) { listener.animationEnds(_source); } } } } }
_animator.addAnimatorListener(new AnimatorListener() { public void animationStarts(Component component) {
public void dispose() { stop(); _timer.removeActionListener(this); _timer = null; } }
/** * Starts flashing. */ public void startFlashing() { clearFlashing(); getAnimator().start(); }
/** * Checks if it is flashing. * * @return true if flashing. */ public boolean isFlashing() { return getAnimator().isRunning(); }
/** * Sets the interval, in ms. If the flashing is running, the new interval will take effect immediately. By default, * it is 300 ms. * * @param interval the new interval. */ public void setInterval(int interval) { int old = _interval; if (old != interval) { _interval = interval; getAnimator().setDelay(interval); } }
/** * Creates an animator for source. * * @param source the source for this animator. * @param initDelay the initial delay before timer starts. * @param delay the delay of the timer * @param totalSteps the number of steps. If -1, it means this animator will never stop until {@link #stop()} is * called. */ public Animator(Component source, int initDelay, int delay, int totalSteps) { _source = source; _totalSteps = totalSteps; _timer = createTimer(delay, this); _timer.setInitialDelay(initDelay); }
/** * Uninstalls the <code>Flashable</code> from the component. Once uninstalled, you have to create a new Flashable in * order to use thflashingng feature again. If you just want to stop flashing, you should use {@link * #stopFlashing()}. */ public void uninstall() { stopFlashing(); _animator.dispose(); _animator = null; getComponent().putClientProperty(CLIENT_PROPERTY_FLASHABLE, null); }
/** * Stops flashing. */ public void stopFlashing() { clearFlashing(); getAnimator().stop(); }
/** * Stop the animator and reset the counter. */ public void stop() { stopTimer(); _currentStep = 0; }