Back to index

wims  3.65+svn20090927
Rekenmachien.java
Go to the documentation of this file.
00001 /*
00002     Written by J.M. Evers 
00003     Used as small but fairly powerfull calculator in WIMS
00004     No memory, no buttons: a single input line.
00005     Capable of sending the result -via javascript- to WIMS.
00006     
00007     Read Arity documentation for capabilities and Copyright/License.
00008     This little program has no copyrights. Ofcourse.
00009     
00010     todo: finish a functionplotter using the Arity-lib. [funcionality triggered by params]
00011 
00012     Example:
00013     <html>
00014        <head></head>
00015        <body>
00016            <script language="javascript" type="text/javascript">
00017               function READTHIS(){
00018                   var input=document.getElementById("calculator").ReadApplet(){
00019                      if(input.indexOf("error")!=-1){
00020                      alert(input);
00021                   }
00022                   else
00023                   {
00024                      alert("the applet will send:\n"+input);
00025                   }
00026               }                                                                                                                                         
00027            </script>                                                                                                                                  
00028            <center>
00029            
00030            <applet id="calculator" code="Rekenmachien.class"  archive="Rekenmachien.jar" width="120" height="60">
00031               <param name="decimals" value="6"> <!-- precision: number of decimals -->
00032               <!-- defaults should be OK ... but if needed override with these params -->
00033               <param name="frame_xsize" value="300"> <!-- xsize of popup frame -->
00034               <param name="frame_ysize" value="240"> <!-- ysize of popup frame -->
00035               <param name="location_x" value="300"> <!-- x location of popup frame -->
00036               <param name="location_y" value="300"> <!-- y location of popup frame -->
00037               <param name="fontsize1" value="10"> <!-- input fontsize -->
00038               <param name="fontsize2" value="10"> <!-- output / remarks fontsize -->
00039               <param name="fontsize3" value="16"> <!-- popup frame fontsize -->
00040               <param name="language" value="en"> <!-- en,nl,fr,de -->
00041               <param name="pencolor1" value="10,3,2"> <!-- input foreground color -->
00042               <param name="pencolor2" value="10,3,2"> <!-- input foreground color -->
00043               <param name="bgcolor1" value="200,250,255"> <!-- input background color -->
00044               <param name="bgcolor2" value="245,255,255"> <!-- canvas background color -->
00045            </applet>
00046            <input type="button" name="Send" value="Send" onclick="javascript:READTHIS();">
00047        </body>
00048     </html>
00049 */
00050 
00051 
00052 import java.awt.*;
00053 import java.applet.*;
00054 import java.util.*;
00055 import javax.swing.*;
00056 import java.awt.event.*;
00057 import java.text.DecimalFormat;
00058 import org.javia.arity.Symbols;
00059 import org.javia.arity.SyntaxException;
00060 
00061 public class Rekenmachien extends JApplet {
00062     GraphWindow graphwindow = new GraphWindow();
00063     InputWindow inputwindow = new InputWindow();
00064     private JTextField input; /* need javax.swing JTextField : no tooltips for TextField !! */
00065     private JTextField output;
00066     private JTextField remarks;
00067     boolean visible=false;
00068     Font myfont1,myfont2,myfont3;
00069     int font_size1=12,font_size2=12,font_size3=14;
00070     int frame_x=300,frame_y=240,x0=300,y0=300,rounding=6;
00071     int R1=225,G1=255,B1=255;
00072     double precision=0.000001;
00073     DecimalFormat decformat;
00074     Color pencolor1,pencolor2,bgcolor1,bgcolor2;
00075     String rem1="\u2023 Mathematical error";
00076     String rem2="\u2023 Nonsense Error";
00077     String rem3="\u2023 calculator";
00078     String rem4="\u2023 done";
00079     String rem5="\u2023 ln(e)=1 log(10)=1";
00080     String rem6="\u2023 Usage [click open/close]";
00081     String rem7="\u2023 Please wait...";
00082     String rem8;
00083     String rem9="\u2023 precision";
00084     String rem10;
00085     String rem11="\u2023 You could also erase this text...\n and type in your formula or calculation...\n Press Enter to start calculations.";
00086 
00087     public void init(){
00088        initparams();
00089        initfonts();
00090        inittextareas();
00091        setLayout(new GridLayout(3, 1));
00092        initpopups();
00093        initlisteners();
00094     }
00095     
00096     public void initlisteners(){
00097        // enter and arrow_down is accepted for starting the calculation in the input field
00098        input.addKeyListener( new KeyAdapter() {
00099            public void keyPressed(KeyEvent evt) {
00100               if(evt.getKeyCode() == evt.VK_ENTER  || evt.getKeyCode() == evt.VK_DOWN ){
00101                   repaint();
00102               }
00103            }
00104        });
00105 
00106        inputwindow.textarea.addKeyListener( new KeyAdapter() {
00107            public void keyPressed(KeyEvent evt) {
00108               if(evt.getKeyCode() == evt.VK_ENTER  || evt.getKeyCode() == evt.VK_DOWN ){
00109                   repaint();
00110               }
00111            }
00112        });
00113        
00114        // remarks area accepts mouse_click to set the GraphWindow frame visible/invisible
00115        remarks.addMouseListener( new MouseAdapter(){
00116            public void mousePressed(MouseEvent e){
00117               if(visible){
00118                   inputwindow.setVisible(false);
00119                   visible=false;
00120               }
00121               else
00122               {
00123                   inputwindow.setVisible(true);
00124                   visible=true;
00125               }
00126            }
00127        });    
00128     }
00129     
00130     public void inittextareas(){
00131        input=new JTextField(font_size1);
00132        output=new JTextField(font_size2);
00133        remarks=new JTextField(font_size2);
00134        input.setForeground(pencolor1);
00135        output.setForeground(pencolor2);
00136        remarks.setForeground(pencolor2);
00137        input.setBackground(bgcolor1);
00138        output.setBackground(bgcolor2);        
00139        remarks.setBackground(bgcolor2);       
00140        input.setFont(myfont1);
00141        output.setFont(myfont2);
00142        remarks.setFont(myfont2);
00143        add(input);add(output);add(remarks);
00144        input.setText("? ");
00145        output.setText("\u2023 "); 
00146        remarks.setText(rem6);
00147        // only a tooltip over the remark inputfield
00148        remarks.setToolTipText(rem8); 
00149        input.setCaretPosition(2); 
00150     }
00151     
00152     public void initpopups(){
00153        inputwindow.setSize(frame_x,frame_y);
00154        inputwindow.setLocation(x0,y0);
00155        inputwindow.textarea.setFont(myfont3);
00156        inputwindow.textarea.setBackground(bgcolor1);
00157        inputwindow.panel1.setBackground(bgcolor1);
00158        graphwindow.setSize(frame_x,frame_y);
00159        graphwindow.setLocation(x0+20,y0+20);
00160     }
00161     public void initfonts(){
00162        myfont1 = new Font("Helvetica", Font.BOLD, font_size1);
00163        myfont2 = new Font("Helvetica", Font.BOLD, font_size2);
00164        myfont3 = new Font("Helvetica", Font.BOLD, font_size3);
00165     }
00166 
00167     public void initparams(){
00168         String param="";
00169        param=getParameter("language");
00170        if(param!=null && param.length()>0){
00171            if(param.equalsIgnoreCase("nl")){
00172               rem1="\u2023 Wiskundige fout";
00173               rem2="\u2023 Onzinnige invoer";
00174               rem3="\u2023 rekenmachine";
00175               rem4="\u2023 klaar";
00176               rem5="\u2023 ln(e)=1 log(10)=1";
00177               rem6="\u2023 info [klik open & dicht]";
00178               rem7="\u2023 even geduld...";
00179               rem9="\u2023 precisie";
00180               rem11="\u2023 Je mag deze tekst ook wissen...\n en dit venster gebruiken voor de berekening \n en druk \"enter\" om je berekening te starten";
00181            } 
00182            else
00183            {
00184               if(param.equalsIgnoreCase("de")){
00185                   rem1="\u2023 Mathematik Fehler";
00186                   rem2="\u2023 Nonsense Fehler";
00187                   rem3="\u2023 Taschenrechner";
00188                   rem4="\u2023 fertig";
00189                   rem5="\u2023 ln(e)=1 log(10)=1";
00190                   rem6="\u2023 info [click open & close]";
00191                   rem7="\u2023 einen moment...";
00192                   rem9="\u2023 precision";
00193                   rem11="\u2023 You could also erase this text...\n and type in your formula or calculation...\n Press Enter to start calculations.";
00194               }
00195               else
00196               {
00197                   if(param.equalsIgnoreCase("fr")){
00198                      rem1="\u2023 Erreur mathematique";
00199                      rem2="\u2023 Nonsense Erreur";
00200                      rem3="\u2023 calculateur";
00201                      rem4="\u2023 fini";
00202                      rem5="\u2023 ln(e)=1 log(10)=1";
00203                      rem6="\u2023 info [click open & close]";
00204                      rem7="\u2023 Please wait...";
00205                      rem9="\u2023 precision";
00206                      rem11="\u2023 You could also erase this text...\n and type in your formula or calculation...\n Press Enter to start calculations.";
00207                   }
00208               }
00209            }
00210        }
00211 
00212        // display precision 
00213        param=getParameter("decimals");
00214        if(param!=null && param.length()>0){
00215            rounding =Integer.parseInt(param, 10);
00216            precision=(double) 1/(Math.pow(10,rounding));
00217        }
00218        String numformat="#.";
00219        for(int n=0;n<rounding;n++){
00220            numformat=numformat+"#";
00221        }
00222        decformat = new DecimalFormat(numformat);
00223 
00224        // very slow java tooltip text: multiline through HTML
00225        rem8="<html><body bgcolor=white><ul><li>\u2023"+rem9+": \u00B1 "+precision+"</li><li>6*(123/4+1234/5)/(7+9)</li><li>(123^(4/3)+5)/6</li><li>sqrt(123/4)/5</li><li>sqrt[3](1234)</li><li>sin(2*pi)</li><li>sinh(pi)</li><li>log(123)/log(10)</li><li>ln(e)=log(e)=1</li></ul>";
00226        rem10=rem9+": \u00B1 "+precision+"\n\u2023 sqrt[3](1234) \n\u2023 sin(2*pi) \n\u2023 sinh(pi) \n\u2023 log(123)/log(10) [ ln(e) == log(e) = 1 ]\n"+rem11;
00227        // adjust the GraphWindow frame...
00228        param=getParameter("frame_xsize");
00229        if(param!=null && param.length()>0){frame_x = Integer.parseInt(param, 10);}
00230        param=getParameter("frame_ysize");
00231        if(param!=null && param.length()>0){frame_y = Integer.parseInt(param, 10);}
00232        param=getParameter("location_x");
00233        if(param!=null && param.length()>0){x0 = Integer.parseInt(param, 10);}
00234        param=getParameter("location_y");
00235        if(param!=null && param.length()>0){y0 = Integer.parseInt(param, 10);}
00236        // adjust the fonts
00237        param=getParameter("fontsize1");
00238        if(param!=null && param.length()>0){font_size1 = Integer.parseInt(param, 10);}
00239        param=getParameter("fontsize2");
00240        if(param!=null && param.length()>0){font_size2 = Integer.parseInt(param, 10);}
00241        param=getParameter("fontsize3");
00242        if(param!=null && param.length()>0){font_size3 = Integer.parseInt(param, 10);}
00243        // adjust the pen colours
00244        param=getParameter("pencolor1"); // foreground color of inputfield "input"
00245        if (param != null && param.length()>0){
00246            param=param.replace(':',',');param=param.replace(';',',');
00247            StringTokenizer q = new StringTokenizer(param, ",");
00248            String k;int rgb;
00249            for( int a=0; a<3 ; a++){
00250               k=q.nextToken();
00251               rgb=Integer.parseInt(k, 10);
00252               if(rgb<0){rgb=0;}
00253               if(rgb>255){rgb=255;}
00254               if(a == 0){R1 = rgb;}
00255               else if(a == 1){G1 = rgb;}
00256               else if(a == 2){B1 = rgb;}
00257            }
00258            pencolor1=new Color(R1,G1,B1);
00259        }
00260        param=getParameter("pencolor2"); // foreground color of inputfield "input"
00261        if (param != null && param.length()>0){
00262            param=param.replace(':',',');param=param.replace(';',',');
00263            StringTokenizer q = new StringTokenizer(param, ",");
00264            String k;int rgb;
00265            for( int a=0; a<3 ; a++){
00266               k=q.nextToken();
00267               rgb=Integer.parseInt(k, 10);
00268               if(rgb<0){rgb=0;}
00269               if(rgb>255){rgb=255;}
00270               if(a == 0){R1 = rgb;}
00271               else if(a == 1){G1 = rgb;}
00272               else if(a == 2){B1 = rgb;}
00273            }
00274            pencolor2=new Color(R1,G1,B1);
00275        }
00276        // adjust the background colours
00277        param=getParameter("bgcolor1"); // Background color of inputfield "input"
00278        if (param != null && param.length()>0){
00279            param=param.replace(':',',');param=param.replace(';',',');
00280            StringTokenizer q = new StringTokenizer(param, ",");
00281            String k;int rgb;
00282            for( int a=0; a<3 ; a++){
00283               k=q.nextToken();
00284               rgb=Integer.parseInt(k, 10);
00285               if(rgb<0){rgb=0;}
00286               if(rgb>255){rgb=255;}
00287               if(a == 0){R1 = rgb;}
00288               else if(a == 1){G1 = rgb;}
00289               else if(a == 2){B1 = rgb;}
00290            }
00291            bgcolor1=new Color(R1,G1,B1);
00292        }
00293        param=getParameter("bgcolor2"); // Background color of canvas
00294        if (param != null && param.length()>0){
00295            param=param.replace(':',',');param=param.replace(';',',');
00296            StringTokenizer q = new StringTokenizer(param, ",");
00297            String k;int rgb;
00298            for( int a=0; a<3 ; a++){
00299               k=q.nextToken();
00300               rgb=Integer.parseInt(k, 10);
00301               if(rgb<0){rgb=0;}
00302               if(rgb>255){rgb=255;}
00303               if(a == 0){R1 = rgb;}
00304               else if(a == 1){G1 = rgb;}
00305               else if(a == 2){B1 = rgb;}
00306            }
00307            bgcolor2=new Color(R1,G1,B1);
00308        }    
00309     } 
00310     
00311     // plot a function
00312     public void plot(String S){
00313        remarks.setText("\u2023 function plot"); /* not really fine ; will need some work... */
00314        input.setText("? ");
00315        output.setText("\u2023 ?");
00316        if(S.indexOf("=") != -1){
00317            S=S.substring(S.indexOf("=")+1);
00318        }
00319        //System.out.println(S);
00320        graphwindow.plotfunction(S);
00321        graphwindow.setVisible(true);
00322     }
00323 
00324     // the actual calculation starts here:
00325     public void calculate(String S){
00326        S=replace(S,"?","");
00327        S=RawMath(S);
00328        if(S.length()>1){
00329            String remark="";
00330            S=replace(S,",",".");
00331            S=replace(S,"**","^");
00332            S=S.toLowerCase();
00333            S=replace(S,"sqr(","sqrt(");/* common error */
00334            if(S.indexOf("sqrt[") != -1){S=sqrtn(S);} /* sqrt[3](4) = 4^(1/3) ... */
00335            if(S.indexOf("log[") != -1){S=logn(S);} /* log[3](4) = log(4)/log(3) ... */
00336            for(int s=0;s<3;s++){/* arity lib throws errors +-5-+3------23 etc */
00337               S=replace(S,"+-","-");
00338                S=replace(S,"-+","-");
00339               S=replace(S,"--","+");
00340                S=replace(S,"++","+");
00341            }
00342            if(S != null){
00343               if(S.indexOf("x")!=-1 || S.indexOf("y")!=-1 ){ /* function to plot */
00344                   plot(S);
00345               }
00346               else
00347               { double result=0.0D;/* double is needed for Arity libs */
00348                   Symbols symbols=new Symbols(); /* Arity */
00349                   String ex[]=S.split("=");
00350                   String out="";
00351                   try { 
00352                   result=symbols.eval(ex[ex.length-1]); /* try to call arity  for evaluation */
00353                   if(result == Double.POSITIVE_INFINITY){out="\u221E";}
00354                   else
00355                   if(result == Double.NEGATIVE_INFINITY){out="-\u221E";}
00356                   else
00357                   if(result == Double.NaN){out="NaN (Not A Number)";}
00358                   else
00359                   if(result == Math.PI){out="-\u03C0";}
00360                   else
00361                   if(result == Math.E){out="e";}
00362                   else
00363                   out=truncate(result);
00364                             
00365                   output.setText("\u2023 "+out);remarks.setText(rem4+remark);
00366                   } catch (SyntaxException e) {output.setText("\u2023 ?");remarks.setText(rem1+remark);}
00367               }
00368            }
00369            else
00370            {
00371               output.setText(rem2);
00372                remarks.setText(rem4+remark);
00373            }        
00374        }
00375        else
00376        {
00377            output.setText("\u2023 ");
00378            remarks.setText(rem6);
00379        }
00380        input.setText("? ");
00381        input.setCaretPosition(2); /* first 2 positions are: ? [space] */
00382     }
00383 
00384     public String RawMath(String i){
00385        i=i.toLowerCase();
00386        i=i.replace(" ","");
00387        i=i.replace("**","^");
00388        if(i.indexOf("e+")!=-1){i=i.replace("e+","*10^");}
00389        if(i.indexOf("e-")!=-1){i=i.replace("e-","*10^-");}
00390        i=i.replace("**","*");
00391        String[] fun={"sin","cos","tan","log","ln","pi","e"};
00392        String[] cons={"pi","e","0","1","2","3","4","5","6","7","8","9"};
00393        for(int p=0;p<fun.length;p++){
00394            for( int d=0;d<cons.length;d++){
00395               while(i.indexOf(cons[d]+""+fun[p])!=-1){
00396                   i=i.replace(cons[d]+""+fun[p],cons[d]+"*"+fun[p]);
00397               }
00398               while(i.indexOf(fun[p]+""+cons[d])!=-1){
00399                   i=i.replace(fun[p]+""+cons[d],fun[p]+"*"+cons[d]);
00400               }
00401            }
00402        }
00403        if(i.indexOf("(")!=-1){
00404            for(int p=0;p<cons.length;p++){
00405               if(i.indexOf(cons[p]+"(")!=-1){
00406                   i=i.replace(cons[p]+"(",cons[p]+"*(");
00407               }
00408               if(i.indexOf(")"+cons[p])!=-1){
00409                   i=i.replace(")"+cons[p],")*"+cons[p]);
00410               }
00411            }
00412            i=i.replace(")(",")*(");
00413        }
00414        if(i.indexOf("e")!=-1){
00415            while(i.indexOf("e")!=-1){
00416               i=i.replace("e","2.718281828459045");
00417            }
00418        }
00419        if(i.indexOf("pi")!=-1){
00420            while(i.indexOf("pi")!=-1){
00421               i=i.replace("pi","3.141592653589793");
00422            }
00423        }
00424 
00425        if(i.indexOf("log(")!=-1 || i.indexOf("ln(")!=-1){i=ConvertLog(i);}
00426        return i;
00427     }
00428     
00429     public String ConvertLog(String t){
00430        int begin=t.indexOf("log(");
00431        if(begin==-1){t=replace(t,"ln","log");return t;}
00432        int tot;int Got;int Wait;int End;char chr;int s;
00433        String value;String L;String R;
00434        while (begin >= 0){
00435            begin=t.indexOf("log(");
00436            tot=t.length();
00437            Wait=0;Got=0;End=0;
00438            for(s=begin+3;s<tot;s++){
00439               if(End==0){
00440                   chr=t.charAt(s);
00441                   if(chr=='('){Wait=Wait+1;}
00442                   if(chr==')'){Got=Got+1;}
00443                   if(Got!=0){if(Wait==Got){End=s;}}
00444               }
00445            }
00446            //System.out.println("begin="+begin+" end="+End);
00447            
00448            value=t.substring(begin+4,End);
00449            L="log("+value+")";R="(@("+value+")/(@(10)))";
00450            t=replace(t,L,R);
00451        }
00452        t=replace(t,"@","log");
00453        t=replace(t,"ln","log");
00454        //System.out.println("corrected log() -> log10() "+t);
00455        return t;
00456     }
00457 
00458     public void paint(Graphics g){
00459        String S=input.getText();
00460        String SS=inputwindow.textarea.getText();
00461        if(SS.length() > S.length()){S=SS;inputwindow.textarea.setText("");}
00462        calculate(S);
00463     }
00464 
00465     public static String replace(String source, String pattern, String replace){ /* java 1.4 lacks decent replace() */
00466        if (source!=null){
00467            final int len = pattern.length();
00468            StringBuffer sb = new StringBuffer();
00469            int found = -1;
00470            int start = 0;
00471            while( (found = source.indexOf(pattern, start) ) != -1){
00472               sb.append(source.substring(start, found));
00473               sb.append(replace);
00474               start = found + len;
00475            }
00476            sb.append(source.substring(start));
00477            return sb.toString();
00478         }
00479         else
00480        {
00481            return "";
00482        }
00483     }
00484 
00485     public String ReadApplet(){ /* interface for sending the answer through javascript to WIMS */
00486        String reply=output.getText();
00487        String tmp[]=reply.split("\u2023");
00488        if( tmp[1].length() == 0){
00489            remarks.setText(rem2); 
00490            return "error";
00491        }
00492        else
00493        {
00494            return " "+tmp[1];
00495        }
00496     }
00497 
00498     private String sqrtn(String t){/* function to replace sqrt[g](n) by n^(1/g) */
00499        int begin=t.indexOf("sqrt[");
00500        String org=t;
00501        int tot;int Got;int Wait;int End;char chr;int s;int restart;
00502        String value;String exp;String val;String L;String R;int cnt=0;
00503        while (begin >= 0){
00504            cnt++;if(cnt>1000){remarks.setText("sqrt[]() syntax error");}
00505            tot=t.length();Wait=0;Got=0;End=0;
00506            for(s=begin+4;s<tot;s++){
00507               if(End==0){
00508                   chr=t.charAt(s);
00509                   if(chr=='['){Wait=Wait+1;}
00510                   if(chr==']'){Got=Got+1;}
00511                   if(Got!=0){if(Wait==Got){End=s;}}
00512               }
00513            }
00514            restart=End;    
00515            exp=t.substring(begin+5,End);
00516            Wait=0;Got=0;End=0;
00517            for(s=restart;s<tot;s++){
00518               if(End==0){
00519                   chr=t.charAt(s);
00520                   if(chr=='('){Wait=Wait+1;}
00521                   if(chr==')'){Got=Got+1;}
00522                   if(Got!=0){if(Wait==Got){End=s;}}
00523               }
00524            }
00525            val=t.substring(restart+2,End);
00526            R="("+val+")^(1/("+exp+"))";L="sqrt["+exp+"]("+val+")";
00527            t=replace(t,L,R);
00528            begin=t.indexOf("sqrt[");
00529        }
00530        return t;
00531     }
00532 
00533     private String logn(String t){/* function to replace sqrt[g](n) by n^(1/g) */
00534        int begin=t.indexOf("log[");
00535        String org=t;
00536        int tot;int Got;int Wait;int End;char chr;int s;int restart;
00537        String value;String exp;String val;String L;String R;int cnt=0;
00538        while (begin >= 0){
00539            cnt++;if(cnt>1000){remarks.setText("log[]() syntax error");}
00540            tot=t.length();Wait=0;Got=0;End=0;
00541            for(s=begin+3;s<tot;s++){
00542               if(End==0){
00543                   chr=t.charAt(s);
00544                   if(chr=='['){Wait=Wait+1;}
00545                   if(chr==']'){Got=Got+1;}
00546                   if(Got!=0){if(Wait==Got){End=s;}}
00547               }
00548            }
00549            restart=End;    
00550            exp=t.substring(begin+4,End);
00551            Wait=0;Got=0;End=0;
00552            for(s=restart;s<tot;s++){
00553               if(End==0){
00554                   chr=t.charAt(s);
00555                   if(chr=='('){Wait=Wait+1;}
00556                   if(chr==')'){Got=Got+1;}
00557                   if(Got!=0){if(Wait==Got){End=s;}}
00558               }
00559            }
00560            val=t.substring(restart+2,End);
00561            R="(log("+val+"))/(log("+exp+"))";L="log["+exp+"]("+val+")";
00562            t=replace(t,L,R);
00563            begin=t.indexOf("log[");
00564        }
00565        return t;
00566     }
00567 
00568     public String getAppletInfo(){
00569        return "Java Calculator\n \u2023 using \"Arity\" library\n \u2023 normal arithmetics \n \u2023 sin(),cos(),tan(),sinh(),etc() \n \u2023 sqrt() sqrt[n]() log() \n \u2023 javascript communication [WIMS] \n \u2023 precision adjustable [\u00B1 "+precision+"]\nJ.M. Evers 10/2008";
00570     }
00571 
00572     public String truncate(double t){
00573        String r = decformat.format(precision*(Math.round(t/precision)));     
00574        return r;    
00575     }
00576     
00577     public void start(){}
00578     
00579     public void stop(){}
00580 
00581     public void run(){}
00582     
00583 
00584 }
00585 
00586 
00587 
00588