org.opensourcephysics.tools
Class Parameter

java.lang.Object
  extended by org.opensourcephysics.tools.Parameter

public class Parameter
extends java.lang.Object

This represents a parameter expression that is parsed and evaluated as a function of other parameters.

Author:
Douglas Brown

Constructor Summary
Parameter(java.lang.String name, java.lang.String function)
          Constructor with name and function.
Parameter(java.lang.String name, java.lang.String function, java.lang.String desc)
          Constructor with name, function and description.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Determines if this is equal to another parameter.
protected  double evaluate(java.util.List<?> parameters)
          Determines the value of this parameter based on input parameter values.
 double evaluate(Parameter[] parameters)
          Determines the value of this parameter based on input parameter values.
 java.lang.String getDescription()
          Gets the description of this parameter.
 java.lang.String getExpression()
          Gets the expression for this parameter.
static XML.ObjectLoader getLoader()
          Returns an ObjectLoader to save and load data for this class.
 java.lang.String getName()
          Gets the name of this parameter.
 double getValue()
          Gets the current value of this parameter.
 boolean isExpressionEditable()
          Returns true if this parameter's expression is user-editable.
 boolean isNameEditable()
          Returns true if this parameter's name is user-editable.
 void setDescription(java.lang.String desc)
          Sets the description of this parameter.
 void setExpressionEditable(boolean edit)
          Sets the expression editable property.
 void setNameEditable(boolean edit)
          Sets the name editable property.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parameter

public Parameter(java.lang.String name,
                 java.lang.String function)
Constructor with name and function.

Parameters:
name - the name
function - the function (parser expression)

Parameter

public Parameter(java.lang.String name,
                 java.lang.String function,
                 java.lang.String desc)
Constructor with name, function and description.

Parameters:
name - the name
function - the function (parser expression)
desc - the description
Method Detail

getName

public java.lang.String getName()
Gets the name of this parameter.

Returns:
the name

getExpression

public java.lang.String getExpression()
Gets the expression for this parameter.

Returns:
the expression

getDescription

public java.lang.String getDescription()
Gets the description of this parameter. May return null.

Returns:
the description

setDescription

public void setDescription(java.lang.String desc)
Sets the description of this parameter.

Parameters:
desc - the description

getValue

public double getValue()
Gets the current value of this parameter.

Returns:
the value (may be NaN)

isExpressionEditable

public boolean isExpressionEditable()
Returns true if this parameter's expression is user-editable.

Returns:
true if editable

setExpressionEditable

public void setExpressionEditable(boolean edit)
Sets the expression editable property.

Parameters:
edit - true if editable

isNameEditable

public boolean isNameEditable()
Returns true if this parameter's name is user-editable.

Returns:
true if editable

setNameEditable

public void setNameEditable(boolean edit)
Sets the name editable property.

Parameters:
edit - true if editable

equals

public boolean equals(java.lang.Object obj)
Determines if this is equal to another parameter.

Overrides:
equals in class java.lang.Object
Parameters:
obj - another object
Returns:
true if equal

evaluate

protected double evaluate(java.util.List<?> parameters)
Determines the value of this parameter based on input parameter values.

Parameters:
parameters - the input parameters
Returns:
the value (may be NaN)

evaluate

public double evaluate(Parameter[] parameters)
Determines the value of this parameter based on input parameter values. This method assumes the array of parameters does not include this.

Parameters:
parameters - the input parameters
Returns:
the value (may be NaN)

getLoader

public static XML.ObjectLoader getLoader()
Returns an ObjectLoader to save and load data for this class.

Returns:
the object loader