1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
   | public class Rotation extends Operation
{
	//déclaration des paramètres de l'image:
	int w;  // largeur de l'image
	int h;  // hauteur de l'image
 
	//déclaration des composants:
	JPanel jp_opt;
	JPanel jp_rot = new JPanel();
	JButton jb_adm=new JButton("-> horaire");
 
[...]
 
       public BufferedImage rotate_horaire(BufferedImage ic)
	{
 
        w = ic.getWidth();
        h = ic.getHeight();
 
        BufferedImage newImg2= new BufferedImage(h, w, BufferedImage.TYPE_INT_RGB);
    	    BufferedImage newImg = ic;
 
    	    AffineTransform tx = new AffineTransform();
    	    AffineTransform tx2 = new AffineTransform();
    	    tx.rotate((Math.toRadians(90)),(w/2),(h/2));
    	    tx.translate((w-h)/2,(w-h)/2);
    	    AffineTransformOp op = new AffineTransformOp(tx,  AffineTransformOp.TYPE_BILINEAR);
    	    AffineTransformOp op2 = new AffineTransformOp(tx2,  AffineTransformOp.TYPE_BILINEAR);
 
    	    op.filter(newImg,newImg2) ;
    	    op2.filter(newImg2,null) ;
    	    return newImg2;
	}
 
[...]
 
public void actionPerformed(ActionEvent ae){
			JButton jb_presse =(JButton) ae.getSource();
			if (jb_presse == jb_adm)//bouton aiguille d'une montre
			{
			//rotation sens des aiguilles d'une montre (rotate_horaire):
				data.setImageToDisplay(rotate_horaire(data.getImageToDisplay()));
			}
} | 
Partager