vmm.core
Class UserExhibit.Support

java.lang.Object
  extended by vmm.core.UserExhibit.Support
Direct Known Subclasses:
UserExhibit3D.Support
Enclosing interface:
UserExhibit

public static class UserExhibit.Support
extends java.lang.Object

An object of type UserExhibit.Support holds the information need for a user exhibit and provides some methods for manipulating that information. Most users of this class will only have to declare an instance variable of type UserExhibit.Support and create and customize the object in the constructor of the user exhibit class (saving references to the UserExhibit.FunctionInfo objects created by the support object). This Support object should be returned as the value of UserExhibit.getUserExhibitSupport().

Note that the once the support object has been created, the system handles most of the details, such as showing the dialog box where the user will enter the definitions of the functions and saving the values of those functions when the user exhibit is saved to a settings file.


Nested Class Summary
protected  class UserExhibit.Support.Dialog
          Implements the dialog box where the user enters the data for a user exhibit.
protected static class UserExhibit.Support.ExtraPanel
          An object of type ExtraPanel can be added to the dialog box to get some extra data from the user.
 
Constructor Summary
UserExhibit.Support(UserExhibit exhibit)
          Create a UserExhibit.Support object for use by a specified UserExhibit
 
Method Summary
 UserExhibit.FunctionInfo addComplexFunction(java.lang.String name, java.lang.String definition, java.lang.String... argumentName)
          Add a complex-valued function to the user info.
 void addFunctionParameter(ComplexVariableParam p)
          In addition to the arguments of the function, the definition of a function can contain refereneces to "parameters".
 void addFunctionParameter(VariableParam p)
          In addition to the arguments of the function, the definition of a function can contain refereneces to "parameters".
 UserExhibit.FunctionInfo addRealFunction(java.lang.String name, java.lang.String definition, java.lang.String... argumentName)
          Add a real-valued function to the user info.
 void addToXML(org.w3c.dom.Document containingDocument, org.w3c.dom.Element userDataElement)
          This is called by the system when the user exhibit is being saved to a settings file to write the user data to the settings file.
protected  UserExhibit.Support.Dialog createDialog(Display display, View view, boolean creating)
          Called by showCreateDialog(Display) and showChangeDialog(Display, View) to actually create the dialog box.
 View defaults()
          This method initializes the user exhibit to the default values from its create dialog.
protected  void finish(UserExhibit.Support.Dialog dialog, View view, boolean creating)
          Called by showCreateDialog(Display) and showChangeDialog(Display, View) after the user has clicked the OK button to dismiss the dialog box.
 boolean getAllowChangeUserDataCommand()
           
 boolean getAllowNewParameters()
           
 int getFunctionCount()
          Returns the number of functions, real and complex, that have been added to this Support object.
 UserExhibit.FunctionInfo getFunctionInfo(int index)
          Returns the FunctionInfo object for the i-th function that was added to this object.
 Parameter[] getFunctionParameters()
          Gets the list of parameters that can be used in the definitions of the functions.
 boolean getShowWindow()
           
 AbstractActionVMM makeChangeUserDataAction(View view)
          Creates the "Change User Data" command for adding to the 3DXM Settings menu.
 void readFromXML(org.w3c.dom.Element userDataElement)
          This method is called by the system when the user exhibit is being read from a settings file.
 void setAllowChangeUserDataCommand(boolean allowChangeUserDataCommand)
          Sets the value of the allowChangeUserData property.
 void setAllowNewParameters(boolean allowNewParameters)
          Sets the value of the allowNewParameters property.
 void setShowWindow(boolean showWindow)
          Sets the value of the showWindow property.
 boolean showChangeDialog(Display display, View view)
          Shows the dialog box where the user enters the data for the exhibit.
 View showCreateDialog(Display display)
          Shows the dialog box where the user enters the data for the exhibit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserExhibit.Support

public UserExhibit.Support(UserExhibit exhibit)
Create a UserExhibit.Support object for use by a specified UserExhibit

Parameters:
exhibit - the UserExhibit that uses this support object. The value of this parameter will ordinarily be specified as "this".
Method Detail

addFunctionParameter

public void addFunctionParameter(VariableParam p)
In addition to the arguments of the function, the definition of a function can contain refereneces to "parameters". (The values of these parameters can be set by the user in the "SetParameters" dialog.) This method adds a real-valued parameter to the user info, so that it can be used in the function definitions. The name of the parameter should be something that will be appropriate for use in a function definition.

Parameters:
p - the non-null parameter to be made available for use in the function definitions. Note that the parameter can belong to the subclass VariableParamAnimateable; if that is the case, then the user will be able to specify upper and lower limits for morphing the parameter.

addFunctionParameter

public void addFunctionParameter(ComplexVariableParam p)
In addition to the arguments of the function, the definition of a function can contain refereneces to "parameters". (The values of these parameters can be set by the user in the "SetParameters" dialog.) This method adds a complex-valued parameter to the user info, so that it can be used in the function definitions. The name of the parameter should be something that will be appropriate for use in a function definition.

Note that, by default, the user can change the list of parameters. See setAllowNewParameters(boolean).

Parameters:
p - the non-null parameter to be made available for use in the function definitions. Note that the parameter can belong to the subclass ComplexVariableParamAnimateable; if that is the case, then the user will be able to specify upper and lower limits for morphing the parameter.

addRealFunction

public UserExhibit.FunctionInfo addRealFunction(java.lang.String name,
                                                java.lang.String definition,
                                                java.lang.String... argumentName)
Add a real-valued function to the user info. The user will be able to modify the definition of the function in a dialog box. A reference to the return value of this function should be saved; that reference is needed to compute the value of the function.

Parameters:
name - The name of the function, which will be used only in the label for the text field where the user enters the definition.
definition - The initial value for the defintion of the function. This can be modified by the user. The defintion will be processed by a Parser to produce the actual function.
argumentName - The names of the arguments of the function, such as the "x" and "y" in "f(x,y)". These arguments can be used in the definition of the function.
Returns:
A FunctionInfo object that will contain the function and that can be used to compute values of the function. (Note that the function is null just after this function is called.)

addComplexFunction

public UserExhibit.FunctionInfo addComplexFunction(java.lang.String name,
                                                   java.lang.String definition,
                                                   java.lang.String... argumentName)
Add a complex-valued function to the user info. The user will be able to modify the definition of the function in a dialog box. A reference to the return value of this function should be saved; that reference is needed to compute the value of the function.

Parameters:
name - The name of the function, which will be used only in the label for the text field where the user enters the definition.
definition - The initial value for the defintion of the function. This can be modified by the user. The defintion will be processed by a Parser to produce the actual complex-valued function.
argumentName - The names of the arguments of the function, such as the "z" and "w" in "f(z,w)". These arguments can be used in the definition of the function.
Returns:
A FunctionInfo object that will contain the function and that can be used to compute values of the function. (Note that the function is null just after this function is called.)

getFunctionCount

public int getFunctionCount()
Returns the number of functions, real and complex, that have been added to this Support object. (This method is used by the system, but is not usually needed otherwise.)


getFunctionInfo

public UserExhibit.FunctionInfo getFunctionInfo(int index)
Returns the FunctionInfo object for the i-th function that was added to this object. (This method is used by the system, but is not usually needed otherwise.)


getFunctionParameters

public Parameter[] getFunctionParameters()
Gets the list of parameters that can be used in the definitions of the functions. (These are not function arguments, but are other parameters.) The parameters were added either by the user or by addFunctionParameter(ComplexVariableParam) or addFunctionParameter(VariableParam). (This method is used by the system, but is not usually needed otherwise.)


getAllowChangeUserDataCommand

public boolean getAllowChangeUserDataCommand()
See Also:
setAllowChangeUserDataCommand(boolean)

setAllowChangeUserDataCommand

public void setAllowChangeUserDataCommand(boolean allowChangeUserDataCommand)
Sets the value of the allowChangeUserData property. The default value is true. When this property is true, a "Change User Data" command appears in the 3DXM Settings menu. This command calls up the dialog box where the user enters the data for the user exhibit. If this property is false, then that command is omitted and the user will not be able to change the user data once it has been created.


getAllowNewParameters

public boolean getAllowNewParameters()
See Also:
setAllowNewParameters(boolean)

setAllowNewParameters

public void setAllowNewParameters(boolean allowNewParameters)
Sets the value of the allowNewParameters property. The default value is true. If this property is true, then the user will be able to add new parameters for use in function definitions and will also be able to remove existing parameters. "Add Parameter" and "Remove Parameter" buttons are added to the dialog box to implement this. If the value of the property if false, then the buttons are omitted from the dialog box, and the only parameters that are available for use in the functions are those added by addFunctionParameter(VariableParam) and addFunctionParameter(ComplexVariableParam).


getShowWindow

public boolean getShowWindow()
See Also:
setShowWindow(boolean)

setShowWindow

public void setShowWindow(boolean showWindow)
Sets the value of the showWindow property. The default value is true. If the value is true, then a panel is added to the dialog box where the user can specify the xy-window (that is, the range of values that are visible in the view) for the exhibit. Setting the property to false removes this panel from the dialog box.


defaults

public View defaults()
This method initializes the user exhibit to the default values from its create dialog. It has the same effect as if showCreateDialog(Display) were called and the user clicked "OK" without making any changes to the data in the dialog box, except that the dialog is not actually shown. This is used to initially load a user exhibit in the main program for 3D-XplorMath-J and in the 3DXM LauncherApplet; it will probably not be used otherwise.

Returns:
A view that is configured according to the default data, or null if an error occurs. There should not be an error, unless there is a bug in the user exhibit.

showCreateDialog

public View showCreateDialog(Display display)
Shows the dialog box where the user enters the data for the exhibit. This method is called by the system just after an object of type UserExhibit is constructed. It will not ordinarily be used directly.

Parameters:
display - The display that serves as the parent component of the dialog box; can be null.

showChangeDialog

public boolean showChangeDialog(Display display,
                                View view)
Shows the dialog box where the user enters the data for the exhibit. This method is called by the system in response to a "Change User Data" command. It will not ordinarily be used directly.


makeChangeUserDataAction

public AbstractActionVMM makeChangeUserDataAction(View view)
Creates the "Change User Data" command for adding to the 3DXM Settings menu. This is called by the system and will not ordinarily be used directly.


addToXML

public void addToXML(org.w3c.dom.Document containingDocument,
                     org.w3c.dom.Element userDataElement)
This is called by the system when the user exhibit is being saved to a settings file to write the user data to the settings file. This method will not oridinarly be used directly.


readFromXML

public void readFromXML(org.w3c.dom.Element userDataElement)
                 throws java.io.IOException
This method is called by the system when the user exhibit is being read from a settings file. This method will not ordinarily be called directly.

Throws:
java.io.IOException

createDialog

protected UserExhibit.Support.Dialog createDialog(Display display,
                                                  View view,
                                                  boolean creating)
Called by showCreateDialog(Display) and showChangeDialog(Display, View) to actually create the dialog box. This can be overridden by a subclass to customize the dialog box.


finish

protected void finish(UserExhibit.Support.Dialog dialog,
                      View view,
                      boolean creating)
Called by showCreateDialog(Display) and showChangeDialog(Display, View) after the user has clicked the OK button to dismiss the dialog box. It can be overridden in a subclass to customize the way the data in the dialog box is applied.