APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.animation

public final Class KeyFrame

extends Object
Class Inheritance
Imports
java.util.Collection, .Collections, .Set, java.util.concurrent.CopyOnWriteArraySet, javafx.beans.NamedArg, javafx.event.ActionEvent, .EventHandler, javafx.util.Duration

Defines target values at a specified point in time for a set of variables that are interpolated along a 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

Field Summary

Modifier and TypeField and Description
private static final String
private static final EventHandler<ActionEvent>
private final String
private final EventHandler<ActionEvent>
private final Duration
private final Set<KeyValue>

Constructor Summary

AccessConstructor and Description
public
KeyFrame(Duration
the time
time
,
String
the name
name
,
EventHandler<ActionEvent>
the onFinished
onFinished
,
Collection<KeyValue> values)

Constructor of KeyFrame

If a passed in KeyValue is null or a duplicate, it will be ignored.

public
KeyFrame(Duration
the time
time
,
String
the name
name
,
EventHandler<ActionEvent>
the onFinished
onFinished
,
KeyValue...
the KeyValue instances
values
)

Constructor of KeyFrame

If a passed in KeyValue is null or a duplicate, it will be ignored.

public
KeyFrame(Duration
the time
time
,
EventHandler<ActionEvent>
the onFinished
onFinished
,
KeyValue...
the KeyValue instances
values
)

Constructor of KeyFrame

public
KeyFrame(Duration
the time
time
,
String
the name
name
,
KeyValue...
the KeyValue instances
values
)

Constructor of KeyFrame

public
KeyFrame(Duration
the time
time
,
KeyValue...
the KeyValue instances
values
)

Constructor of KeyFrame

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this is the same as obj, otherwise false
equals
(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public String

Returns:

the name
getName
()

Returns the name of this KeyFrame.

public EventHandler<ActionEvent>

Returns:

the onFinished event handler
getOnFinished
()

Returns the onFinished event handler of this KeyFrame.

public Duration

Returns:

the time offset
getTime
()

Returns the time offset of this KeyFrame.

public Set<KeyValue>

Returns:

an immutable Set of KeyValue instances
getValues
()

Returns an immutable Set of KeyValue instances.

public int

Returns:

the hash code
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code for this KeyFrame object.

public String

Returns:

the string representation
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this KeyFrame object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

DEFAULT_NAMEback to summary
private static final String DEFAULT_NAME
DEFAULT_ON_FINISHEDback to summary
private static final EventHandler<ActionEvent> DEFAULT_ON_FINISHED
nameback to summary
private final String name
onFinishedback to summary
private final EventHandler<ActionEvent> onFinished
timeback to summary
private final Duration time
valuesback to summary
private final Set<KeyValue> values

Constructor Detail

KeyFrameback to summary
public KeyFrame(Duration time, String name, EventHandler<ActionEvent> onFinished, Collection<KeyValue> values)

Constructor of KeyFrame

If a passed in KeyValue is null or a duplicate, it will be ignored.

Parameters
time:Duration

the time

name:String

the name

onFinished:EventHandler<ActionEvent>

the onFinished

values:Collection<KeyValue>

a javafx.collections.ObservableList of KeyValue instances

Exceptions
NullPointerException:
if time is null
IllegalArgumentException:
if time is invalid (see time)
KeyFrameback to summary
public KeyFrame(Duration time, String name, EventHandler<ActionEvent> onFinished, KeyValue... values)

Constructor of KeyFrame

If a passed in KeyValue is null or a duplicate, it will be ignored.

Parameters
time:Duration

the time

name:String

the name

onFinished:EventHandler<ActionEvent>

the onFinished

values:KeyValue[]

the KeyValue instances

Exceptions
NullPointerException:
if time is null
IllegalArgumentException:
if time is invalid (see time)
KeyFrameback to summary
public KeyFrame(Duration time, EventHandler<ActionEvent> onFinished, KeyValue... values)

Constructor of KeyFrame

Parameters
time:Duration

the time

onFinished:EventHandler<ActionEvent>

the onFinished

values:KeyValue[]

the KeyValue instances

Exceptions
NullPointerException:
if time is null
IllegalArgumentException:
if time is invalid (see time)
KeyFrameback to summary
public KeyFrame(Duration time, String name, KeyValue... values)

Constructor of KeyFrame

Parameters
time:Duration

the time

name:String

the name

values:KeyValue[]

the KeyValue instances

Exceptions
NullPointerException:
if time is null
IllegalArgumentException:
if time is invalid (see time)
KeyFrameback to summary
public KeyFrame(Duration time, KeyValue... values)

Constructor of KeyFrame

Parameters
time:Duration

the time

values:KeyValue[]

the KeyValue instances

Exceptions
NullPointerException:
if time is null
IllegalArgumentException:
if time is invalid (see time)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one. Two KeyFrames are considered equal, if their time, onFinished, and values are equal.

Returns:boolean

true if this is the same as obj, otherwise false

Annotations
@Override
getNameback to summary
public String getName()

Returns the name of this KeyFrame. If a named KeyFrame is added to a Timeline, a cuepoint with the name and the time of the KeyFrame will be added automatically. If the KeyFrame is removed, the cuepoint will also be removed.

Returns:String

the name

getOnFinishedback to summary
public EventHandler<ActionEvent> getOnFinished()

Returns the onFinished event handler of this KeyFrame. The onFinished event handler is a function that is called when the elapsed time on a cycle passes the specified time of this KeyFrame. The onFinished function variable will be called if the elapsed time passes the indicated value, even if it never equaled the time value exactly.

Returns:EventHandler<ActionEvent>

the onFinished event handler

getTimeback to summary
public Duration getTime()

Returns the time offset of this KeyFrame. The returned javafx.util.Duration defines the time offset within a single cycle of a Timeline at which the KeyValues will be set and at which the onFinished function variable will be called.

The time of a KeyFrame has to be greater than or equal to javafx.util.Duration#ZERO and it cannot be javafx.util.Duration#UNKNOWN.

Note

While the unit of time 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:Duration

the time offset

getValuesback to summary
public Set<KeyValue> getValues()

Returns an immutable Set of KeyValue instances. A KeyValue defines a target and the desired value that should be interpolated at the specified time of this KeyFrame.

Returns:Set<KeyValue>

an immutable Set of KeyValue instances

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code for this KeyFrame object.

Returns:int

the hash code

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this KeyFrame object.

Returns:String

the string representation

Annotations
@Override