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

FloatRefValues

public class FloatRefValues extends Object implements RefValues
version
$Id: FloatRefValues.java,v 1.3 2006/04/21 06:37:00 st125089 Exp $

Fields Summary
FloatSegment[]
segments
This RefValues FloatSegments.
float[]
w
A working array to return a value from the compute method.
float
length
Used to store the length of this RefValues
float[]
segLength
Used to store the length of each segment.
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

        segments[si].compute(p, w);
        return w;
    
public intgetComponents()
FloatRefValues only have one component. This returns the number of components in the start value of the first segment.

return
the number of components. There is an array of float for each component.

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

return
the total length of this FloatRefValues. The distance is defined as the average distance between r

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

param
si the segment index.

        return segLength[si];
    
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 the working buffer
        final int nc = segments[0].start.length;

        w = new float[nc][];

        final int ns = segments.length;

        // Initialize the segments.
        for (int si = 0; si < ns; si++) {
            segments[si].initialize();
        }

        segLength = new float[ns];

        // The length of a FloatSegment, is the average distance between each
        // component.
        for (int ci = 0; ci < nc; ci++) {
            w[ci] = new float[segments[0].start[ci].length];
        }

        length = 0;
        for (int si = 0; si < ns; si++) {
            segLength[si] = segments[si].getLength();
            length += segLength[si];
        }
    
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.

        FloatSegment[] tmpSegments = new FloatSegment[segments.length + 1];
        System.arraycopy(segments, 0, tmpSegments, 0, segments.length);
        FloatSegment lastSeg = segments[segments.length - 1];
        FloatSegment newSeg = new FloatSegment();
        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("FloatRefValues[" + getSegments() + "]\n");
        for (int si = 0; si < getSegments(); si++) {
            Segment seg = getSegment(si);
            sb.append("seg[" + si + "] : " + seg.toString() + "\n");
        }
        return sb.toString();