webMathematica`

MSPManipulate

MSPManipulate[expr, {u, umin, umax}]

generates interactive web controls that allow interactive manipulation of the value of u

MSPManipulate[expr, {u, umin, umax,du}]

allows the value of u to vary between umin and umax in steps du

MSPManipulate[expr, {{u,uinit}, umin, umax,}]

takes the initial value of u to be uinit

MSPManipulate[expr, {{u,uinit,ulbl}, umin, umax,}]

labels the controls for u with ulbl

MSPManipulate[expr, {u, {u1, u2,}}]

allows u to take on discrete values u1,u2,

MSPManipulate[expr, {u,}, {v, }, ]

provides controls to manipulate each of the u, v,

Details

  • MSPManipulate provides a web version of the function Manipulate.
  • You must load the MSPManipulate` package to use the webMathematica interactive tools.
  • MSPManipulate automatically formats the expression expr into an image.
  • MSPManipulate creates the following controls by default.
  • {u, min, max}slider ranging in value from min to max
    {u, min, max, step}slider ranging in value from min to max in increments of step
    {u, {True, False}}checkbox
    {u, {u1, u2, }}setter bar for few elements; popup menu for more
    {u}blank input field
    {{u,uinit},}control with initial value uinit
    {{u,uinit,ulbl}, }control with label ulbl
  • MSPManipulate takes the following options.
  • ContainerStyleformatting for the web page container
    ControlPlacementplacement of controls
    ControlTypetype of controls to use
    FormatTypethe type of formatting to use
    OutputSizethe size in pixels for the entire interactive control
  • ControlType and ControlPlacement pos options can be given separately for each control.
  • The option setting ControlPlacement pos specifies that controls should be placed at positionpos relative to expr. Possible settings forpos are Bottom, Left, Right, and Top.
  • The option setting ContainerStyle {styles} gives styles for the web container. Possible style settings are:
  • "BorderColor"Blackcolor to draw the border
    "BorderThickness"1thickness for the border
    "BorderStyle"solidstyle to draw the border
    "PaddingTop"10padding on the top
    "PaddingBottom"10padding on the bottom
    "PaddingLeft"10padding on the left
    "PaddingRight"10padding on the right
  • The option setting ControlsRendering type specifies the style used to render sliders. The default setting forpos is "Generic" which gives standard Flash sliders. Alternatively, it can be set to "FrontEnd.Windows" or "FrontEnd.Macintosh" which will display with the sliders similar to those used by the notebook front end on Windows or Macintosh respectively. A setting of "FrontEnd" will display with Macintosh sliders in browsers on Macintosh platforms otherwise it will use the front end Windows style.

Examples

open allclose all

Basic Examples  (1)

The following creates an interactive plot controlled by a slider and a checkbox.

<msp:evaluate>
MSPManipulate[
Plot[ Cos[var+x], {x,0,2Pi}, Frame -> frame],
{var, 0,20}, {frame, {True,False}}]
</msp:evaluate>

You can change the default style of some of the controls using the ControlType option. The following example uses a PopupMenu to represent the choices; without the option a SetterBar would be used.

<msp:evaluate>
MSPManipulate[ Plot[ fun[x],{x,0,20}], {fun, {Sin, Cos}},
ControlType -> PopupMenu]
</msp:evaluate>

MSPManipulate always formats its argument into an image; by default it uses StandardForm. However, it can be changed to format into TraditionalForm; which is shown in the following.

<msp:evaluate>
MSPManipulate[ Integrate[ 1/(1^-num),x], {num, 1,20,1},
FormatType -> TraditionalForm]
</msp:evaluate>

The size of the finished interactive web output can be controlled by the OutputSize option. This has a default that tries to keep track of the number of controls. If there is not enough space then scrollbars will be added automatically. In the following example a size of 800 by 800 pixels is used.

<msp:evaluate>
MSPManipulate[ Integrate[ 1/(1^-num),x], {num, 1,20,1},
OutputSize -> {800,800}]
</msp:evaluate>

Scope  (3)

Style  (1)

The variable can be displayed in different styles using a Style specification.

<msp:evaluate>
MSPManipulate[ Plot[Sin[x+var],{x,0,2Pi}],
        {{var,0,Style[var, FontSize ->15, FontColor -> Red]}, 0,2Pi}]
</msp:evaluate>

Static Labels  (1)

You can include static expressions that don't render to controls in the list. These are useful for labelling.

<msp:evaluate>
MSPManipulate[ Plot[Sin[ x+phase],{x,0,2Pi}],
"Control Parameter for Phase",
    {phase, 0,2Pi}]
</msp:evaluate>

The label can be displayed in different styles using a Style specification.

<msp:evaluate>
MSPManipulate[ Plot[Sin[fact x+phase],{x,0,2Pi}],
Style[ "Control Parameter for Phase", FontFamily ->"Times"],
    {phase, 0,2Pi},
Style[ "Control Parameter for Factor", FontFamily ->"Times"],
{fact, 1,20}]
</msp:evaluate>

Control Label Formatting  (1)

If you want to use typesetting or extended font characters in the label for the control you can use StandardForm or TraditionalForm as a wrapper.

<msp:evaluate>
MSPManipulate[ Plot[Sin[x+var],{x,0,2Pi}],
    {{var,0,TraditionalForm[Subscript[\[CapitalPhi],1]]}, 0,2Pi}]
</msp:evaluate>

Options  (4)

ContainerStyle  (1)

The ContainerStyle option can be used to change the border style. Here no border is shown.

<msp:evaluate>
MSPManipulate[ Plot[Sin[x+var],{x,0,2Pi}], {var, 0,2Pi},
ContainerStyle -> {"BorderStyle" -> "none"}]
</msp:evaluate>

ControlPlacement  (1)

The ControlPlacement option can be used to change the location of the controls.

<msp:evaluate>
MSPManipulate[ Plot[Sin[x+var],{x,0,2Pi}],
    {var, 0,2Pi},ControlPlacement -> Left]
</msp:evaluate>

You can give settings to individual controls.

<msp:evaluate>
MSPManipulate[ Plot[Sin[fact x+var],{x,0,2Pi}],
    {var, 0,2Pi,ControlPlacement -> Left},
{fact, 1,20,ControlPlacement -> Right}]
</msp:evaluate>

ControlsRendering  (1)

The ControlsRendering option can be used to change the appearance of sliders. The following gives the appearance of a Macintosh type slider.

<msp:evaluate>
MSPManipulate[ Plot[Sin[x+var],{x,0,2Pi}],
    {var, 0,2Pi},ControlsRendering -> "FrontEnd.Macintosh"]
</msp:evaluate>

The following use the front end style for Macintosh in browsers on Macintosh platforms. Otherwise it uses the front end style for Windows.

<msp:evaluate>
MSPManipulate[ Plot[Sin[x+var],{x,0,2Pi}],
    {var, 0,2Pi},ControlsRendering -> "FrontEnd"]
</msp:evaluate>

FieldSize  (1)

The FieldSize option can be used to change the size of input fields. The following uses a longer input field.

<msp:evaluate>
MSPManipulate[ Plot[fun[x],{x,0,2Pi}],
    {{fun,Sin}, FieldSize -> 30}]
</msp:evaluate>