FileDocCategorySizeDatePackage
StringRefValues.javaAPI DocphoneME MR2 API (J2ME)4709Wed May 02 18:00:34 BST 2007com.sun.perseus.model

StringRefValues

public class StringRefValues extends Object implements RefValues
version
$Id: StringRefValues.java,v 1.2 2006/04/21 06:38:51 st125089 Exp $

Fields Summary
StringSegment[]
segments
The RefValues StringSegments
float[]
length
Used to store the length of this RefValues
Constructors Summary
Methods Summary
public java.lang.Object[]compute(int si, float p)
Computes the value for the input interpolated values. There should be as many entries in the return array as there are components in the RefValues.

param
si the current segment index
param
p the current penetration
param
the interpolated value.

        return segments[si].compute(p);
    
public intgetComponents()
StringRefValues only have one component.

return
the number of string components

        return segments[0].start.length;
    
public floatgetLength()
Computes the length of the RefValues. This is meant for paced timing computation.

return
the length between the various ref values. For strings, we consider that each segment is of length 1, so this simply returns the number of segments.

        return segments.length;
    
public floatgetLength(int si)
Computes the length of segment at index si.

param
si the segment index.

        // The length of a StringSegment is _always_ 1.
        return 1;
    
public SegmentgetSegment(int i)

param
i requested segment index.
return
Segment at index i

        return segments[i];
    
public intgetSegments()

return
the number of segments in refValues

        return segments.length;
    
public voidinitialize()
Should be called after the RefValue's configuration is complete to give the implementation a chance to initialize internal data and cache values.

        // Initialize segments.
        final int ns = segments.length;

        // Initialize length cache
        length = new float[segments[0].start.length];
        
        // The length of a StringSegment is 1, in all cases.
        for (int ci = 0; ci < length.length; ci++) {
            length[ci] = segments.length;
        }
    
public voidmakeDiscrete()
Adds a new time segment so accomodate for discreet behavior. If there is only one segment for discreet animations, the last value is never shown. To accomodate for that, this method should add a segment to the RefValues so that the last animation value is shown during the last value interval of a discreet animation.

        StringSegment[] tmpSegments = new StringSegment[segments.length + 1];
        System.arraycopy(segments, 0, tmpSegments, 0, segments.length);
        StringSegment lastSeg = segments[segments.length - 1];
        StringSegment newSeg = new StringSegment();
        newSeg.start = lastSeg.end;
        newSeg.end = lastSeg.end;
        tmpSegments[tmpSegments.length - 1] = newSeg;
        segments = tmpSegments;        
    
public java.lang.StringtoString()
Debug helper.

        StringBuffer sb = new StringBuffer();
        sb.append("StringRefValues[" + getSegments() + "]\n");
        for (int si = 0; si < getSegments(); si++) {
            Segment seg = getSegment(si);
            sb.append("seg[" + si + "] : " + seg.toString() + "\n");
        }
        return sb.toString();