Creating Maplets Using the Maplet Builder
The following examples highlight several of the main features of the Maplet Builder.
To start the Maplet Builder, from the Tools menu, select Assistants, and then Maplet Builder.
A box layout is selected as the outermost Maplet layout scheme. This is the default setting when creating a new Maplet. To define a Maplet using a different layout scheme, from the File menu, select New with layout.
To learn about the structure of the Maplet Builder, see the Overview of the Maplet Builder help page.
To learn about the elements available when designing a Maplet, see the Overview of the Palette Pane help page.
General Information
When dragging elements to the Layout pane, the active region is highlighted.
Each element has a set of properties that customizes its appearance when applicable and sets its behavior. To access the properties of an element, select it from the drop-down menu in the Properties pane.
When entering functions, do not end the statement with a semi-colon (;).
Elements are referenced using names of the form Button1, Slider1, and BoxColumn1. To assign a name that is more informative, change the reference property for the element in the Properties pane.
To change the background or foreground color of an element, double-click the background or foreground property in the Properties pane to select a color from the Color dialog that displays.
To close a running Maplet, click the X in the top-right corner of the window.
Example 1a: Simple Maplet
This Maplet displays a string.
Maplet Image
Steps
To add text to the Maplet, use the Label element.
1. From the Body palette, drag the Label element to the Layout pane.
To change the caption on the Label element, edit the caption property.
2. In the Properties pane,
a. from the drop-down menu, select Label1.
b. edit the caption property by deleting Label1 and adding Hello World.
To run this Maplet, select Run.
3. From the File menu, select Run.
Note: Each time you select Run from the File menu, you are prompted to save the Maplet. To save the Maplet, click Yes.
Example 1b: Adding a Button
Building from the previous example, this Maplet includes a button that closes the Maplet when the user clicks it.
To add a button to the Maplet, use the Button element.
1. From the Body palette, drag the Button element below the Label element.
To change the caption and set the action of the button, refer to the button properties.
a. from the drop-down menu, select Button1.
b. change the caption to Close.
c. to close the running Maplet, select the onclick region to display a drop-down menu of actions that can be performed when the user clicks the button.
d. to specify that the Maplet closes when the user clicks the button, select <Shutdown>. The Shutdown Event dialog displays.
In the Shutdown Event dialog,
a. to return no information to the worksheet when the Maplet closes, simply click Ok.
Example 2a: Add a Button, TextField, and Plotter Element
This Maplet accepts input from the user and plots the corresponding graph.
Start a new Maplet and define the layout
To start a new Maplet definition, refer to the File menu.
1. From the File menu, select New.
To add multiple rows to the BoxColumn element, refer to the BoxColumn properties.
a. select BoxColumn1.
b. in the numrows property, enter 3.
Define the elements in the first row: Plotter region
To add a plot region to the Maplet, use the Plotter element.
1. From the Body palette, drag the Plotter element to the first row in the Layout pane.
To change the appearance of the plot region, refer to the Plotter properties.
a. from the drop-down menu, select Plotter1.
b. double-click the background property. In the Color dialog that appears, click the white font in the top-left corner of the color palette, and then click OK.
Define the elements in the second row: Label and text field
To add columns to a specific row, edit the BoxRow properties.
1. In the Properties pane,
a. from the drop-down menu, select BoxRow2.
b. change the numcolumns property to 2.
2. Drag the Label element to the left column in the Layout pane.
3. In the Properties pane,
b. change the caption property to Enter a function of x:.
To add an input region for Maplet users to enter information, use the TextField element.
4. Drag the TextField element to the right column in the Layout pane. This allows the user to enter input in the Maplet.
Define the elements in the third row: Two buttons
a. from the drop-down menu, select BoxRow3.
2. Drag a Button element to the left column in the third row in the Layout pane.
To change the caption and plot the function entered in the text region, refer to the button properties to set the action associated with this button.
b. in the caption property, enter Plot.
c. in the onclick property, select <Evaluate>. An Evaluate Expression window appears. The Target menu lists the available target elements. The Option menu lists the available elements for the target selected. The List group box lists the available elements to retrieve information from.
In the Evaluate Expression window,
a. ensure the Target is set to Plotter1.
b. enter the expression to evaluate. Enter plot(TextField1, x=0..10). (Instead of entering TextField1, you can also double-click the element in the List window to include this element in the plot command). Note: Ensure that you do not include a semi-colon (;) at the end of the plot command.
c. click Ok to return to the Maplet Builder.
4. Drag a Button element to the right column in the third row.
5. In the Properties pane,
a. from the drop-down menu, select Button2.
b. in the caption property, enter Close.
c. in the onclick property, select <Shutdown>.
In the Shutdown Event Dialog,
a. click Ok.
6. From the File menu, select Run.
Example 2b: Add a Slider Element
This version of the plotter Maplet includes a Slider element that controls the plot range displayed.
To display a region that allows the user to select an integer between two points, use the Slider element.
1. From the Body palette, drag the Slider below the Plotter element in the Layout pane.
To alter the range of the plot based on the slider value, edit the Slider properties.
a. from the drop-down menu, select Slider1.
b. change the filled property to true. c. change the majorticks property to 5. d. change the upper property to 20. e. in the onchange property select clickButton1. f. select Button1 in the drop-down menu.
g. in the onclick property, select <Evaluate>. In the Evaluate Expression window,
a. change the plot expression to plot(TextField1, x=0..Slider1).
b. click Ok.
Example 3: Adding a Drop-down Box
To define a Maplet with a BoxRow as the outermost layout scheme, as opposed to a BoxColumn, refer to the File menu.
1. From the File menu, select New with layout.
To define multiple rows in the BoxLayout, refer to the Default layout type and properties dialog.
2. In the Default layout type and properties dialog,
a. from the choose layout type group box, select Box layout.
b. select with rows.
c. ensure the default number of rows is set to 2.
d. click Ok.
Define the elements in the Maplet
a. from the drop-down menu, select BoxRow1.
2. Drag a Label element to the left column.
b. change the caption property to Select your favorite city:.
To add a drop-down menu, use the DropDownBox element.
4. Drag the DropDownBox element to the right column.
To add entries in the DropDownBox, refer to the element properties.
a. from the drop-down menu, select DropDownBox1.
b. in the itemlist property, enter San Francisco,Chicago,Boston,New Orleans,Phoenix,Portland,New York. Note: do not place spaces in the itemlist entry.
6. Drag a Button element to the second row.
7. In the Properties pane,
b. change the caption property to OK.
In the Shutdown Event Dialog that appears,
a. click OK.
8. From the File menu, select Run.
Example 4: Adding a Table
Start a new Maplet definition
To add a table to the Maplet, use the Table element.
1. Drag the Table element to the Layout pane.
To edit number of rows and columns in the table, refer to the table properties.
a. from the drop-down menu, select Table1.
b. double-click the background property. In the Color dialog that displays, select white and click Ok.
c. change the numcolumns property to 2.
d. change the numrows property to 2.
To add values to the table, enter the value in table of the Layout pane.
3. In the first row, left column, enter sin(x).
4. In the first row, right column, enter cos(x).
5. In the second row, left column, enter sin(x)^2.
6. In the second row, right column, enter 2*sin(x)*cos(x).
To change the column headings, refer to the TableItem properties.
a. from the drop-down menu, select TableItem1.
b. change the caption property to Function.
c. from the drop-down menu, select TableItem2.
d. change the caption property to Derivative.
Example 5: Adding a MathMLViewer Region
a. from the drop-down menu, select BoxColumn1.
b. change the numcolumns property to 3.
To display the expressions in 2D math, use the MathMLViewer element.
2. Drag a MathMLViewer element to the first row 3.
3. Drag a TextField element to the second row.
4. Drag a Button element to the third row.
b. in the caption property, enter MathML.
c. in the onclick property, select <Evaluate>.
a. verify that the Target field is set to MathMLViewer1 and the Option field is set to value.
To display the expression in 2D math, you must export the expression to MathML.
b. enter MathML[Export](TextField1).
c. click Ok.
6. From the File menu, select Run
Example 6: Adding a MathMLEditor Region
1. From the File menu, select New
b. change the numcolumns property of the BoxColumn element to 3.
To enter expression as 2D math, use the MathMLEditor element.
2. Drag a MathMLEditor element to the first row.
b. change the caption property to Text.
d. in the onclick property, select <Evaluate>.
a. change the Target field to TextField1.
b. select the Argument Form tab.
To display 2D math as 1D math, you must import the MathMLEditor entry as MathML.
c. in the Function window, enter MathML[Import].
d. double-click MathMLEditor1 to select this element as an Argument element.
When importing 2D math, you must specify that the argument is passed as a string in the Argument property.
6. In the Properties pane,
a. from the drop-down menu, select Argument1.
b. in the quotedtext property, select true.
7. From the File menu, select Run.
Advanced Examples
For advanced examples of creating Maplet using the Maplet Builder, see the Advanced Maplet Builder Examples worksheet.
Return to Example Worksheet Index
Download Help Document