String str = st.nextToken();
String type = str.trim();
String value;
if(st.hasMoreTokens()) {
value = st.nextToken().trim();
SVGTransformImpl transform = new SVGTransformImpl();
if(type.equals("translate")) {
float xlen = 0;
float ylen = 0;
int pos = value.indexOf(",");
if(pos != -1) {
SVGLengthImpl length;
length = new SVGLengthImpl();
length.setValueAsString(value.substring(0, pos).trim());
xlen = length.getValue();
length = new SVGLengthImpl();
length.setValueAsString(value.substring(pos + 1, value.length()).trim());
ylen = length.getValue();
}
transform.setTranslate(xlen, ylen);
list.addElement(transform);
} else if(type.equals("skewX")) {
// SVGAngleImpl angle = new SVGAngleImpl();
// angle.setValueAsString(value);
float angle = Float.valueOf(value).floatValue();
transform.setSkewX(angle);
list.addElement(transform);
} else if(type.equals("skewY")) {
// SVGAngleImpl angle = new SVGAngleImpl();
// angle.setValueAsString(value);
float angle = Float.valueOf(value).floatValue();
transform.setSkewY(angle);
list.addElement(transform);
} else if(type.equals("scale")) {
float xlen = 0;
float ylen = 0;
int pos = value.indexOf(",");
if(pos != -1) {
// try {
xlen = Float.valueOf(value.substring(0, pos).trim()).floatValue();
// } catch(Exception e) {
// }
// try {
ylen = Float.valueOf(value.substring(pos + 1, value.length()).trim()).floatValue();
// } catch(Exception e) {
// }
}
transform.setScale(xlen, ylen);
list.addElement(transform);
} else if(type.equals("rotate")) {
// SVGAngleImpl angle = new SVGAngleImpl();
// angle.setValueAsString(value);
float angle = Float.valueOf(value).floatValue();
transform.setRotate(angle, 0, 0);
list.addElement(transform);
} else if(type.equals("matrix")) {
SVGMatrixImpl matrix = new SVGMatrixImpl();
StringTokenizer mt = new StringTokenizer(value, " ,\r\n-", true);
// need to handle negatives
String tok;
boolean neg = false;
if(mt.hasMoreTokens()) {
tok = mt.nextToken();
while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
if(tok.equals("-")) {
neg = true;
}
if(!mt.hasMoreTokens())
break;
tok = mt.nextToken();
}
float floatVal = Float.valueOf(tok).floatValue();
if(neg)
floatVal = -floatVal;
matrix.setA(floatVal);
}
if(mt.hasMoreTokens()) {
tok = mt.nextToken();
while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
if(tok.equals("-")) {
neg = true;
}
if(!mt.hasMoreTokens())
break;
tok = mt.nextToken();
}
float floatVal = Float.valueOf(tok).floatValue();
if(neg)
floatVal = -floatVal;
matrix.setB(floatVal);
}
if(mt.hasMoreTokens()) {
tok = mt.nextToken();
while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
if(tok.equals("-")) {
neg = true;
}
if(!mt.hasMoreTokens())
break;
tok = mt.nextToken();
}
float floatVal = Float.valueOf(tok).floatValue();
if(neg)
floatVal = -floatVal;
matrix.setC(floatVal);
}
if(mt.hasMoreTokens()) {
tok = mt.nextToken();
while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
if(tok.equals("-")) {
neg = true;
}
if(!mt.hasMoreTokens())
break;
tok = mt.nextToken();
}
float floatVal = Float.valueOf(tok).floatValue();
if(neg)
floatVal = -floatVal;
matrix.setD(floatVal);
}
SVGLengthImpl length;
if(mt.hasMoreTokens()) {
tok = mt.nextToken();
while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
if(tok.equals("-")) {
neg = true;
}
if(!mt.hasMoreTokens())
break;
tok = mt.nextToken();
}
float floatVal = Float.valueOf(tok).floatValue();
if(neg)
floatVal = -floatVal;
// if(neg)
// tok = "-" + tok;
// length = new SVGLengthImpl();
// length.setValueAsString(tok);
matrix.setE(floatVal);
}
if(mt.hasMoreTokens()) {
tok = mt.nextToken();
while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
if(tok.equals("-")) {
neg = true;
}
if(!mt.hasMoreTokens())
break;
tok = mt.nextToken();
}
float floatVal = Float.valueOf(tok).floatValue();
if(neg)
floatVal = -floatVal;
// if(neg)
// tok = "-" + tok;
// length = new SVGLengthImpl();
// length.setValueAsString(tok);
matrix.setF(floatVal);
}
transform.setMatrix(matrix);
list.addElement(transform);
} else {
MessageHandler.errorln("WARNING: Unknown Transform type : " + type);
}
}