}
@Test
public void testSetTransformation() {
SVGTransform t = new SVGTransform();
SVGMatrix m;
try {
t.setTransformation(null);
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation(""); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("iueozi"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
t.setTransformation("\n \t translate ( 2\n \n\t 4 ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_TRANSLATE);
assertTrue(t.isTranslation());
assertEquals(t.getTX(), 2., 0.0001);
assertEquals(t.getTY(), 4., 0.0001);
t.setTransformation("\n \t translate ( 2\n \n\t , 4 ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_TRANSLATE);
assertTrue(t.isTranslation());
assertEquals(t.getTX(), 2., 0.0001);
assertEquals(t.getTY(), 4., 0.0001);
t.setTransformation("\n \t translate ( 2\n \n\t ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_TRANSLATE);
assertTrue(t.isTranslation());
assertEquals(t.getTX(), 2., 0.0001);
assertEquals(t.getTY(), 2., 0.0001);
try {
t.setTransformation("\n \t translate"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t translate("); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t translate(ds"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t translate(2 "); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t translate(2 ,"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t translate(2 , ds"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t translate(2 , 2"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
t.setTransformation("\n \t scale ( 2\n \n\t 4 ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_SCALE);
assertTrue(t.isScale());
assertEquals(t.getXScaleFactor(), 2., 0.0001);
assertEquals(t.getYScaleFactor(), 4., 0.0001);
t.setTransformation("\n \t scale ( 2\n \n\t , 4 ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_SCALE);
assertTrue(t.isScale());
assertEquals(t.getXScaleFactor(), 2., 0.0001);
assertEquals(t.getYScaleFactor(), 4., 0.0001);
t.setTransformation("\n \t scale ( 2\n \n\t ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_SCALE);
assertTrue(t.isScale());
assertEquals(t.getXScaleFactor(), 2., 0.0001);
assertEquals(t.getYScaleFactor(), 2., 0.0001);
try {
t.setTransformation("\n \t scale"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t scale("); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t scale(ds"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t scale(2 "); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t scale(2 ,"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t scale(2 , ds"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t scale(2 , 2"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
t.setTransformation("\n \t matrix ( 2\n \n\t 4 \t 5 \n 6 7 8 ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_MATRIX);
m = t.getMatrix();
assertEquals(m.getA(), 2., 0.0001);
assertEquals(m.getB(), 4., 0.0001);
assertEquals(m.getC(), 5., 0.0001);
assertEquals(m.getD(), 6., 0.0001);
assertEquals(m.getE(), 7., 0.0001);
assertEquals(m.getF(), 8., 0.0001);
t.setTransformation("\n \t matrix ( 2 ,\n \n\t 4 \t 5 ,\n 6 7 , 8 ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_MATRIX);
m = t.getMatrix();
assertEquals(m.getA(), 2., 0.0001);
assertEquals(m.getB(), 4., 0.0001);
assertEquals(m.getC(), 5., 0.0001);
assertEquals(m.getD(), 6., 0.0001);
assertEquals(m.getE(), 7., 0.0001);
assertEquals(m.getF(), 8., 0.0001);
try {
t.setTransformation("\n \t matrix"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t matrix("); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t matrix(ds"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t matrix(2 "); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t matrix(2 ,"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t matrix(2 , ds"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t matrix(2 , 2"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t matrix(2 , 2 3"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t matrix(2 , 2 3 5"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t matrix(2 , 2 3 , 5 7"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t matrix(2 , 2 3 5 7 9"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
t.setTransformation("\n \t skewX ( 2\n \n\t ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_SKEWX);
assertTrue(t.isXSkew());
assertEquals(t.getXSkewAngle(), 2., 0.0001);
try {
t.setTransformation("\n \t skewX"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t skewX("); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t skewX(ds"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t skewX(2 "); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
t.setTransformation("\n \t skewY ( 3\n \n\t ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_SKEWY);
assertTrue(t.isYSkew());
assertEquals(t.getYSkewAngle(), 3., 0.0001);
try {
t.setTransformation("\n \t skewY"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t skewY("); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t skewY(ds"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t skewY(2 "); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
t.setTransformation("\n \t rotate ( 3\n \n\t ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_ROTATE);
assertTrue(t.isRotation());
assertEquals(t.getRotationAngle(), 3., 0.0001);
t.setTransformation("\n \t rotate ( 1\n \n\t , 4 \n 6 \n \t ) \n"); //$NON-NLS-1$
assertEquals(t.getType(), SVGTransform.SVG_TRANSFORM_ROTATE);
assertTrue(t.isRotation());
assertEquals(t.getRotationAngle(), 1., 0.0001);
m = t.getMatrix();
try {
t.setTransformation("\n \t rotate"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t rotate("); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t rotate(ds"); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t rotate(2 "); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
try {
t.setTransformation("\n \t rotate(2 4 "); //$NON-NLS-1$
fail();
}
catch(IllegalArgumentException e){ /**/ }
}