Creating the HWscroll Templates |
Template Variables
As with the normal HAMweather operation, templates are used when outputting the forecast information. These templates define what exactly should be displayed to the user. You will specify what weather information to display using the same template variables used with HAMweather. Whenever you want certian weather information to appear in the output you put the corresponding template variable in the template.
There are many variables that can be used in your HWscroll templates. The following table lists them. Some variables are only available for certain forecast types. This is indicated as well. As you will notice these are the same as used by normal HAMweather templates.
|
Directives
Along with the weather template variables you can also include other information inthe HWscroll template to be used to display additional data and/or control the HWscroll applet. When the applet retrieves the template output from either the hamweather.cgi or the hwscroll.cgi, it reads the data one line at a time. Each line the applet reads is treated one of two ways, depending on the first two characters of the line:
First of all, what is a "directive?" The HWscroll applet operates by requesting weather information from HAMweather from over the network and displaying HAMweathers output. Part of the applet's strength comes from the fact that it can be modified during runtime with extreme flexibility. By embedding directives in the HAMweather templates file the applet is to display, the web developer can alter the way their text will appear in the applet. Directives are the commands embedded in the HAMweather templates file. Since they directly correspond with the methods the applet publishes with the same names, they can almost be though of as method calls.
How does the applet determine what is text is should display, and what is text it should try to interpret as a directive call? Directive calls in the text file are indicated by lines beginning with two caret symbols (^^), that is, the character resulting from a "Shift"-ed 6 on IBM keyboards, inserted twice.
If you wanted to just display "Zone Forecast for Roanoke, Virginia" in HWscroll, you would create a template file containing the following:
Zone Forecast for Ronaoke, Virginia
When HWscroll displayed this data, it would use all the default settings, and scroll it at a comfortable speed in black text on a white background. However, what if you wanted to change it so the text were blue? There are two ways to do this:
<APPLET CODEBASE="http://www.hamweather.com/hwscroll" CODE="HWTextScroll.class" WIDTH=100 HEIGHT=200> <PARAM NAME="foreground" VALUE="0,0,255"> </APPLET>
This will set the initial foreground color of all your text to a bright blue.
Zone Forecast for Ronaoke, Virginia
To tell HWscroll we want the text to be blue, we could use the setForegroundColor directive. Now, the contents of our text file would be:
^^setForegroundColor (0,0,255) Zone Forecast for Ronaoke, Virginia
Using setForegroundColor allows you tighter control over the colors, since you can call it multiple times in the same file, and change the colors throughout the document.
Let's look at a more detailed example (its the actual zonejava.txt template included in the HWscroll software package). The following illustrates several of the directives and Template variables. Assume we have a text file containing the following text:
^^setURL (http://www.hamweather.com/cgi-bin/hamweather.cgi?forecast=zandh&state=%%state%%&place=%%place%%) ^^setSpeed (40) ^^setFontSize (16) ^^setCenter (true) ^^setBold (true) Zone Forecast for %%lcplace%%, %%lcstate%% ^^setBold (false) ^^setFontSize (12) Dated:%%forecastdate%% ^^setCenter (false) %%zforecast%%
Here's how the applet will behave when it reads this file. Lets examine this line-by-line.
This sets it so when the user clicks on the applet, it loads the given URL into the page, just as if the user clicked on a link.
This sets the scroll speed to 40, out of a possible 100, with 100 being the fastest and 1 being the slowest.
This sets the font size applet will use to display text to 16 point.
This sets the alignment to centering. All text following this method call will be centered, until a call to setCenter(false) is made.
This sets the font to Bold style. All text following this method call will be bold, until a call to setBold(false) is made.
This is the first line of actual text to be displayed.
These template varibles will be turned into the appropriate place and state names by HAMweather during output to the HWscroll applet and will be the second line of actual text to be displayed
This turns off the bold font style. All text following this method call will be not be bold, until a call to setBold(true) is made.
This sets the font size applet will use to display text to 12 point.
The template varible %%forecastdate%% will be turned into the appropriate date by HAMweather during output to the HWscroll applet and will be the third line of actual text to be displayed
This stops the alignment to centering. All text following this method call will be left justified, until a call to setCenter(true) is made
The template varible %%zforecast%% will be turned into the appropriate forecast text by HAMweather during output to the HWscroll applet and will be the remaining lines of actual text to be displayed.
The following is a complete list of supported directives for HWScroll.
setSpeed (int) | Sets the scroll speed to the given integer. The scroll speed must be between HWTextScroll.MIN_SPEED (1) and HWTextScroll.MAX_SPEED (100). If it is not, then the speed is left unchanged. |
pause (int) | This causes the applet to pause scrolling for the given number of milliseconds. |
pause () | This causes the applet to pause scrolling until the user clicks the text area. Note that this might cause a conflict if you have a URL set with setURL (). If you do have a URL set with setURL () and include the pause () directive, then if the user clicks on the applet, the URL will be loaded, and scrolling will never resume. Be extra careful when mixing this directive and setURL (). |
setForegroundColor (int,int,int) | Sets the foreground color to the given RGB value. If the given parameters do not form a legal RGB value, the current foreground color is left unchanged. This is the same as setRightForegroundColor. |
setLeftForegroundColor (int,int,int) | Sets the foreground color for the left pane to the given RGB value. If the given parameters do not form a legal RGB value, the current foreground color for the left pane is left unchanged. Panes are discussed below, in the section titled Panes. |
setRightForegroundColor (int,int,int) | Sets the foreground color for the right pane to the given RGB value. If the given parameters do not form a legal RGB value, the current foreground color for the right is left unchanged. Panes are discussed below, in the section titled Panes. |
setBackgroundColor (int,int,int) | Sets the background color to the given RGB value. If the given parameters do not form a legal RGB value, the current background color is left unchanged. This is the same as setRightBackgroundColor. |
setLeftBackgroundColor (int,int,int) | Sets the background color for the left pane to the given RGB value. If the given parameters do not form a legal RGB value, the current background color is left unchanged. Panes are discussed below, in the section titled Panes. |
setRightBackgroundColor (int,int,int) | Sets the background color for the right pane to the given RGB value. If the given parameters do not form a legal RGB value, the current background color is left unchanged. Panes are discussed below, in the section titled Panes. |
setFontFace (String) | Sets the font face to use to the given String. This should be one of:
This is the same as setRightFontFace. |
setLeftFontFace (String) | Sets the font face to use in the left pane to the given String. This should be one of:
Panes are discussed below, in the section titled Panes. |
setRightFontFace (String) | Sets the font face to use in the right pane to the given String. This should be one
of:
Panes are discussed below, in the section titled Panes. |
setFontSize (int) | Sets the size of the font to use to the given integer. This is the same as setRightFontSize. |
setLeftFontSize (int) | Sets the size of the font to use in the left pane to the given integer. Panes are discussed below, in the section titled Panes. |
setRightFontSize (int) | Sets the size of the font to use in the right pane to the given integer. Panes are discussed below, in the section titled Panes. |
setCenter (boolean) | Sets the centering flag. If the given boolean is true, then all subsequent text is centered, until the directive is invoked with a false value. This is the same as setRightCenter. |
setLeftCenter (boolean) | Sets the centering flag for the left pane. If the given boolean is true, then all subsequent text in the left pane is centered, until the directive is invoked with a false value. Panes are discussed below, in the section titled Panes. |
setRightCenter (boolean) | Sets the centering flag for the right pane. If the given boolean is true, then all subsequent text in the right pane is centered, until the directive is invoked with a false value. Panes are discussed below, in the section titled Panes. |
setBold (boolean) | Sets the bold flag. If the given boolean is true, then all subsequent text is printed in bold style, until the directive is invoked with a false value. This is the same as setRightBold. |
setLeftBold (boolean) | Sets the bold flag for the left pane. If the given boolean is true, then all subsequent text in the left pane is printed in bold style, until the directive is invoked with a false value. Panes are discussed below, in the section titled Panes. |
setRightBold (boolean) | Sets the bold flag for the right pane. If the given boolean is true, then all subsequent text in the right pane is printed in bold style, until the directive is invoked with a false value. Panes are discussed below, in the section titled Panes. |
setItalic (boolean) | Sets the italic flag. If the given boolean is true, then all subsequent text is printed in italic style, until the directive is invoked with a false value. This is the same as setRightItalic. |
setLeftItalic (boolean) | Sets the italic flag for the left pane. If the given boolean is true, then all subsequent text in the left pane is printed in italic style, until the directive is invoked with a false value. Panes are discussed below, in the section titled Panes. |
setRightItalic (boolean) | Sets the italic flag for the rightpane. If the given boolean is true, then all subsequent text in the right pane is printed in italic style, until the directive is invoked with a false value. Panes are discussed below, in the section titled Panes. |
setInset (int) | Sets the value of the inset, or how many pixels in to print text. |
setURL (String) | Sets the URL of the page to be loaded when the applet is clicked on. The String can also be "null" to set the applet so that when the user clicks on it, it simply toggles the scrolling on and off. text. Note that the URL must be a full URL, including the "http://" at the beginning. |
setURL (String, String) | Sets the URL of the page to be loaded when the applet is clicked on, BUT it
will be loaded in the named frame, not the same frame as the applet. The two arguments
are:
This directive is best illustrated with some examples.
|
setLeftText (String) | Sets the text to display in the left pane to the given String. |