import java.applet.*; import java.awt.*; import java.awt.event.*; import java.net.*; public class tinyFader extends Applet implements Runnable { // Threaded application int spacing=12, // spacing, between lines delay=50, // delay, controls speed of trans. step=4, // step, controls speed of trans. XPos=5, // XPos, indent YPos=12, // YPos, vertical starting point current=1, // Data set (or mode) direction=1, // Black to white or vice-versa color=255; // color String[] Line = new String[24]; // Lines, to be displayed, 24 max Font outFont; // Output font (if passed) boolean customFont = false; // Flag, is there a custom font? Graphics offGrfx; // Double buffering to eliminate Image offImage; // frame flicker Color background; Thread runner; public void init() { /**** Get attributes, if available ****/ String bgRed$ = getParameter("BGRED"); String bgGreen$ = getParameter("BGGREEN"); String bgBlue$ = getParameter("BGBLUE"); String spacing$ = getParameter("SPACING"); String delay$ = getParameter("DELAY"); String XPos$ = getParameter("XPOS"); String YPos$ = getParameter("YPOS"); String fontName$ = getParameter("FONTNAME"); String fontSize$ = getParameter("FONTSIZE"); /**** Data lines, set 1 ****/ Line[0] = getParameter("LINE1"); Line[1] = getParameter("LINE2"); Line[2] = getParameter("LINE3"); Line[3] = getParameter("LINE4"); Line[4] = getParameter("LINE5"); Line[5] = getParameter("LINE6"); Line[6] = getParameter("LINE7"); Line[7] = getParameter("LINE8"); Line[8] = getParameter("LINE9"); Line[9] = getParameter("LINE10"); Line[10] = getParameter("LINE11"); Line[11] = getParameter("LINE12"); /**** Data lines, set 2 ****/ Line[12] = getParameter("LINE13"); Line[13] = getParameter("LINE14"); Line[14] = getParameter("LINE15"); Line[15] = getParameter("LINE16"); Line[16] = getParameter("LINE17"); Line[17] = getParameter("LINE18"); Line[18] = getParameter("LINE19"); Line[19] = getParameter("LINE20"); Line[20] = getParameter("LINE21"); Line[21] = getParameter("LINE22"); Line[22] = getParameter("LINE23"); Line[23] = getParameter("LINE24"); /**** Setting Font ****/ if ((fontSize$ != null) && (fontName$ !=null)) { int size = Integer.parseInt(fontSize$); outFont = new Font(fontName$, Font.PLAIN, size); customFont = true; } /**** Convert BG color values ****/ int BGred = 255; if (bgRed$ != null) BGred = Integer.parseInt(bgRed$); int BGgreen = 255; if (bgGreen$ != null) BGgreen = Integer.parseInt(bgGreen$); int BGblue = 255; if (bgBlue$ != null) BGblue = Integer.parseInt(bgBlue$); /**** Convert attribute values ****/ if (spacing$ != null) spacing = Integer.parseInt(spacing$); if (delay$ != null) delay = Integer.parseInt(delay$); if (XPos$ != null) XPos = Integer.parseInt(XPos$); if (YPos$ != null) YPos = Integer.parseInt(YPos$); /**** Set background color ****/ background = new Color(BGred, BGgreen, BGblue); setBackground(background); offImage = createImage(size().width, size().height); offGrfx = offImage.getGraphics(); } public void paint(Graphics screen) { Color nColor = new Color(color, color, color); if (current==1) { offGrfx.setColor(background); offGrfx.fillRect(0, 0, size().width, size().height); offGrfx.setColor(nColor); try { offGrfx.setFont(outFont); } catch (NullPointerException e) {} for (int i=0; i<12; i++) offGrfx.drawString(Line[i], XPos, YPos + (i * spacing)); screen.drawImage(offImage, 0, 0, this); } else { offGrfx.setColor(background); offGrfx.fillRect(0, 0, size().width, size().height); offGrfx.setColor(nColor); try { offGrfx.setFont(outFont); } catch (NullPointerException e) {} for (int i=12; i<24; i++) offGrfx.drawString(Line[i], XPos, YPos + ((i-12) * spacing)); screen.drawImage(offImage, 0, 0, this); } } public void update(Graphics screen) { paint(screen); } public void start() { if (runner == null) { runner = new Thread(this); runner.start(); } } public void run() { while (true) { repaint(); if (direction == 1) { color--; if (color < 0) { color = 0; direction = 0; } } else { color++; if (color > 255) { color = 255; direction = 1; current = current * -1; } } try { Thread.sleep(delay); } catch (InterruptedException e) { } } } public void stop() { if (runner != null) { runner.stop(); runner = null; } } }