Examples of SLAxes


Examples of com.mockturtlesolutions.snifflib.graphics.SLAxes

   
      FigureReporter rep = this.getFigureReporter("Residuals");
     
      SLFigure fig = rep.getNewFigure();

      SLAxes ax = new SLAxes(fig);
      ax.setXLabel("pH");
      ax.setYLabel("Cb Residual");
      SLLegend legend = new SLLegend(ax,ax,SLLegend.ALPHA_ORDER);
      legend.setLegendLocale(SLLegend.LEGEND_SOUTH);

      pHtoolsPrefs prefs = new pHtoolsPrefs();
      prefs.initialize();
      DblMatrix Xref = new DblMatrix(2);
      //DblMatrix Yref;
      for (int r=0;r<pH4CbThatShouldBeZero.size();r++)
      {
        DblMatrix pHdata = (DblMatrix)pH4CbThatShouldBeZero.get(r);
        DblMatrix Cbdata = (DblMatrix)CbThatShouldBeZero.get(r);

        Xref.setDblAt(pHdata.min(),0);
        Xref.setDblAt(pHdata.max(),1);
        //Yref.setDblAt(DblMatrix.min(Cbdata),0);
        //Yref.setDblAt(DblMatrix.max(Cbdata),1);

        SLLine line = new SLLine(ax);
        line.setXData(pHdata);
        line.setYData(Cbdata);
        line.setMarkerEdgeColor(r);
        line.setLineColor(r);
        line.setMarkerType(r);
        line.updatePreferences("default",prefs);
       
        SLAnnotation annot = (SLAnnotation)legendStrings.get(r);
       
       
        legend.addLegend(annot.getText(),annot,line);
      }
     
      //System.out.println("updatePreferences for legend of Residuals");
     
      legend.updatePreferences("default",prefs);
      SLLine refline = new SLLine(ax);
      refline.setXData(Xref);
      refline.setYData(new DblMatrix(2));
      refline.setMarkerType(-1);//No Marker
      refline.setLineColor(Color.RED);

      FigureReportInstance ev = new FigureReportInstance();
      ev.setFigure(fig);
      ////


      ax.updatePreferences("default",prefs);
      fig.updatePreferences("default",prefs);
      refline.updatePreferences("default",prefs);
      ////

      rep.addToReport(ev);
      //////////////////////////////////////////////////////////////////////////////////

      ///////////////////////////////////////////////////////////////////////////////
      //Report on the predicted Cb!!
      rep = this.getFigureReporter("Predicted");
      if (rep != null)
      {
        fig = rep.getNewFigure();

        ax = new SLAxes(fig);
        ax.setXLabel("pH");
        ax.setYLabel("Cb");
        legend = new SLLegend(ax,ax,SLLegend.ALPHA_ORDER);
        legend.setLegendLocale(SLLegend.LEGEND_SOUTH);

        prefs = new pHtoolsPrefs();
        prefs.initialize();
        Xref = new DblMatrix(2);
        //DblMatrix Yref;
        for (int r=0;r<pH4CbThatShouldBeZero.size();r++)
        {

          DblMatrix pHdata = (DblMatrix)pH4CbThatShouldBeZero.get(r);
          //DblMatrix Cbdata = (DblMatrix)CbThatShouldBeZero.get(r);
          param = this.mkParameterName(new String[]{"C",buffername});
          DblMatrix thisConc = this.getParam(param);
          BufferSolution sol = new BufferSolution();
          sol.setConnection(this.connection);
          sol.setRepository(this.repository);
          sol.initialize();
          sol.add(this.transientStorage,thisConc);
          DblMatrix Cbdata = (DblMatrix)((HashMap)sol.Cb(pHdata)).get("total");//We take a peak at the Cb that would be given by the current parameterization.
          Cbdata = DblMatrix.abs(Cbdata);
          //We take absolute value here since generally we can't distinguish between +/- acid/base.

          Xref.setDblAt(pHdata.min(),0);
          Xref.setDblAt(pHdata.max(),1);
          //Yref.setDblAt(DblMatrix.min(Cbdata),0);
          //Yref.setDblAt(DblMatrix.max(Cbdata),1);


          SLLine line = new SLLine(ax);
          line.setXData(pHdata);
          line.setYData(Cbdata);
          line.setMarkerEdgeColor(r);
          line.setLineColor(r);
          line.setMarkerType(r);
          line.updatePreferences("default",prefs);

          legend.addLegend((String)legendStrings.get(r),line);
        }

        legend.updatePreferences("default",prefs);
        // SLLine refline = new SLLine(ax);
    //     refline.setXData(Xref);
    //     refline.setYData(new DblMatrix(2));
    //     refline.setMarkerType(-1);//No Marker
    //     refline.setLineColor(Color.RED);

        ev = new FigureReportInstance();
        ev.setFigure(fig);
        ////


        ax.updatePreferences("default",prefs);
        fig.updatePreferences("default",prefs);

        ////

        rep.addToReport(ev);
View Full Code Here

Examples of com.mockturtlesolutions.snifflib.graphics.SLAxes

//                   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

Examples of com.mockturtlesolutions.snifflib.graphics.SLAxes


      SLFigure fig = rep.getNewFigure();


      SLAxes ax = new SLAxes(fig);
      ax.setXLabel("pH");
      ax.setYLabel("Cb Residual");
      SLLegend legend = new SLLegend(ax,ax,SLLegend.ALPHA_ORDER);
      legend.setLegendLocale(SLLegend.LEGEND_SOUTH);

      pHtoolsPrefs prefs = new pHtoolsPrefs();
      prefs.initialize();
      DblMatrix Xref = new DblMatrix(2);
      //DblMatrix Yref;
      for (int r=0;r<pH4CbThatShouldBeZero.size();r++)
      {

        DblMatrix pHdata = (DblMatrix)pH4CbThatShouldBeZero.get(r);
        DblMatrix Cbdata = (DblMatrix)CbThatShouldBeZero.get(r);

        Xref.setDblAt(pHdata.min(),0);
        Xref.setDblAt(pHdata.max(),1);
        //Yref.setDblAt(DblMatrix.min(Cbdata),0);
        //Yref.setDblAt(DblMatrix.max(Cbdata),1);


        SLLine line = new SLLine(ax);
        line.setXData(pHdata);
        line.setYData(Cbdata);
        line.setMarkerEdgeColor(r);
        line.setLineColor(r);
        line.setMarkerType(r);
        line.updatePreferences("default",prefs);

        legend.addLegend((String)legendStrings.get(r),line);
      }

      legend.updatePreferences("default",prefs);
      SLLine refline = new SLLine(ax);
      refline.setXData(Xref);
      refline.setYData(new DblMatrix(2));
      refline.setMarkerType(-1);//No Marker
      refline.setLineColor(Color.RED);

      FigureReportInstance ev = new FigureReportInstance();
      ev.setFigure(fig);
      ////


      ax.updatePreferences("default",prefs);
      fig.updatePreferences("default",prefs);
      refline.updatePreferences("default",prefs);
      ////

      rep.addToReport(ev);
      //////////////////////////////////////////////////////////////////////////////////

      ///////////////////////////////////////////////////////////////////////////////
      //Report on the predicted Cb!!
      rep = this.getFigureReporter("Predicted");
      if (rep != null)
      {
        fig = rep.getNewFigure();

        ax = new SLAxes(fig);
        ax.setXLabel("pH");
        ax.setYLabel("Cb");
        legend = new SLLegend(ax,ax,SLLegend.ALPHA_ORDER);
        legend.setLegendLocale(SLLegend.LEGEND_SOUTH);

        prefs = new pHtoolsPrefs();
        prefs.initialize();
        Xref = new DblMatrix(2);
        //DblMatrix Yref;
        for (int r=0;r<pH4CbThatShouldBeZero.size();r++)
        {

          DblMatrix pHdata = (DblMatrix)pH4CbThatShouldBeZero.get(r);
          //DblMatrix Cbdata = (DblMatrix)CbThatShouldBeZero.get(r);
          param = this.mkParameterName(new String[]{"C",buffername});
          DblMatrix thisConc = this.getParam(param);
          BufferSolution sol = new BufferSolution();
          sol.setConnection(this.connection);
          sol.setRepository(this.repository);
          sol.initialize();
          sol.add(this.transientStorage,thisConc);
          DblMatrix Cbdata = (DblMatrix)((HashMap)sol.Cb(pHdata)).get("total");//We take a peak at the Cb that would be given by the current parameterization.
          Cbdata = DblMatrix.abs(Cbdata);
          //We take absolute value here since generally we can't distinguish between +/- acid/base.

          Xref.setDblAt(pHdata.min(),0);
          Xref.setDblAt(pHdata.max(),1);
          //Yref.setDblAt(DblMatrix.min(Cbdata),0);
          //Yref.setDblAt(DblMatrix.max(Cbdata),1);


          SLLine line = new SLLine(ax);
          line.setXData(pHdata);
          line.setYData(Cbdata);
          line.setMarkerEdgeColor(r);
          line.setLineColor(r);
          line.setMarkerType(r);
          line.updatePreferences("default",prefs);

          legend.addLegend((String)legendStrings.get(r),line);
        }

        legend.updatePreferences("default",prefs);
        // SLLine refline = new SLLine(ax);
    //     refline.setXData(Xref);
    //     refline.setYData(new DblMatrix(2));
    //     refline.setMarkerType(-1);//No Marker
    //     refline.setLineColor(Color.RED);

        ev = new FigureReportInstance();
        ev.setFigure(fig);
        ////


        ax.updatePreferences("default",prefs);
        fig.updatePreferences("default",prefs);

        ////

        rep.addToReport(ev);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.