ScrollingUpdate (Version 1.3)
ScrollingUpdate is canvas sub-class that can be used to vertically scroll text over
a static background image. The text is read from a file on the host, and the host text
file is (optionally) read periodically for updates. If an update to the text file occurs,
then the vertically scrolling text displayed by the applet is dynamically updated. |
Operation
The following documentation describes how the ScrollingUpdate canvas class is used.
Also available is the ScrollingUpdateApplet which can be used to plug the canvas
directly into a web page. The ScrollingUpdateApplet class is documented separately.
ScrollingUpdate.class requires NetworkTextFile.class. Both of these objects
are included in the download package.
During initialization, ScrollingUpdate can either load a GIF or JPEG image that
will be used as the background image, or it can create a solid colored background.
Also during initialization the NetworkTextFile.class class reads a specified file
from the host that contains the text that is to be scrolled vertically over the
background.
The are a number of parameters (documented below) that control how the text will be
rendered over the background. Both the font characteristics and the location of the scroll
region within the background can be specified.
The number of words that appear on a single line in the scroll region is automatically
determined based upon the font characteristics and the width of the scroll region. Because
each line of text is automatically formatted, the text entered in the text file does not
need to be manually formatted with carriage returns. If you wish to create a line break in
the text, enter the <BR> code or the <P>
code in the text file where the line break should be placed. The code should be entered on
a single line or with a least one space on either side of the code. The <BR>
code will place a line break in the text at the location of the code. The <P>
code will insert a blank line in addition to inserting the line break.
The frequency at which the class checks for changes to the text file can be specified (or
disabled), as well as whether or not a notification indicator should be displayed whenever
an update check occurs.
The class determines if the text file has been changed by reading the very first line of
text in the file (the file header) and comparing it to the header that was read on
the previous read. Note that the header is never displayed, so the header line in the file
can be can be anything that you wish, such as the date and time that the file was last
changed.
When you want to indicate that the text in the file has changed, simply modify the header
and save the file. The next time that the class checks the text file, it will find that
the header has changed and will then reload and re-render the text to be scrolled.
Scrolling text can be paused either by clicking anywhere within the boundaries of the
Canvas, or by moving the mouse within the Canvas boundaries (based on the pauseType
parameter). A second click or moving the mouse out of the Canvas boundaries will start the
text scrolling once again. |
ample
|
|
If your browser supports Java, you
should see a demonstration of the ScrollingUpdateApplet
(which uses ScrollingUpdate).
You can view the text file that is being
read to create the scrolling text. |
|
onstructor
The constructor and the parameters for the class constructor are listed below.
public ScrollingUpdate(
URL base, String textFile, int maxSizeKB,
int refresh, boolean notifyOnRead,
String font, int fontSize, int fontStyle,
Color fontColor, int justification,
int frameDelay, String background,
Rectangle displayRegion, int pauseType
) throws MalformedURLException |
URL |
base |
The base directory for locating the textFile and background
files. |
String |
textFile |
The name of the text file that contains the text to be
vertically scrolled.
The file must reside in the same directory as the Java applet. |
int |
maxSizeKB |
The maximum size that the text file can be in kilobytes. |
int |
refresh |
The frequency in seconds that the text file should be checked
for updates.
A value of 0 (zero) will cause the text file to be read only during initialization
(i.e., only once). |
boolean |
notifyOnRead |
If this parameter is set to "true", then a
small red square indicator will blink in the top left corner of the screen each time that
the text file is checked for updates.
If set to "false", then no indication will be displayed that the text
file has been checked. |
String |
font |
The name of the font to use when rendering the text to be
scrolled.
It is recommended that only the standard fonts for Java be specified unless you are
certain that the font that you specify will be available on all clients. |
int |
fontSize |
The size of the font used to render the text to be scrolled. |
int |
fontStyle |
This parameter can be set to any of the valid style constants
defined in the Font class (e.g., Font.bold, Font.italic, Font.plain,
etc.). |
Color |
fontColor |
The color of the scrolled text . |
int |
justification |
1=justify left, 2=justify center, and 3=justify
right. |
int |
frameDelay |
The number of milliseconds to delay between each frame of
animation (this controls how quickly the text scrolls). |
String |
background |
The background color or the file name of a GIF or JPEG image
that will be drawn behind the scrolling text.
If a color is specified, then the String must contain a hexadecimal RGB value. For
instance "FF0000" would result in a red background, and "888888" would
result in a medium gray background.
If a file name is specified for this parameter, then any file path is based starting with
the directory in which the Java class files are located. |
Rectangle |
displayRegion |
A rectangle bounding the region in which the text is scrolled.
Note that text can be scrolled over any portion of the background. |
int |
pauseType |
Controls what action will cause the scrolling text to pause.
The valid values are:
- 0 = scrolling cannot be paused
- 1 = scrolling will pause when mouse enters Canvas
- 2 = scrolling will pause when mouse is clicked in Canvas
- 3 = scrolling will pause when mouse enters or is clicked in Canvas
|
|
ublic Methods
This section lists the methods that can be called from a Java program to control or alter
the behavior of the class.
Starts the vertical text scroll and the text file monitoring.
Stops the vertical text scroll and the text file monitoring.
public void setFrameRate(int milliSeconds) |
Changes the number of milliseconds to delay between each frame of
animation (this controls how quickly the text scrolls).
|
Copyright
This documentation and the object code for ScrollingUpdateApplet and ScrollingUpdate
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 by Modern Minds, Inc. |