Back to index

wims  3.65+svn20090927
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Package Attributes | Static Package Attributes | Private Member Functions
WIMSchem.MainApplet Class Reference
Inheritance diagram for WIMSchem.MainApplet:
Inheritance graph
[legend]
Collaboration diagram for WIMSchem.MainApplet:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void init ()
String[] GetTemplateURL ()
void GetFile ()
String getLanguage ()
Boolean ViewHydrogen ()
Boolean ViewCarbon ()
String[] GetMyAtoms ()
String[] AtomString2AtomArray (String t)
boolean[] getMenus ()
boolean[] getTools ()
Properties loadProperties (String lang)
String getAppletInfo ()
boolean SetMoleculeNative (String Source)
boolean SetMoleculeMDLMol (String Source)
boolean AppendMoleculeNative (String Source)
boolean AppendMoleculeMDLMol (String Source)
String GetMoleculeNative ()
String GetMoleculeMDLMol ()
void GetQuestion (String i)
String ReadApplet ()
String CompareNative ()
void AnalyseMolecule (String S, boolean whatisit)
double getScore ()
void componentHidden (ComponentEvent e)
void componentMoved (ComponentEvent e)
void componentResized (ComponentEvent e)
void componentShown (ComponentEvent e)

Static Public Member Functions

static byte[] loadURL (URL url) throws IOException
static String loadFile (String fname) throws IOException
static String load (String fileOrURL) throws IOException

Public Attributes

boolean[] selected_tools
boolean[] selected_menus
String Correct_answer = ""
String feedback = ""
boolean continu = true
String replytext = ""
String Student_answer = ""
String language
int typeset = 0
String plain_formula_ca = ""
String html_formula_ca = ""
String latex_formula_ca = ""
String plain_formula_sa = ""
String html_formula_sa = ""
String latex_formula_sa = ""
int[] charge_ca
int[] radical_ca
int[] charge_sa
int[] radical_sa
String[] elements_ca
String[] elements_sa
int[] hydro_ca
int[] hydro_sa
int num_sa = 0
int num_ca = 0
int bond_sa = 0
int bond_ca = 0
String[] my_atoms
boolean ViewH
boolean ViewC

Static Public Attributes

static Properties translation = new Properties()
static String[] templateURL

Package Attributes

MainPanel mainPanel = null
MainPanel Language = null
MainPanel Translation = null
double weight_ca = 0
double weight_sa = 0
String html_smiles_ca = ""
String html_smiles_sa = ""

Static Package Attributes

static String[] tools = {"TOOL_CURSOR","TOOL_ROTATOR","TOOL_ERASOR","TOOL_DIALOG","TOOL_EDIT","TOOL_SETATOM","TOOL_SINGLE","TOOL_DOUBLE","TOOL_TRIPLE","TOOL_ZERO","TOOL_INCLINED","TOOL_DECLINED","TOOL_UNKNOWN","TOOL_CHARGE","TOOL_UNDO","TOOL_REDO","TOOL_TEMPLATE","TOOL_CUT","TOOL_COPY","TOOL_PASTE"}
static String[] menus = {"MENU_BLOCK","MENU_SELECT","MENU_TRANSFORM","MENU_ZOOM","MENU_SHOW","MENU_HYDROGEN","MENU_STEREO","MENU_HELP"}
static int N = Molecule.ELEMENTS.length

Private Member Functions

Molecule ParseParams ()

Detailed Description

Definition at line 21 of file MainApplet.java.


Member Function Documentation

void WIMSchem.MainApplet.AnalyseMolecule ( String  S,
boolean  whatisit 
) [inline]

Definition at line 582 of file MainApplet.java.

                                                            {
       // jm.evers
       // whatisit=false : correct answer e.g. from javascript by wims.
       // whatisit=true  : student drawing
       // reading data , preparing representation formulas
       if(whatisit){System.out.println("analysing student reply");}else{System.out.println("analysing correct answer");}
       String[] s=S.split("\n");String[] atom;int s1=s[0].indexOf('(');int s2=s[0].indexOf(',');int s3=s[0].indexOf(')');
       int n_s=Integer.parseInt(s[0].substring(s1+1,s2).trim());int b_s=Integer.parseInt(s[0].substring(s2+1,s3).trim());
       String[] E_s=new String[n_s];int[] H_s=new int[n_s];int[] C_s=new int[n_s];int[] R_s=new int[n_s];
       int[] this_A=new int[N];int[] this_C=new int[N];int[] this_R=new int[N];int[] this_H=new int[N];
       String plainformula="";String htmlformula="";String latexformula="";
       String R_plain="";String R_html="";String R_latex="";
       String C_plain="";String C_html="";String C_latex="";
       String sign;
       double weight_s=0.0D;int r=0;
       
       // loop only through the atom part of the file-string 
       for( int p=0; p<n_s ;p++){
           atom=s[p+1].split("[\\=\\,\\;]"); //first line is mimetype
           E_s[p]=atom[0];r=0;
           for(int n=0;n<N;n++){
              if(atom[0].equals(Molecule.ELEMENTS[n])){
                  weight_s=(double)(weight_s + Molecule.WEIGHTS[n]);
                  this_A[n]++;r=n;n=N;
              }
           }
           C_s[p]=Integer.parseInt(atom[3]);
           this_C[r]=C_s[p];
           R_s[p]=Integer.parseInt(atom[4]);
           this_R[p]=R_s[p];
           if( atom[5].indexOf("i")!=-1){
              atom[5]=atom[5].replaceAll("i","");H_s[p]=Integer.parseInt(atom[5]);this_H[r]=H_s[p];this_A[1]=this_A[1]+H_s[p];//hydrogen
           }
           else
           {
              atom[5]=atom[5].replaceAll("e","");H_s[p]=Integer.parseInt(atom[5]);this_H[r]=H_s[p];this_A[1]=this_A[1]+H_s[p];//hydrogen
           }      
           weight_s=(double)(weight_s + H_s[p]);
       }

       if(this_A[6]!=0){
           if(this_R[6] != 0){R_plain="\u2022";R_latex="^{^{\\cdot}}";R_html="<sup>&cdot;</sup>";}
           if(this_C[6] != 0){
              if(this_C[6]>0){sign="+";}else{sign="-";this_C[6]=(int) (Math.abs(this_C[6]));}
              C_plain=this_C[6]+sign;C_latex="^{"+this_C[6]+sign+"}";C_html="<sup><small>"+this_C[6]+sign+"</small></sup>";
           }
           if(this_A[6] == 1 ){// C1 is not done:  CH4
              plainformula="C"+C_plain+R_plain+" ";
               htmlformula="<font size=+1><tt>C"+C_html+R_html+"</tt></font>";
              latexformula="\\Bf{C"+C_latex+R_latex+"}";
           }
           else
           {//C2H5OH
              plainformula="C"+C_plain+R_plain+this_A[6];
              htmlformula="<font size=+1><tt>C"+C_html+R_html+"</tt></font><sub><small>"+this_A[6]+"</small></sub>";
              latexformula="\\Bf{C"+C_latex+R_latex+"}_{"+this_A[6]+"}";
           }
       }
       // the rest
       for(int p = 0; p<N; p++){
           if( p == 6 ){ p = 7;} // we already covered carbon
           if( this_A[p] != 0 ){
              R_plain="";R_html="";R_latex="";C_plain="";C_html="";C_latex="";sign="";
              if( this_R[p] != 0 ){ R_plain=this_R[p]+"\u2022";R_latex="^{^{"+this_R[p]+"\\cdot}}";R_html="<sup><sup>"+this_R[p]+"&cdot;</sup></sup>";}
              if( this_C[p] != 0 ){ if( this_C[p]>0 ){ sign="+"; } else { sign="-"; this_C[p]=-1*this_C[p];}C_plain=this_C[p]+sign;C_latex="^{"+this_C[p]+sign+"}";C_html="<sup><small>"+this_C[p]+sign+"</small></sup>";}
              if( this_A[p] == 1 ){
                  plainformula=plainformula+" "+Molecule.ELEMENTS[p]+""+C_plain+""+R_plain;
                  htmlformula=htmlformula+" <font size=+1><tt>"+Molecule.ELEMENTS[p]+C_html+R_html+"</tt></font>";
                  latexformula=latexformula+"\\,\\Bf{"+Molecule.ELEMENTS[p]+C_latex+R_latex+"}";
              }
              else
              {
                  plainformula=plainformula+" "+Molecule.ELEMENTS[p]+""+C_plain+""+R_plain+""+this_A[p];
                  htmlformula=htmlformula+" <font size=+1><tt>"+Molecule.ELEMENTS[p]+C_html+R_html+"</tt></font><sub><small>"+this_A[p]+"</small></sub>";
                  latexformula=latexformula+"\\,\\Bf{"+Molecule.ELEMENTS[p]+C_latex+R_latex+"}_{"+this_A[p]+"}";
              }
           }
       }
       
       if(whatisit){// these are used for getting a score
           elements_sa=E_s;hydro_sa=H_s;charge_sa=C_s;radical_sa=R_s;weight_sa=weight_s;
           plain_formula_sa=plainformula;html_formula_sa=htmlformula;latex_formula_sa=latexformula;num_sa=n_s;bond_sa=b_s;
       }
       else
       {
           elements_ca=E_s;hydro_ca=H_s;charge_ca=C_s;radical_ca=R_s;weight_ca=weight_s;
           plain_formula_ca=plainformula;html_formula_ca=htmlformula;latex_formula_ca=latexformula;num_ca=n_s;bond_ca=b_s;
       }
    }// end AnalyseMolecule()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 414 of file MainApplet.java.

                                                      {
       try
       {
           Molecule mol=MoleculeStream.ReadMDLMOL(new BufferedReader(new StringReader(Source.toString())));     
           mainPanel.AddMolecule(mol);
           mainPanel.repaint();
           return true;
       }
       catch (IOException e) {System.out.println("error"+e);}
       
       return false;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 401 of file MainApplet.java.

                                                      {
       try
       {
           Molecule mol=MoleculeStream.ReadNative(new BufferedReader(new StringReader(Source.toString())));
           mainPanel.AddMolecule(mol);
           mainPanel.repaint();
           return true;
       }
       catch (IOException e) {System.out.println("error"+e);}
       
       return false;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

String [] WIMSchem.MainApplet.AtomString2AtomArray ( String  t) [inline]

Definition at line 230 of file MainApplet.java.

                                                  {
       //jm.evers: parsing params into array...fieldseparators are "," ":" ";" " "
       StringTokenizer q;
       if(t.indexOf(",")!=-1){
           q = new StringTokenizer(t, ",");
       }
       else
       {
           if(t.indexOf(":")!=-1){
              q = new StringTokenizer(t, ":");   
           }
           else
           {
              if(t.indexOf(";")!=-1){
                  q = new StringTokenizer(t, ";");      
              }
              else
              {
                  if(t.indexOf(" ")>2){
                     q = new StringTokenizer(t, " ");   
                  }
                  else
                  {
                     return null;
                  }
              }
           }
       }
       int max=q.countTokens();if( max > 50 ){ max = 50;}
       String[] tmp=new String[max];String s="";
       for( int p = 0 ; p<max ; p++){
           s=q.nextToken();
           //System.out.println("found atom "+s);
           if(s.length()==1 || s.length()==2){
              tmp[p]=s;
              //System.out.println("added");
           }
       }
       return tmp;
    }     

Here is the call graph for this function:

Here is the caller graph for this function:

String WIMSchem.MainApplet.CompareNative ( ) [inline]

Definition at line 538 of file MainApplet.java.

                                 { 
       // jm.evers: 
       // only usefull if called [javascript] together with GetQuestion(). See example in javascript !
       System.out.println("entering function CompareNative()");
       try
       {
           StringWriter sw=new StringWriter();BufferedWriter bw=new BufferedWriter(sw);
           MoleculeStream.WriteNative(bw,mainPanel.MolData());
           Student_answer=sw.toString();Student_answer=Student_answer.replaceAll(" ","");
           System.out.println("Student answer is:"+Student_answer);
           
           if(Student_answer.indexOf("WIMSchem!")!=-1 || Student_answer.indexOf("!FIN")!=-1){
              if(Student_answer.length() < 22){// !WIMSchem(0,0) \n !FIN 
                  feedback=translation.getProperty("empty_answer");;
                  continu=false;
              }
           }
           else
           {
              continu=false;
              feedback=translation.getProperty("no_sketchfile_answer");
           }
       }
       catch (IOException e) {System.out.println("error"+e);continu=false;feedback=translation.getProperty("no_sketchfile_answer");}

       if(continu){
           feedback="";num_sa=0;num_ca=0;bond_sa=0;bond_ca=0;weight_sa=0.0;weight_ca=0.0;
           AnalyseMolecule(Student_answer,true);
           AnalyseMolecule(Correct_answer,false);
           double score=getScore();
           // a smiles representation -at least it could look like smiles ...
           html_smiles_sa=MoleculeStream.GetSmiles(mainPanel.MolData());
           try {
              html_smiles_ca=MoleculeStream.GetSmiles(MoleculeStream.ReadNative(new BufferedReader(new StringReader(Correct_answer))));
           }
           catch(IOException e) { System.out.println("error"+e);}
           return score+"\n"+weight_sa+"\n"+weight_ca+"\n"+plain_formula_sa+"\n"+plain_formula_ca+"\n"+html_formula_sa+"\n"+html_formula_ca+"\n"+html_smiles_sa+"\n"+html_smiles_ca+"\n"+latex_formula_sa+"\n"+latex_formula_ca+"\n"+feedback+"\n@"+Student_answer+"\n@"+Correct_answer;
       }
       else
       {
           return "error\n"+feedback;
       }
    }

Here is the call graph for this function:

void WIMSchem.MainApplet.componentHidden ( ComponentEvent  e) [inline]

Definition at line 716 of file MainApplet.java.

{}
void WIMSchem.MainApplet.componentMoved ( ComponentEvent  e) [inline]

Definition at line 717 of file MainApplet.java.

{}
void WIMSchem.MainApplet.componentResized ( ComponentEvent  e) [inline]

Definition at line 718 of file MainApplet.java.

{}
void WIMSchem.MainApplet.componentShown ( ComponentEvent  e) [inline]

Definition at line 719 of file MainApplet.java.

                                                {
    mainPanel.ScaleToFit();
    mainPanel.repaint();
    }

Here is the call graph for this function:

String WIMSchem.MainApplet.getAppletInfo ( ) [inline]

Definition at line 330 of file MainApplet.java.

                                 {
       return  translation.getProperty("WIMSchem_Applet_Description");
    }
void WIMSchem.MainApplet.GetFile ( ) [inline]

Definition at line 140 of file MainApplet.java.

                         {
    //jm.evers : try to load a file as string from the URL given in the params
       String filename=getParameter("file");
       if (filename!=null){
           try
           {
              //System.out.println("trying to load "+filename);
              // jm.evers: is param showfile is set, draw to canvas...
              String showfile=getParameter("showfile");
              if(showfile.equalsIgnoreCase("yes") ||  showfile.equals("1")){
                  //System.out.println("loaded file will be drawn to canvas ");
                  String DemoMol=(load(filename)).toString();
                  if(DemoMol.indexOf("WIMSchem!")!=-1 && DemoMol.indexOf("!FIN")!=-1){
              //     System.out.println("it is in Native fileformat");
                     AppendMoleculeNative(DemoMol);
                  }
                  else
                  {
                     if( DemoMol.indexOf("molfile")!=-1){
              //         System.out.println("it is in MDLMol fileformat");
                         AppendMoleculeMDLMol(DemoMol);
                     }
                     else
                     {
                         System.out.println("Unknown filetype or corrupt file "+filename+"\n"+DemoMol);
                     }
                  }
              }
              else
              {
                  Correct_answer=(load(filename)).toString();
                  //System.out.println("loaded file will be used as Correct_answer molecule \n"+Correct_answer);              
                  GetQuestion(Correct_answer);
              }
           }
           catch (Exception e){System.out.println("Could not load "+filename);continu=false;}
       }
       else
       {
           System.out.println("param \"file\" is empty\nWill not use fileloading");
       }
    }  

Here is the call graph for this function:

Here is the caller graph for this function:

String WIMSchem.MainApplet.getLanguage ( ) [inline]

Definition at line 183 of file MainApplet.java.

                               {
       // jm.evers: reading language. default english
       String param = getParameter("language");
       if(param != null){param = param.toLowerCase();}else{param = "en";}
       return param;
    }

Here is the caller graph for this function:

Definition at line 271 of file MainApplet.java.

                               {
       // jm.evers: configuring menus through appletparams
       String param;
       selected_menus=new boolean[8];
       for(int p=0;p<8;p++){
           param=getParameter(menus[p]);
           if(param!=null){
              if(param.equalsIgnoreCase("yes") || param.equals("1")){
                  selected_menus[p]=true;
              }
              else
              {
                  selected_menus[p]=false;
              }
           }
           else
           {
              selected_menus[p]=true;
           }
       }
       return selected_menus;
    
    }

Here is the caller graph for this function:

Definition at line 442 of file MainApplet.java.

                                     {
       try
       {
           StringWriter sw=new StringWriter();
           BufferedWriter bw=new BufferedWriter(sw);
           MoleculeStream.WriteMDLMOL(bw,mainPanel.MolData());
           return sw.toString();
       }
       catch (IOException e) {System.out.println("error"+e);}
       
       return null;
    }

Here is the call graph for this function:

Definition at line 428 of file MainApplet.java.

                                     {
       try
       {
           StringWriter sw=new StringWriter();
           BufferedWriter bw=new BufferedWriter(sw);
           MoleculeStream.WriteNative(bw,mainPanel.MolData());
           return sw.toString();
       }
       catch (IOException e) {System.out.println("error"+e);}
       
       return null;
    }

Here is the call graph for this function:

String [] WIMSchem.MainApplet.GetMyAtoms ( ) [inline]

Definition at line 216 of file MainApplet.java.

                                {
       // jm.evers: reading atoms from params
       String param = getParameter("atoms");
       if(param != null){
           System.out.println("found Atoms: "+param);
           my_atoms=AtomString2AtomArray(param);
           return my_atoms;
       }
       else
       {
           return null;
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void WIMSchem.MainApplet.GetQuestion ( String  i) [inline]

Definition at line 455 of file MainApplet.java.

                                     {
       //jm.evers: 
       // called by javascript to "upload" the chemical from a javascript variable. [a wims "record" in my modules]
       // and the same javascript function could call "CompareNative()" to compare this molecule with the drawing  
       // OR
       // if <param name="file" value="http://whatever_wims_server/filename"> is set
       feedback="";
       if(i.indexOf("WIMSchem!")!=-1 && i.indexOf("!FIN")!=-1){
           //Correct_answer=i.replaceAll(" ","");continu=true;
           //System.out.println("found Native WIMSchem file :"+Correct_answer);
           System.out.println("Native fileformat detected");
              Molecule elmol=new Molecule();
              try
              {
                  elmol=MoleculeStream.ReadNative(new BufferedReader(new StringReader(i.toString())));
                  System.out.println("Native stringfile converted to molecule");
              }
              catch (IOException e) {System.out.println("error"+e);continu=false;}
              // then convert molecule to Native string...
              try
              {
                  Correct_answer=MoleculeStream.Molecule2String(elmol);
                  continu=true;
              }
              catch (IOException e) {System.out.println("error"+e+"trouble with converting native molecule to string:"+i );continu=false;}
       }
       else
       {
           if( i.indexOf("molfile")!=-1){
              System.out.println("molfile detected");
              // first convert MDMOL to molecule
              Molecule mdmol=new Molecule();
              try
              {
                  mdmol=MoleculeStream.ReadMDLMOL(new BufferedReader(new StringReader(i.toString())));
                  System.out.println("MDMOL file converted to molecule");
              }
              catch (IOException e) {System.out.println("error"+e);continu=false;}
              // then convert molecule to Native string...
              try
              {
                  Correct_answer=MoleculeStream.Molecule2String(mdmol);
                  continu=true;
              }
              catch (IOException e) {System.out.println("error"+e+"trouble with converting molecule to string:"+i );continu=false;}
           }
           else
           {
              if(Correct_answer.length() == 0){
                  feedback=translation.getProperty("empy_string_question");continu=false;
              }
              else
              {
                  feedback=translation.getProperty("invalid_question");continu=false;
              }
           }
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

double WIMSchem.MainApplet.getScore ( ) [inline]

Definition at line 672 of file MainApplet.java.

                            {
       System.out.println("entering function getScore()");
       // jm.evers:
       // comparing the molecules studentanswer [sa] and correct answer [ca]
       // giving somekind of score: ofcourse any "score < 10" is technically plain wrong !!
       // feedback is not yet operational...because it gives disturbing messages :(
       int hit=0;String tmp_remark="";
       boolean[] done=new boolean[num_sa];
       double finalscore=0.0D;
       for(int p=0;p<num_sa;p++){
           done[p]=true;
       }
       if( num_ca == num_sa  && bond_ca == bond_sa ){
           for( int c=0; c < num_ca ; c++){
              for( int s=0; s < num_sa ;s++){
                  if(done[s]){
                     if( elements_ca[c].equals(elements_sa[s]) && charge_ca[c] == charge_sa[s] && radical_ca[c] == radical_sa[s] && hydro_ca[c] == hydro_sa[s]){
                         done[s]=false;
                         hit++;s=num_sa;break;
                     }
                     else
                     {
                         if( elements_ca[c].equals(elements_sa[s]) ){
                            if( charge_ca[c] != charge_sa[s] ){ tmp_remark="wrong_charge "+elements_ca[c]+"="+charge_ca[c]+",";}
                             if( radical_ca[c] != radical_sa[s] ){ tmp_remark="wrong_radical "+elements_ca[c]+"="+radical_ca[c]+",";}
                            if( hydro_ca[c] != hydro_sa[s] ){ tmp_remark="wrong_amount_hydrogen "+elements_ca[c]+"="+hydro_ca[c]+","; }
                         }
                     }
                  }
              }
           }
       }      
       feedback=feedback+tmp_remark;
       if(num_ca > num_sa){
           finalscore=(double)(10*hit/num_ca);
       }
       else
       {
           finalscore=(double)(10*hit/num_sa);
       }
       System.out.println("finalscore="+finalscore);
       return finalscore;
    }

Here is the caller graph for this function:

String [] WIMSchem.MainApplet.GetTemplateURL ( ) [inline]

Definition at line 117 of file MainApplet.java.

                                    {
       // jm.evers : retreive an unknown amount of templates via params called template1,template2...
       // these templates will be called by Template.java
       String parm=getParameter("template1");
       if( parm != null && parm.length()!=0 ){
           int p=0;
           while( parm!=null && parm.length()!=0 ){
              p++;
              parm=getParameter("template"+p);
           }
           String[] templateURL=new String[p-1];
           for(int s=1;s<p;s++){
              parm=getParameter("template"+s);
               templateURL[s-1]=parm;
           }
           return templateURL;
       }
       else
       {
           return null;
       }
    }

Here is the caller graph for this function:

Definition at line 294 of file MainApplet.java.

                               {
       // jm.evers: configuring toolbar through appletparams
       String param;
       selected_tools=new boolean[20];
       for(int p=0;p<20;p++){
           param=getParameter(tools[p]);
           if(param!=null){
              if(param.equalsIgnoreCase("yes") || param.equals("1")){
                  selected_tools[p]=true;
              }
              else
              {
                  selected_tools[p]=false;
              }
           }
           else
           {
              selected_tools[p]=true;
           }
       }
       return selected_tools;
    }

Here is the caller graph for this function:

void WIMSchem.MainApplet.init ( ) [inline]

Definition at line 67 of file MainApplet.java.

                      {
       templateURL=GetTemplateURL();
       ViewH=ViewHydrogen();
       ViewC=ViewCarbon();
       selected_tools=getTools();
       selected_menus=getMenus();
       my_atoms=GetMyAtoms();
       language=getLanguage();
       translation=loadProperties(language);
       getContentPane().setLayout(new BorderLayout());
       mainPanel=new MainPanel(null,false,true,null,language,translation,selected_tools,selected_menus,my_atoms,ViewH,ViewC);
       getContentPane().add(mainPanel,BorderLayout.CENTER);
       Molecule mol=ParseParams();
       if (mol!=null){mainPanel.SetMolecule(mol);}      
       addComponentListener(this);
       GetFile();
       repaint(1000);
    }

Here is the call graph for this function:

static String WIMSchem.MainApplet.load ( String  fileOrURL) throws IOException [inline, static]

Definition at line 107 of file MainApplet.java.

                                                                   {
    // jm.evers :handy functions !!! not mine :(
       try {
           URL url = new URL(fileOrURL);
           return new String(loadURL(url));
       } catch (Exception e) {
       return loadFile(fileOrURL);
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static String WIMSchem.MainApplet.loadFile ( String  fname) throws IOException [inline, static]

Definition at line 101 of file MainApplet.java.

                                                                   {
    // jm.evers :handy functions !!! not mine :(
       byte[] bytes = loadURL(new URL("file:" + fname));
       return new String(bytes);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Properties WIMSchem.MainApplet.loadProperties ( String  lang) [inline]

Definition at line 317 of file MainApplet.java.

                                                  {
       translation=new Properties();
       // jm.evers : trying global properties file with translations
       try{
           InputStream in = getClass().getResourceAsStream("/lang/WIMSchemProperties_"+lang+".properties");
           translation.load(in);in.close();
           return translation;
       } 
       catch (Exception e){ System.out.println("error reading /lang/WIMSchemProperties_"+lang+".properties\n"+e);}         
            return null;                                                                                                               
    }  

Here is the caller graph for this function:

static byte [] WIMSchem.MainApplet.loadURL ( URL  url) throws IOException [inline, static]

Definition at line 86 of file MainApplet.java.

                                                              {
    // jm.evers :handy functions !!! not mine :(
        int bufSize = 1024 * 2;
       byte [] buf = new byte[bufSize];
       ByteArrayOutputStream bout = new ByteArrayOutputStream();
       BufferedInputStream   in   = new BufferedInputStream(url.openStream());
       int n;
       while ((n = in.read(buf)) > 0) {
           bout.write(buf, 0, n);
       }
       try 
       { in.close(); } catch (Exception ignored) { }
       return bout.toByteArray();
    }

Here is the caller graph for this function:

Definition at line 338 of file MainApplet.java.

                                  {
       try
       {
           String str=getParameter("nlines");
           if (str==null) return null;
           int nlines=Integer.valueOf(str).intValue();
           if (nlines<3 || nlines>10000) return null; // insanity

           StringBuffer buff=new StringBuffer();
           for (int n=1;n<=nlines;n++)
           {
              str=getParameter("line"+n);
              if (str==null) return null;
              for (int i=0;i<str.length();i++) 
              {
                  if (str.charAt(i)=='_') str=str.substring(0,i)+" "+str.substring(i+1); else break;
              }
              buff.append(str+"\n");
           }
           
           Molecule mol=MoleculeStream.ReadNative(new BufferedReader(new StringReader(buff.toString())));
           if (mol.NumAtoms()>0) return mol;
           return null;
       }
       catch (Exception e) 
       {
           JOptionPane.showMessageDialog(null,translation.getProperty("Unable_to_parse_parameter_molecule")+e.getMessage(),"zog",JOptionPane.ERROR_MESSAGE); 
       }

       return null;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

String WIMSchem.MainApplet.ReadApplet ( ) [inline]

Definition at line 514 of file MainApplet.java.

                              {
       //jm.evers:
       // return info of the shown molecule... e.g. using the applet as image viewer
       // accet
       try
       {
           StringWriter sw=new StringWriter();BufferedWriter bw=new BufferedWriter(sw);MoleculeStream.WriteNative(bw,mainPanel.MolData());
           Correct_answer=sw.toString();Correct_answer=Correct_answer.replaceAll(" ","");
           if(Correct_answer.indexOf("WIMSchem!")!=-1 || Correct_answer.indexOf("!FIN")!=-1){
              if(Correct_answer.length() < 22){// !WIMSchem(0,0) \n !FIN 
                  feedback=translation.getProperty("empty_answer");continu=false;
              }
           }
           else
           {
              continu=false;feedback=translation.getProperty("no_sketchfile_answer");
           }
       }
       catch (IOException e) {System.out.println("error"+e);continu=false;feedback=translation.getProperty("no_sketchfile_answer");}
       AnalyseMolecule(Correct_answer,false);
       html_smiles_ca=MoleculeStream.GetSmiles(mainPanel.MolData());
       return        weight_ca+"\n"+plain_formula_ca+"\n"+html_formula_ca+"\n"+html_smiles_ca+"\n"+latex_formula_ca;
    }

Here is the call graph for this function:

boolean WIMSchem.MainApplet.SetMoleculeMDLMol ( String  Source) [inline]

Definition at line 386 of file MainApplet.java.

                                                    {
       try
       {
           Molecule mol=MoleculeStream.ReadMDLMOL(new BufferedReader(new StringReader(Source.toString())));
           //Molecule mol=MoleculeStream.ReadUnknown(new BufferedReader(new StringReader(Source)));
           mainPanel.SetMolecule(mol);
           mainPanel.repaint();
           return true;
       }
       catch (IOException e) { System.out.println("error"+e);}
       return false;
    }

Here is the call graph for this function:

boolean WIMSchem.MainApplet.SetMoleculeNative ( String  Source) [inline]

Definition at line 373 of file MainApplet.java.

                                                    {
       try
       {
           Molecule mol=MoleculeStream.ReadNative(new BufferedReader(new StringReader(Source.toString())));
           //Molecule mol=MoleculeStream.ReadUnknown(new BufferedReader(new StringReader(Source)));
           mainPanel.SetMolecule(mol);
           mainPanel.repaint();
           return true;
       }
       catch (IOException e) { System.out.println("error"+e);}
       return false;
    }

Here is the call graph for this function:

Boolean WIMSchem.MainApplet.ViewCarbon ( ) [inline]

Definition at line 203 of file MainApplet.java.

                               {
       // jm.evers: reading elements param. 27/12/2008
       String param = getParameter("show_carbon");
       boolean c=true;
       if(param != null){param = param.toLowerCase();
           if(param.equals("0") || param.equals("no")){
              c=false;
           }
       }
       System.out.println("viewC="+c+" param="+param);
       return c;
    }

Here is the caller graph for this function:

Boolean WIMSchem.MainApplet.ViewHydrogen ( ) [inline]

Definition at line 190 of file MainApplet.java.

                                 {
       // jm.evers: reading hydrogen param. 27/12/2008
       String param = getParameter("show_hydrogen");
       boolean h=true;
       if(param != null){param = param.toLowerCase();
           if(param.equals("0") || param.equals("no")){
              h=false;
           }
       }
       System.out.println("viewH="+h+" param="+param);
       return h;
    }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 61 of file MainApplet.java.

Definition at line 60 of file MainApplet.java.

Definition at line 46 of file MainApplet.java.

Definition at line 48 of file MainApplet.java.

Definition at line 34 of file MainApplet.java.

Definition at line 32 of file MainApplet.java.

Definition at line 50 of file MainApplet.java.

Definition at line 51 of file MainApplet.java.

Definition at line 33 of file MainApplet.java.

Definition at line 40 of file MainApplet.java.

Definition at line 43 of file MainApplet.java.

String WIMSchem.MainApplet.html_smiles_ca = "" [package]

Definition at line 56 of file MainApplet.java.

String WIMSchem.MainApplet.html_smiles_sa = "" [package]

Definition at line 57 of file MainApplet.java.

Definition at line 52 of file MainApplet.java.

Definition at line 53 of file MainApplet.java.

Definition at line 25 of file MainApplet.java.

Definition at line 37 of file MainApplet.java.

Definition at line 41 of file MainApplet.java.

Definition at line 44 of file MainApplet.java.

Definition at line 24 of file MainApplet.java.

String [] WIMSchem.MainApplet.menus = {"MENU_BLOCK","MENU_SELECT","MENU_TRANSFORM","MENU_ZOOM","MENU_SHOW","MENU_HYDROGEN","MENU_STEREO","MENU_HELP"} [static, package]

Definition at line 28 of file MainApplet.java.

Definition at line 62 of file MainApplet.java.

Definition at line 45 of file MainApplet.java.

Definition at line 59 of file MainApplet.java.

Definition at line 58 of file MainApplet.java.

Definition at line 39 of file MainApplet.java.

Definition at line 42 of file MainApplet.java.

Definition at line 47 of file MainApplet.java.

Definition at line 49 of file MainApplet.java.

Definition at line 35 of file MainApplet.java.

Definition at line 30 of file MainApplet.java.

Definition at line 29 of file MainApplet.java.

Definition at line 36 of file MainApplet.java.

String [] WIMSchem.MainApplet.templateURL [static]

Definition at line 65 of file MainApplet.java.

String [] WIMSchem.MainApplet.tools = {"TOOL_CURSOR","TOOL_ROTATOR","TOOL_ERASOR","TOOL_DIALOG","TOOL_EDIT","TOOL_SETATOM","TOOL_SINGLE","TOOL_DOUBLE","TOOL_TRIPLE","TOOL_ZERO","TOOL_INCLINED","TOOL_DECLINED","TOOL_UNKNOWN","TOOL_CHARGE","TOOL_UNDO","TOOL_REDO","TOOL_TEMPLATE","TOOL_CUT","TOOL_COPY","TOOL_PASTE"} [static, package]

Definition at line 27 of file MainApplet.java.

Definition at line 26 of file MainApplet.java.

Properties WIMSchem.MainApplet.translation = new Properties() [static]

Definition at line 31 of file MainApplet.java.

Definition at line 38 of file MainApplet.java.

Definition at line 64 of file MainApplet.java.

Definition at line 63 of file MainApplet.java.

double WIMSchem.MainApplet.weight_ca = 0 [package]

Definition at line 54 of file MainApplet.java.

double WIMSchem.MainApplet.weight_sa = 0 [package]

Definition at line 55 of file MainApplet.java.


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