Package com.mockturtlesolutions.snifflib.graphics

Examples of com.mockturtlesolutions.snifflib.graphics.PlotFrame


                 
                  //Plot Cbplot = new Plot(Cbdata);
                  Cbplot.addPredictorVariable("pH");
                  //Cbplot.addResponseVariable("total");
                 
                  PlotFrame plotstuff = new PlotFrame(Cbplot);
                 
                  // pHtoolsPrefs prefs = new pHtoolsPrefs();
//                   prefs.initialize();
//                  
//                  
//                   System.out.println("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT");
//                   plotstuff.setAxesPreferences(prefs);
//                   plotstuff.setFigurePreferences(prefs);
//                   plotstuff.setLineSegmentRendererPreferences(prefs);
//                  
                 
                  SLAxes ax = Cbplot.getAxes();
                  ax.setYLabel("Approx. Moles/L Hydroxyl Added");
                  ax.setXLabel("pH")
                  plotstuff.setVisible(true);
                 
                }
               
                if (selection.equalsIgnoreCase("get cb density"))
                {
               
                  JProgressBar progressBar = null;
                  Container parent = getParent();
                  System.out.println("Here");
                  if (parent !=null)
                  {
                    System.out.println("Here A");
                    if (parent instanceof WorkBenchPanel)
                    {
                      System.out.println("Here B");
                      Container frame;
                      while (true)
                      {
                        frame = parent.getParent();
                        parent = frame;
                        if (frame instanceof jpHtoolsWBFrame)
                        {
                          break;
                        }
                       
                        if (frame == null)
                        {
                          break;
                        }
                     
                      }
                     
                      if (frame != null)
                      {
                        jpHtoolsWBFrame wbframe =  (jpHtoolsWBFrame)frame;
                        progressBar = wbframe.getProgressBar();
                        progressBar.setVisible(true);
                        progressBar.setString("Determining HPD for Cb...");
                        progressBar.setIndeterminate(true);
                      }
                    }
                  }
                 
                  final JProgressBar bar = progressBar;
                 
                 
                  Thread t = new Thread(new Runnable()
                  {
                    public void run()
                    {
                      HashMap CbHPDresult = null;
                      DblMatrix pH2run = getpH();
                      double prob = 0.95;

                      try
                      {
                        //CbHPDresult = ((BufferSolution)model).CbHPD(pH2run,prob,true);
                      }
                      catch (Exception err)
                      {
                        throw new RuntimeException("Problem getting Cb.",err);
                      }


                      Set keys = CbHPDresult.keySet();
                      String[] hdrs = new String[keys.size()];
                      Class[] cls = new Class[keys.size()];

                      Iterator iter = keys.iterator();
                      String col;
                      DblMatrix val;
                      DataSet Cbdata = new DataSet("pH",Double.class);


                      for (int j=0;j<pH2run.getN();j++)
                      {
                        Cbdata.addRow(j);
                        Cbdata.setValueAt(pH2run.getDoubleAt(j),j,0);

                      }


                      int i=1;// pH is in the first column (index=0) so we start at index 1 now.
                      Plot Cbplot = new Plot(Cbdata);

                      ////
                      pHtoolsPrefs prefs = new pHtoolsPrefs();
                      prefs.initialize();
                      Cbplot.setAxesPreferences(prefs);
                      Cbplot.setFigurePreferences(prefs);
                      Cbplot.setLineSegmentRendererPreferences(prefs);
                      prefs.setConfigValue(repos,"legenddomainnamefilter","none");
                      Cbplot.setLegendPreferences(prefs);

                      ////

                      while (iter.hasNext())
                      {
                        col = (String)iter.next();
                        String upperLabel = (col+"_U"+prob);
                        String lowerLabel = (col+"_L"+prob);

                        Cbplot.addResponseVariable(lowerLabel);
                        Cbplot.addResponseVariable(upperLabel);

                        //System.out.println("Next column:"+col);
                        DblMatrix[] CI = (DblMatrix[])CbHPDresult.get(col);


                        Cbdata.addColumn(lowerLabel,Double.class);
                        Cbdata.addColumn(upperLabel,Double.class);

                        for (int j=0;j<CI[0].getN();j++)
                        { 
                          //System.out.println("Adding Cbdata row:"+j);
                          //Cbdata.addRow(j);
                          Cbdata.setValueAt(CI[0].getDoubleAt(j),j,i);
                          Cbdata.setValueAt(CI[1].getDoubleAt(j),j,i+1)
                        }
                        i = i+2;
                      }

                      //Plot Cbplot = new Plot(Cbdata);
                      Cbplot.addPredictorVariable("pH");
                      //Cbplot.addResponseVariable("total");

                      PlotFrame plotstuff = new PlotFrame(Cbplot);

                      // pHtoolsPrefs prefs = new pHtoolsPrefs();
    //                   prefs.initialize();
    //                  
    //                  
    //                   System.out.println("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT");
    //                   plotstuff.setAxesPreferences(prefs);
    //                   plotstuff.setFigurePreferences(prefs);
    //                   plotstuff.setLineSegmentRendererPreferences(prefs);
    //                  

                      SLAxes ax = Cbplot.getAxes();
                      ax.setYLabel("Approx. Moles/L Hydroxyl Added");
                      ax.setXLabel("pH")
                      plotstuff.setVisible(true);
                     
                      if (bar != null)
                      {
                        bar.setIndeterminate(false);
                        bar.setVisible(false);
                      }
                    }
                 
                  });
       
                  t.start(); // Start it running
                }
               
               
               
                if (selection.equalsIgnoreCase("get species concentration"))
                {
                  DblMatrix pH2run = getpH();
                  HashMap Cbresult = null;
                  try
                  {
                    Cbresult = ((BufferSolution)model).species(pH2run);
                  }
                  catch (Exception err)
                  {
                    throw new RuntimeException("Problem getting species concentration.",err);
                  }
                 
                  Set keys = Cbresult.keySet();
                  Set ionKeys;
                  String[] hdrs = new String[keys.size()];
                  Class[] cls = new Class[keys.size()];
                 
                  Iterator iter = keys.iterator();
                  Iterator ionIter;
                  String col,ion;
                  DblMatrix val;
                  DataSet Cbdata = new DataSet("pH",Double.class);
                  HashMap ionMap;
                 
                  for (int j=0;j<pH2run.getN();j++)
                  {
                    Cbdata.addRow(j);
                    Cbdata.setValueAt(pH2run.getDoubleAt(j),j,0);
                 
                  }
                 
                  Plot Cbplot = new Plot(Cbdata);
                 
                 
                  ////
                  pHtoolsPrefs prefs = new pHtoolsPrefs();
                  prefs.initialize();
                  Cbplot.setAxesPreferences(prefs);
                  Cbplot.setFigurePreferences(prefs);
                  Cbplot.setLineSegmentRendererPreferences(prefs);
                  Cbplot.setLegendPreferences(prefs);
                  ////
                 
                 
                  Log10 logfun = new Log10();
                  Cbplot.setYTransformation((UniUniFunction)logfun);
                 
                  Cbplot.addPredictorVariable("pH");
                  int i=1;
                  Vector labels = new Vector();
                  String label;
                  while (iter.hasNext())
                  {
                    col = (String)iter.next();
                    System.out.println("Next column:"+col);
                    ionMap = (HashMap)Cbresult.get(col);
                   
                    ionKeys = ionMap.keySet();
                    ionIter = ionKeys.iterator();
                    while (ionIter.hasNext())
                    {
                      ion = (String)ionIter.next();
                      label = col+":"+ion;
                      labels.add(label);
                      Cbdata.addColumn(label,Double.class);
                      val = (DblMatrix)ionMap.get(ion);
                      for (int j=0;j<val.getN();j++)
                      { 
                        //System.out.println("Adding Cbdata row:"+j);
                        //Cbdata.addRow(j);
                        Cbdata.setValueAt(val.getDoubleAt(j),j,i)
                      }
                     
                      Cbplot.addResponseVariable(label);
                      i++;
                    }
                   
                  }
                 
                 
                  //Cbplot.addPredictorVariable("pH");
                  //Cbplot.addResponseVariable("total");
                 
                  PlotFrame plotstuff = new PlotFrame(Cbplot);
                  SLAxes ax = Cbplot.getAxes();
                  ax.setYLabel("Log10 species concentation");
                  ax.setXLabel("pH")
                  plotstuff.setVisible(true);
                 
                 
                }
               
                if (selection.equalsIgnoreCase("get buffer capacity"))
                {
                   
                  DblMatrix pH2run = getpH();
                  HashMap Cbresult = null;
                  try
                  {
                    Cbresult = ((BufferSolution)model).buffCapEval(pH2run,true);
                  }
                  catch (Exception err)
                  {
                    throw new RuntimeException("Problem getting the buffer capacity.",err);
                  }
                 
                  Set keys = Cbresult.keySet();
                  String[] hdrs = new String[keys.size()];
                  Class[] cls = new Class[keys.size()];
                 
                  Iterator iter = keys.iterator();
                  String col;
                  DblMatrix val;
                  DataSet Cbdata = new DataSet("pH",Double.class);
                 
                 
                  for (int j=0;j<pH2run.getN();j++)
                  {
                    Cbdata.addRow(j);
                    Cbdata.setValueAt(pH2run.getDoubleAt(j),j,0);
                 
                  }
                 
                 
                  int i=1;
                  Plot Cbplot = new Plot(Cbdata);
                 
                  ////
                  pHtoolsPrefs prefs = new pHtoolsPrefs();
                  prefs.initialize();
                  Cbplot.setAxesPreferences(prefs);
                  Cbplot.setFigurePreferences(prefs);
                  Cbplot.setLineSegmentRendererPreferences(prefs);
                  Cbplot.setLegendPreferences(prefs);
                  ////
                 
                  while (iter.hasNext())
                  {
                    col = (String)iter.next();
                    Cbplot.addResponseVariable(col);
                    System.out.println("Next column:"+col);
                    val = (DblMatrix)Cbresult.get(col);
                    Cbdata.addColumn(col,Double.class);
                   
                    for (int j=0;j<val.getN();j++)
                    { 
                      //System.out.println("Adding Cbdata row:"+j);
                      //Cbdata.addRow(j);
                      Cbdata.setValueAt(val.getDoubleAt(j),j,i)
                    }
                    i++;
                  }
                 
                  //Plot Cbplot = new Plot(Cbdata);
                  Cbplot.addPredictorVariable("pH");
                  //Cbplot.addResponseVariable("total");
                 
                  PlotFrame plotstuff = new PlotFrame(Cbplot);
                  SLAxes ax = Cbplot.getAxes();
                  ax.setYLabel("Buffer Capacity");
                  ax.setXLabel("pH")
                  plotstuff.setVisible(true);
                }
               
                if (selection.equalsIgnoreCase("get ionic strength"))
                {
                  DblMatrix pH2run = getpH();
                  HashMap Cbresult = null;
                  try
                  {
                    Cbresult = ((BufferSolution)model).ionicStr(pH2run,true);
                  }
                  catch (Exception err)
                  {
                    throw new RuntimeException("Problem getting the ionic strength.",err);
                  }
                 
                  Set keys = Cbresult.keySet();
                  String[] hdrs = new String[keys.size()];
                  Class[] cls = new Class[keys.size()];
                 
                  Iterator iter = keys.iterator();
                  String col;
                  DblMatrix val;
                  DataSet Cbdata = new DataSet("pH",Double.class);
                 
                 
                  for (int j=0;j<pH2run.getN();j++)
                  {
                    Cbdata.addRow(j);
                    Cbdata.setValueAt(pH2run.getDoubleAt(j),j,0);
                 
                  }
                 
                 
                  int i=1;
                  Plot Cbplot = new Plot(Cbdata);
                 
                  ////
                  pHtoolsPrefs prefs = new pHtoolsPrefs();
                  prefs.initialize();
                  Cbplot.setAxesPreferences(prefs);
                  Cbplot.setFigurePreferences(prefs);
                  Cbplot.setLineSegmentRendererPreferences(prefs);
                  Cbplot.setLegendPreferences(prefs);
                  ////
                 
                  while (iter.hasNext())
                  {
                 
                   
                    col = (String)iter.next();
                    Cbplot.addResponseVariable(col);
                    //System.out.println("Next column:"+col);
                    val = (DblMatrix)Cbresult.get(col);
                   
                    val.show("val");
                    Cbdata.addColumn(col,Double.class);
                   
                    for (int j=0;j<val.getN();j++)
                    { 
                      System.out.println("Adding Cbdata row:"+j);
                      //Cbdata.addRow(j);
                      Cbdata.setValueAt(val.getDoubleAt(j),j,i)
                    }
                    i++;
                  }
                 
                  //Plot Cbplot = new Plot(Cbdata);
                  Cbplot.addPredictorVariable("pH");
                  //Cbplot.addResponseVariable("total");
                 
                  PlotFrame plotstuff = new PlotFrame(Cbplot);
                  SLAxes ax = Cbplot.getAxes();
                  ax.setYLabel("Ionic strength");
                  ax.setXLabel("pH")
                  plotstuff.setVisible(true);
                 
                }
               
              }
            });
View Full Code Here

TOP

Related Classes of com.mockturtlesolutions.snifflib.graphics.PlotFrame

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.