1

I use SVG Salamander to display and manipulate SVG images in Java. I managed to change fill, stroke or text of elements and display the changes.

Now I want to rotate an element. So I tried to manipulate the transformation matrix:

SVGElement e = diagram.getElement("path4150");
System.out.println(e.getPresAbsolute("transform").getStringValue());
StyleAttribute t = e.getPresAbsolute("transform");
double[] d = t.getDoubleList();
d[0] = -0.39394618;
d[1] = -0.91913346;
d[2] = 0.91913357;
d[3] = -0.39394618;
d[4] = -429.42706;
d[5] = 1513.019;
t.setStringValue("matrix(" + Joiner.on(",").join(Doubles.asList(d)) + ")");
System.out.println(e.getPresAbsolute("transform").getStringValue());
diagram.render(graphics);

Output:

matrix(0.87615346,0.48203226,-0.48203232,0.87615346,468.09264,-25.725313) matrix(-0.39394618,-0.91913346,0.91913357,-0.39394618,-429.42706,1513.019)

As I can see in the output, the matrix is changed. But the element is not rotating in the picture.

4

1 回答 1

1

我刚刚开始了解这一点 - 但 SVGSalamander 文档提到需要在已修改元素(或者可能只是根元素?)的容器上调用 updateTime(),以强制它重绘。如果您不使用动画,那么任何值(0.0?)作为 updateTime() 的参数都可以......

于 2016-03-22T04:25:14.167 回答