public final class KeyFrame extends Object
Timeline
.
The developer controls the interpolation of a set of variables for the
interval between successive key frames by providing a target value and an
Interpolator
associated with each variable. The variables are
interpolated such that they will reach their target value at the specified
time. An onFinished
function is invoked on each KeyFrame
if one
is provided. A KeyFrame
can optionally have a name
, which
will result in a cuepoint that is automatically added to the Timeline
.
- Since:
- JavaFX 2.0
- See Also:
Timeline
,KeyValue
,Interpolator
-
Constructor Summary
Constructors Constructor Description KeyFrame(Duration time, String name, KeyValue... values)
Constructor ofKeyFrame
KeyFrame(Duration time, String name, EventHandler<ActionEvent> onFinished, Collection<KeyValue> values)
Constructor ofKeyFrame
KeyFrame(Duration time, String name, EventHandler<ActionEvent> onFinished, KeyValue... values)
Constructor ofKeyFrame
KeyFrame(Duration time, KeyValue... values)
Constructor ofKeyFrame
KeyFrame(Duration time, EventHandler<ActionEvent> onFinished, KeyValue... values)
Constructor ofKeyFrame
-
Method Summary
Modifier and Type Method Description boolean
equals(Object obj)
Indicates whether some other object is "equal to" this one.String
getName()
Returns thename
of thisKeyFrame
.EventHandler<ActionEvent>
getOnFinished()
Returns theonFinished
event handler of thisKeyFrame
.Duration
getTime()
Returns the time offset of thisKeyFrame
.Set<KeyValue>
getValues()
Returns an immutableSet
ofKeyValue
instances.int
hashCode()
Returns a hash code for thisKeyFrame
object.String
toString()
Returns a string representation of thisKeyFrame
object.
-
Constructor Details
-
KeyFrame
public KeyFrame(Duration time, String name, EventHandler<ActionEvent> onFinished, Collection<KeyValue> values)Constructor ofKeyFrame
If a passed in
KeyValue
isnull
or a duplicate, it will be ignored.- Parameters:
time
- thetime
name
- thename
onFinished
- theonFinished
values
- aObservableList
ofKeyValue
instances- Throws:
NullPointerException
- iftime
is nullIllegalArgumentException
- iftime
is invalid (seetime
)
-
KeyFrame
public KeyFrame(Duration time, String name, EventHandler<ActionEvent> onFinished, KeyValue... values)Constructor ofKeyFrame
If a passed in
KeyValue
isnull
or a duplicate, it will be ignored.- Parameters:
time
- thetime
name
- thename
onFinished
- theonFinished
values
- theKeyValue
instances- Throws:
NullPointerException
- iftime
is nullIllegalArgumentException
- iftime
is invalid (seetime
)
-
KeyFrame
Constructor ofKeyFrame
- Parameters:
time
- thetime
onFinished
- theonFinished
values
- theKeyValue
instances- Throws:
NullPointerException
- iftime
is nullIllegalArgumentException
- iftime
is invalid (seetime
)
-
KeyFrame
Constructor ofKeyFrame
- Parameters:
time
- thetime
name
- thename
values
- theKeyValue
instances- Throws:
NullPointerException
- iftime
is nullIllegalArgumentException
- iftime
is invalid (seetime
)
-
KeyFrame
Constructor ofKeyFrame
- Parameters:
time
- thetime
values
- theKeyValue
instances- Throws:
NullPointerException
- iftime
is nullIllegalArgumentException
- iftime
is invalid (seetime
)
-
-
Method Details
-
getTime
Returns the time offset of thisKeyFrame
. The returnedDuration
defines the time offset within a single cycle of aTimeline
at which theKeyValues
will be set and at which theonFinished
function variable will be called.The
time
of aKeyFrame
has to be greater than or equal toDuration.ZERO
and it cannot beDuration.UNKNOWN
. Note: While the unit oftime
is a millisecond, the granularity depends on the underlying operating system and will in general be larger. For example animations on desktop systems usually run with a maximum of 60fps which gives a granularity of ~17 ms.- Returns:
- the time offset
-
getValues
Returns an immutableSet
ofKeyValue
instances. AKeyValue
defines a target and the desired value that should be interpolated at the specified time of thisKeyFrame
.- Returns:
- an immutable
Set
ofKeyValue
instances
-
getOnFinished
Returns theonFinished
event handler of thisKeyFrame
. TheonFinished
event handler is a function that is called when the elapsed time on a cycle passes the specified time of thisKeyFrame
. TheonFinished
function variable will be called if the elapsed time passes the indicated value, even if it never equaled the time value exactly.- Returns:
- the
onFinished
event handler
-
getName
Returns thename
of thisKeyFrame
. If a namedKeyFrame
is added to aTimeline
, a cuepoint with thename
and thetime
of theKeyFrame
will be added automatically. If theKeyFrame
is removed, the cuepoint will also be removed.- Returns:
- the
name
-
toString
Returns a string representation of thisKeyFrame
object. -
hashCode
public int hashCode()Returns a hash code for thisKeyFrame
object. -
equals
Indicates whether some other object is "equal to" this one. TwoKeyFrames
are considered equal, if theirtime
,onFinished
, andvalues
are equal.
-