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

StringSegment

public class StringSegment extends Object implements Segment
Represents String segment in an animation.
version
$Id: StringSegment.java,v 1.3 2006/06/29 10:47:34 ln156897 Exp $

Fields Summary
String[]
start
The segment's begin value.
String[]
end
The segment's end value.
Constructors Summary
Methods Summary
public voidaddToEnd(java.lang.Object[] by)
Adds the input value to this Segment's end value.

param
by the value to add. Throws IllegalArgumentException if this Segment type is not additive or if the input value is incompatible (e.g., different number of components or different number of dimensions on a component).

        throw new IllegalArgumentException();
    
public voidcollapse(Segment seg, Animation anim)
Collapses this segment with the one passed as a parameter. Note that if the input segment is not of the same class as this one, an IllegalArgumentException is thrown. The method also throws an exception if the input segment's end does not have the same number of components as this segment's end. After this method is called, this segment's end value is the one of the input seg parameter.

param
seg the Segment to collapse with this one.
param
anim the Animation this segment is part of.

        StringSegment mseg = (StringSegment) seg;
        if (mseg.end.length != end.length) {
            throw new IllegalArgumentException();
        }

        end = mseg.end;
    
public java.lang.String[]compute(float p)
Computes an interpolated value for the given penetration in the segment.

param
p the segment penetration. Should be in the [0, 1] range.
return
the interpolated value.

        if (p == 1) {
            return end;
        } else {
            return start;
        }
    
public java.lang.Object[]getEnd()

return
set end value.

        return end;
    
public final floatgetLength()
Computes this segment's length. This is always the value '1' for a string segment.

        return 1;
    
public java.lang.Object[]getStart()

return
the start value.

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

    
public booleanisAdditive()

return
true if this segment type supports addition. false otherwise.

        return false;
    
public voidsetStart(java.lang.Object[] newStart)
Sets the start value.

param
newStart the new segment start value.

        start = (String[]) newStart;
    
public voidsetZeroStart()
Sets the start value to its notion of 'zero'. For a StringSegment, a 'zero' start means empty strings on all components.

        for (int i = 0; i < start.length; i++) {
            start[i] = "";
        }
    
public java.lang.StringtoString()
Debug helper.

        StringBuffer sb = new StringBuffer();
        sb.append("StringSegment[");
        if (start == null) {
            sb.append("null");
        } else {
            sb.append("start[" + start.length + "] : {");
            for (int ci = 0; ci < start.length; ci++) {
                sb.append("\"" + start[ci] + "\"");
                if (ci < start.length - 1) {
                    sb.append(",");
                }
            }
            sb.append("}");
        }

        if (end == null) {
            sb.append(" null");
        } else {
            sb.append(" end[" + end.length + "] : {");
            for (int ci = 0; ci < end.length; ci++) {
                sb.append("\"" + end[ci] + "\"");
                if (ci < end.length - 1) {
                    sb.append(",");
                }
            }
            sb.append("}");
        }


        return sb.toString();