Back to index

wims  3.65+svn20090927
Public Member Functions | Static Public Member Functions | Package Attributes | Static Package Attributes
rene.zirkel.expression.DExpression Class Reference
Inheritance diagram for rene.zirkel.expression.DExpression:
Inheritance graph
[legend]
Collaboration diagram for rene.zirkel.expression.DExpression:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DExpression (BasicExpression e)
double getValue () throws ConstructionException
void reset ()
PointObject getPoint (int n) throws ConstructionException
void translate ()
String toString ()
boolean isNumber ()
boolean isLogical ()

Static Public Member Functions

static BasicExpression scan (ExpressionText t, String name) throws ConstructionException
static BasicExpression scan (ExpressionText t) throws ConstructionException
static BasicExpression scan (ExpressionText t, int sign) throws ConstructionException
static BasicExpression scanBracket (ExpressionText t) throws ConstructionException

Package Attributes

double Old = 0
double Old1 = 0
boolean start = false
int F
BasicExpression E []
int NParams

Static Package Attributes

static final String Functions []
static final int NX = 10
static final int NY = 11
static final int ND = 14
static final int NA = 15
static final int NS = 19
static final int NSUM = 22
static final int NIF = 23
static final int NINT = 26
static final int NZERO = 27
static final int NDIFF = 28
static final int NMIN = 29
static final int NMAX = 30
static final int NLENGTH = 31
static final int NZ = 40
static final int NSIM = 41
static final int NINSIDE = 42
static final int MINUS = -1
static final int PLUS = 1

Detailed Description

Definition at line 999 of file Expression.java.


Constructor & Destructor Documentation

Definition at line 1004 of file Expression.java.

       {      super(21,e);
       }

Member Function Documentation

PointObject rene.zirkel.expression.FunctionExpression.getPoint ( int  n) throws ConstructionException [inline, inherited]

Definition at line 966 of file Expression.java.

       {      PointObject p;
              try
              {      p=(PointObject)((ObjectExpression)E[n]).getObject();
              }
              catch (Exception e)
              {      throw new ConstructionException("exception.notfound");
              }
              if (!p.valid()) throw new ConstructionException("exception.invalid");
              return p;
       }

Here is the caller graph for this function:

Reimplemented from rene.zirkel.expression.FunctionExpression.

Definition at line 1008 of file Expression.java.

       {      if (E[0] instanceof ObjectExpression)
              {      ConstructionObject o=((ObjectExpression)E[0]).getObject();
                     if (o instanceof PointObject)
                     {      PointObject p=(PointObject)o;
                            if (p.dontUpdate()) return 0;
                            double x=p.getX(),y=p.getY();
                            if (start)
                            {      double res=(x-Old)*(x-Old)+(y-Old1)*(y-Old1);
                                   Old=x; Old1=y;
                                   return Math.sqrt(res);
                            }
                            Old=x; Old1=y;
                            start=true;
                            return 0;
                     }
                     else if (o instanceof AngleObject)
                     {      AngleObject a=(AngleObject)o;
                            double x=a.getValue();
                            if (start)
                            {      double res=x-Old;
                                   if (res<-180) res+=180;
                                   if (res>180) res-=180;
                                   Old=x;
                                   return res;
                            }
                            Old=x;
                            start=true;
                            return 0;
                     }
              }
              double x=E[0].getValue();
              double res;
              if (start)
              {      res=x-Old;
              }
              else
              {      res=0;
                     start=true;
              }
              Old=x;
              return res;
       }

Here is the call graph for this function:

Reimplemented in rene.zirkel.expression.OrExpression, rene.zirkel.expression.AndExpression, rene.zirkel.expression.NotExpression, and rene.zirkel.expression.CompareExpression.

Definition at line 143 of file Expression.java.

       {      return false;
       }

Here is the caller graph for this function:

Reimplemented in rene.zirkel.expression.MinusExpression, rene.zirkel.expression.ElementaryExpression, rene.zirkel.expression.BracketExpression, and rene.zirkel.expression.DoubleExpression.

Definition at line 135 of file Expression.java.

       {      return false;
       }

Here is the caller graph for this function:

Reimplemented from rene.zirkel.expression.FunctionExpression.

Definition at line 1052 of file Expression.java.

       {      start=false;
              super.reset();
       }
static BasicExpression rene.zirkel.expression.BasicExpression.scan ( ExpressionText  t,
int  sign 
) throws ConstructionException [inline, static, inherited]

Definition at line 107 of file Expression.java.

       {      if (sign==MINUS)
              {      if (t.next()=='(') return new MinusExpression(scanBracket(t));
                     return new MinusExpression(ElementaryExpression.scan(t));
              }
              if (t.next()=='(') return scanBracket(t);
              return ElementaryExpression.scan(t);
       }

Here is the call graph for this function:

static BasicExpression rene.zirkel.expression.FunctionExpression.scan ( ExpressionText  t,
String  name 
) throws ConstructionException [inline, static, inherited]

Definition at line 572 of file Expression.java.

       {      int f=-1;
              for (int i=0; i<Functions.length; i++)
              {      if (name.equals(Functions[i])) { f=i; break; }
              }
              if (f<0)
              {      boolean forward=false;
                     ConstructionObject o=t.getConstruction().find(name,t.getObject());
                     if (o==null)
                     {      o=t.getConstruction().find(name);
                            forward=true;
                     }
                     if (o!=null && (o instanceof FunctionObject || o instanceof UserFunctionObject) && !(o==t.getObject())
                                   && !t.getConstruction().dependsOn(o,t.getObject()))
                     {      if (t.next()!='(')
                                   throw new ConstructionException(Zirkel.name("exception.parameter"));
                            t.advance();
                            MyVector ex=new MyVector();
                            while (true)
                            {      BasicExpression e=TopExpression.scan(t);
                                   ex.addElement(e);
                                   if (t.next()==')') break;
                                   if (t.next()!=',')
                                          throw new ConstructionException(Zirkel.name("exception.parameter"));
                                   t.advance();
                            }
                            t.advance();
                            t.getDepList().add(o);
                            if (forward) t.getConstruction().needsOrdering();
                            BasicExpression exp[]=new BasicExpression[ex.size()];
                            ex.copyInto(exp);
                            return new UserFunctionExpression(o,exp);
                     }
                     throw new ConstructionException(Zirkel.name("exception.function")
                            +" ("+name+")");
              }
              if (t.next()!='(')
                            throw new ConstructionException(Zirkel.name("exception.parameter"));
              t.advance();
              BasicExpression e=TopExpression.scan(t);
              if (f==NX || f==NY || f==NZ)
              {      if (e instanceof FindObjectExpression)
                            e=new FunctionExpression(f,e);
                     else if (e instanceof ObjectExpression &&
                            ((ObjectExpression)e).getObject() instanceof PointObject)
                            e=new FunctionExpression(f,e);
                     else
                            throw new ConstructionException(Zirkel.name("exception.parameter")
                                   +" ("+Functions[f]+")");           
              }
              else if (f==ND)
              {      if (t.next()!=',')
                     {      e=new DExpression(e);
                     }
                     else
                     {      t.advance();
                            BasicExpression ee=TopExpression.scan(t);
                            if (
                                   ((e instanceof ObjectExpression &&
                                          ((ObjectExpression)e).getObject() instanceof PointObject)
                                   || e instanceof FindObjectExpression)
                                    && 
                                    ((ee instanceof ObjectExpression &&
                                          ((ObjectExpression)ee).getObject() instanceof PointObject)
                                   || ee instanceof FindObjectExpression)
                                   )
                                   e=new FunctionExpression(f,e,ee);
                            else
                                   throw new ConstructionException(Zirkel.name("exception.parameter")
                                          +" ("+Functions[f]+")");
                     }
              }
              else if (f==NA)
              {      if (t.next()!=',')
                            throw new ConstructionException(Zirkel.name("exception.parameter"));
                     t.advance();
                     BasicExpression ee=TopExpression.scan(t);
                     if (t.next()!=',')
                            throw new ConstructionException(Zirkel.name("exception.parameter"));
                     t.advance();
                     BasicExpression eee=TopExpression.scan(t);
                     if (
                            ((e instanceof ObjectExpression &&
                                   ((ObjectExpression)e).getObject() instanceof PointObject)
                            || e instanceof FindObjectExpression)
                             && 
                             ((ee instanceof ObjectExpression &&
                                   ((ObjectExpression)ee).getObject() instanceof PointObject)
                            || ee instanceof FindObjectExpression)
                             && 
                            ((eee instanceof ObjectExpression &&
                                   ((ObjectExpression)eee).getObject() instanceof PointObject)
                            || eee instanceof FindObjectExpression)
                            )
                                   e=new FunctionExpression(f,e,ee,eee);
                     else
                            throw new ConstructionException(Zirkel.name("exception.parameter")
                                   +" ("+Functions[f]+")");           
                     
              }
              else if (f==NS)
              {      if (t.next()!=',')
                            throw new ConstructionException(Zirkel.name("exception.parameter"));
                     t.advance();
                     BasicExpression ee=TopExpression.scan(t);
                     if (t.next()!=',')
                            throw new ConstructionException(Zirkel.name("exception.parameter"));
                     t.advance();
                     BasicExpression eee=TopExpression.scan(t);
                     e=new FunctionExpression(f,e,ee,eee);                   
              }
              else if (f==NSUM)
              {      if (t.next()!=',')
                     {      e=new CumSumExpression(e);
                     }
                     else
                     {      t.advance();
                            BasicExpression ee=TopExpression.scan(t);
                            e=new CumSumExpression(e,ee);
                     }
              }
              else if (f==NIF)
              {      if (t.next()!=',')
                            throw new ConstructionException(Zirkel.name("exception.parameter"));
                     t.advance();
                     BasicExpression ee=TopExpression.scan(t);
                     if (t.next()!=',')
                            throw new ConstructionException(Zirkel.name("exception.parameter"));
                     t.advance();
                     BasicExpression eee=TopExpression.scan(t);
                     e=new IfExpression(e,ee,eee);
              }
              else if (f==NINT || f==NZERO || f==NMIN || f==NMAX || f==NLENGTH)
              {      if (!(e instanceof ObjectExpression))
                     {      if (f==NMAX || f==NMIN)
                            {      if (t.next()!=',')
                                          throw new ConstructionException(Zirkel.name("exception.parameter"));
                                   t.advance();
                                   BasicExpression ee=TopExpression.scan(t);
                                   e=new FunctionExpression(f,e,ee);
                            }
                            else
                                   throw new ConstructionException(Zirkel.name("exception.parameter")
                                                 +" ("+Functions[f]+")");                         
                     }
                     else
                     {      boolean function=((ObjectExpression)e).getObject() instanceof FunctionObject
                                   || ((ObjectExpression)e).getObject() instanceof TrackObject;
                            if ((f==NINT || f==NLENGTH) && t.next()==')')
                            {      if (!function)
                                                 throw new ConstructionException(Zirkel.name("exception.parameter")
                                                               +" ("+Functions[f]+")");                         
                                   e=new FunctionExpression(f,e);
                            }
                            else if (f==NLENGTH)
                            {      throw new ConstructionException(Zirkel.name("exception.parameter"));
                            }
                            else
                            {      if (t.next()!=',')
                                          throw new ConstructionException(Zirkel.name("exception.parameter"));
                                   t.advance();
                                   BasicExpression ee=TopExpression.scan(t);
                                   if (function)
                                   {      if (t.next()!=',')
                                                 throw new ConstructionException(Zirkel.name("exception.parameter"));
                                          t.advance();
                                          BasicExpression eee=TopExpression.scan(t);
                                          e=new FunctionExpression(f,e,ee,eee);
                                   }
                                   else if (f==NMIN || f==NMAX)
                                   {      e=new FunctionExpression(f,e,ee);
                                   }
                                   else
                                          throw new ConstructionException(Zirkel.name("exception.parameter")
                                                        +" ("+Functions[f]+")");                                
                            }
                     }
              }
              else if (f==NDIFF)
              {      if (!(e instanceof ObjectExpression) ||
                            !(((ObjectExpression)e).getObject() instanceof FunctionObject))
                                   throw new ConstructionException(Zirkel.name("exception.parameter")
                                                 +" ("+Functions[f]+")");
                     if (t.next()!=',')
                            throw new ConstructionException(Zirkel.name("exception.parameter"));
                     t.advance();
                     BasicExpression ee=TopExpression.scan(t);
                     e=new FunctionExpression(f,e,ee);
              }
              else if (f==NSIM)
              {      if (t.next()!=',')
                            throw new ConstructionException(Zirkel.name("exception.parameter"));
                     t.advance();
                     BasicExpression ee=TopExpression.scan(t);
                     if (t.next()!=',')
                            throw new ConstructionException(Zirkel.name("exception.parameter"));
                     t.advance();
                     BasicExpression eee=TopExpression.scan(t);
                     if (
                            (e instanceof ObjectExpression &&
                                   ((ObjectExpression)e).getObject() instanceof SimulationObject)
                            ||
                            !(eee instanceof ObjectExpression)
                            )
                     {      ConstructionObject SO=((ObjectExpression)e).getObject();
                            if (t.getConstruction().dependsOn(SO,t.getObject()))
                                   throw new ConstructionException(Zirkel.name("exception.parameter")
                                                 +" ("+Functions[f]+")");           
                            e=new SimulationExpression(
                                   ((ObjectExpression)e).getObject(),t.getObject(),ee,
                                   ((ObjectExpression)eee).getObject());
                     }
                     else 
                            throw new ConstructionException(Zirkel.name("exception.parameter")
                                          +" ("+Functions[f]+")");           
                     
              }
              else if (f==NINSIDE)
              {      if (t.next()!=',')
                            throw new ConstructionException(Zirkel.name("exception.parameter"));
                     t.advance();
                     BasicExpression ee=TopExpression.scan(t);
                     if (
                            ((e instanceof ObjectExpression &&
                                   ((ObjectExpression)e).getObject() instanceof PointObject)
                            || e instanceof FindObjectExpression)
                             && 
                             ((ee instanceof ObjectExpression &&
                                   ((ObjectExpression)ee).getObject() instanceof InsideObject)
                            || ee instanceof FindObjectExpression)
                            )
                            e=new FunctionExpression(f,e,ee);
                     else
                            throw new ConstructionException(Zirkel.name("exception.parameter")
                                   +" ("+Functions[f]+")");
              }
              else
              {      e=new FunctionExpression(f,e);
              }
              if (t.next()!=')')
                     throw new ConstructionException(Zirkel.name("exception.parameter"));
              t.advance();
              return e;
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 118 of file Expression.java.

       {      t.advance();
              BasicExpression E=TopExpression.scan(t);
              if (t.next()==')') t.advance();
              else
                     throw new ConstructionException(Zirkel.name("exception.bracket"));
              return E;
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 989 of file Expression.java.

       {      String s=Functions[F]+"(";
              for (int i=0; i<NParams; i++)
              {      if (i>0) s=s+",";
                     s=s+E[i];
              }
              return s+")";
       }

Reimplemented from rene.zirkel.expression.BasicExpression.

Definition at line 979 of file Expression.java.

       {      for (int i=0; i<NParams; i++)
                     E[i].translate();
       }

Member Data Documentation

Reimplemented from rene.zirkel.expression.BasicExpression.

Definition at line 536 of file Expression.java.

Definition at line 535 of file Expression.java.

final String rene.zirkel.expression.FunctionExpression.Functions[] [static, package, inherited]
Initial value:
              {      "sin","cos","tan","arcsin","arccos","arctan",
                     "sqrt","exp","log","round","x","y","floor","ceil",
                     "d","a","angle180","angle360","abs","scale","sign","d","sum",
                     "if","deg","rad","integrate","zero","diff","min","max","length",
                     "rsin","rcos","rtan","rarcsin","rarccos","rarctan",
                     "sinhyp","coshyp","z","simulate","inside"
              }

Definition at line 560 of file Expression.java.

final int rene.zirkel.expression.BasicExpression.MINUS = -1 [static, package, inherited]

Definition at line 91 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NA = 15 [static, package, inherited]

Definition at line 568 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.ND = 14 [static, package, inherited]

Definition at line 568 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NDIFF = 28 [static, package, inherited]

Definition at line 569 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NIF = 23 [static, package, inherited]

Definition at line 569 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NINSIDE = 42 [static, package, inherited]

Definition at line 570 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NINT = 26 [static, package, inherited]

Definition at line 569 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NLENGTH = 31 [static, package, inherited]

Definition at line 569 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NMAX = 30 [static, package, inherited]

Definition at line 569 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NMIN = 29 [static, package, inherited]

Definition at line 569 of file Expression.java.

Definition at line 537 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NS = 19 [static, package, inherited]

Definition at line 568 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NSIM = 41 [static, package, inherited]

Definition at line 570 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NSUM = 22 [static, package, inherited]

Definition at line 569 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NX = 10 [static, package, inherited]

Definition at line 568 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NY = 11 [static, package, inherited]

Definition at line 568 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NZ = 40 [static, package, inherited]

Definition at line 570 of file Expression.java.

final int rene.zirkel.expression.FunctionExpression.NZERO = 27 [static, package, inherited]

Definition at line 569 of file Expression.java.

Definition at line 1000 of file Expression.java.

Definition at line 1001 of file Expression.java.

final int rene.zirkel.expression.BasicExpression.PLUS = 1 [static, package, inherited]

Definition at line 91 of file Expression.java.

Definition at line 1002 of file Expression.java.


The documentation for this class was generated from the following file: