|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensourcephysics.tools.UserFunction
public class UserFunction
A known function for which the expression and parameters are user-editable.
| Nested Class Summary | |
|---|---|
protected static class |
UserFunction.Loader
A class to save and load UserFunction data in an XMLControl. |
| Field Summary | |
|---|---|
protected java.lang.String |
description
|
protected static java.lang.String[] |
dummyVars
|
protected java.lang.String |
expression
|
protected ParsedMultiVarFunction |
function
|
protected java.lang.String[] |
functionNames
|
protected java.lang.String |
inputString
|
protected java.lang.String |
name
|
protected boolean |
nameEditable
|
protected java.lang.String[] |
paramNames
|
protected double[] |
paramValues
|
protected UserFunction[] |
references
|
protected java.lang.String[] |
vars
|
| Constructor Summary | |
|---|---|
UserFunction(java.lang.String name)
Constructor. |
|
| Method Summary | |
|---|---|
UserFunction |
clone()
Returns a clone of this UuserFunction. |
double |
evaluate(double x)
Evaluates the function for a single variable x. |
double |
evaluate(double[] x)
Evaluates the function for a variables array x. |
protected double[] |
evaluateSupportFunctions(double x)
Evaluates the support functions for a single variable x. |
protected double[] |
evaluateSupportFunctions(double[] x)
Evaluates the support functions for a variables array x. |
java.lang.String |
getDescription()
Gets the description of this function. |
java.lang.String |
getExpression()
Gets the expression using the current variables. |
java.lang.String |
getExpression(java.lang.String indepVarName)
Gets the expression and sets the independent variable. |
java.lang.String |
getExpression(java.lang.String[] varNames)
Gets the expression and sets the independent variables. |
java.lang.String |
getFullExpression(java.lang.String[] varNames)
Gets the full expression using the current variables. |
java.lang.String |
getIndependentVariable()
Gets the current independent variable. |
java.lang.String[] |
getIndependentVariables()
Gets the current independent variables. |
java.lang.String |
getInputString()
Gets the expression. |
static XML.ObjectLoader |
getLoader()
Returns the XML.ObjectLoader for this class. |
java.lang.String |
getName()
Gets the name. |
int |
getParameterCount()
Gets the parameter count. |
java.lang.String |
getParameterName(int i)
Gets a parameter name. |
double |
getParameterValue(int i)
Gets a parameter value. |
boolean |
isNameEditable()
Returns true if the name is user-editable. |
void |
setDescription(java.lang.String desc)
Sets the description of this function. |
boolean |
setExpression(java.lang.String exp,
java.lang.String[] varNames)
Sets the expression. |
void |
setName(java.lang.String name)
Sets the name. |
void |
setNameEditable(boolean editable)
Sets the name editable property. |
void |
setParameters(java.lang.String[] names,
double[] values)
Sets the parameters. |
void |
setParameterValue(int i,
double value)
Sets a parameter value. |
void |
setReferences(UserFunction[] functions)
Sets the reference functions. |
void |
updateReferenceParameters()
Sets the parameters of reference functions to those of this function. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static java.lang.String[] dummyVars
protected java.lang.String name
protected java.lang.String[] paramNames
protected double[] paramValues
protected java.lang.String expression
protected java.lang.String inputString
protected ParsedMultiVarFunction function
protected java.lang.String[] vars
protected UserFunction[] references
protected boolean nameEditable
protected java.lang.String description
protected java.lang.String[] functionNames
| Constructor Detail |
|---|
public UserFunction(java.lang.String name)
name - the function name| Method Detail |
|---|
public java.lang.String getName()
getName in interface KnownFunctionpublic void setName(java.lang.String name)
name - the namepublic boolean isNameEditable()
public void setNameEditable(boolean editable)
editable - true if editablepublic java.lang.String getIndependentVariable()
public java.lang.String[] getIndependentVariables()
public java.lang.String getInputString()
public java.lang.String getExpression()
public java.lang.String getExpression(java.lang.String indepVarName)
getExpression in interface KnownFunctionindepVarName - the name of the independent variable
public java.lang.String getExpression(java.lang.String[] varNames)
varNames - the name of the independent variables
public java.lang.String getFullExpression(java.lang.String[] varNames)
varNames - the name of the independent variables
public boolean setExpression(java.lang.String exp,
java.lang.String[] varNames)
exp - a parsable expression of the parameters and variablesvarNames - the name of the independent variables
public int getParameterCount()
getParameterCount in interface KnownFunctionpublic java.lang.String getParameterName(int i)
getParameterName in interface KnownFunctioni - the parameter index
public double getParameterValue(int i)
getParameterValue in interface KnownFunctioni - the parameter index
public void setParameterValue(int i,
double value)
setParameterValue in interface KnownFunctioni - the parameter indexvalue - the value
public void setParameters(java.lang.String[] names,
double[] values)
names - the parameter namesvalues - the parameter valuespublic void updateReferenceParameters()
public void setReferences(UserFunction[] functions)
functions - the functions referenced by this onepublic java.lang.String getDescription()
public void setDescription(java.lang.String desc)
desc - the descriptionpublic double evaluate(double x)
evaluate in interface Functionx -
public double evaluate(double[] x)
evaluate in interface MultiVarFunctionx -
public UserFunction clone()
clone in class java.lang.Objectprotected double[] evaluateSupportFunctions(double x)
x -
protected double[] evaluateSupportFunctions(double[] x)
x -
public static XML.ObjectLoader getLoader()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||