package haupt;
import horcher.EscapeTaste;
import java.awt.image.BufferedImage;
import leinwand.Leinwand;
public class ScrollHorizontal implements Runnable{
private Steuerung s = null;
private Leinwand lw = null;
private BufferedImage i = null;
int[] iData = null;
int[] iDat = null ;
private int w = 0, h = 0;
public ScrollHorizontal(Steuerung s) {
this.s = s;
i = s.getFlaeche();
lw = s.getLeinwand();
w = i.getWidth();
h = i.getHeight();
iData = new int[(w-1)*h];
iDat = new int[h];
s.resetEnde();
lw.setFocusable(true);
lw.requestFocus();
lw.addKeyListener(new EscapeTaste(s));
new Thread(this).start();
}
public void run() {
int j = 0;
while (j<10 & !s.isEnde()) {
lw.setFocusable(true);
lw.requestFocus();
if (lw.hasFocus()) System.out.println("h-Fokus: Leinwand");
if (s.isEnde()) System.out.print("e");
if (!s.isEnde()) System.out.print("n");
i.getRGB(0, 0 , w-1, h, iData, 0, w-1);
i.getRGB(w-1, 0, 1, h, iDat, 0, 1);
i.setRGB(0, 0, 1, h, iDat, 0, 1);
i.setRGB(1, 0 , w-1, h, iData, 0, w-1);
lw.setLeinwand(i);
lw.paintImmediately(
(int) lw.getLocation().getX(),
(int) lw.getLocation().getY(),
lw.getWidth(),
lw.getHeight());
lw.setFocusable(true);
lw.requestFocus();
if (lw.isFocusOwner()) System.out.println("1");
j++;
try {
Thread.sleep(20);
}
catch(InterruptedException ex){}
}
s.setFlaeche(i);
}
}