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);