ModernJava
http://www.modernminds.com
W aveBanner (Version 1.0)

WaveBanner is a Canvas subclass that can be used to animate a line of text for use as a banner. The animation moves each character in the string of text up and then down in a sequential manner so that the effect is similar to a wave modulating the line of text. Two additional optional effects are also included: an "inverting vertical wipe" effect and character highlighting effect.

The following documentation describes how the WaveBanner canvas class is used. Also available is WaveBannerApplet which can be used to plug the animation directly into a web page. The WaveBannerApplet class is documented separately.
O peration

When loaded, WaveBanner initializes by determining the largest size of the font Helvetica Bold that can be used to draw the entire string of text within the confines of the canvas' boundaries. The class then begins an animation based upon the parameters that were specified. The parameters and their effects are described below.
S ample

No Java Support

If your browser supports Java, you should see a demonstration of the WaveBannerApplet (which uses the canvas WaveBanner) above this text.
C onstructor

Below is the constructor for the canvas class WaveBanner.

public WaveBanner(
  String text, int width, int height,
  Color color1, Color color2,
  Color colorHL, Color colorFrame,
  int waveHeight,
  int cycleMS, int waveMS, int wipeMS
)

The constructor parameters are defined as follows:

String text The text string to display in the banner.

The font size is scaled so that the entire string will fit within the dimensions of the applet. (See also waveHeight below.)
int width The total width of the canvas.
int height The total height of the canvas.
Color color1 The background color.

If the "wipe" effect is enabled (see wipeMS below), then the background color and the foreground color will alternate with each other.
Color color2 The foreground color.

If the "wipe" effect is enabled (see wipeMS below), then the background color and the foreground color will alternate with each other.
Color colorHL Character highlight color for "wave" effect.

If the "wave" effect is enabled (see waveHeight below), and if a color is specified for this parameter (i.e., the parameter is not null), then character highlighting will be performed with the specified color when the character crosses the baseline during animation.
Color colorFrame The highlight color used in a frame around the canvas.

A frame around the canvas area is drawn only if a color is specified for this parameter (i.e., the parameter is not null).
int waveHeight The maximum vertical distance that a character will travel during the "wave" animation.

This value will also affect the size of the font as the font is scaled so that the maximum wave height can be reached.

If this parameter is zero, then the wave animation will not be performed.
int cycleMS The number of milliseconds to delay at the end of each animation cycle.
int waveMS The number of milliseconds to delay between each frame of "wave" animation.

This parameter determines the speed of the "wave."
int wipeMS The number of milliseconds to delay between each frame of "wipe" animation.

This parameter determines the speed of the "wipe."

If this parameter is zero, then "wipe" animation will not be performed.
P ublic Methods

This section lists the methods that can be called from a Java program to control or alter the animation.


public void start()

Starts the animation.

public void stop()

Stops the animation.
D ownload

The WaveBanner class file, along with a copy of this documentation, is available for download as a standard zip file, as a self-extracting file (for Windows95/NT users), or as a self-installing Java class file.
C opyright

This documentation and the object code for WaveBannerApplet and WaveBanner may be copied and distributed freely for non-commercial purposes so long as neither the code nor the documentation is altered in any way. If the object code is distributed with any documentation whatsoever, then this unaltered document must accompany the code.


Copyright © 1997, 1998 by Modern Minds, Inc.