[VCLab-Main] [Software] [Slider Applet]


Slider Applet 3.0

This applet realizes a slider for changing of a given value within an interval [min,max] in steps of given size. The value which can be changed by this applet must be a variable which resides in the MATLAB workspace. Thus, the MATLAB VCLab Plugin must be embedded on a page and the slider applet must be linked to the MATLAB Plugin.

The following is the minimal form shown using an example:

     ...
<embed type="application/x-matlab" width="10" height="10"
display="false" name="matlab"></embed>
...

<applet code=slider.class archive="slider.zip" height="50width="200" MAYSCRIPT>
</applet>

The orange part shows the embedding of the MATLAB Plugin, which has the object name "matlab". The display of the window associated with this plugin is not of interest in this example. Thus, the display is disabled and set to a small size. The blue part is the applet section for this example. This statement will generate a slider element of 200 x 50 pixels. The attribute MAYSCRIPT is necessary for communication of the Java applet with the MATLAB Plugin methods. The applet shown below is generated by this statement.


Hot Links

Parameters ---- Methods ---- Examples ----- Download


Slider Applet Syntax at Glance

<applet code=slider.class archive="slider.zip" height="50" width="200"

name="slider" MAYSCRIPT>
<param name="var"         value="
MATLAB variable">
<param name="text" value="
true | false |
left | right |
top | bottom">
<param name="textcols" value="
4">
<param name="orientation" value="
horizontal | vertical">
<param name="min" value="
100">
<param name="minlock" value="
true | false">
<param name="x0" value="
500">
<param name="max" value="
1000">
<param name="maxlock" value="
true | false">
<param name="steps" value="
100">
<param name="bgcolor" value="
FFFFFF">
<param name="tfgcolor" value="
000000">
<param name="tbgcolor" value="
FFFFFF">
<param name="sbgcolor" value="
00FF00">
<param name="vclab" value="
name of the VCLab plugin">
<param name="action" value="
MATLAB command string">
<param name="gaction" value="
MATLAB graphic command string">
<param name="script" value="
JavaScript statements">
<param name="clpbrd" value="
name of the Graphic plugin">
</applet>

Slider Parameters

The applet can be parametrized with optional parameters with the general parameter syntax
<param name="name" value="value">
Parameter Type Code Syntax
Applet name
<applet name="appletname" ...>
       appletname = slider (default)
This optional parameter is part of the applet main statement and not included in the optional parameter section. It is the applet object name on the page. The name can be used for referencing the applet when using slider applet methods.
Slider variable
<param name="var" value="MATLAB variable">
Name identifier of the MATLAB variable associated with the slider. The default name is the name of the applet as given above by appletname. If appletname is not specified slider is used.
Lower limit
<param name="min" value="low">
The lower limit of the slider is given by low. The default value is -1.
Upper limit
<param name="max" value="high">
The upper limit of the slider is given by high. The default value is 1.
Start value
<param name="x0" value="start">
When starting the applet this start value is taken as the initial value. If not specified, the mean value of the range [low,high] is taken.
Step size
<param name="steps" value="number of steps">
Moving the slider, the value is changed in small increments, which are specified by the number of steps which divide the range [low,high].
Slider orientation
<param name="orientation" value="direction">
       direction = horizontal (default)
                   vertical
Text fields The lower limit, the upper limit and the actual value of the slider can be displayed and entered in text fields. These fields have different default positions depending on the slider orientation.
<param name="text" value="position">

position = true the fields are displayed (default)
false no fields are visible
top fields at the top if direction = horizontal
bottom fields at the bottom if direction = horizontal (default)
left fields left of the slider if direction = vertical
right fields right of the slider if direction = vertical (default)
Text columns
<param name="textcols" value="number of text columns">
The number of character positions in the text fields is given by number of text columns. The default value is 4.
Lower limit lock
<param name="minlock" value="lock">
       lock = false (default)
              true
If this value ist true, changing of the lower limit in the text field is not possible.
Upper limit lock
<param name="maxlock" value="lock">
       lock = false (default)
              true
If this value ist true, changing of the upper limit in the text field is not possible.
Surrounding background color The default surrounding (applet) background color can be modified by the hex value rrggbb
<param name="bgcolor" value="rrggbb">
Text foreground color The applet text default foreground color (default: black) can be modified by the hex value rrggbb
<param name="tfgcolor" value="rrggbb">
Text background color The applet text default background color (default: white) can be modified by the hex value rrggbb
<param name="tbgcolor" value="rrggbb">
Slider background color The default slider background color can be modified by the hex value rrggbb
<param name="sbgcolor" value="rrggbb">
MATLAB VCLab Plugin identification Name syntax:
<param name="vclab" value="name of the MATLAB plugin">
The object name of the MATLAB Plugin is given by this parameter. The default name is matlab, which refers to the object document.matlab.

Object syntax:
<param name="vclab" value="@object variable">
This syntax must be used, if the MATLAB Plugin object name is stored in an object variable. E.g., if the MATLAB Plugin matlab is in an other frame with the name other, the object name is parent.other.document.matlab. For referencing this object it must be assigned to an object variable.
MATLAB expression execution
<param name="action" value="MATLAB command string">
MATLAB command string to be executed after a slider move. If graphic operation is included, use the gaction parameter.
JavaScript expression execution
<param name="script" value="JavaScript statements">
JavaScript string to be executed after a slider move. This action is performed after the MATLAB expression execution, if defined.
The JavaScript statements are restricted: it is not possible to call any Java applet or plugin methods directly or indirectly via this JavaScript interface.
MATLAB Graphics Plugin identification Name syntax:
<param name="clpbrd" value="name of the MATLAB Graphics plugin">
The graphic display method of this plugin is called after a slider move. This action is performed after the JavaScript expression execution, if defined. This parameter needs the MATLAB Graphics Plugin embedded on the same page, but not necessarily in the same frame.
The object name of the Graphics Plugin is given by this parameter. E.g., if plot is given, it refers to the object document.plot.

Object syntax:
<param name="clpbrd" value="@object variable">
This syntax must be used, if the Graphics Plugin object name is stored in an object variable. E.g., if the Graphics Plugin plot is in an other frame with the name other, the object name is parent.other.document.plot. For referencing this object it must be assigned to an object variable.
MATLAB graphic expression execution
<param name="gaction" value="MATLAB graphic command string">
MATLAB graphic command string to be executed after a slider move. This action is performed only when the clpbrd parameter is specified. This parameter simplifies output when slider movement results in redrawing graphics. The operation is performed after the JavaScript expression execution, if defined.

Slider Methods

Methods Syntax
Sets values <applet name>.setValue(low, value, high)
This method modifies als values in the text fields and the slider values.
Sets value <applet name>.setValue(value )
This method modifies the value of the slider and the text field.
Enable/Disable text input <applet name>.setEnabled(boolvalue)
boolvalue = true: the text field input of this applet is enabled.
boolvalue = false: the text field input of this applet is disabled.
Disable text input <applet name>.disable()
The text field input of this applet is disabled.
Deprecated method for Java 1.1. Use setEnabled.
Enable text input <applet name>.enable()
The text field input of this applet is enabled.
Deprecated method for Java 1.1. Use setEnabled.

Examples

Look at the MATLAB workspace and check slider variables

Example Type Code Example
Sliders without text
<APPLET CODE="slider.class"
ARCHIVE="slider.zip"
HEIGHT="20" WIDTH="100"

NAME="slider1" MAYSCRIPT>
<PARAM name="text" value="false">
<PARAM name="min" value="10.1">
<PARAM name="x0" value="15">
<PARAM name="max" value="99.35">
<PARAM name="sbgcolor" value="10a010">
</APPLET>
<APPLET CODE="slider.class"
ARCHIVE="slider.zip"
HEIGHT="100" WIDTH="15"
NAME="slider2" MAYSCRIPT>
<PARAM name="text" value="false">
<PARAM name="min" value="-55">
<PARAM name="max" value="55">
<PARAM name="sbgcolor" value="ff0000">
</APPLET>
Sliders with text
with/without lock option,
different text sizes

and
script parameter
<APPLET CODE="slider.class"
ARCHIVE="slider.zip"
HEIGHT="50" WIDTH="200"
NAME="slider3" MAYSCRIPT>
<PARAM name="text" value="top">
<PARAM name="min" value="100">
<PARAM name="x0" value="500">
<PARAM name="max" value="1000">
<PARAM name="maxlock" value="true">
<PARAM name="minlock" value="true">
<PARAM name="bgcolor" value="d9efff">
<PARAM name="tbgcolor" value="000000">
<PARAM name="tfgcolor" value="ffffff">
</APPLET>
<APPLET CODE="slider.class"
ARCHIVE="slider.zip"
HEIGHT="150" WIDTH="110"
NAME="slider4" MAYSCRIPT>
<PARAM name="text"value="left">
<PARAM name="orientation" value="vertical">
<PARAM name="min"value="10000">
<PARAM name="x0" value="50000">
<PARAM name="max"value="100000">
<PARAM name="bgcolor" value="d9efff">
<PARAM name="textcols" value="8">
</APPLET>
<APPLET CODE="slider.class"
ARCHIVE="slider.zip"
HEIGHT="150" WIDTH="80"
NAME="slider4" MAYSCRIPT>
<PARAM name="text"value="left">
<PARAM name="orientation" value="vertical">
<PARAM name="min"value="100">
<PARAM name="x0" value="500">
<PARAM name="max"value="1000">
<PARAM name="script" value="alert('slider4 moved')">
<PARAM name="bgcolor" value="d9efff">
</APPLET>
Slider methods
enable/disable

and
action parameter
<FORM>
<INPUT TYPE="button" VALUE="enable"
ONCLICK="document.slider5.enable()">
<INPUT TYPE="button" VALUE="disable"
ONCLICK="document.slider5.disable()">
</FORM>
<APPLET CODE="slider.class"
ARCHIVE="slider.zip"
HEIGHT="50" WIDTH="200"
NAME="slider5" MAYSCRIPT>
<PARAM name="var" value="Ts">
<PARAM name="action" value="fTs=-2*Ts;">
<PARAM name="min"value="100">
<PARAM name="x0" value="500">
<PARAM name="max"value="1000">
<PARAM name="bgcolor" value="d9efff">
<PARAM name="sbgcolor" value="9DD6F7">
<PARAM name="tbgcolor" value="d9efff">
<PARAM name="tfgcolor" value="0000ff">
</APPLET>
Slider method
setValue
<APPLET CODE="slider.class"
ARCHIVE="slider.zip"
HEIGHT="150" WIDTH="80"
NAME="slider6" MAYSCRIPT>
<PARAM name="orientation" value="vertical">
<PARAM name="min"value="100">
<PARAM name="x0" value="500">
<PARAM name="max" value="1000">
<PARAM name="bgcolor" value="d9efff">
</APPLET>
<FORM>
<INPUT TYPE="button" VALUE="set slider values"
ONCLICK="document.slider6.setValue(-200,0,200)"><BR>
<INPUT TYPE="button" VALUE="set slider value"
ONCLICK="document.slider6.setValue(150)"></FORM>


Slider Download

The slider applet can be downloaded below.

slider 3.0
Download slider.zip (21 KB)

[VCLab-Main] [Software] [Slider Applet]


© CS 1996, 1997, 1998, 2001