@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();
}