Package org.jdesktop.animation.timing

# Class TimingSource

java.lang.Object
org.jdesktop.animation.timing.TimingSource

public abstract class TimingSource extends Object
This class provides a generic wrapper for arbitrary Timers that may be used with the Timing Framework. Animator creates its own internal TimingSource by default, but an Animator can be directed to use a different TimingSource by calling `Animator.setTimer(TimingSource)`. The implementation details of any specific timer may vary widely, but any timer should be able to expose the basic capabilities used in this interface. Animator depends on these capabilities for starting, stopping, and running any TimingSource. The usage of an external TimingSource object for sending in timing events to an Animator is to implement this interface appropriately, pass in that object to `Animator.setTimer(TimingSource)`, which adds the Animator as a listener to the TimingSource object, and then send in any later timing events from the object to the protected method `timingEvent()`, which will send these timing events to all listeners.

## Constructor Summary

Constructors
Constructor
Description
`TimingSource()`

## Method Summary

Modifier and Type
Method
Description
`final void`
`addEventListener(TimingEventListener listener)`
Adds a TimingEventListener to the set of listeners that receive timing events from this TimingSource.
`final void`
`removeEventListener(TimingEventListener listener)`
Removes a TimingEventListener from the set of listeners that receive timing events from this TimingSource.
`abstract void`
`setResolution(int resolution)`
Sets the delay between callback events.
`abstract void`
`setStartDelay(int delay)`
Sets delay which should be observed by the TimingSource after a call to `start()`.
`abstract void`
`start()`
Starts the TimingSource
`abstract void`
`stop()`
Stops the TimingSource
`protected final void`
`timingEvent()`
Subclasses call this method to post timing events to this object's `TimingEventListener` objects.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### TimingSource

public TimingSource()

## Method Details

### start

public abstract void start()
Starts the TimingSource

### stop

public abstract void stop()
Stops the TimingSource

### setResolution

public abstract void setResolution(int resolution)
Sets the delay between callback events. This will be called by Animator if its `setResolution(int)` method is called. Note that the actual resolution may vary, according to the resolution of the timer used by the framework as well as system load and configuration; this value should be seen more as a minimum resolution than a guaranteed resolution.

Parameters:
  `resolution` - delay, in milliseconds, between each timing event callback.
Throws:
  `IllegalArgumentException` - resolution must be >= 0
See Also:
  - `Animator.setResolution(int)`

### setStartDelay

public abstract void setStartDelay(int delay)
Sets delay which should be observed by the TimingSource after a call to `start()`. Some timers may not be able to adhere to specific resolution requests

Parameters:
  `delay` - delay, in milliseconds, to pause before starting timing events.
Throws:
  `IllegalArgumentException` - resolution must be >= 0
See Also:
  - `Animator.setStartDelay(int)`

### addEventListener

public final void addEventListener(TimingEventListener listener)
Adds a TimingEventListener to the set of listeners that receive timing events from this TimingSource.

Parameters:
  `listener` - the listener to be added.

### removeEventListener

public final void removeEventListener(TimingEventListener listener)
Removes a TimingEventListener from the set of listeners that receive timing events from this TimingSource.

Parameters:
  `listener` - the listener to be removed.

### timingEvent

protected final void timingEvent()
Subclasses call this method to post timing events to this object's `TimingEventListener` objects.