Scripting

Use the following Javascript methods to communicate with the Editor Applet:

Javascript methodDescription
string getContentMathML()Returns a string containing formatted content MathML markup for the current equation. If content markup generation fails, this will return the string "conversion error," and will visually report errors or warnings.
string getContentSelection()Returns a string containing formatted content MathML markup for the selected portion of the current equation. If content markup generation fails, this will return the string "conversion error," and will visually report errors or warnings.
string getDoubleEscapedContentMathML()Returns a string containing double-escaped packed content MathML markup for the current equation. If content markup generation fails, this will return the string "conversion error," and will visually report errors or warnings.
string getDoubleEscapedMathML()Returns a string containing packed MathML markup for the current equation in which unicode characters have been double escaped, in the format of "&" + EntityName + ";".
string getFormattedMathML(int markupTypeint formatLevel, boolean namespaceAttr, string namespacePrefix, int characterType)Returns the MathML for the current equation with the specified format. Specific values for the parameters are as follows:

markupType
0 Mixed content/presentation markup
1 Presentation markup format
2 Content markup format (if possible)
3 Normalized presentation format (extra mrows removed)

formatLevel
0 Pretty printed (on multiple lines and indented to make reading easier)
1 Packed (all on one line, no indenting or extra spaces)
2 Packed and escaped (all on one line, all <>& shown as escaped characters)
3 Packed and wrapped (no extra white space, but returns added at nearest tag at 80 columns)

namespaceAttr States whether or not a namespace prefix should be added to each tag.

namespacePrefix Used with namespaceAttr. Prepends every tag with this namespace.

characterType
0 Special characters are shown as entity names if possible.
1 Special characters are shown in the format &#xXXXX; where X is a hexadecimal value.
2 Special characters are shown in UTF-8 format. This is the binary representation of the characters and may look strange in many text-processing programs.  
string getFormattedMathMLSelection(int markupType, int formatLevel, boolean namespaceAttr, string namespacePrefix, int characterType)Returns the MathML for the selected portion of the current equation with the selected format.
string getMathML()Returns a string containing formatted presentation MathML markup for the current equation.
equation getMathMLDocument()Returns the top level DOM Document node for the current equation.
string getPackedContentMathML()Returns a string containing unformatted content MathML markup for the current equation.
string getPackedMathML()Returns a string containing unformatted MathML markup for the current equation. The markup is stripped of extra white space including linefeeds and indenting, and is much more compact than formatted MathML.
string getSelection()Returns a string containing formatted MathML markup for the selected portion of the current equation.
void insertMathMLAtCursor(string new_mml)Inserts the new equation with the specified MathML markup at the current cursor location.
void setMathML(string new_mml)Sets the MathML source for the current equation.
string getURLEncodedContentMathML()Returns a string containing URL-encoded packed content MathML markup for the current equation. If content markup generation fails, this will return the string "conversion error," and will visually report errors or warnings.
string getURLEncodedMathML()Returns a string containing URL-encoded packed MathML markup for the current equation in which necessary characters have been escaped in order for the string to be safely transmitted as CGI data. The following characters will be encoded:
" " → %20
"+" → %2B
"&" → %26
"<" → %3C
"=" → %3D
">" → %3E
"?" → %3F
void setURLEncodedMathML(string mml)Sets the URL-encoded MathML source for the current equation. Specifically, the following character sequences in the mml argument will be decoded:
%20 → " "
%2B → "+"
%26 → "&"
%3C → "<"
%3D → "="
%3E → ">"
%3F → "?"

Use the following Javascript methods to get images from the editor applet:

Javascript methodDescription
Image getEquationImage()Returns an AWT Image of the current equation, only useful from another Java applet.
Image getEquationImage(int pointSize)Returns an AWT Image of the current equation rendered at the specified font point size.
Image getEquationImage(int pointSize, String bgColor)Returns an AWT Image of the current equation rendered at the specified font point size and with the specified background color, which can either be of the form #rrggbb, #rgb, or a CSS color keyword, such as "blue".
Image getEquationImage(int pointSize, int dpi, String fgColor, String bgColor, String halignment, String valignment, int border, int breakwidth, int width, int height)Returns an AWT Image of the current equation rendered with the specified properties.
void clearEquation()Clears the current equation.

Use the following Javascript methods to get and set values in the editor applet:

Javascript methodDescription
int getAppletHeight()Returns the proper height parameter value for a MathMLViewerApplet rendering the equation at the current font point size. The applet height differs from the equation height because the applet pads the equation so that the baseline lies on the centerline of the applet.
int getAppletHeightAt(String ptsize)Returns the proper height parameter value for a MathMLViewerApplet rendering the equation at the specified font point size.
String getBackgroundColor()Returns the background color of the current equation, in the form of #rrggbb, #rgb, or a CSS color keyword, such as "blue".
void setBackgroundColor(String bgColor)Sets the background color of the current equation.
int getPointSize()Returns the base font point size for the current equation.
void setPointSize(int user_size)Sets the base font point size for the current equation.
String getForegroundColor()Returns the foreground color of the current equation, in the form of #rrggbb, #rgb, or a CSS color keyword, such as "blue".
void setForegroundColor(String fgColor)Sets the foreground color of the current equation.
int getPreferredAscent()Returns the preferred ascent above the baseline in pixels of the current equation.
int getPreferredAscentAt(String ptsize)Returns the preferred ascent above the baseline in pixels of the current equation rendered at the specified font point size.
int getPreferredHeight()Returns the preferred height in pixels of the current equation.
int getPreferredHeightAt(String ptsize)Returns the preferred height in pixels of the current equation rendered at the specified font point size.
int getPreferredWidth()Returns the preferred width in pixels of the current equation.
int getPreferredWidthAt(String ptsize)Returns the preferred width in pixels of the current equation rendered at the specified font point size.
String getVersion()Returns the MathFlow SDK version string for this editor applet.

Select the type of help system to use and where the help file(s) are located.

Javascript methodDescription
void setHelp(int helpType, String helpFile)Sets the help type and the path to the HTML help file.

helpType
0 Context sensitive JavaHelp, this is the default and assumes the helpfiles are in the jar file.
1 Context sensitive help using HTML page provided in the SDK.
2 Point to a HTML page that is not context sensitive. This can be the files provided by the SDK or one of your own.

helpFile
The path to the HTML help file or the jar containing JavaHelp (usually MFStyleEditor.jar or MFStructureEditor.jar)
NOTE: The Simple Editor Applet is limited to supporting help option 2.

Simple Editor applet

You can use Javascript to change the UI of the Simple Editor Applet. The following methods allow the general editing preferences of an editor applet to be persisted (i.e., saved and restored by your applet). Note that the Simple Editor Applet and the Style Editor Applet use different methods for setting preferences.

Javascript methodDescription
void setEditingPreferences(int spacebar, boolean autoStretchy, boolean autoItalics, boolean autoFunctions, boolean greekNormal, boolean ddDoubleStruck)spacebar
Sets the pattern of insertion when we press the keyboard spacebar.

autoStretchy
Sets whether or not keyboard entries of ( ), { }, [ ] and | | should be made stretchy by default.

autoItalics
Sets whether or not single-character variables should be made italic by default.

autoFunctions
Sets whether or not common functions should be automatically recognized.

greekNormal
Sets whether or not uppercase Greek letters should be made normal by default.

ddDoubleStruck
Sets whether or not differential d should be rendered in double struck.
boolean getAutoFunctions()Returns whether common functions are automatically recognized.
boolean getAutoItalics()Returns whether single-character variables are made italic by default.
boolean getAutoStretchy()Returns whether keyboard entries of ( ), { }, [ ] and | | are made stretchy by default.
boolean getDifferentialDDoubleStruck()Returns whether differential d is rendered in double struck.
boolean getDisplayStyle()Returns whether the current equation is in display style.
void setDisplayStyle(boolean b)Sets whether or not the current equation is in display style.
int getSpacebarBehavior()Returns the pattern of insertion when we press the keyboard spacebar. The valid values are:

0 Invisible times after an operand, space otherwise
1 Invisible times always
2 Space always
3 Nothing  
boolean getUpperGreekNormal()Returns whether uppercase Greek letters are made normal by default.
void setToolbarMarkup(String toolbarMarkup)Sets the toolbar configuration markup for the current editor applet. If there is any error in the markup, it will default back to the previous toolbar. See the MathFlow SDK Programmer's Guide for the description of the toolbar configuration language.
void hideToolbar()Hides the MathFlow toolbar if it is visible.
void showToolbar()Shows the MathFlow toolbar if it is hidden.

Style Editor applet

You can use Javascript to change the UI of the Style Editor Applet. The following methods allow the general editing preferences of a Style Editor Applet to be persisted (i.e., saved and restored by your applet). The boolean useDefault indicates whether to return the default value or the stored value.

Javascript methodDescription
void setEditingPreferences(int spacebar, boolean autoStretchy, boolean autoItalics, boolean autoFunctions, boolean greekNormal, boolean ddDoubleStruck)spacebar
Sets the pattern of insertion when we press the keyboard spacebar.

autoStretchy
Sets whether or not keyboard entries of ( ), { }, [ ] and | | should be made stretchy by default.

autoItalics
Sets whether or not single-character variables should be made italic by default.

autoFunctions
Sets whether or not common functions should be automatically recognized.

greekNormal
Sets whether or not uppercase Greek letters should be made normal by default.

ddDoubleStruck
Sets whether or not differential d should be rendered in double struck.
boolean getAutoFunctions()Returns whether common functions are automatically recognized.
boolean getAutoItalics()Returns whether single-character variables are made italic by default.
boolean getAutoStretchy()Returns whether keyboard entries of ( ), { }, [ ] and | | are made stretchy by default.
String getCommonFunctionsList()Returns the comma seperated list of common functions.
void setCommonFunctionsList(String list)Sets the list of common functions.
boolean getDifferentialDDoubleStruck()Returns whether differential d is rendered in double struck.
boolean getDisplayStyle()Returns whether the current equation is in display style.
void setDisplayStyle(boolean b)Sets whether or not the current equation is in display style.
int getSpacebarBehavior()Returns the pattern of insertion when we press the keyboard spacebar. The valid values are:

0 Invisible times after an operand, space otherwise
1 Invisible times always
2 Space always
3 Nothing
boolean getUpperGreekNormal()Returns whether uppercase Greek letters are made normal by default.
String getToolbarName()Returns the toolbar name.
void setToolbarMarkup(String toolbarMarkup)Sets the toolbar configuration markup for the current editor applet. If there is any error in the markup, it will default back to the previous toolbar. See the MathFlow SDK Programmer's Guide for the description of the toolbar configuration language.
void setToolbarPreferences(String tbname, String config)Sets the toolbar preferences. If you set the wrong value, it will display an error message and revert back to the original toolbar. Valid values for tbname are "#standard", "#basic", "#extrasymbols" and "#websafe."

Structure Editor applet

You can use Javascript to change the UI of the Structure Editor Applet. The following methods allow the general editing preferences of a Structure Editor Applet to be persisted, (i.e., saved and restored by your applet). The boolean useDefault indicates whether to return the default value or the stored value.

Javascript methodDescription
void setEditingPreferences(int spacebar, boolean autoStretchy, boolean autoItalics, boolean autoFunctions, boolean greekNormal, boolean ddDoubleStruck)spacebar
Sets the pattern of insertion when we press the keyboard spacebar.

autoStretchy
Sets whether or not keyboard entries of ( ), { }, [ ] and | | should be made stretchy by default.

autoItalics
Sets whether or not single-character variables should be made italic by default.

autoFunctions
Sets whether or not common functions should be automatically recognized.

greekNormal
Sets whether or not uppercase Greek letters should be made normal by default.

ddDoubleStruck
Sets whether or not differential d should be rendered in double struck.
boolean getAutoFunctions()Returns whether common functions are automatically recognized.
boolean getAutoItalics()Returns whether single-character variables are made italic by default.
boolean getAutoStretchy()Returns whether keyboard entries of ( ), { }, [ ] and | | are made stretchy by default.
String getCommonFunctionsList()Returns the comma seperated list of common functions.
void setCommonFunctionsList(String list)Sets the list of common functions.
boolean getDifferentialDDoubleStruck()Returns whether differential d is rendered in double struck.
boolean getDisplayFMWarning()Returns a value indicating if a warning dialog should appear to signal the presence of foreign markup
void setDisplayFMWarning(boolean b)Sets a value indicating if a dialog box will appear when mathml contains foreign markup.
boolean getDisplayStyle()Returns whether the current equation is in display style.
void setDisplayStyle(boolean b)Sets whether or not the current equation is in display style.
boolean getDisplayNonMML()Returns a value indicating if non-MathML tags are displayable.
void setDisplayNonMML(boolean b)Sets a value indicating if non-MathML tags are displayable.
int getNonMMLDisplayTypes()Returns a value that represents the non-MathML tags that will be displayed.
void setNonMMLDisplayTypes(int i)Sets a value that determines what kinds of non-MathML tags will be displayed.
boolean getRulerEnabled()Returns the whether to show the ruler.
void setRulerEnabled(boolean b)Sets whether to show the ruler.
String getRulerUnit()Returns the general preference for the ruler unit.
void setRulerUnit(String rulerUnit)Sets the general preference for the ruler unit.
int getSpacebarBehavior()Returns the pattern of insertion when we press the keyboard spacebar. The valid values are:

0 Invisible times after an operand, space otherwise
1 Invisible times always
2 Space always
3 Nothing
boolean getUpperGreekNormal()Returns whether uppercase Greek letters are made normal by default.
String getToolbarName()Returns the toolbar name.
void setToolbarMarkup(String toolbarMarkup)Sets the toolbar configuration markup for the current editor applet. If there is any error in the markup, it will default back to the previous toolbar. See the MathFlow SDK Programmer's Guide for the description of the toolbar configuration language.
void setToolbarPreferences(String tbname, String config)Sets the toolbar preferences. If you set the wrong value, it will display an error message and revert back to the original toolbar. Valid values for tbname are "#standard", and "#extrasymbols."

You can use the following Javascript methods for miscellaneous interaction with the editor component's applet.

Javascript methodDescription
boolean isEquationEmpty()Returns true if the current equation is empty.
void highlightSyntax(boolean turnOn)Turns on/off the syntax highlighting mode for the current equation. Calling this function has the same effect as clicking the "Check syntax" button on the default toolbar.
void setPromptString(String message)Sets the status line cue for the browser until the status line message is replaced by the browser for any other reason.