AlineTransform 的应用

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
public class MyCoordinates extends Frame implements ActionListener {
Button shun=new Button("顺时针");
Button ni=new Button("逆时针");
Graphics2D g;
int tate;
public MyCoordinates(String title){
super(title);
setLayout(new FlowLayout());
add(shun);add(ni);
shun.addActionListener(this);ni.addActionListener(this);
}//end gouzao
public void actionPerformed(ActionEvent e){
if(e.getSource()==shun)
tate=15;
else if(e.getSource()==ni)
tate=-15;
repaint();
}//end actionPerformed
public void paint(Graphics g3){
if(g==null)
{
g=(Graphics2D)(Graphics2D)getGraphics();
g.translate(150,150);
}
g.rotate(Math.toRadians(tate));
g.draw(new Line2D.Float(-150, 0, 150, 0));
g.draw(new Line2D.Float(0, -150, 0, 150));
g.fill(new Ellipse2D.Float(50, 50, 20, 20));
}
public static void main(String[] args) {
Frame mc=new MyCoordinates("坐标轴的旋转");
mc.setSize(500,500);
mc.setVisible(true);

}

}

你可能感兴趣的:(transform)