public class PropertyValuesHolder extends Object implements Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
PropertyValuesHolder.PropertyValues |
Modifier and Type | Method and Description |
---|---|
PropertyValuesHolder |
clone()
Creates and returns a copy of this object.
|
String |
getPropertyName()
Gets the name of the property that will be animated.
|
void |
getPropertyValues(PropertyValuesHolder.PropertyValues values)
PropertyValuesHolder is Animators use to hold internal animation related data.
|
Class |
getValueType() |
static PropertyValuesHolder |
ofFloat(Property<?,Float> property,
float... values)
Constructs and returns a PropertyValuesHolder with a given property and
set of float values.
|
static PropertyValuesHolder |
ofFloat(String propertyName,
float... values)
Constructs and returns a PropertyValuesHolder with a given property name and
set of float values.
|
static PropertyValuesHolder |
ofInt(Property<?,Integer> property,
int... values)
Constructs and returns a PropertyValuesHolder with a given property and
set of int values.
|
static PropertyValuesHolder |
ofInt(String propertyName,
int... values)
Constructs and returns a PropertyValuesHolder with a given property name and
set of int values.
|
static PropertyValuesHolder |
ofKeyframe(Property property,
Keyframe... values)
Constructs and returns a PropertyValuesHolder object with the specified property and set
of values.
|
static PropertyValuesHolder |
ofKeyframe(String propertyName,
Keyframe... values)
Constructs and returns a PropertyValuesHolder object with the specified property name and set
of values.
|
static PropertyValuesHolder |
ofMultiFloat(String propertyName,
float[][] values)
Constructs and returns a PropertyValuesHolder with a given property name and
set of
float[] values. |
static PropertyValuesHolder |
ofMultiFloat(String propertyName,
Path path)
Constructs and returns a PropertyValuesHolder with a given property name to use
as a multi-float setter.
|
static <T> PropertyValuesHolder |
ofMultiFloat(String propertyName,
TypeConverter<T,float[]> converter,
TypeEvaluator<T> evaluator,
Keyframe... values)
Constructs and returns a PropertyValuesHolder object with the specified property name or
setter name for use in a multi-float setter function using ObjectAnimator.
|
static <V> PropertyValuesHolder |
ofMultiFloat(String propertyName,
TypeConverter<V,float[]> converter,
TypeEvaluator<V> evaluator,
V... values)
Constructs and returns a PropertyValuesHolder with a given property and
set of Object values for use with ObjectAnimator multi-value setters.
|
static PropertyValuesHolder |
ofMultiInt(String propertyName,
int[][] values)
Constructs and returns a PropertyValuesHolder with a given property name and
set of
int[] values. |
static PropertyValuesHolder |
ofMultiInt(String propertyName,
Path path)
Constructs and returns a PropertyValuesHolder with a given property name to use
as a multi-int setter.
|
static <T> PropertyValuesHolder |
ofMultiInt(String propertyName,
TypeConverter<T,int[]> converter,
TypeEvaluator<T> evaluator,
Keyframe... values)
Constructs and returns a PropertyValuesHolder object with the specified property name or
setter name for use in a multi-int setter function using ObjectAnimator.
|
static <V> PropertyValuesHolder |
ofMultiInt(String propertyName,
TypeConverter<V,int[]> converter,
TypeEvaluator<V> evaluator,
V... values)
Constructs and returns a PropertyValuesHolder with a given property and
set of Object values for use with ObjectAnimator multi-value setters.
|
static <V> PropertyValuesHolder |
ofObject(Property<?,V> property,
TypeConverter<PointF,V> converter,
Path path)
Constructs and returns a PropertyValuesHolder with a given property and
a Path along which the values should be animated.
|
static <T,V> PropertyValuesHolder |
ofObject(Property<?,V> property,
TypeConverter<T,V> converter,
TypeEvaluator<T> evaluator,
T... values)
Constructs and returns a PropertyValuesHolder with a given property and
set of Object values.
|
static <V> PropertyValuesHolder |
ofObject(Property property,
TypeEvaluator<V> evaluator,
V... values)
Constructs and returns a PropertyValuesHolder with a given property and
set of Object values.
|
static PropertyValuesHolder |
ofObject(String propertyName,
TypeConverter<PointF,?> converter,
Path path)
Constructs and returns a PropertyValuesHolder with a given property name and
a Path along which the values should be animated.
|
static PropertyValuesHolder |
ofObject(String propertyName,
TypeEvaluator evaluator,
Object... values)
Constructs and returns a PropertyValuesHolder with a given property name and
set of Object values.
|
void |
setConverter(TypeConverter converter)
Sets the converter to convert from the values type to the setter's parameter type.
|
void |
setEvaluator(TypeEvaluator evaluator)
The TypeEvaluator will be automatically determined based on the type of values
supplied to PropertyValuesHolder.
|
void |
setFloatValues(float... values)
Set the animated values for this object to this set of floats.
|
void |
setIntValues(int... values)
Set the animated values for this object to this set of ints.
|
void |
setKeyframes(Keyframe... values)
Set the animated values for this object to this set of Keyframes.
|
void |
setObjectValues(Object... values)
Set the animated values for this object to this set of Objects.
|
void |
setProperty(Property property)
Sets the property that will be animated.
|
void |
setPropertyName(String propertyName)
Sets the name of the property that will be animated.
|
String |
toString()
Returns a string representation of the object.
|
protected Property mProperty
public static PropertyValuesHolder ofInt(String propertyName, int... values)
propertyName
- The name of the property being animated.values
- The values that the named property will animate between.public static PropertyValuesHolder ofInt(Property<?,Integer> property, int... values)
property
- The property being animated. Should not be null.values
- The values that the property will animate between.public static PropertyValuesHolder ofMultiInt(String propertyName, int[][] values)
int[]
values. At least two int[]
values must be supplied,
a start and end value. If more values are supplied, the values will be animated from the
start, through all intermediate values to the end value. When used with ObjectAnimator,
the elements of the array represent the parameters of the setter function.propertyName
- The name of the property being animated. Can also be the
case-sensitive name of the entire setter method. Should not be null.values
- The values that the property will animate between.IntArrayEvaluator.IntArrayEvaluator(int[])
,
ObjectAnimator.ofMultiInt(Object, String, TypeConverter, TypeEvaluator, Object[])
public static PropertyValuesHolder ofMultiInt(String propertyName, Path path)
propertyName
- The name of the property being animated. Can also be the
case-sensitive name of the entire setter method. Should not be null.
The setter must take exactly two int
parameters.path
- The Path along which the values should be animated.ObjectAnimator.ofPropertyValuesHolder(Object, PropertyValuesHolder...)
@SafeVarargs public static <V> PropertyValuesHolder ofMultiInt(String propertyName, TypeConverter<V,int[]> converter, TypeEvaluator<V> evaluator, V... values)
int[]
using the converter.propertyName
- The property being animated or complete name of the setter.
Should not be null.converter
- Used to convert the animated value to setter parameters.evaluator
- A TypeEvaluator that will be called on each animation frame to
provide the necessary interpolation between the Object values to derive the animated
value.values
- The values that the property will animate between.ObjectAnimator.ofMultiInt(Object, String, TypeConverter, TypeEvaluator, Object[])
,
ObjectAnimator.ofPropertyValuesHolder(Object, PropertyValuesHolder...)
public static <T> PropertyValuesHolder ofMultiInt(String propertyName, TypeConverter<T,int[]> converter, TypeEvaluator<T> evaluator, Keyframe... values)
TypeEvaluator
can be used to to evaluate the animated value. The
converter
converts the values to parameters in the setter function.
At least two values must be supplied, a start and an end value.
propertyName
- The name of the property to associate with the set of values. This
may also be the complete name of a setter function.converter
- Converts values
into int parameters for the setter.
Can be null if the Keyframes have int[] values.evaluator
- Used to interpolate between values.values
- The values at specific fractional times to evaluate betweenpublic static PropertyValuesHolder ofFloat(String propertyName, float... values)
propertyName
- The name of the property being animated.values
- The values that the named property will animate between.public static PropertyValuesHolder ofFloat(Property<?,Float> property, float... values)
property
- The property being animated. Should not be null.values
- The values that the property will animate between.public static PropertyValuesHolder ofMultiFloat(String propertyName, float[][] values)
float[]
values. At least two float[]
values must be supplied,
a start and end value. If more values are supplied, the values will be animated from the
start, through all intermediate values to the end value. When used with ObjectAnimator,
the elements of the array represent the parameters of the setter function.propertyName
- The name of the property being animated. Can also be the
case-sensitive name of the entire setter method. Should not be null.values
- The values that the property will animate between.FloatArrayEvaluator.FloatArrayEvaluator(float[])
,
ObjectAnimator.ofMultiFloat(Object, String, TypeConverter, TypeEvaluator, Object[])
public static PropertyValuesHolder ofMultiFloat(String propertyName, Path path)
propertyName
- The name of the property being animated. Can also be the
case-sensitive name of the entire setter method. Should not be null.
The setter must take exactly two float
parameters.path
- The Path along which the values should be animated.ObjectAnimator.ofPropertyValuesHolder(Object, PropertyValuesHolder...)
@SafeVarargs public static <V> PropertyValuesHolder ofMultiFloat(String propertyName, TypeConverter<V,float[]> converter, TypeEvaluator<V> evaluator, V... values)
float[]
using the converter.propertyName
- The property being animated or complete name of the setter.
Should not be null.converter
- Used to convert the animated value to setter parameters.evaluator
- A TypeEvaluator that will be called on each animation frame to
provide the necessary interpolation between the Object values to derive the animated
value.values
- The values that the property will animate between.ObjectAnimator.ofMultiFloat(Object, String, TypeConverter, TypeEvaluator, Object[])
public static <T> PropertyValuesHolder ofMultiFloat(String propertyName, TypeConverter<T,float[]> converter, TypeEvaluator<T> evaluator, Keyframe... values)
TypeEvaluator
can be used to to evaluate the animated value. The
converter
converts the values to parameters in the setter function.
At least two values must be supplied, a start and an end value.
propertyName
- The name of the property to associate with the set of values. This
may also be the complete name of a setter function.converter
- Converts values
into float parameters for the setter.
Can be null if the Keyframes have float[] values.evaluator
- Used to interpolate between values.values
- The values at specific fractional times to evaluate betweenpublic static PropertyValuesHolder ofObject(String propertyName, TypeEvaluator evaluator, Object... values)
Note: The Object values are stored as references to the original objects, which means that changes to those objects after this method is called will affect the values on the PropertyValuesHolder. If the objects will be mutated externally after this method is called, callers should pass a copy of those objects instead.
propertyName
- The name of the property being animated.evaluator
- A TypeEvaluator that will be called on each animation frame to
provide the necessary interpolation between the Object values to derive the animated
value.values
- The values that the named property will animate between.public static PropertyValuesHolder ofObject(String propertyName, TypeConverter<PointF,?> converter, Path path)
TypeConverter
to convert from PointF
to the target
type.
The PointF passed to converter
or property
, if
converter
is null
, is reused on each animation frame and should
not be stored by the setter or TypeConverter.
propertyName
- The name of the property being animated.converter
- Converts a PointF to the type associated with the setter. May be
null if conversion is unnecessary.path
- The Path along which the values should be animated.@SafeVarargs public static <V> PropertyValuesHolder ofObject(Property property, TypeEvaluator<V> evaluator, V... values)
Note: The Object values are stored as references to the original objects, which means that changes to those objects after this method is called will affect the values on the PropertyValuesHolder. If the objects will be mutated externally after this method is called, callers should pass a copy of those objects instead.
property
- The property being animated. Should not be null.evaluator
- A TypeEvaluator that will be called on each animation frame to
provide the necessary interpolation between the Object values to derive the animated
value.values
- The values that the property will animate between.@SafeVarargs public static <T,V> PropertyValuesHolder ofObject(Property<?,V> property, TypeConverter<T,V> converter, TypeEvaluator<T> evaluator, T... values)
TypeConverter
to convert from animated values to the type
of the property. If only one value is supplied, the TypeConverter
must be a BidirectionalTypeConverter
to retrieve the current
value.
Note: The Object values are stored as references to the original objects, which means that changes to those objects after this method is called will affect the values on the PropertyValuesHolder. If the objects will be mutated externally after this method is called, callers should pass a copy of those objects instead.
property
- The property being animated. Should not be null.converter
- Converts the animated object to the Property type.evaluator
- A TypeEvaluator that will be called on each animation frame to
provide the necessary interpolation between the Object values to derive the animated
value.values
- The values that the property will animate between.setConverter(TypeConverter)
,
TypeConverter
public static <V> PropertyValuesHolder ofObject(Property<?,V> property, TypeConverter<PointF,V> converter, Path path)
TypeConverter
to convert from PointF
to the target
type.
The PointF passed to converter
or property
, if
converter
is null
, is reused on each animation frame and should
not be stored by the setter or TypeConverter.
property
- The property being animated. Should not be null.converter
- Converts a PointF to the type associated with the setter. May be
null if conversion is unnecessary.path
- The Path along which the values should be animated.public static PropertyValuesHolder ofKeyframe(String propertyName, Keyframe... values)
TypeEvaluator
can be found that matches
the common type.
If there is only one value, it is assumed to be the end value of an animation,
and an initial value will be derived, if possible, by calling a getter function
on the object. Also, if any value is null, the value will be filled in when the animation
starts in the same way. This mechanism of automatically getting null values only works
if the PropertyValuesHolder object is used in conjunction
ObjectAnimator
, and with a getter function
derived automatically from propertyName
, since otherwise PropertyValuesHolder has
no way of determining what the value should be.
propertyName
- The name of the property associated with this set of values. This
can be the actual property name to be used when using a ObjectAnimator object, or
just a name used to get animated values, such as if this object is used with an
ValueAnimator object.values
- The set of values to animate between.public static PropertyValuesHolder ofKeyframe(Property property, Keyframe... values)
TypeEvaluator
can be found that matches
the common type.
If there is only one value, it is assumed to be the end value of an animation,
and an initial value will be derived, if possible, by calling the property's
Property.get(Object)
function.
Also, if any value is null, the value will be filled in when the animation
starts in the same way. This mechanism of automatically getting null values only works
if the PropertyValuesHolder object is used in conjunction with
ObjectAnimator
, since otherwise PropertyValuesHolder has
no way of determining what the value should be.
property
- The property associated with this set of values. Should not be null.values
- The set of values to animate between.public void setIntValues(int... values)
ObjectAnimator
, and with a getter function
derived automatically from propertyName
, since otherwise PropertyValuesHolder has
no way of determining what the value should be.values
- One or more values that the animation will animate between.public void setFloatValues(float... values)
ObjectAnimator
, and with a getter function
derived automatically from propertyName
, since otherwise PropertyValuesHolder has
no way of determining what the value should be.values
- One or more values that the animation will animate between.public void setKeyframes(Keyframe... values)
values
- One or more values that the animation will animate between.public void setObjectValues(Object... values)
ObjectAnimator
, and with a getter function
derived automatically from propertyName
, since otherwise PropertyValuesHolder has
no way of determining what the value should be.
Note: The Object values are stored as references to the original objects, which means that changes to those objects after this method is called will affect the values on the PropertyValuesHolder. If the objects will be mutated externally after this method is called, callers should pass a copy of those objects instead.
values
- One or more values that the animation will animate between.public void setConverter(TypeConverter converter)
BidirectionalTypeConverter
.converter
- The converter to use to convert values.public PropertyValuesHolder clone()
Object
x
, the expression:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true
, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x)
true
, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
super.clone
. If a class and all of its superclasses (except
Object
) obey this convention, it will be the case that
x.clone().getClass() == x.getClass()
.
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by super.clone
before returning it. Typically, this means
copying any mutable objects that comprise the internal "deep structure"
of the object being cloned and replacing the references to these
objects with references to the copies. If a class contains only
primitive fields or references to immutable objects, then it is usually
the case that no fields in the object returned by super.clone
need to be modified.
The method clone
for class Object
performs a
specific cloning operation. First, if the class of this object does
not implement the interface Cloneable
, then a
CloneNotSupportedException
is thrown. Note that all arrays
are considered to implement the interface Cloneable
and that
the return type of the clone
method of an array type T[]
is T[]
where T is any reference or primitive type.
Otherwise, this method creates a new instance of the class of this
object and initializes all its fields with exactly the contents of
the corresponding fields of this object, as if by assignment; the
contents of the fields are not themselves cloned. Thus, this method
performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object
does not itself implement the interface
Cloneable
, so calling the clone
method on an object
whose class is Object
will result in throwing an
exception at run time.
public void setEvaluator(TypeEvaluator evaluator)
evaluator
- public void setPropertyName(String propertyName)
foo
will result
in a call to the function setFoo()
on the target object. If either
valueFrom
or valueTo
is null, then a getter function will
also be derived and called.
Note that the setter function derived from this property name
must take the same parameter type as the
valueFrom
and valueTo
properties, otherwise the call to
the setter function will fail.
propertyName
- The name of the property being animated.public void setProperty(Property property)
Note that if this PropertyValuesHolder object is used with ObjectAnimator, the property must exist on the target object specified in that ObjectAnimator.
property
- The property being animated.public String getPropertyName()
foo
will result
in a call to the function setFoo()
on the target object. If either
valueFrom
or valueTo
is null, then a getter function will
also be derived and called.public void getPropertyValues(PropertyValuesHolder.PropertyValues values)
public Class getValueType()
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())