FloatTraitAnimpublic class FloatTraitAnim extends TraitAnim
Constructors Summary |
---|
public FloatTraitAnim(ElementNode targetElement, String traitName, String traitType)Constructs a new FloatTraitAnim for a given ElementNode trait.
super(targetElement, ElementNode.NULL_NS, traitName, traitType);
|
Methods Summary |
---|
void | apply()Applies the animation effect. The implementation makes sure it
implements the sandwich model by 'pulling' values from the
root animation (i.e., the animation with the highest priority).
float[][] v = (float[][]) rootAnim.compute();
targetElement.setFloatArrayTrait(traitName, v);
| public java.lang.Object[] | getBaseValue()Returns the BaseValue as an array of objects.
return targetElement.validateFloatArrayTrait(
traitName,
getSpecifiedTraitNS(),
targetElement.getNamespaceURI(),
targetElement.getLocalName(),
traitNamespace,
traitName);
| protected java.lang.String | getTraitImpl()
// This returns the computed trait value, using the specified
// trait value.
float[][] v = targetElement.validateFloatArrayTrait(
traitName,
specifiedTraitValue,
targetElement.getNamespaceURI(),
targetElement.getLocalName(),
traitNamespace,
traitName);
// Now, convert that value to a string.
return targetElement.toStringTrait(traitName, v);
| public java.lang.Object[] | multiply(java.lang.Object[] value, int iter)Used to multiply an animated trait value by a number of iterations.
float[][] fv = (float[][]) value;
float[][] r = new float[fv.length][];
for (int ci = 0; ci < fv.length; ci++) {
r[ci] = new float[fv[ci].length];
for (int di = 0; di < fv[ci].length; di++) {
r[ci][di] = fv[ci][di] * iter;
}
}
return r;
| void | setTraitImpl(java.lang.String value)Sets the trait's base value, as a String.
targetElement.validateFloatArrayTrait(traitName,
value,
targetElement.getNamespaceURI(),
targetElement.getLocalName(),
traitNamespace,
traitName);
specifiedTraitValue = value;
| public java.lang.Object[] | sum(java.lang.Object[] valueA, java.lang.Object[] valueB)Used to sum two animated trait values.
if (valueA == null) {
return valueB;
}
float[][] fva = (float[][]) valueA;
float[][] fvb = (float[][]) valueB;
for (int ci = 0; ci < fva.length; ci++) {
for (int di = 0; di < fva[ci].length; di++) {
fvb[ci][di] += fva[ci][di];
}
}
return valueB;
| boolean | supportsInterpolation()
return true;
| RefValues | toRefValues(Animation anim, java.lang.String[] values, java.lang.String reqTraitNamespace, java.lang.String reqTraitName)Converts the input values set to a RefValues object.
FloatRefValues refValues = new FloatRefValues();
if (values.length < 1) {
throw new IllegalArgumentException();
}
if (values.length == 1) {
String[] tmpValues = new String[2];
tmpValues[0] = values[0];
tmpValues[1] = values[0];
values = tmpValues;
}
int nSegments = values.length - 1;
refValues.segments = new FloatSegment[nSegments];
// Build the first segment.
refValues.segments[0] = new FloatSegment();
refValues.segments[0].start =
targetElement.validateFloatArrayTrait(anim.traitName,
values[0],
anim.getNamespaceURI(),
anim.getLocalName(),
reqTraitNamespace,
reqTraitName);
refValues.segments[0].end =
targetElement.validateFloatArrayTrait(anim.traitName,
values[1],
anim.getNamespaceURI(),
anim.getLocalName(),
reqTraitNamespace,
reqTraitName);
FloatSegment prevSegment = refValues.segments[0];
for (int i = 1; i < nSegments; i++) {
refValues.segments[i] = new FloatSegment();
refValues.segments[i].start = prevSegment.end;
refValues.segments[i].end =
targetElement.validateFloatArrayTrait(anim.traitName,
values[i + 1],
anim.getNamespaceURI(),
anim.getLocalName(),
reqTraitNamespace,
reqTraitName);
prevSegment = refValues.segments[i];
}
return refValues;
|
|