Class TopScroll

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--TopScroll

public class TopScroll
extends java.applet.Applet
implements java.lang.Runnable

Scrolling Applet, you can put a top scroll object directly onto a web page, its a standalone object. It will scroll text from right to left and add a distortion effect to the page. The speed is adjustable from 1 very slow thru 10 very fast (4 is default) using the SPEED parameter in the HTML file. Set the Text filename and Image Filename parameters from your HTML page. The Text parmeter is TEXTFILE and should be set to the file name relative to the html file's path. The Image parameter is IMAGENAME and should be a .gif file of 256 colours or less, again this is relative to the html file. The font must be fixed width and height. If the font width and height are not 20 pixels per letter, you must set these too, the parameters are FONTWIDTH and FONTHEIGHT. ALWAYS make the width divisible by the font width, and the height is twice the size of the letters.

See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
TopScroll()
          TopScroll constructor, empty, actually uses start for thread creation.
 
Method Summary
protected  void generateDistortion()
          generates the distortion effect that is rolled across the scrolling text, this is calculated once at the start, and held in memory.
 java.lang.String getAppletInfo()
          Returns the applet information
protected  void getIndexColourData(java.awt.Image img, byte[][] byPixels, byte[] byReds, byte[] byGreens, byte[] byBlues)
          converts an image containing the letters into a 256 colour version, thats split up by letter rather than by line.
protected  int GetNextCharIndex(char letter)
          Given a character value, this function will convert this value into an index position into the image file containing the chars
 void init()
          initialises the scroller and sets up the instance data.
 void paint(java.awt.Graphics g)
          draws the current buffer that was created by the last call to the scrollit() function.
protected  java.lang.String readTextFile(java.lang.String name)
           
 void run()
          just stays in a loop moving the scroller to its new location, then doing a repaint and waiting 1/60th of a second before repeating.
protected  void scrollit()
          after scrolling the contents by calling StepScroll the scrollit function places the distortion effect onto the current image.
 void start()
          create a new thread for our Applet to run in
protected  void StepScroll()
          move the scroller one position, if the scroller has moved by one full letter position, then a new letter is added and the smooth scroll offset is reset.
 void stop()
          stop our applets thread, its done!
 void update(java.awt.Graphics g)
          We handle update so that drawing is smoother and doesnt flash, this function directly calls paint(Graphics g);
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TopScroll

public TopScroll()
TopScroll constructor, empty, actually uses start for thread creation.
Method Detail

getAppletInfo

public java.lang.String getAppletInfo()
Returns the applet information
Returns:
Applet information string
Overrides:
getAppletInfo in class java.applet.Applet

readTextFile

protected java.lang.String readTextFile(java.lang.String name)
                                 throws java.lang.Exception

init

public void init()
initialises the scroller and sets up the instance data.
Overrides:
init in class java.applet.Applet

update

public void update(java.awt.Graphics g)
We handle update so that drawing is smoother and doesnt flash, this function directly calls paint(Graphics g);
Parameters:
g - the awt graphics device
Overrides:
update in class java.awt.Container

paint

public void paint(java.awt.Graphics g)
draws the current buffer that was created by the last call to the scrollit() function.
Parameters:
g - the awt graphics device.
Overrides:
paint in class java.awt.Container

scrollit

protected void scrollit()
after scrolling the contents by calling StepScroll the scrollit function places the distortion effect onto the current image.

start

public void start()
create a new thread for our Applet to run in
Overrides:
start in class java.applet.Applet

stop

public void stop()
stop our applets thread, its done!
Overrides:
stop in class java.applet.Applet

run

public void run()
just stays in a loop moving the scroller to its new location, then doing a repaint and waiting 1/60th of a second before repeating.
Specified by:
run in interface java.lang.Runnable

GetNextCharIndex

protected int GetNextCharIndex(char letter)
Given a character value, this function will convert this value into an index position into the image file containing the chars
Parameters:
letter - the letter to be converted
Returns:
the index into the image file.

StepScroll

protected void StepScroll()
move the scroller one position, if the scroller has moved by one full letter position, then a new letter is added and the smooth scroll offset is reset.

getIndexColourData

protected void getIndexColourData(java.awt.Image img,
                                  byte[][] byPixels,
                                  byte[] byReds,
                                  byte[] byGreens,
                                  byte[] byBlues)
converts an image containing the letters into a 256 colour version, thats split up by letter rather than by line.
Parameters:
img - the image file to be converted
byPixels - the pixel array where each image will be stored
byReds - the color index for reds
byGreens - the color index for greens
byBlues - the color index for blues

generateDistortion

protected void generateDistortion()
generates the distortion effect that is rolled across the scrolling text, this is calculated once at the start, and held in memory. the distortion is stored as an array of offsets into a memory representation of an image.


1