import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.util.*; class RotateCanvas extends Canvas implements Runnable { Image[] img; ActionListener[] al; int countListeners = 0; boolean done = false; int curNum = 0; Color sfondo; public final static int MAX_LISTENERS = 10; public RotateCanvas(Image image, Color sfondo) { super(); img = new Image[4]; this.sfondo = sfondo; this.img[0] = image; al = new ActionListener[MAX_LISTENERS]; Thread t = new Thread(this); t.start(); } public void run() { PixelGrabber pg = new PixelGrabber(img[0], 0, 0, img[0].getWidth(null), img[0].getHeight(null), true); try { pg.grabPixels(); } catch(InterruptedException e) { } int[] pix = (int[]) pg.getPixels(); int[] copy = new int[pix.length]; int w = img[0].getHeight(null); int h = img[0].getWidth(null); int count = 0; for(int col = (w-1); col>=0; col-=1) { for(int riga = 0; riga=0; col-=1) { for(int riga = 0; riga=0; col-=1) { for(int riga = 0; riga= 4) curNum = 0; repaint(); } public void addActionListener(ActionListener listener) throws TooManyListenersException { if(countListeners >= MAX_LISTENERS) throw new TooManyListenersException("Massimo == " + MAX_LISTENERS); else al[countListeners++] = listener; } }