FileDocCategorySizeDatePackage
ViewBoxParser.javaAPI DocphoneME MR2 API (J2ME)2635Wed May 02 18:00:36 BST 2007com.sun.perseus.parser

ViewBoxParser

public class ViewBoxParser extends NumberParser
The ViewBoxParser class converts attributes conforming to the SVG viewbox syntax into an array of four floating point values corresponding to the input string.
version
$Id: ViewBoxParser.java,v 1.3 2006/04/21 06:40:44 st125089 Exp $

Fields Summary
Constructors Summary
Methods Summary
public float[][]parseViewBox(java.lang.String value)

param
value the string containing the viewbox specification
return
an array of four float corresponding to the input viewbox specification. The method throws an IllegalArgumentException if the viewbox string is malformed.

        setString(value);
        current = read();

        if (current == -1) {
            return null;
        }

        float[][] vb = new float[3][];
        vb[0] = new float[2];
        vb[1] = new float[1];
        vb[2] = new float[1];
        skipSpaces();
        vb[0][0] = parseNumber();
        skipCommaSpaces();
        vb[0][1] = parseNumber();
        skipCommaSpaces();
        vb[1][0] = parseNumber();
        skipCommaSpaces();
        vb[2][0] = parseNumber();
        skipSpaces();
        if (current != -1) {
            throw new IllegalArgumentException();
        }

        // A negative value for <width> or <height> is an error
        if (vb[1][0] < 0 || vb[2][0] < 0) {
            throw new IllegalArgumentException();
        }
      
        return vb;