FEJDMath
Class FctParser

java.lang.Object
  extended byFEJDMath.FctParser

class FctParser
extends java.lang.Object

Used to evaluate a function given as a string in the data file, the parser understands tan, sin, cos, exp, ln, log, sqrt, pi, X, Y


Field Summary
private  int arraySize
          The size of the array containing the tokens
private  java.lang.String function
          The string representing the function
private  Token[] liste
          The token list on which we work
private  int maxToken
          The maximum numbr of token that the string may have (all symbols including spaces are considered tokens)
private  Token[] originalListe
          The original token list
private  double x
          The coordinates at which the function is calculated
private  double y
          The coordinates at which the function is calculated
 
Constructor Summary
FctParser(java.lang.String s)
          Creates a new parser and loads the string s
 
Method Summary
private  void caculToken(int deb, int fin)
          Computes each token which represents an operation (+ * - /)
 double calcFctAt(double x, double y)
          Computes the loaded function at the point (x,y)
 void dispToken()
          Displays the list of tokens
private  int findNext(int z, int fin)
          Finds the following non empty token in liste
private  int findPrec(int z, int deb)
          Finds the preceding non empty token in liste
 java.lang.String getFunction()
          Returns the string representing the function
private  void replaceMFct(int deb, int fin)
          Computes the math functions
private  void splitPar(int deb, int fin)
          Splits the string according to parentheses and calls calculToken to compute each token
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxToken

private final int maxToken
The maximum numbr of token that the string may have (all symbols including spaces are considered tokens)

See Also:
Constant Field Values

liste

private Token[] liste
The token list on which we work


originalListe

private Token[] originalListe
The original token list


function

private java.lang.String function
The string representing the function


arraySize

private int arraySize
The size of the array containing the tokens


x

private double x
The coordinates at which the function is calculated


y

private double y
The coordinates at which the function is calculated

Constructor Detail

FctParser

public FctParser(java.lang.String s)
Creates a new parser and loads the string s

Method Detail

calcFctAt

public double calcFctAt(double x,
                        double y)
Computes the loaded function at the point (x,y)


splitPar

private void splitPar(int deb,
                      int fin)
Splits the string according to parentheses and calls calculToken to compute each token


caculToken

private void caculToken(int deb,
                        int fin)
Computes each token which represents an operation (+ * - /)


replaceMFct

private void replaceMFct(int deb,
                         int fin)
Computes the math functions


findPrec

private int findPrec(int z,
                     int deb)
Finds the preceding non empty token in liste


findNext

private int findNext(int z,
                     int fin)
Finds the following non empty token in liste


dispToken

public void dispToken()
Displays the list of tokens


getFunction

public java.lang.String getFunction()
Returns the string representing the function