StringTraitAnimpublic final class StringTraitAnim extends TraitAnim
Fields Summary |
---|
String[] | baseValueThe trait's base value. |
Constructors Summary |
---|
public StringTraitAnim(ElementNode targetElement, String traitNamespace, String traitName)Constructs a new StringTraitAnim for a given ElementNode trait
in the given namespace.
super(targetElement,
traitNamespace,
traitName,
ElementNode.TRAIT_TYPE_STRING);
|
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).
String value = (String) rootAnim.compute()[0];
if (traitNamespace == ElementNode.NULL_NS) {
targetElement.setTraitImpl(traitName, value);
} else {
targetElement.setTraitNSImpl(traitNamespace, traitName, value);
}
| public java.lang.Object[] | getBaseValue()Returns the BaseValue as an array of objects.
baseValue[0] = getTraitImpl();
return baseValue;
| protected java.lang.String | getTraitImpl()
// This returns the computed trait value, using the specified
// trait value.
return targetElement.validateTraitNS(traitNamespace,
traitName,
getSpecifiedTraitNS(),
targetElement.getNamespaceURI(),
targetElement.getLocalName(),
traitNamespace,
traitName);
| public java.lang.Object[] | multiply(java.lang.Object[] value, int iter)Used to multiply an animated trait value by a number of iterations.
// String animations do not support additive behavior.
throw new Error();
| void | setTraitImpl(java.lang.String value)Sets the trait's base value, as a String.
// Validate on set so that we do not get an error later.
// However, we keep the specified value around, for properties
// that may have relative or inherited values.
targetElement.validateTraitNS(traitNamespace,
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. Because String traits cannot
be summed, this always returns the second parameter value.
// String animations do not support additive behavior.
throw new Error();
| 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.
StringRefValues refValues = new StringRefValues();
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 StringSegment[nSegments];
// Build the first segment.
refValues.segments[0] = new StringSegment();
refValues.segments[0].start = new String[] {values[0]};
refValues.segments[0].end = new String[] {values[1]};
targetElement.validateTraitNS(anim.traitNamespace,
anim.traitName,
refValues.segments[0].start[0],
anim.getNamespaceURI(),
anim.getLocalName(),
reqTraitNamespace,
reqTraitName);
targetElement.validateTraitNS(anim.traitNamespace,
anim.traitName,
refValues.segments[0].end[0],
anim.getNamespaceURI(),
anim.getLocalName(),
reqTraitNamespace,
reqTraitName);
StringSegment prevSegment = refValues.segments[0];
for (int i = 1; i < nSegments; i++) {
refValues.segments[i] = new StringSegment();
refValues.segments[i].start = prevSegment.end;
refValues.segments[i].end = new String[] {values[i + 1]};
targetElement.validateTraitNS(anim.traitNamespace,
anim.traitName,
refValues.segments[i].end[0],
anim.getNamespaceURI(),
anim.getLocalName(),
reqTraitNamespace,
reqTraitName);
prevSegment = refValues.segments[i];
}
return refValues;
|
|