Java Site MenuProgramming SectionsMiscellaneous StuffConsultancy ServicesDownloadsFeedback Form

[Previous] [Home]

This ticker board was my first applet and almost my first bit of Java. It takes a string passed as a parameter from the HTML file and converts it into a dot-encoded font then scrolls this, one dot or light wide at a time, across a bar of a parameterised number of lights wide. The size of the lights, the color of the on and off lights are also controllable via HTML parameters. Here is the tag I used for the copy above:

    <APPLET CODE=TickerTape.class CODEBASE=../code WIDTH=300 HEIGHT=16>
      <PARAM name=fg value=#ffff00>
      <PARAM name=bg value=#000>
      <PARAM name=strips value=150>
      <PARAM name=light_size value=2>
      <PARAM name=string value="TickerTape.class">
    </APPLET>
The applet comprises a number of classes:
  1. DotChar
  2. DotFont
  3. LightStrip
  4. TickerBar
  5. Ticker
  6. WrapApplet
  7. TickerTape
  8. ColorHelper
DotChar
This class holds information on a single character, it's bit pattern, width and height.
DotFont
The font itself is defined by this class. It makes use of an array of DotChar objects to hold the data for the characters. All the usual printable characters are defined.
LightStrip
This class represents a single vertical strip of lights, each light being a rectangle that is either drawn in the background color for a light that is off, or in the foreground color for a light that is on.
TickerBar
This class creates an array of LightStrips and does the work of setting each strip to the correct value in order to display the characters in sequence from right to left.
Ticker
A Runnable class that creates and animates a TickerBar. It can be constructed either as a standalone object, or with a WrapApplet from which it collects the required parameters, foreground and background colors (fg and bg), string to display (string), number of light strips to create (strips) and the size of each light (light_size). The colors can be specified either as hexadecimal #RGB or as one of a limited number of strings.
ColorHelper
This class aids in the decyphering of color specification strings, returning a Color object from either a #RGB value or color name.
WrapApplet
A extension of the Applet class with built-in parameter fetching methods.
TickerTape
The applet class, an extension of WrapApplet. Simply instantiates a Ticker object passing the WrapApplet and starts it.


[Fiendish Home]


Content of this page Copyright © Robert Quince 1996 - 2005.
Site Comments