Embedded Components - Maple Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : System : Information : Updates : Maple 2016 : Embedded Components

 Embedded Components

Tables as Embedded Components

Table Properties

In Maple 2016 some Table properties can be accessed programmatically, meaning properties can be updated using the DocumentTools package. To enable this, Tables now have a name (or identity), which is listed in the Table Properties dialogue. Note the name is not the same as the title.

      

The following commands will update the Table above.

$\mathrm{with}\left(\mathrm{DocumentTools}\right):$



For more information, see Table Properties using DocumentTools.

Programmable Tables

Tables can be also be created and inserted (or embedded) using DocumentTools commands:

$\mathrm{with}\left(\mathrm{DocumentTools}\right):$

$\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Layout}\right):$

 x y z 1 2 3

The Tabulate command provides built-in support for laying out lists, Arrays, Vectors, Matrices and DataFrames containing strings, numbers, math expressions, and plots. By constructing the content using the DocumentTools commands, further customization is possible and the inserted Table can also be subsequently altered programmatically.

 > $Mâ‰”\mathrm{ImportMatrix}\left(\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/datasets/sunspots.csv"\right)\right)\left[1..15,..\right]$
 ${M}{â‰”}\left[\begin{array}{c}{\mathrm{15 x 2}}{\mathrm{Matrix}}\\ {\mathrm{Data Type:}}{\mathrm{anything}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (1.2.1)
 >
 ${m}{,}{n}{â‰”}{15}{,}{2}$ (1.2.2)
 >

 Date Mean Sunspot Number 1700 5.0 1701 11.0 1702 16.0 1703 23.0 1704 36.0 1705 58.0 1706 29.0 1707 20.0 1708 10.0 1709 8.0 1710 3.0 1711 0. 1712 0. 1713 2.0

The Table inserted above may receive a new identity upon insertion if the value of the identity option supplied to the Table constructor is already in use in the worksheet. The name lookup has been assigned a table which can be used to look up the identity that has been used for insertion. In this example, the identity has not changed since the supplied identity is not already used in any other component in the worksheet.

 > $\mathrm{lookup}\left["sunspot_table"\right]$
 ${"sunspot_table"}$ (1.2.3)

The next command hides rows 11 through 14 of the above Table. The identity of the inserted Table is used for this.

 > $\mathrm{SetProperty}\left(\mathrm{lookup}\left["sunspot_table"\right],\mathrm{visible}\left[11..14,..\right],\mathrm{false}\right)$

And those rows can be made visible once more.

 > $\mathrm{SetProperty}\left(\mathrm{lookup}\left["sunspot_table"\right],\mathrm{visible}\left[11..14,..\right],\mathrm{true}\right)$
 >

Hidden Options Example



In this example, we use the table's ability to show or hide cells, rows, or columns. This example presents an interactive application of an area chart in which you can easily change some options that affect how the plot is displayed.  After you get the look you want, you can hide the options in order to reduce screen clutter. For demonstration purposes, the "Hide Options" button is implemented using a captioned Button component, but this could be reduced to a simple unobtrusive icon.

  Format: Grid Lines: Markers: Scale: 

The above application was created by dragging components off the Components palette. The action handlers of the various embedded components obtain the relevant options and generate the plot using the AreaChartPlot module defined in the following Code Edit Region. Note how AreaChartPlot:-Options implements hiding the options column.

AreaChartPlot := module()

For more applications and details, see the example worksheet Programmatic Content Generation.

Plot Component

The following properties of a Plot Component can now be accessed programmatically:

 • hoverx: the x-coordinate position where the mouse is currently hovering
 • hovery: the y-coordinate position where the mouse is currently hovering

In addition, it is now possible for the Plot component to run action code on the event of a mouse hover.

Example 1

The hover over action on Plot components allows code to be run any time the mouse hovers in the plot. In this example, the hover action code updates two TextArea components with information on the current position of the mouse cursor. In addition, the action code updates the plot shown in the Plot component with a pointplot corresponding to the current position of the mouse.

 Hover Coordinates x : y : 

Example 2

In this example, as the mouse moves from one quadrant of the plot to the next, the action code updates the plot shown in the Plot component. The action code also updates the TextArea components.

 Hover Coordinates x : y : 

Example 3

As a part of the new ThermophysicalData package, you can now generate psychrometric charts for humid air. The following chart, for example, is generated at 101325 Pa.

In this example, as the mouse hovers over the psychrometric chart, Maple:

 • Calculates thermophysical data for the current dry bulb temperature and humidity ratio.
 • Overlays the information on top of the chart.



Math Containers

The following properties of a Math Container  can now be accessed programmatically:

 • editable: specify if the math container contents can be edited or not.
 • minimumpixelheight: set the minimum pixel height. Used in conjunction with the autofit option.
 • minimumpixelwidth: set the minimum pixel width. Used in conjunction with the autofit option.

Note: These properties can also be accessed through the Math Container Properties window. For more information, see the Math Container help page.

Component Font Color

You can now control the font color for Buttons, Check Boxes, Combo Boxes, Labels, List Boxes, Radio Buttons, Sliders, and Text Areas. This can be adjusted from the component properties dialog or programmatically accessed using the following option:

 • fontcolor: specify the font color of the component.

Component Transparency and Fill Color

By default, most embedded components are now transparent, meaning that they will use the same background color as the table cell they are in. Check Boxes, Labels, List Boxes, Math Expression Component, Plot Components, Radio Buttons, Sliders, and Text Areas are not transparent by default but now have a new customizable background fillcolor option. This can be adjusted from the component properties dialog or programmatically accessed using the following option:

 • fillcolor: specify the background color of the component.

Examples: Transparent Components

Shortcut

Examples: Components with fillcolor option

 > $\mathrm{DocumentTools}:-\mathrm{SetProperty}\left("TextAreaCT1",\mathrm{fillcolor},"WhiteSmoke"\right)$

 > $\mathrm{DocumentTools}:-\mathrm{SetProperty}\left("SliderCT1",\mathrm{fillcolor},\left[128,128,128\right]\right)$

Example: Background Colors on Components

The following components can make use of the background fill color option.

 >

 123
 >

Example: Interactive Table

Consider the following example that uses coloring to delimit the rows. The contents inside of the Table are live active components. The numbers in the 'n' column are housed in TextArea components, and the series approximations are housed in MathContainer components. All components have their background color set to match the Table cells' fill color.

This example is interactive. Try changing n=6 to n=8 by putting your cursor on the 6 and typing over it with 8.



 n taylor(exp(x),x,n)

The following Code Edit Region implements the TaylorTable command seen above:

TaylorTable := proc( fn, var, ord )

 Programmatic Content Generation There have also been several new additions that build on the framework for programmatic content generation, including the ability to replace existing worksheet content and add a notion of state to components. For more details on Component State, see the what's new page for Component State For more details on Replaceable Content, see the what's new page for Replaceable Content