Math Expression Component - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Document Tools : Embedded Components : MathExpressionComponent

Math Expression Component

Insert a math expression region in a Standard Maple worksheet or document.

 

Description

Component Palette Image

Mathematical Expression Properties

Making the Expression Read-only

Math Expression Component Example

Description

• 

The mathematical expression component displays 2-D math expressions passed from another embedded component. It also provides editing functionality for entering math expressions.

• 

The math expression component returns the value of its contents as a string of MathML elements. To convert this into a Maple expression, use the MathML[ImportModified] command.

• 

The mathematical expression component is customized by setting options in the MathContainer Properties. To display component properties, right-click (Control-click for Macintosh) the embedded component, select Component, and then select Component Properties. Actions are associated with components using routines in the DocumentTools package. For more information, see the Math Expression Component Example on this page.

• 

The Name property is used to reference the math expression component when using the routines from the DocumentTools package.

Component Palette Image

Mathematical Expression Properties

• 

The following table describes the control and use of the mathematical expression component options.

  

An x in the G column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.

  

An x in the S column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.

Option              G  S  Option Type     
                                   
autoFit             x  x  true or false   
  editable            x  x  true or false     

expression          x  x  expression      
fillcolor           x  x  color           
minimumpixelheight  x  x  positive integer
minimumpixelwidth   x  x  positive integer
pixelHeight         x  x  positive integer
pixelWidth          x  x  positive integer
showBorders         x  x  true or false   
value               x  x  MathML          
visible             x  x  true or false   
   
                                    

  

autoFit 

  

Specifies whether to automatically resize the Math Expression component to fit its contents.  By default, the value is false.

  

editable

  

Specifies whether or not the mathematical expression component is editable. By default, the value is true.

  

expression 

  

The contents of the Math Expression component (MathContainer) as a Maple expression. The usual simplification rules are applied to the expression. For example, retrieving the expression from a MathContainer into which 3*4 has been entered will return 12. To obtain the contents exactly as they were entered, use InertForm[FromMathContainer] or the value property.

  

fillcolor

  

Specifies the background color of the component. The color can be given by RGB values (a list of three integers between 0 and 255) or a string representing a color name, for example, [255,0,0] or “Red”. The default value is [255,255,255] which corresponds to white.

  

minimumpixelheight 

  

The minimum height of the mathematical expression region in pixels. Used with autoFit=true. By default, the value is 200.

  

minimumpixelwidth 

  

The minimum width of the mathematical expression region in pixels. Used with autoFit=true. By default, the value is 300.

  

pixelHeight 

  

The height of the mathematical expression region in pixels. By default, the value is 200.

  

pixelWidth 

  

The width of the mathematical expression region in pixels. By default, the value is 300.

  

showBorders

  

Specifies if the border of the component is visible. By default, the value is true.

  

value 

  

The contents in the component in MathML. Note that since the content is in MathML, use of DocumentTools[Do] should either retrieve the value unparsed (i.e. %%ComponentName(value)) or use the expression property.

  

visible 

  

Specifies if the component is visible. By default, the value is true.

 

• 

These properties can be accessed programmatically. You can access the contents of the MathContainer, for example, using expr:= DocumentTools:-GetProperty(ComponentName,expression); as demonstrated in the example.

Making the Expression Read-only

The mathematical expression component can be made read-only (non-editable).

To make the mathematical expression component read-only:

Right-click inside the component.

In the MathContainer properties window, from the available Options, uncheck Editable.

Click OK.

The expression is no longer editable.

Math Expression Component Example

Note: To interact with the example provided below, open this help page as a worksheet, and then execute the worksheet.

This example uses a List Box component to display some expressions. Selecting an expression from the List Box displays the integrated expression in the Math Expression component.

To insert the label, list box, and mathematical expression components, and then configure the label component:

1. 

Insert a Label, ListBox and MathExpression component using the Components palette. For information on displaying the Maple palettes, see the Show Palettes help page.

2. 

Right-click (Control-click for Macintosh) the Label component, and then select Component Properties.

3. 

In the Caption field, enter Select a function to integrate, and then click OK.

To add the expressions to the list box:

1. 

Right-click (Control-click for Macintosh) the List Box component, and then select Component Properties.

2. 

Click the Edit button of the Item List field.

3. 

Double-click the first row and replace ListBox with sin(x)*2.

4. 

Click Add ,double-click the new field, and then replace the default entry with exp(x)^2.

5. 

Repeat step 4 and add the following items to the list: cos(x)/2 and sin(x)^2-cos(2*x).

6. 

Click OK to close the List Editor.

7. 

Click OK to close the ListBox Properties dialog.

To display the integral of the expression selected from the list box:

1. 

Right-click (Control-click for Macintosh) the List Box component, and then select Edit Select Action.

This launches a dialog with preset statements and additional information on how to program actions between embedded components.

2. 

Before the end use; statement in the dialog, enter the following command:

Do(%MathContainer0 = (Int(%ListBox0,x) = int(%ListBox0,x)));

Note: Ensure the names of the components are correct (that is, that they match the Name fields for their components).

3. 

From the File menu, select Save Code to accept all changes.

4. 

From the File menu, select Close Code Editor.

When you select an item from the list box, the math expression component displays the integral for the expression.

 

You can verify the syntax of the embedded component action by executing the command in the worksheet.

DocumentTools[Do](%MathContainer0 = (Int(%ListBox0, x) = int(%ListBox0, x)));

∫sinx2cos2xⅆx=12sinxcosx+12x12sin2x

(5.1)

To display the contents of the Math Expression component, access the expression property or use the MathML[ImportModified]  command on the value.

DocumentTools[GetProperty]('MathContainer0','expression');

∫sinx2cos2xⅆx=12sinxcosx+12x12sin2x

(5.2)

MathML[ImportModified](DocumentTools[GetProperty]('MathContainer0','value'));

∫sinx2cos2xⅆx=12sinxcosx+12x12sin2x

(5.3)

See Also

ButtonComponent

CheckBoxComponent

ComboBoxComponent

DataTableComponent

DialComponent

DocumentTools

DocumentTools[Do]

DocumentTools[GetProperty]

DocumentTools[SetProperty]

EmbeddedComponents

InertForm[FromMathContainer]

LabelComponent

ListBoxComponent

MathML[ImportModified]

MeterComponent

PlotComponent

RadioButtonComponent

RotaryGaugeComponent

ShortcutComponent

SliderComponent

TextAreaComponent

ToggleButtonComponent

VideoPlayerComponent

VolumeGaugeComponent

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam