public class PixelMapping { public ComplexImage complexImage; public PixelMapping next; public int ox,oy; public boolean allowDrag = true; boolean startAgain = false; public PixelMapping(ComplexImage ci, PixelMapping ne){complexImage=ci;next=ne;} public void setOrigin(int x,int y) { ox=x;oy=y;startAgain = true; if (next!=null) next.setOrigin(x,y); } public boolean morePixels() { //System.out.println("Pixelmapping: morePixels returns :"+startAgain); //return startAgain; if (next!=null) { return next.morePixels(); } else { return startAgain; } } public PixelDesc nextPixel() { if (next==null) { startAgain=false; PixelDesc pd = new PixelDesc(); pd.x = ox; pd.y = oy; pd.amount = 1; // return (new PixelDesc(new PixelOp(),ox,oy,1)); // why doesnt this work?? return(pd); } else { if (startAgain==true) { startAgain=false; next.setOrigin(ox,oy); if (next.morePixels()) return next.nextPixel(); else return null; } else { if (next.morePixels()) return next.nextPixel(); else return null; } } } }