我所看到的例子都是“障眼法”
只是旋转了画笔,图形没有真正旋转!有人知道知道旋转图形的方法吗?
比如Rectangle2D.Double r = new Rectangle2D.Double(30, 50, 100, 60);
怎么旋转这个r?

解决方案 »

  1.   

    用AffineTransform.getRotateInstance的话
    会把整个画布搞乱的!
    旋转过后就什么东西都是旋转后的了!
    鼠标位置都不对了!
      

  2.   

    只要在画的时候调用Graphics2D.rotate()方法就可以了
      

  3.   

    参考这两个方法
    rotate
    public abstract void rotate(double theta)Concatenates the current Graphics2D Transform with a rotation transform. Subsequent rendering is rotated by the specified radians relative to the previous origin. This is equivalent to calling transform(R), where R is an AffineTransform represented by the following matrix: 
    [   cos(theta)    -sin(theta)    0   ]
    [   sin(theta)     cos(theta)    0   ]
    [       0              0         1   ]
     Rotating with a positive angle theta rotates points on the positive x axis toward the positive y axis. Parameters:
    theta - the angle of rotation in radians--------------------------------------------------------------------------------rotate
    public abstract void rotate(double theta,
                                double x,
                                double y)Concatenates the current Graphics2D Transform with a translated rotation transform. Subsequent rendering is transformed by a transform which is constructed by translating to the specified location, rotating by the specified radians, and translating back by the same amount as the original translation. This is equivalent to the following sequence of calls: 
    translate(x, y);
    rotate(theta);
    translate(-x, -y);
     Rotating with a positive angle theta rotates points on the positive x axis toward the positive y axis. Parameters:
    theta - the angle of rotation in radians
    x - the x coordinate of the origin of the rotation
    y - the y coordinate of the origin of the rotation
      

  4.   

    abstract  void rotate(double theta) 
              Concatenates the current Graphics2D Transform with a rotation transform. 
    abstract  void rotate(double theta, double x, double y) 
              Concatenates the current Graphics2D Transform with a translated rotation transform.