Back to index

wims  3.65+svn20090927
FunctionObject.java
Go to the documentation of this file.
00001 package rene.zirkel.objects;
00002 
00003 // file: Functionbject.java
00004 
00005 import java.awt.*;
00006 import java.awt.event.*;
00007 import java.util.*;
00008 
00009 import rene.gui.*;
00010 import rene.util.xml.*;
00011 import rene.zirkel.*;
00012 import rene.zirkel.construction.*;
00013 import rene.zirkel.dialogs.*;
00014 import rene.zirkel.expression.*;
00015 import rene.zirkel.graphics.*;
00016 import rene.dialogs.*;
00017 
00018 class CurveEditDialog extends ObjectEditDialog
00019 {      TextField VarMin,VarMax,DVar,Var,EX,EY;
00020        IconBar IC,TypeIB;
00021        ZirkelCanvas ZC;
00022        Checkbox Special;
00023         // jm.evers                                                                                                                        
00024          public String xaxis_variable;                                                                                                      
00025          public String yaxis_variable;
00026        //jm.evers
00027        
00028        public CurveEditDialog (ZirkelCanvas zc, FunctionObject o)
00029        {      super(zc.getFrame(),Zirkel.name("edit.function.title"),o,"function");
00030               ZC=zc;
00031        }
00032        
00033        public void addFirst (Panel P)
00034        {      
00035               
00036               FunctionObject f=(FunctionObject)O;
00037               VarMin=new TextFieldAction(this,"varmin",""+f.VarMin,30);
00038               P.add(new MyLabel(Zirkel.name("function.varmin"))); P.add(VarMin);
00039               VarMax=new TextFieldAction(this,"varmax",""+f.VarMax,30);
00040               P.add(new MyLabel(Zirkel.name("function.varmax"))); P.add(VarMax);
00041               DVar=new TextFieldAction(this,"dvar",""+f.DVar,30);
00042               
00043               P.add(new MyLabel(Zirkel.name("function.dvar"))); P.add(DVar);
00044               Var=new TextFieldAction(this,"var",""+f.getVar(),30);
00045               P.add(new MyLabel(Zirkel.name("function.var"))); P.add(Var);
00046               String ex=f.getEX();
00047               if (ex.equals(f.Var)) ex="";
00048               EX=new TextFieldAction(this,"ex",""+ex,30);
00049        
00050 
00051               P.add(new MyLabel(Zirkel.name("function.x"))); P.add(EX);
00052               EY=new TextFieldAction(this,"ey",""+f.getEY(),30);
00053               P.add(new MyLabel(Zirkel.name("function.y"))); P.add(EY);
00054        }
00055        
00056        public void addSecond (Panel P)
00057        {      FunctionObject Func=(FunctionObject)O;
00058               
00059               IC=new IconBar(F);
00060               IC.setIconBarListener(this);
00061               IC.addOnOffLeft("filled");
00062               IC.setState("filled",Func.isFilled());
00063               IC.setIconBarListener(this);
00064               P.add(new MyLabel(""));
00065               P.add(IC);
00066 
00067               TypeIB=new IconBar(F);
00068               TypeIB.addToggleGroupLeft("type",6);
00069               TypeIB.toggle("type",Func.getType());
00070               P.add(new MyLabel("")); P.add(TypeIB);
00071               
00072               P.add(new MyLabel(Zirkel.name("edit.discrete"))); P.add(Special=new Checkbox());
00073               Special.setState(Func.isSpecial());
00074        }
00075        
00076        public void addButton (Panel P)
00077        {      FunctionObject f=(FunctionObject)O;
00078               if (!f.Var.equals(f.EX))
00079               {      if (f.Center==null)
00080                             P.add(new ButtonAction(this,Zirkel.name("edit.function.center"),
00081                                    "SetCenter"));
00082                      else
00083                             P.add(new ButtonAction(this,Zirkel.name("edit.function.free"),
00084                                    "SetFree"));
00085                      P.add(new MyLabel(" "));
00086               }
00087        }
00088        
00089        public void iconPressed (String o)
00090        {      if (o.equals("filled"))
00091               {      if (IC.getState("filled"))
00092                      {      IB.setState("isback",true);
00093                             ThicknessIB.setEnabled("solid",true);
00094                      }
00095                      else
00096                      {      IB.setState("isback",false);
00097                             ThicknessIB.setState("solid",false);
00098                             ThicknessIB.setEnabled("solid",false);
00099                      }
00100               }
00101               super.iconPressed(o);
00102        }
00103 
00104        public void setAction ()
00105        {      FunctionObject f=(FunctionObject)O;
00106               f.setExpressions(Var.getText(),EX.getText(),EY.getText());            
00107               f.setRange(VarMin.getText(),VarMax.getText(),DVar.getText());
00108               f.setFilled(IC.getState("filled"));
00109               f.setType(TypeIB.getToggleState("type"));
00110               f.setSpecial(Special.getState());
00111        }
00112        
00113        public void doAction (String o)
00114        {      if (o.equals("SetCenter"))
00115               {      ZC.setCurveCenter((FunctionObject)O);
00116                      super.doAction("OK");
00117               }
00118               else if (o.equals("SetFree"))
00119               {      ((FunctionObject)O).Center=null;
00120                      super.doAction("OK");
00121               }
00122               else super.doAction(o);
00123        }
00124 
00125        public void focusGained (FocusEvent e)
00126        {      VarMin.requestFocus();
00127        }
00128        
00129 }
00130 
00140 public class FunctionObject extends ConstructionObject
00141        implements PointonObject
00142 {      Expression EX=null,EY=null;
00143        Expression VarMin=null,VarMax=null,DVar=null;
00144        double X[]={0};
00145        String Var[]={"x"};
00146        boolean Filled=false;
00147        Expression Center=null;
00148        protected int Type=0;
00149        public final static int SQUARE=0,DIAMOND=1,CIRCLE=2,DOT=3,CROSS=4,DCROSS=5;
00150        protected boolean Special=false;
00151 
00152        public FunctionObject (Construction c)
00153        {      super(c);
00154               VarMin=new Expression("-10",c,this);
00155               VarMax=new Expression("10",c,this);
00156               DVar=new Expression("0.1",c,this);
00157               validate();
00158               updateText();
00159        }
00160        
00161        public void setFilled (boolean flag)
00162        {      Filled=flag;
00163        }
00164        public boolean isFilled ()
00165        {      return Filled;
00166        }      
00167 
00168        public String getTag () { return "Function"; }
00169        public int getN () { return N.next(); }
00170        
00171        public void updateText ()
00172        {      if (EX!=null && EY!=null)
00173                      setText(text2(Zirkel.name("text.function"),EX.toString(),EY.toString()));
00174               else
00175                      setText(text2(Zirkel.name("text.function"),"",""));
00176        }
00177        
00178        public void validate ()
00179        {      if (EX!=null && EY!=null)
00180               {      Valid=EX.isValid() && EY.isValid() && VarMin.isValid()
00181                      && VarMax.isValid() && DVar.isValid();
00182               }
00183               else Valid=false;
00184        }
00185 
00186        public void setExpressions (String t, String ex, String ey)
00187        {      StringTokenizer tok=new StringTokenizer(t);
00188               Var=new String[tok.countTokens()];
00189               X=new double[tok.countTokens()];
00190               int i=0;
00191               while (tok.hasMoreTokens())
00192               {      Var[i++]=tok.nextToken();
00193               }
00194               if (ex.equals("")) ex=Var[0];
00195               EX=new Expression(ex,getConstruction(),this,Var);
00196               EY=new Expression(ey,getConstruction(),this,Var);
00197               validate();
00198        }
00199 
00200        public void setRange (String min, String max, String d)
00201        {      VarMin=new Expression(min,getConstruction(),this); 
00202               VarMax=new Expression(max,getConstruction(),this);
00203               DVar=new Expression(d,getConstruction(),this);
00204        }
00205 
00206        public String getEX ()
00207        {      if (EX!=null) return EX.toString();
00208               else return Var[0];
00209        }
00210 
00211        public String getEY ()
00212        {      if (EY!=null) return EY.toString();
00213               else return "0";
00214        }
00215 
00216        PolygonFiller PF=null;
00217        double C1,C2;
00218        int C,R,W,H;
00219        
00220        public void paint (MyGraphics g, ZirkelCanvas zc)
00221        {      if (!Valid || mustHide(zc)) return;
00222               double varmin,varmax,d;
00223               boolean special=Special,reverse=false;
00224               try
00225               {      varmin=VarMin.getValue();
00226                      varmax=VarMax.getValue();
00227                      d=DVar.getValue();
00228                      if (varmin>varmax)
00229                      {      double h=varmin; varmin=varmax; varmax=h;
00230                             reverse=true;
00231                      }
00232                      if (d<0) d=-d;
00233                      if (d<(varmax-varmin)/1000) d=(varmax-varmin)/1000;
00234               }
00235               catch (Exception e)
00236               {      Valid=false; return;
00237               }
00238               X[0]=varmin;
00239               if (isStrongSelected() && g instanceof MyGraphics13)
00240               {      PolygonDrawer pm=new PolygonDrawer(g,this);
00241                      pm.useAsMarker();
00242                      double x1=0,y1=0;
00243                      while (true)
00244                      {      try
00245                             {      x1=EX.getValue();
00246                                    y1=EY.getValue();
00247                                    if (Math.abs(zc.col(x1))+Math.abs(zc.col(y1))>1e5)
00248                                    {      finish(g,zc);
00249                                           C1=X[0];
00250                                           if (pm!=null) pm.finishPolygon();
00251                                    }
00252                                    else
00253                                    {      if (!special || isFilled()) 
00254                                           {      if (special && isFilled())
00255                                                  {      if (pm.hasStarted())
00256                                                         {      if (reverse)
00257                                                                {      pm.drawTo(pm.c(),zc.row(y1));
00258                                                                       pm.drawTo(zc.col(x1),zc.row(y1));
00259                                                                }
00260                                                                else
00261                                                                {      pm.drawTo(zc.col(x1),pm.r());
00262                                                                       pm.drawTo(zc.col(x1),zc.row(y1));
00263                                                                }
00264                                                         }
00265                                                  }
00266                                                  pm.drawTo(zc.col(x1),zc.row(y1));
00267                                           }
00268                                           else 
00269                                           {      ((MyGraphics13)g).drawMarkerLine(zc.col(x1),zc.row(y1),zc.col(x1),zc.row(y1));
00270                                           }
00271                                           C2=X[0];
00272                                    }
00273                             }
00274                             catch (Exception e) 
00275                             {      finish(g,zc);
00276                                    C1=X[0];
00277                                    pm.finishPolygon();
00278                             }
00279                             if (X[0]>=varmax) break;
00280                             X[0]=X[0]+d;
00281                             if (X[0]>varmax) X[0]=varmax;
00282                      }
00283                      pm.finishPolygon();
00284               }
00285               X[0]=varmin;
00286               g.setColor(this);
00287               PolygonDrawer pd=null;
00288               if (!special || isFilled()) pd=new PolygonDrawer(g,this);
00289               if (isFilled())
00290               {      if (PF==null) PF=new PolygonFiller(g,this);
00291                      PF.start();
00292                      PF.setGraphics(g);
00293               }
00294               C1=X[0];
00295               double x1=0,y1=0;
00296               while (true)
00297               {      try
00298                      {      x1=EX.getValue();
00299                             y1=EY.getValue();
00300                             if (Math.abs(zc.col(x1))+Math.abs(zc.col(y1))>1e5)
00301                             {      finish(g,zc);
00302                                    C1=X[0];
00303                                    if (pd!=null) pd.finishPolygon();
00304                             }
00305                             else
00306                             {      if (isFilled())
00307                                    {      if (PF.length()==0) C1=X[0];
00308                                           if (special)
00309                                           {      if (pd.hasStarted())
00310                                                  {      if (reverse)
00311                                                         {      PF.drawTo(pd.c(),zc.row(y1));
00312                                                                PF.drawTo(zc.col(x1),zc.row(y1));
00313                                                         }
00314                                                         else
00315                                                         {      PF.drawTo(zc.col(x1),pd.r());
00316                                                                PF.drawTo(zc.col(x1),zc.row(y1));
00317                                                         }
00318                                                  }
00319                                                  else
00320                                                         PF.drawTo(zc.col(x1),zc.row(y1));
00321                                           }
00322                                           else
00323                                                  PF.drawTo(zc.col(x1),zc.row(y1),X[0]<varmax);
00324                                    }
00325                                    if (pd!=null) 
00326                                    {      if (special && isFilled())
00327                                           {      if (pd.hasStarted())
00328                                                  {      if (reverse)
00329                                                         {      pd.drawTo(pd.c(),zc.row(y1));
00330                                                                pd.drawTo(zc.col(x1),zc.row(y1));
00331                                                         }
00332                                                         else
00333                                                         {      pd.drawTo(zc.col(x1),pd.r());
00334                                                                pd.drawTo(zc.col(x1),zc.row(y1));
00335                                                         }
00336                                                  }
00337                                           }
00338                                           pd.drawTo(zc.col(x1),zc.row(y1));
00339                                    }
00340                                    else 
00341                                    {      PointObject.drawPoint(g,zc,this,x1,y1,Type);
00342                                    }
00343                                    C2=X[0];
00344                             }
00345                      }
00346                      catch (Exception e) 
00347                      {      finish(g,zc);
00348                             C1=X[0];
00349                             pd.finishPolygon();
00350                      }
00351                      if (X[0]>=varmax) break;
00352                      X[0]=X[0]+d;
00353                      if (X[0]>varmax) X[0]=varmax;
00354               }
00355               finish(g,zc);
00356               if (pd!=null) pd.finishPolygon();
00357        }
00358        
00359        static double x[]=new double[4],y[]=new double[4];
00360        
00361        public void finish (MyGraphics g, ZirkelCanvas zc)
00362        {      if (isFilled())
00363               {      if (getEX().equals(getVar()))
00364                      {      System.out.println(C1+" "+C2);
00365                             PF.drawTo(zc.col(C2),zc.row(0));
00366                             PF.drawTo(zc.col(C1),zc.row(0));
00367                      }
00368                      else
00369                      {      if (getCenter()!=null)
00370                                    PF.drawTo(zc.col(getCenter().getX()),
00371                                                  zc.row(getCenter().getY()));
00372                             else
00373                                    PF.drawTo(zc.col(0),zc.row(0));
00374                      }
00375                      PF.finishPolygon();
00376               }
00377        }
00378        
00379        public double getValue ()
00380               throws ConstructionException
00381        {      if (!Valid) throw new InvalidException("exception.invalid");
00382               return X[0];
00383        }
00384        
00385        public double getValue (String var)
00386               throws ConstructionException
00387        {      if (!Valid) throw new InvalidException("exception.invalid");
00388               for (int i=0; i<Var.length; i++)
00389                      if (var.equals(Var[i])) return X[i];
00390               return X[0];
00391        }
00392 
00393        public double getIntegral ()
00394               throws ConstructionException
00395        {      return getSum();
00396        }
00397        
00398        public String getDisplayValue ()
00399        {      if (getEX().equals(getVar())) return EY.toString();
00400               else return "("+EX.toString()+","+EY.toString()+")"; 
00401        }
00402        
00403        public boolean nearto (int cc, int rr, ZirkelCanvas zc)
00404        {      if (!displays(zc)) return false;
00405               int size=(int)zc.selectionSize();
00406               double varmin,varmax,d;
00407               try
00408               {      varmin=VarMin.getValue();
00409                      varmax=VarMax.getValue();
00410                      d=DVar.getValue();
00411                      if (varmin>varmax)
00412                      {      double h=varmin; varmin=varmax; varmax=h;
00413                      }      
00414                      if (d<0) d=-d;
00415                      if (d<(varmax-varmin)/1000) d=(varmax-varmin)/1000;
00416               }
00417               catch (Exception e)
00418               {      Valid=false; return false;
00419               }
00420               X[0]=varmin;
00421               double x=zc.x(cc),y=zc.y(rr);
00422               boolean last=false;
00423               double x0=0;
00424               double y0=0;
00425               while (X[0]<varmax)
00426               {      X[0]=X[0]+d;
00427                      if (X[0]>varmax) X[0]=varmax;
00428                      try
00429                      {      double x1=EX.getValue();
00430                             double y1=EY.getValue();
00431                             if (Math.abs(zc.col(x1))+Math.abs(zc.col(y1))>1e5)
00432                                    throw new Exception("");
00433                             if (last)
00434                             {      Value=Math.abs(cc-zc.col(x1))+Math.abs(rr-zc.row(y1));
00435                                    if (Value<=size) return true;
00436                                    double r=Math.sqrt(Math.abs(x1-x0)*Math.abs(x1-x0)
00437                                                  +Math.abs(y1-y0)*Math.abs(y1-y0));
00438                                    if (r>1e-5)
00439                                    {      double h=((x-x0)*(x1-x0)+(y-y0)*(y1-y0))/r;
00440                                           if (h>=0 && h<=r)
00441                                           {      Value=Math.abs(((x-x0)*(y1-y0)-(y-y0)*(x1-x0))/r)
00442                                                         /zc.dx(1);
00443                                                  if (Value<=size) return true;
00444                                           }
00445                                    }
00446                             }
00447                             x0=x1; y0=y1; last=true;
00448                      }
00449                      catch (Exception e) 
00450                      {      last=false;
00451                      }
00452               }
00453               return false;
00454        }
00455        
00456        public boolean EditAborted;
00457               
00458        public void edit (ZirkelCanvas zc)
00459        {      ObjectEditDialog d;
00460               while (true)
00461               {      d=new CurveEditDialog(zc,this);
00462                      d.setVisible(true);
00463                      EditAborted=false;
00464                      if (d.isAborted())
00465                      {      EditAborted=true;
00466                             break;
00467                      }
00468                      else if (!EX.isValid())
00469                      {      Frame F=zc.getFrame();
00470                             Warning w=new Warning(F,EX.getErrorText(),
00471                                    Zirkel.name("warning"),true);
00472                             w.center(F);
00473                             w.setVisible(true);
00474                      }
00475                      else if (!EY.isValid())
00476                      {      Frame F=zc.getFrame();
00477                             Warning w=new Warning(F,EY.getErrorText(),
00478                                    Zirkel.name("warning"),true);
00479                             w.center(F);
00480                             w.setVisible(true);
00481                      }
00482                      else break;
00483               }
00484               validate();
00485               updateText();
00486               zc.getConstruction().updateCircleDep();
00487               zc.repaint();
00488               if (d.wantsMore())
00489               {      new EditConditionals(zc.getFrame(),this);
00490                      validate();
00491               }
00492        }
00493 
00494        public void printArgs (XmlWriter xml)
00495        {      xml.printArg("x",EX.toString());
00496               xml.printArg("y",EY.toString());
00497               xml.printArg("var",getVar());
00498               xml.printArg("min",""+VarMin);
00499               xml.printArg("max",""+VarMax);
00500               xml.printArg("d",""+DVar);
00501               if (Special) xml.printArg("special","true");
00502               printType(xml);
00503               if (Filled) xml.printArg("filled","true");
00504               if (getCenter()!=null) xml.printArg("center",getCenter().getName());
00505        }
00506        
00507        public void setType (int type)
00508        {      Type=type;
00509        }
00510        public int getType ()
00511        {      return Type;
00512        }
00513 
00514        public void printType (XmlWriter xml)
00515        {      if (Type!=0)
00516               {      switch (Type)
00517                      {      case DIAMOND : xml.printArg("shape","diamond"); break;
00518                             case CIRCLE : xml.printArg("shape","circle"); break;
00519                             case DOT : xml.printArg("shape","dot"); break;
00520                             case CROSS : xml.printArg("shape","cross"); break;
00521                             case DCROSS : xml.printArg("shape","dcross"); break;
00522                      }
00523               }
00524 
00525        }
00526 
00527        public void translate ()
00528        {      try
00529               {      EX=new Expression(EX.toString(),getConstruction(),this,Var);
00530                      EY=new Expression(EY.toString(),getConstruction(),this,Var);
00531                      VarMin=new Expression(VarMin.toString(),getConstruction(),this);
00532                      VarMax=new Expression(VarMax.toString(),getConstruction(),this);
00533                      DVar=new Expression(DVar.toString(),getConstruction(),this);
00534                      ConstructionObject O=getTranslation();
00535                      setTranslation(this);
00536                      EX.translate(); 
00537                      EY.translate();
00538                      VarMin.translate(); 
00539                      VarMax.translate(); 
00540                      DVar.translate();
00541                      if (getCenter()!=null)
00542                      {      setCenter(getCenter().getName());
00543                             Center.translate();
00544                      }
00545                      validate();
00546                      setTranslation(O);
00547               }
00548               catch (Exception e)
00549               {      System.out.println();
00550                      System.out.println(getName());
00551                      System.out.println(e);
00552                      e.printStackTrace();
00553               }
00554        }
00555 
00556        public boolean onlynearto (int x, int y, ZirkelCanvas zc)
00557        {      return false;
00558               //return nearto(x,y,zc);
00559        }
00560 
00561        public boolean equals (ConstructionObject o)
00562        {      return false;
00563        }
00564 
00565        public Enumeration depending ()
00566        {      DL.reset();
00567               addDepending(EX);
00568               addDepending(EY);
00569               addDepending(VarMin);
00570               addDepending(VarMax);
00571               addDepending(DVar);
00572               return DL.elements();
00573        }
00574        
00575        public void addDepending (Expression E)
00576        {      if (E!=null)
00577               {      Enumeration e=E.getDepList().elements();
00578                      while (e.hasMoreElements())
00579                      {      DL.add((ConstructionObject)e.nextElement());
00580                      }
00581               }
00582        }
00583 
00584        public boolean hasUnit ()
00585        {      return false;
00586        }
00587        
00588        public double evaluateF (double x[])
00589               throws ConstructionException
00590        {      int n=x.length;
00591               if (n>X.length) n=X.length;
00592               for (int i=0; i<n; i++) X[i]=x[i];
00593               for (int i=n; i<X.length; i++) X[i]=0;
00594               try
00595               {      return EY.getValue();
00596               }
00597               catch (Exception e)
00598               {      throw new ConstructionException("");
00599               }
00600        }
00601        
00602 
00603        public double evaluateF (double x)
00604               throws ConstructionException
00605        {      X[0]=x;
00606               for (int i=1; i<X.length; i++) X[i]=0;
00607               try
00608               {      return EY.getValue();
00609               }
00610               catch (Exception e)
00611               {      throw new ConstructionException("");
00612               }
00613        }
00614 
00615        
00616        public void project (PointObject P) 
00617        {      double varmin,varmax,dvar;
00618               try
00619               {      varmin=VarMin.getValue();
00620                      varmax=VarMax.getValue();
00621                      dvar=DVar.getValue();
00622                      if (varmin>varmax)
00623                      {      double h=varmin; varmin=varmax; varmax=h;
00624                      }      
00625                      if (dvar<(varmax-varmin)/1000) 
00626                             dvar=(varmax-varmin)/1000;
00627               }
00628               catch (Exception e)
00629               {      Valid=false; return;
00630               }
00631               X[0]=varmin;
00632               double x=0,y=0,x0=0,y0=0,dmin=0;
00633               boolean started=false;
00634               while (true)
00635               {      try
00636                      {      double x1=EX.getValue();
00637                             double y1=EY.getValue();
00638                             if (!started)
00639                             {      dmin=Math.sqrt((P.getX()-x1)*(P.getX()-x1)+
00640                                                  (P.getY()-y1)*(P.getY()-y1));
00641                                    x0=x=x1; y0=y=y1;
00642                                    started=true;
00643                             }
00644                             else
00645                             {      double h=(x1-x0)*(x1-x0)+(y1-y0)*(y1-y0);
00646                                    double g=(P.getX()-x0)*(x1-x0)+(P.getY()-y0)*(y1-y0);
00647                                    if (g<0) g=0;
00648                                    if (g>h) g=h;
00649                                    double x2=x0+g/h*(x1-x0),y2=y0+g/h*(y1-y0);
00650                                    double d=Math.sqrt((P.getX()-x2)*(P.getX()-x2)+
00651                                           (P.getY()-y2)*(P.getY()-y2));
00652                                    if (d<dmin)
00653                                    {      dmin=d;
00654                                           x=x2; y=y2;
00655                                    }
00656                                    x0=x1; y0=y1;
00657                             }
00658                      }
00659                      catch (Exception e) 
00660                      {}
00661                      if (X[0]>=varmax) break;
00662                      X[0]=X[0]+dvar;
00663                      if (X[0]>varmax) X[0]=varmax;
00664               }
00665               if (started)
00666               {      P.setXY(x,y);
00667               }
00668        }
00669 
00670        public double getSum ()
00671        {      double varmin,varmax,dvar;
00672               boolean reverse=false;
00673               boolean parametric=!getEX().equals(getVar());
00674               try
00675               {      varmin=VarMin.getValue();
00676                      varmax=VarMax.getValue();
00677                      dvar=DVar.getValue();
00678                      if (varmin>varmax)
00679                      {      double h=varmin; varmin=varmax; varmax=h;
00680                             reverse=true;
00681                      }      
00682                      if (dvar<0) dvar=-dvar;
00683                      if (dvar<(varmax-varmin)/1000) 
00684                             dvar=(varmax-varmin)/1000;
00685               }
00686               catch (Exception e)
00687               {      Valid=false; return 0;
00688               }
00689               X[0]=varmin;
00690               double x0=0,y0=0;
00691               boolean started=false;
00692               double sum=0;
00693               while (true)
00694               {      try
00695                      {      double x1=EX.getValue();
00696                             double y1=EY.getValue();
00697                             if (parametric)
00698                             {      double x=0,y=0;
00699                                    if (getCenter()!=null)
00700                                    {      x=getCenter().getX(); y=getCenter().getY();
00701                                    }
00702                                    if (started) 
00703                                           sum+=((x0-x)*(y1-y)-(y0-y)*(x1-x))/2;
00704                             }
00705                             else
00706                             {      if (started)
00707                                    {      if (Special)
00708                                           {      if (reverse) sum+=(x1-x0)*y1;
00709                                                  else sum+=(x1-x0)*y0;
00710                                           }
00711                                           else
00712                                           {      sum+=(x1-x0)*(y0+y1)/2;
00713                                           }
00714                                    }
00715                             }
00716                             x0=x1; y0=y1;
00717                             started=true;
00718                      }
00719                      catch (Exception e) {}
00720                      if (X[0]>=varmax) break;
00721                      X[0]=X[0]+dvar;
00722                      if (X[0]>varmax) X[0]=varmax;
00723               }
00724               return sum;
00725        }
00726        
00727        public double getLength ()
00728        {      double varmin,varmax,dvar;
00729               boolean reverse=false;
00730               boolean parametric=!getEX().equals(getVar());
00731               try
00732               {      varmin=VarMin.getValue();
00733                      varmax=VarMax.getValue();
00734                      dvar=DVar.getValue();
00735                      if (varmin>varmax)
00736                      {      double h=varmin; varmin=varmax; varmax=h;
00737                             reverse=true;
00738                      }      
00739                      if (dvar<0) dvar=-dvar;
00740                      if (dvar<(varmax-varmin)/1000) 
00741                             dvar=(varmax-varmin)/1000;
00742               }
00743               catch (Exception e)
00744               {      Valid=false; return 0;
00745               }
00746               X[0]=varmin;
00747               double x0=0,y0=0;
00748               boolean started=false;
00749               double sum=0;
00750               while (true)
00751               {      try
00752                      {      double x1=EX.getValue();
00753                             double y1=EY.getValue();
00754                             if (started)
00755                                    sum+=Math.sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
00756                             started=true;
00757                             x0=x1; y0=y1;
00758                      }
00759                      catch (Exception e) {}
00760                      if (X[0]>=varmax) break;
00761                      X[0]=X[0]+dvar;
00762                      if (X[0]>varmax) X[0]=varmax;
00763               }
00764               return sum;
00765        }
00766        
00767        public boolean isSpecial ()
00768        {      return Special;
00769        }
00770        public void setSpecial (boolean f)
00771        {      Special=f;    
00772        }
00773        
00774        public void project(PointObject P, double alpha) 
00775        {      project(P);
00776        }
00777 
00778        public boolean maybeTransparent ()
00779        {      return true;
00780        }
00781 
00782        public boolean canDisplayName ()
00783        {      return false;
00784        }
00785        
00786        public void setCenter (String s)
00787        {      if (Cn==null) return;
00788               Center=new Expression("@\""+s+"\"",Cn,this);
00789        }
00790        
00791        public boolean isFilledForSelect ()
00792        {      return false;
00793        }
00794        
00795        public PointObject getCenter ()
00796        {      try
00797               {      return (PointObject)Center.getObject();
00798               }
00799               catch (Exception e)
00800               {      return null;
00801               }
00802        }
00803 
00804        public String getVar ()
00805        {      String vars=Var[0];
00806               for (int i=1; i<Var.length; i++) vars=vars+" "+Var[i];
00807               return vars;
00808        }
00809 
00810        public boolean canInteresectWith(ConstructionObject o) 
00811        {      return true;
00812        }
00813 
00814 }