import java.applet.*; import java.awt.*; import java.net.*; public class Beh extends Thread { public static int MAXX = 200, MAXY = 200, PAUSE = 5; Graphics g, os; Image offscreen; Applet app; Rotate rotate; Item item; public Beh(Applet ap) { app = ap; MAXX = new Integer(app.getParameter("MAXX")).intValue(); MAXY = new Integer(app.getParameter("MAXY")).intValue(); // app.resize(MAXX, MAXY); PAUSE = new Integer(app.getParameter("PAUSE")).intValue(); int pocet = new Integer(app.getParameter("POC")).intValue(); if (pocet < 1) pocet = 1; int rtxt = new Integer(app.getParameter("RTXT")).intValue(); int rmax = new Integer(app.getParameter("RMAX")).intValue(); int rmin = new Integer(app.getParameter("RMIN")).intValue(); int color = new Integer(app.getParameter("COLOR")).intValue(); double a = new Double(app.getParameter("A")).doubleValue(); int w = new Integer(app.getParameter("TEXTWIDTH")).intValue(); int tr = new Integer(app.getParameter("TXTR")).intValue(); int tg = new Integer(app.getParameter("TXTG")).intValue(); int tb = new Integer(app.getParameter("TXTB")).intValue(); int i; for (i = 0; app.getParameter("Text"+i) != null; i ++) {} String []s = new String[i]; URL []u = new URL[i]; for (i = 0; i < s.length; i ++) { s[i] = app.getParameter("TEXT"+i); } for (i = 0; i < u.length; i ++) { try { u[i] = new URL(app.getDocumentBase(), app.getParameter("URL"+i)); } catch (MalformedURLException e) { System.out.println("Špatná URL adresa: " + u[i]); } } g = app.getGraphics(); offscreen = app.createImage(MAXX, MAXY); os = offscreen.getGraphics(); rotate = new Rotate(pocet, MAXX/2, MAXY/2, rmin, rmax, color, a, os); item = new Item(s, u, MAXX/2, MAXY/2, color, new Color(tr, tg, tb), w, rtxt, os); } public void kresli() { os.setColor(new Color(0, 0, 0)); os.fillRect(0, 0, MAXX, MAXY); item.kresli(); rotate.kresli(); g.drawImage(offscreen, 0, 0, app); } public void run() { while (true) { kresli(); try { Thread.sleep(PAUSE); } catch(InterruptedException e) { System.out.println("Preruseni behu"); } } } public void setActive(int x, int y) { item.setActive(x, y); } public void setDocument() { URL url = item.getUrl(); if (url != null) { AppletContext ac = app.getAppletContext(); ac.showDocument(url); } } }