org.fraid.function
Class DefinedFunction

java.lang.Object
  extended by org.fraid.function.ComplexFunction
      extended by org.fraid.function.DefinedFunction
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
RungeKuttaFunction

public class DefinedFunction
extends ComplexFunction

Represents the user defined functions in FrAid.

See Also:
Serialized Form

Field Summary
protected  DefinedFunctionCore mCore
           
protected  GeneratorFunction mGenerator
           
protected  java.util.Set<javax.swing.event.ChangeListener> mListeners
           
 
Fields inherited from class org.fraid.function.ComplexFunction
mName, mNumberOfArguments
 
Constructor Summary
DefinedFunction()
           
DefinedFunction(Samples aSamples)
           
DefinedFunction(java.lang.String aFunctionName)
           
DefinedFunction(java.lang.String aName, int aNumberOfArguments)
           
DefinedFunction(java.lang.String aFunctionName, Samples aSamples)
           
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener aListener)
           
 void clearGenerator()
           
 java.lang.Object clone()
          Used when a panel is cloned to be saved in a file.
 void copyFunctionality(DefinedFunction aOther)
           
static java.util.HashMap<java.lang.String,java.lang.Integer> createDummyArgumentList(int aNumberArgs)
           
 void duplicateListenersToNode(SimpleNode aNode)
           
 java.util.HashMap<java.lang.String,java.lang.Integer> getArgumentsDescription()
           
 DefinedFunction getBaseSampledFunction()
           
 Samples getBaseSamples()
           
static DefinedFunction getDefinedFunction(java.lang.String aFunctionName, java.util.HashMap<java.lang.String,java.lang.Integer> aArgumentsMap, SymbolTable aSymbTable)
           
 java.lang.String getDependancies()
          On what other definitions this function depends.
 void getDependancies(java.util.Vector<ComplexFunction> aVector, java.util.HashSet<ComplexFunction> aAllreadyPassed)
           
 Samples getEvaluatedSamples()
           
 GeneratorFunction getGenerator()
           
 int getNumberOfArguments()
          How many arguments this function takes.
 SimpleNode getRoot()
           
 Samples getSamples()
           
 java.lang.String getSignature()
          The signature of the function...
 Complex invoke(Complex[] aArgs)
          The actual call to the function.
 boolean isBasedOnSampled()
           
 boolean isSampled()
           
 boolean isTreeBasedGenerated()
           
 void notifyListeners()
           
 void regenerate()
           
 int removeChangeListener(javax.swing.event.ChangeListener aListener)
           
 java.lang.String rename(java.lang.String aNewName)
           
 void setArgumentsDescription(java.util.HashMap<java.lang.String,java.lang.Integer> newArgumentsDescription)
           
 void setGenerator(GeneratorFunction aGf)
           
 void setRegenerationFlag()
           
 void setRoot(SimpleNode aNode)
           
 void setSamples(Samples aSamples)
           
 java.lang.String toString()
          The String representataion (DefinedFunction gives you back the complete definition).
 java.lang.String toStringGenerated()
           
 java.lang.String toStringSamples()
           
 
Methods inherited from class org.fraid.function.ComplexFunction
exec, getName, setName, setNumberOfArguments
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mListeners

protected java.util.Set<javax.swing.event.ChangeListener> mListeners

mGenerator

protected GeneratorFunction mGenerator

mCore

protected DefinedFunctionCore mCore
Constructor Detail

DefinedFunction

public DefinedFunction()

DefinedFunction

public DefinedFunction(java.lang.String aName,
                       int aNumberOfArguments)

DefinedFunction

public DefinedFunction(java.lang.String aFunctionName)
                throws SymbTableException
Throws:
SymbTableException

DefinedFunction

public DefinedFunction(Samples aSamples)

DefinedFunction

public DefinedFunction(java.lang.String aFunctionName,
                       Samples aSamples)
                throws SymbTableException
Throws:
SymbTableException
Method Detail

clone

public java.lang.Object clone()
Description copied from class: ComplexFunction
Used when a panel is cloned to be saved in a file. The clone is transient (not included in the symbtable). This ensures the function won't change while we are generating large files.

Overrides:
clone in class ComplexFunction
Returns:
an Object value

setSamples

public void setSamples(Samples aSamples)

getSamples

public Samples getSamples()

getBaseSamples

public Samples getBaseSamples()

getEvaluatedSamples

public Samples getEvaluatedSamples()
                            throws java.lang.Exception
Throws:
java.lang.Exception

getBaseSampledFunction

public DefinedFunction getBaseSampledFunction()

isSampled

public boolean isSampled()

isBasedOnSampled

public boolean isBasedOnSampled()

toString

public java.lang.String toString()
Description copied from class: ComplexFunction
The String representataion (DefinedFunction gives you back the complete definition).

Overrides:
toString in class ComplexFunction
Returns:
a String value
See Also:
DefinedFunction

getSignature

public java.lang.String getSignature()
Description copied from class: ComplexFunction
The signature of the function...

Overrides:
getSignature in class ComplexFunction
Returns:
a String value

toStringSamples

public java.lang.String toStringSamples()

toStringGenerated

public java.lang.String toStringGenerated()

getDependancies

public void getDependancies(java.util.Vector<ComplexFunction> aVector,
                            java.util.HashSet<ComplexFunction> aAllreadyPassed)

getDependancies

public java.lang.String getDependancies()
Description copied from class: ComplexFunction
On what other definitions this function depends. Example: a=5; b='a; //now b depends on a, if I want to use it tomorrow need to save the whole thing.

Overrides:
getDependancies in class ComplexFunction
Returns:
a String value
See Also:
DefinedFunction

getArgumentsDescription

public java.util.HashMap<java.lang.String,java.lang.Integer> getArgumentsDescription()

setArgumentsDescription

public void setArgumentsDescription(java.util.HashMap<java.lang.String,java.lang.Integer> newArgumentsDescription)

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener aListener)

removeChangeListener

public int removeChangeListener(javax.swing.event.ChangeListener aListener)

notifyListeners

public void notifyListeners()

duplicateListenersToNode

public void duplicateListenersToNode(SimpleNode aNode)

setRoot

public void setRoot(SimpleNode aNode)

getRoot

public SimpleNode getRoot()

invoke

public Complex invoke(Complex[] aArgs)
               throws java.lang.Exception
Description copied from class: ComplexFunction
The actual call to the function.

Specified by:
invoke in class ComplexFunction
Parameters:
aArgs - the arguments, can be (and usualy are) SimpleNode's
Returns:
a Complex value
Throws:
java.lang.Exception - if an error occurs
See Also:
SimpleNode

getNumberOfArguments

public int getNumberOfArguments()
Description copied from class: ComplexFunction
How many arguments this function takes. Used for identification only, the function can actually process diff. number.

Overrides:
getNumberOfArguments in class ComplexFunction
Returns:
an int value

rename

public java.lang.String rename(java.lang.String aNewName)

copyFunctionality

public void copyFunctionality(DefinedFunction aOther)

clearGenerator

public void clearGenerator()

setGenerator

public void setGenerator(GeneratorFunction aGf)

getGenerator

public GeneratorFunction getGenerator()

isTreeBasedGenerated

public boolean isTreeBasedGenerated()

regenerate

public void regenerate()

setRegenerationFlag

public void setRegenerationFlag()

getDefinedFunction

public static DefinedFunction getDefinedFunction(java.lang.String aFunctionName,
                                                 java.util.HashMap<java.lang.String,java.lang.Integer> aArgumentsMap,
                                                 SymbolTable aSymbTable)
                                          throws ComplexFunctionException
Throws:
ComplexFunctionException

createDummyArgumentList

public static java.util.HashMap<java.lang.String,java.lang.Integer> createDummyArgumentList(int aNumberArgs)


Fraid (system and language). (C) 2003-2007 Ivaylo Iliev
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.