Date post: | 27-Nov-2014 |
Category: |
Documents |
Upload: | sumant-diwakar |
View: | 318 times |
Download: | 7 times |
A JAVA TOPIC
LAVATRON
Lavatron
Lavatron is a Space arena lightbulb display. David LaVallee, the author of the many
different applet had written the lavatron. The history of lavatron begins way back in 1974. In 1992 , Lavallee wrote the first version of
Lavatron in objective C and Postscript. Finally in 1995, Lavatron was written again from scratch to run under java, and it has
undergone several performance tweaks and iterations since.
How Lavatron works?
Lavatron is able to present interesting image on screen because of a small trick that it
employs. And its side effect allow the applet load very quickly. The reason it loads so
quickly is that there is not much data transmitted over the net. The source image is JPEG image that is 64 times smaller than the
displayed image. Each pixel in the source image is scaled up to an 8*8 pixel square. Lavatron paints so fast because it doesn’t have to repaint what it has already drawn.
The Source code
Lavatron starts by initializing data, which includes loading the source image and creating the column of bulb images. The last stage of initialization is painting the offscreen image full of dimmed lightbulbs to start the display with a clean image.
The Applet tagthe source code starts with the Applet tag.
<applet code=Lavatron.class width=560 height=130>
<param name=“img” value = “s.jpg”> </applet>
Lavatron.javathe main applet is small about 100 lines of java source code.
init()the init() method first determines the size of the applet by using getSize().
createBlubs()the createBulbs() method is helper to init().
Color()the color() method returns the color of the pixel at the x, y position in the source image as a color object.
Update()Lavatron overrides update() to do nothing.
Paint()the paint() method is quite simple.
Start(), stop(), run()when the applet starts, it creates and start a new Thread called t. this thread will call run() method. When the stop() method is called, stopFlag is set to true.
SUMANT DIWAKAR
Thank you