T
- the type of the values the KeyFrames
instance constructed
by this builder will hold.@NotThreadSafe @TrackPartiallyInitialized public static final class KeyFrames.Builder<T> extends java.lang.Object
KeyFrames
instances.
Instances of this class are not thread safe and are intended to be
thread-confined. However, the KeyFrames
objects produces are
thread-safe.
Client code should never mutate values that have been passed into a key frames instance. The behavior of the constructed key frames instance is undefined if its values are mutate by client code.
Constructor and Description |
---|
KeyFrames.Builder()
Constructs an key frames builder instance.
|
KeyFrames.Builder(T startValue)
Constructs an key frames builder instance and specifies the first, or
starting, key frame.
|
Modifier and Type | Method and Description |
---|---|
KeyFrames.Builder<T> |
addFrame(KeyFrames.Frame<T> frame)
Adds a frame to the list of key frames being built.
|
KeyFrames.Builder<T> |
addFrame(T value)
Adds a frame to the list of key frames being built.
|
KeyFrames.Builder<T> |
addFrame(T value,
double atTimeFraction)
Adds a frame to the list of key frames being built.
|
KeyFrames.Builder<T> |
addFrame(T value,
double atTimeFraction,
Interpolator interpolator)
Adds a frame to the list of key frames being built.
|
KeyFrames.Builder<T> |
addFrame(T value,
Interpolator interpolator)
Adds a frame to the list of key frames being built.
|
KeyFrames.Builder<T> |
addFrames(java.util.List<T> values)
Adds a list of frames to the list of key frames being built.
|
KeyFrames.Builder<T> |
addFrames(T... values)
Adds a list of frames to the list of key frames being built.
|
KeyFrames<T> |
build()
Constructs a key frames instance with the settings defined by this
builder.
|
KeyFrames.Builder<T> |
setEvaluator(Evaluator<T> evaluator)
Sets the evaluator between values for the list of key frames being built.
|
KeyFrames.Builder<T> |
setInterpolator(Interpolator interpolator)
Sets the global interpolator to be used for the list of key frames being
built.
|
public KeyFrames.Builder()
public KeyFrames.Builder(T startValue)
startValue
- the key frame value at zero. Client code should never
mutate values that have been passed into a key frames instance.
The behavior of the constructed key frames instance is undefined
if its values are mutate by client code.public KeyFrames.Builder<T> addFrame(T value)
The time fraction when this fame occurs will be calculated, linearly, from the previous and next specified time fractions.
The interpolator between the previous key frame and the one being added
is set with setInterpolator(Interpolator)
or the default
LinearInterpolator
will be used. The first key frame does not
have an interpolator.
value
- the value for the key frame. Client code should never
mutate values that have been passed into a key frames instance.
The behavior of the constructed key frames instance is undefined
if its values are mutate by client code.public KeyFrames.Builder<T> addFrame(T value, double atTimeFraction)
The interpolator between the previous key frame and the one being added
is set with setInterpolator(Interpolator)
or the default
LinearInterpolator
will be used. The first key frame does not
have an interpolator.
value
- the value for the key frame. Client code should never
mutate values that have been passed into a key frames instance.
The behavior of the constructed key frames instance is undefined
if its values are mutate by client code.atTimeFraction
- the time fraction in the range [0,1] when the value should
occur. A negative value indicates that the time fraction when
this fame occurs should be calculated, linearly, from the
previous and next specified time fractions.public KeyFrames.Builder<T> addFrame(T value, Interpolator interpolator)
The time fraction when this fame occurs will be calculated, linearly, from the previous and next specified time fractions.
value
- the value for the key frame. Client code should never
mutate values that have been passed into a key frames instance.
The behavior of the constructed key frames instance is undefined
if its values are mutate by client code.interpolator
- the interpolator that should be used between the previous key
frame and the one being added. A null
value indicates
that either the interpolator set with
setInterpolator(Interpolator)
or the default
LinearInterpolator
should be used for this key frame.
The first key frame does not have an interpolator—if set,
it will be ignored.public KeyFrames.Builder<T> addFrame(T value, double atTimeFraction, Interpolator interpolator)
value
- the value for the key frame. Client code should never
mutate values that have been passed into a key frames instance.
The behavior of the constructed key frames instance is undefined
if its values are mutate by client code.atTimeFraction
- the time fraction in the range [0,1] when the value should
occur. A negative value indicates that the time fraction when
this fame occurs should be calculated, linearly, from the
previous and next specified time fractions.interpolator
- the interpolator that should be used between the previous key
frame and the one being added. A null
value indicates
that either the interpolator set with
setInterpolator(Interpolator)
or the default
LinearInterpolator
should be used for this key frame.
The first key frame does not have an interpolator—if set,
it will be ignored.public KeyFrames.Builder<T> addFrame(KeyFrames.Frame<T> frame)
frame
- a frame.java.lang.IllegalArgumentException
- if frame is null
.KeyFrames.Frame
public KeyFrames.Builder<T> addFrames(T... values)
This is a convenience method that invokes addFrame(Object)
for
each of the passed values.
values
- a series values. Client code should never mutate values
that have been passed into a key frames instance. The behavior
of the constructed key frames instance is undefined if its
values are mutate by client code.public KeyFrames.Builder<T> addFrames(java.util.List<T> values)
This is a convenience method that invokes addFrame(Object)
for
each of the passed values.
values
- a series values. Client code should never mutate values
that have been passed into a key frames instance. The behavior
of the constructed key frames instance is undefined if its
values are mutate by client code.public KeyFrames.Builder<T> setInterpolator(Interpolator interpolator)
A value of null
will clear the global interpolator, if any, that
was previously set via a call to this method and use the interpolators
set on individual frames.
interpolator
- a global interpolator, or null
to clear any previously
set global interpolator.public KeyFrames.Builder<T> setEvaluator(Evaluator<T> evaluator)
Typically, this method does not need to be called because
build()
obtains an Evaluator
instance by examining the
type of the values the KeyFrames
instance constructed by this
builder will hold and calling
KnownEvaluators.getEvaluatorFor(Class)
.
If the type of the values the KeyFrames
instance constructed by
this builder will hold is not known, then you will have to implement a
custom evaluator for that type and pass it to this method—or to
KnownEvaluators.register(Evaluator)
.
A value of null
will clear the evaluator, if any, that was
previously set via a call to this method and have build()
invoke
KnownEvaluators.getEvaluatorFor(Class)
to obtain an
Evaluator
instance.
evaluator
- an evaluator, or null
to clear any previously set
evaluator.KnownEvaluators
public KeyFrames<T> build()
java.lang.IllegalArgumentException
- if the settings defined by this builder are invalid and are not
conducive to the construction of a valid key frames instance.