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

See Also

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 Mathematical Expression context panel. To display the options in the context panel, select the embedded component. 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 Get column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.

  

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

  

 

Option

Get

Set

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

type

x

 

string

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 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.

  

type 

  

The type of the component. This returns "MathContainer".

  

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:

Click the component.

In the Mathematical Expression context panel, clear the check box Editable.

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. 

Click the Label component to display the context panel.

3. 

In the Caption field, enter Select a function to integrate.

To add the expressions to the list box:

1. 

Click the List Box component to display the context panel.

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.

 

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

1. 

Click the List Box component, and then select Edit Select Code.

This launches the Code Editor dialog.

2. 

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

SetProperty("MathContainer0", value, (Int(parse(GetProperty("ListBox0", value)), x) = int(parse(GetProperty("ListBox0", value)), x)));

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

3. 

Click  or 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.

 

with(DocumentTools):

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

SetProperty("MathContainer0", value, (Int(parse(GetProperty("ListBox0", value)), x) = int(parse(GetProperty("ListBox0", value)), x)));

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

GetProperty("MathContainer0",expression);

∫12cosxⅆx=12sinx

(5.1)

MathML[ImportModified](GetProperty("MathContainer0",value));

∫sinx2cos2xⅆx=12sinxcosx+12x12sin2x

(5.2)

See Also

DocumentTools, DocumentTools[GetProperty], DocumentTools[SetProperty], EmbeddedComponents, InertForm[FromMathContainer], MathML[ImportModified], Maplets[Elements][MathMLViewer]