Class Timeline
- java.lang.Object
-
- org.pushingpixels.radiance.animation.api.Timeline
-
- All Implemented Interfaces:
TimelineScenario.TimelineScenarioActor
- Direct Known Subclasses:
SwingComponentTimeline
,SwingRepaintTimeline
public class Timeline extends java.lang.Object implements TimelineScenario.TimelineScenarioActor
The main entry point into Animation. Usebuilder()
orbuilder(Object)
and methods on theTimeline.BaseBuilder
to configure one or more properties to be interpolated over a period of time. In the simplest case, a timeline operates on a single object passed tobuilder(Object)
, and one or more properties that have matching public setters. In that case, use theTimeline.BaseBuilder.addPropertyToInterpolate(String, Object, Object)
API to configure which properties should be interpolated.In a more complex case, use
Timeline.BaseBuilder.addPropertyToInterpolate(TimelinePropertyBuilder)
together withproperty(String)
andTimelinePropertyBuilder.on(Object)
to interpolate properties of multiple objects.TimelinePropertyBuilder.setWith(TimelinePropertyBuilder.PropertySetter)
,TimelinePropertyBuilder.getWith(TimelinePropertyBuilder.PropertyGetter)
andTimelinePropertyBuilder.accessWith(TimelinePropertyBuilder.PropertyAccessor)
can be used to work with properties that are not exposed via public setters or getters.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Timeline.BaseBuilder<T extends Timeline,B extends Timeline.BaseBuilder<?,?,?>,M>
static class
Timeline.Builder
(package private) class
Timeline.Chain
static class
Timeline.RepeatBehavior
private class
Timeline.Setter
static class
Timeline.TimelineState
private class
Timeline.UISetter
-
Field Summary
Fields Modifier and Type Field Description (package private) Timeline.Chain
callbackChain
private static long
counter
Is used to create unique value for theid
field.private long
cycleDelay
static long
DEFAULT_DURATION
static TimelineEase
DEFAULT_EASE
private int
doneCount
private long
duration
(package private) float
durationFraction
Timeline position.private TimelineEase
ease
(package private) TimelineEngine.FullObjectID
fullObjectID
(package private) long
id
Unique ID.private long
initialDelay
(package private) boolean
isLooping
private java.lang.Object
mainObject
private boolean
mainObjectIsUiComponent
private java.lang.String
name
private java.util.List<TimelinePropertyBuilder.AbstractFieldInfo<?>>
propertiesToInterpolate
private Timeline.RepeatBehavior
repeatBehavior
(package private) int
repeatCount
private java.lang.Comparable<?>
secondaryId
private java.util.Stack<Timeline.TimelineState>
stateStack
(package private) float
timelinePosition
Timeline position.(package private) long
timeUntilPlay
(package private) boolean
toCancelAtCycleBreak
Indication whether the looping timeline should stop at reaching the end of the cycle.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Timeline(java.lang.Object mainTimelineObject)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
Aborts this timeline.protected void
addCallback(TimelineCallback callback)
static Timeline.Builder
builder()
static Timeline.Builder
builder(java.lang.Object mainTimelineObject)
void
cancel()
Cancels this timeline.void
cancelAtCycleBreak()
Requests that the specified timeline should stop at the end of the cycle.void
end()
Ends this timeline.long
getCycleDelay()
long
getDuration()
float
getDurationFraction()
TimelineEase
getEase()
protected static long
getId()
Returns a unique ID.long
getInitialDelay()
java.lang.Object
getMainObject()
java.lang.String
getName()
Timeline.RepeatBehavior
getRepeatBehavior()
java.lang.Comparable<?>
getSecondaryId()
Timeline.TimelineState
getState()
float
getTimelinePosition()
boolean
isDone()
void
play()
void
playLoop(int loopCount, Timeline.RepeatBehavior repeatBehavior)
void
playLoop(Timeline.RepeatBehavior repeatBehavior)
void
playLoopSkipping(int loopCount, Timeline.RepeatBehavior repeatBehavior, long msToSkip)
void
playLoopSkipping(Timeline.RepeatBehavior repeatBehavior, long msToSkip)
void
playReverse()
void
playReverseSkipping(long msToSkip)
void
playSkipping(long msToSkip)
(package private) Timeline.TimelineState
popState()
static <T> TimelinePropertyBuilder<T>
property(java.lang.String propertyName)
(package private) void
pushState(Timeline.TimelineState state)
(package private) void
replaceState(Timeline.TimelineState state)
void
replay()
void
replayReverse()
void
resetDoneFlag()
void
resume()
protected boolean
shouldForceUiUpdate()
boolean
supportsReplay()
void
suspend()
java.lang.String
toString()
-
-
-
Field Detail
-
DEFAULT_DURATION
public static final long DEFAULT_DURATION
- See Also:
- Constant Field Values
-
DEFAULT_EASE
public static final TimelineEase DEFAULT_EASE
-
mainObject
private java.lang.Object mainObject
-
secondaryId
private java.lang.Comparable<?> secondaryId
-
fullObjectID
TimelineEngine.FullObjectID fullObjectID
-
duration
private long duration
-
initialDelay
private long initialDelay
-
cycleDelay
private long cycleDelay
-
isLooping
boolean isLooping
-
repeatCount
int repeatCount
-
repeatBehavior
private Timeline.RepeatBehavior repeatBehavior
-
mainObjectIsUiComponent
private boolean mainObjectIsUiComponent
-
callbackChain
Timeline.Chain callbackChain
-
name
private java.lang.String name
-
propertiesToInterpolate
private java.util.List<TimelinePropertyBuilder.AbstractFieldInfo<?>> propertiesToInterpolate
-
counter
private static long counter
Is used to create unique value for theid
field.
-
id
long id
Unique ID.
-
durationFraction
float durationFraction
Timeline position.
-
timelinePosition
float timelinePosition
Timeline position.
-
timeUntilPlay
long timeUntilPlay
-
toCancelAtCycleBreak
boolean toCancelAtCycleBreak
Indication whether the looping timeline should stop at reaching the end of the cycle. Relevant only whenisLooping
istrue
.
-
stateStack
private java.util.Stack<Timeline.TimelineState> stateStack
-
ease
private TimelineEase ease
-
doneCount
private int doneCount
-
-
Method Detail
-
builder
public static Timeline.Builder builder()
-
builder
public static Timeline.Builder builder(java.lang.Object mainTimelineObject)
-
addCallback
protected final void addCallback(TimelineCallback callback)
-
property
public static <T> TimelinePropertyBuilder<T> property(java.lang.String propertyName)
-
shouldForceUiUpdate
protected boolean shouldForceUiUpdate()
-
play
public void play()
- Specified by:
play
in interfaceTimelineScenario.TimelineScenarioActor
-
playSkipping
public void playSkipping(long msToSkip)
-
playReverse
public void playReverse()
-
playReverseSkipping
public void playReverseSkipping(long msToSkip)
-
replay
public void replay()
-
replayReverse
public void replayReverse()
-
playLoop
public void playLoop(Timeline.RepeatBehavior repeatBehavior)
-
playLoopSkipping
public void playLoopSkipping(Timeline.RepeatBehavior repeatBehavior, long msToSkip)
-
playLoop
public void playLoop(int loopCount, Timeline.RepeatBehavior repeatBehavior)
-
playLoopSkipping
public void playLoopSkipping(int loopCount, Timeline.RepeatBehavior repeatBehavior, long msToSkip)
-
cancel
public void cancel()
Cancels this timeline. The timeline transitions to theTimeline.TimelineState.CANCELLED
state, preserving its current timeline position. After application callbacks and field interpolations are done on theTimeline.TimelineState.CANCELLED
state, the timeline transitions to theTimeline.TimelineState.IDLE
state. Application callbacks and field interpolations are done on this state as well.
-
end
public void end()
Ends this timeline. The timeline transitions to theTimeline.TimelineState.DONE
state, with the timeline position set to 0.0 or 1.0 - based on the direction of the timeline. After application callbacks and field interpolations are done on theTimeline.TimelineState.DONE
state, the timeline transitions to theTimeline.TimelineState.IDLE
state. Application callbacks and field interpolations are done on this state as well.
-
abort
public void abort()
Aborts this timeline. The timeline transitions to theTimeline.TimelineState.IDLE
state. No application callbacks or field interpolations are done.
-
suspend
public void suspend()
-
resume
public void resume()
-
cancelAtCycleBreak
public void cancelAtCycleBreak()
Requests that the specified timeline should stop at the end of the cycle. This method should be called only on looping timelines.
-
getId
protected static long getId()
Returns a unique ID.- Returns:
- Unique ID.
-
getTimelinePosition
public final float getTimelinePosition()
-
getDurationFraction
public final float getDurationFraction()
-
getState
public final Timeline.TimelineState getState()
-
isDone
public boolean isDone()
- Specified by:
isDone
in interfaceTimelineScenario.TimelineScenarioActor
-
supportsReplay
public boolean supportsReplay()
- Specified by:
supportsReplay
in interfaceTimelineScenario.TimelineScenarioActor
-
resetDoneFlag
public void resetDoneFlag()
- Specified by:
resetDoneFlag
in interfaceTimelineScenario.TimelineScenarioActor
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
replaceState
void replaceState(Timeline.TimelineState state)
-
pushState
void pushState(Timeline.TimelineState state)
-
popState
Timeline.TimelineState popState()
-
getDuration
public final long getDuration()
-
getInitialDelay
public long getInitialDelay()
-
getCycleDelay
public long getCycleDelay()
-
getRepeatBehavior
public Timeline.RepeatBehavior getRepeatBehavior()
-
getName
public java.lang.String getName()
-
getEase
public TimelineEase getEase()
-
getMainObject
public java.lang.Object getMainObject()
-
getSecondaryId
public java.lang.Comparable<?> getSecondaryId()
-
-