net.sourceforge.webcompmath.functions.beans
Class WCMDerivativeBean

java.lang.Object
  extended by net.sourceforge.webcompmath.functions.FunctionParserExtension
      extended by net.sourceforge.webcompmath.functions.WrapperFunction
          extended by net.sourceforge.webcompmath.functions.beans.WCMDerivativeBean
All Implemented Interfaces:
java.io.Serializable, ParserMathObject, ExpressionCommand, Function, MathObject, ParserExtension

public class WCMDerivativeBean
extends WrapperFunction
implements ParserMathObject

This class is used with GUI builders to create an object that is the derivative of some function. When you set it's function, it gets the derivative of the function you pass in and uses that as it's own definition (via a WrapperFunction).

Author:
Tom Downey
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sourceforge.webcompmath.functions.FunctionParserExtension
name
 
Constructor Summary
WCMDerivativeBean()
          The default constructor.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Just pass through to the support class
 MathObject getMathObject()
          Returns itself
 void redefine()
          Update the derivative if the function changes.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          just pass through to the support class )
 void setFunction(Function f)
          Set this object's function to the derivative of the argument.
 void setName(java.lang.String name)
          Fire a property change event if the name changes.
 java.lang.String toString()
          Return the toString of the super class, unless the function is an ExpressionFunction (which is too wordy in it's toString).
 
Methods inherited from class net.sourceforge.webcompmath.functions.WrapperFunction
apply, dependsOn, derivative, derivative, getArity, getFunction, getVal, getValueWithCases
 
Methods inherited from class net.sourceforge.webcompmath.functions.FunctionParserExtension
appendOutputString, compileDerivative, doParse, extent, getName, setParensCanBeOptional
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sourceforge.webcompmath.data.MathObject
getName
 

Constructor Detail

WCMDerivativeBean

public WCMDerivativeBean()
The default constructor. Initializes the function to a constant 0 function, so that GUI builder setter ordering issues don't cause null pointer exceptions. The actualy function whose derivative this bean is supposed to represent needs to be set before the bean will actually do useful work.

Method Detail

setFunction

public void setFunction(Function f)
Set this object's function to the derivative of the argument. Always assumes that the variable that the derivative is taken with respect to is the first one (or usually the only one) in the parameters that were defined with f.

Overrides:
setFunction in class WrapperFunction
Parameters:
f - The non-null function to be used in this WrapperFunction object. It must have the same arity as the current function.
See Also:
WrapperFunction.setFunction(net.sourceforge.webcompmath.data.Function)

redefine

public void redefine()
Update the derivative if the function changes. Useful if the function is an ExpressionFunction.


getMathObject

public MathObject getMathObject()
Returns itself

Specified by:
getMathObject in interface ParserMathObject
Returns:
the MathObject that will be added to a parser
See Also:
ParserMathObject.getMathObject()

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Just pass through to the support class

Specified by:
addPropertyChangeListener in interface ParserMathObject
See Also:
ParserMathObject.addPropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
just pass through to the support class )

Specified by:
removePropertyChangeListener in interface ParserMathObject
See Also:
ParserMathObject.removePropertyChangeListener(java.beans.PropertyChangeListener)

setName

public void setName(java.lang.String name)
Fire a property change event if the name changes.

Specified by:
setName in interface MathObject
Overrides:
setName in class FunctionParserExtension
Parameters:
name - name of the object
See Also:
FunctionParserExtension.setName(java.lang.String)

toString

public java.lang.String toString()
Return the toString of the super class, unless the function is an ExpressionFunction (which is too wordy in it's toString).

Overrides:
toString in class WrapperFunction
See Also:
WrapperFunction.toString()