2010-05-19 45 views
0

使用Graphics2D绘图时使用AffineTransform。在绘制它之前,我使用它来转换Shape。 rx和ry应该是旋转的,但是在绘制图形时剪切不会旋转。我如何执行轮换?我尝试使用默认的构造函数,然后调用旋转,缩放和平移,但形状看起来不像他们应该看起来。如何设置AffineTransform旋转而不是剪切?

transform = new AffineTransform(sx, rx, ry, sy, tx, ty); 
transform.createTransformedShape(shape); // Where shape is a GeneralPath instance 

回答

0

可以使用旋转方法一样

transform = g2d.getTransform(); 
transform.rotate(Math.toRadians(angleInDegree), pivotX, pivotY); 
g2d.setTransform(transform);  
// draw anything and it will be rotated based on rotate method 
transform.rotate(Math.toRadians(0), pivotX, pivotY); 
g2d.setTransform(transform); // now further drawing will no be drawn rotated