Shapes Class Reference

Collaboration diagram for Shapes:

Collaboration graph
[legend]

List of all members.


Public Member Functions

Paper getPaper ()
void setPaper (Paper p)
Dataset getDataset ()
void setDataset (Dataset d)
String getQueryParam ()
String getQueryParam (String param)
List< Dataset > getDatasets ()
List< Paper > getPapers ()
YAxis getYAxis ()
void setYAxis (YAxis y)
List< YAxis > getYAxes ()
Link getChart3 ()
XYIntervalSeries getDataSeries (YAxis yaxis)
StreamResponse onChart (final int width, final int height, final int numberRun, int number)

Detailed Description

Definition at line 50 of file Shapes.java.


Member Function Documentation

Paper getPaper (  ) 

Definition at line 61 of file Shapes.java.

00061 { return _paper; }

void setPaper ( Paper  p  ) 

Definition at line 62 of file Shapes.java.

00062 { _paper = p; }

Dataset getDataset (  ) 

Definition at line 67 of file Shapes.java.

00067 { return _dataset; }

void setDataset ( Dataset  d  ) 

Definition at line 68 of file Shapes.java.

00068 { _dataset = d; }

String getQueryParam (  ) 

Definition at line 71 of file Shapes.java.

Referenced by Shapes.getDatasets(), Shapes.getPapers(), and Shapes.getYAxes().

00071                                  {
00072        return _reqGlobals.getRequest().getParameter("irn");
00073     }

String getQueryParam ( String  param  ) 

Definition at line 75 of file Shapes.java.

00075                                              {
00076        return _reqGlobals.getRequest().getParameter(param);
00077     }

List<Dataset> getDatasets (  ) 

Definition at line 79 of file Shapes.java.

References Shapes.getQueryParam().

00079                                       {
00080         String _sirn = this.getQueryParam("dataset");
00081         int _spiresid = Integer.parseInt(this.getQueryParam("irn"));
00082         Query q = null;
00083         if(_sirn.indexOf(",")>-1){
00084             int _i = _sirn.indexOf(",");
00085             String _s1 = _sirn.substring(0,_i);
00086             String _s2 = _sirn.substring( _i+1,_sirn.length() );
00087             if(_s1.indexOf("-")==-1 && _s2.indexOf("-")==-1 ){
00088                 //eg  n,m
00089                 int _ds1 = Integer.parseInt( _s1 );
00090                 int _ds2 = Integer.parseInt( _s2 );
00091                 q = _session.createQuery("select d from Dataset d,Paper p where p._spiresId = :irn and (d._localId = :ds1 or d._localId = :ds2) and d._paper = p");
00092                 q.setLong("ds1", _ds1) ;
00093                 q.setLong("ds2", _ds2) ;
00094            }
00095            if(_s1.indexOf("-")>-1 && _s2.indexOf("-")==-1 ){
00096                 //eg n1-n2,m
00097                 int _i1 = _s1.indexOf("-");
00098                 int _ds11 = Integer.parseInt( _s1.substring(0,_i1) );
00099                 int _ds12 = Integer.parseInt( _s1.substring( _i1+1,_s1.length() ) );
00100                 int _ds2 = Integer.parseInt( _s2 );
00101                 q = _session.createQuery("select d from Dataset d,Paper p where p._spiresId = :irn and ((d._localId > :ds11 and d._localId < :ds12) or d._localId = :ds2) and d._paper = p");
00102                 q.setLong("ds11", _ds11-1) ;
00103                 q.setLong("ds12", _ds12+1) ;
00104                 q.setLong("ds2", _ds2) ;
00105            }
00106             if(_s1.indexOf("-")==-1 && _s2.indexOf("-")>-1 ){
00107                 //eg n,m1-m2
00108                 int _i2= _s2.indexOf("-");
00109                 int _ds21 = Integer.parseInt( _s2.substring(0,_i2) );
00110                 int _ds22 = Integer.parseInt( _s2.substring( _i2+1,_s2.length() ) );
00111                 int _ds1 = Integer.parseInt( _s1 );
00112                 q = _session.createQuery("select d from Dataset d,Paper p where p._spiresId = :irn and (d._localId = :ds1 or (d._localId > :ds21 and d._localId < :ds22)) and d._paper = p");
00113                 q.setLong("ds21", _ds21-1) ;
00114                 q.setLong("ds22", _ds22+1) ;
00115                 q.setLong("ds1", _ds1) ;
00116            }
00117             if(_s1.indexOf("-")>-1 && _s2.indexOf("-")>-1 ){
00118                 //eg n1-n2,m1,m2
00119                 int _i1 = _s1.indexOf("-");
00120                 int _i2 = _s2.indexOf("-");
00121                 int _ds11 = Integer.parseInt( _s1.substring(0,_i1) );
00122                 int _ds12 = Integer.parseInt( _s1.substring( _i1+1,_s1.length() ) );
00123                 int _ds21 = Integer.parseInt( _s2.substring(0,_i2) );
00124                 int _ds22 = Integer.parseInt( _s2.substring( _i2+1,_s2.length() ) );
00125                 q = _session.createQuery("select d from Dataset d,Paper p where p._spiresId = :irn and ((d._localId > :ds11 and d._localId < :ds12) or (d._localId > :ds21 and d._localId < :ds22)) and d._paper = p");
00126                 q.setLong("ds11", _ds11-1) ;
00127                 q.setLong("ds12", _ds12+1) ;
00128                 q.setLong("ds21", _ds21-1) ;
00129                 q.setLong("ds22", _ds22+1) ;
00130            }
00131         }
00132         else{
00133              if(_sirn.indexOf("-")>-1){
00134                  //eg n1-n2
00135                  int _i = _sirn.indexOf("-");
00136                  int _ds1 = Integer.parseInt( _sirn.substring(0,_i) );
00137                  int _ds2 = Integer.parseInt( _sirn.substring( _i+1,_sirn.length() ) );
00138                  q = _session.createQuery("select d from Dataset d,Paper p where p._spiresId = :irn and d._localId > :ds1 and d._localId < :ds2 and d._paper = p");
00139                  q.setLong("ds1", _ds1-1) ;
00140                  q.setLong("ds2", _ds2+1) ;
00141              }
00142              else{
00143                  //eg n
00144                  int _ds = Integer.parseInt(_sirn);
00145                  q = _session.createQuery("select d from Dataset d,Paper p where p._spiresId = :irn and d._localId = :ds and d._paper = p");
00146                  q.setLong("ds", _ds) ; 
00147              }
00148          }
00149          q.setLong("irn", _spiresid) ;      
00150          return q.list(); 
00151     }    

List<Paper> getPapers (  ) 

Definition at line 152 of file Shapes.java.

References Shapes.getQueryParam().

00152                                    {
00153        int _spiresid = Integer.parseInt(this.getQueryParam("irn"));
00154 
00155       Query q = _session.createQuery("from Paper p where p._spiresId = :irn");
00156       q.setLong("irn", _spiresid) ;
00157       return q.list();
00158 
00159     }

YAxis getYAxis (  ) 

Definition at line 164 of file Shapes.java.

00164 { return _yaxis; }

void setYAxis ( YAxis  y  ) 

Definition at line 165 of file Shapes.java.

00165 {_yaxis = y; }

List<YAxis> getYAxes (  ) 

Definition at line 171 of file Shapes.java.

References Shapes.getQueryParam().

00171                                   {
00172         List <YAxis> yaxs = new ArrayList();  
00173         if(getQueryParam("yaxis").indexOf(",")>-1){
00174             String words[] = getQueryParam("yaxis").split(",");
00175             for (int i=0; i<words.length; i++){
00176                 yaxs.add(_dataset.getYAxis(Integer.parseInt(words[i])));
00177             } 
00178         }
00179         else if(getQueryParam("yaxis").indexOf("-")>-1){
00180             String words[] = getQueryParam("yaxis").split("-");
00181             for (int i=Integer.parseInt(words[0]); i<=Integer.parseInt(words[1]); i++){
00182                  yaxs.add(_dataset.getYAxis(i));
00183             }
00184         }
00185         else{
00186             int _ya = Integer.parseInt(this.getQueryParam("yaxis"));
00187             yaxs.add(_dataset.getYAxis(_ya));
00188         } 
00189         return yaxs;
00190     }

Link getChart3 (  ) 

Definition at line 202 of file Shapes.java.

References Shapes.getDataSeries().

00202                            {          
00203         if (numberRun > 10000) {
00204             numberRun=0;
00205         }
00206         numberRun +=1;
00207         XYIntervalSeries series1 = getDataSeries(_yaxis);
00208         seriesMap.put(numberRun,series1);
00209         xLabelMap.put(numberRun,_yaxis.getDataset().getXAxis(1).getHeader());
00210         yLabelMap.put(numberRun,_yaxis.getHeader());
00211         for (String comment : _yaxis.getDataset().getComments()){
00212             commentMap.put(numberRun,comment);
00213         }
00214         return _resources.createActionLink("chart", false, new Object[]{"400","400",numberRun,"1"});
00215     }

XYIntervalSeries getDataSeries ( YAxis  yaxis  ) 

Definition at line 217 of file Shapes.java.

Referenced by Shapes.getChart3().

00217                                                       {
00218         XAxis _xaxis =  yaxis.getDataset().getXAxis(1);
00219 //      System.out.println(yaxis.toString());
00220        for (String comment : yaxis.getDataset().getComments()){
00221             System.out.println(comment);
00222 //            titlestring = comment;
00223         }
00224         XYIntervalSeries series = new  XYIntervalSeries("data1");
00225         for (int ip=1; ip<=yaxis.getPoints().size(); ip++){
00226             try{
00227             double y = yaxis.getPoint(ip).getValue();
00228             double eplus = 0.0;
00229             double eminus = 0.0;
00230             for (Uncertainty e : yaxis.getPoint(ip).getErrors()){
00231                eplus = eplus + e.getPlus()*e.getPlus(); 
00232                eminus = eminus - e.getMinus()*e.getMinus(); 
00233             }
00234             eplus = Math.sqrt(eplus);
00235             eminus = Math.sqrt(eminus);
00236             double yhigh = y + eplus;
00237             double ylow = y - eplus;
00238             double x;
00239             double xhigh;
00240             double xlow;
00241             if(_xaxis.getBin(ip).getLowValue() != null  && _xaxis.getBin(ip).getHighValue() != null){
00242                 x = (_xaxis.getBin(ip).getLowValue()+_xaxis.getBin(ip).getHighValue())/2;
00243                 xlow =  _xaxis.getBin(ip).getLowValue();
00244                 xhigh =  _xaxis.getBin(ip).getHighValue();
00245             }
00246             else{
00247                 x = _xaxis.getBin(ip).getFocus();
00248                 xhigh = _xaxis.getBin(ip).getFocus();
00249                 xlow = _xaxis.getBin(ip).getFocus();
00250             }
00251             series.add(x,xlow,xhigh,y,ylow,yhigh);
00252             System.out.println("x" + x + " " + xhigh + " " + xlow + " " + y + " " + yhigh + " " + ylow);
00253             }
00254             catch(Exception ex){} // again catch no data  point
00255         }
00256             return series;
00257     }

StreamResponse onChart ( final int  width,
final int  height,
final int  numberRun,
int  number 
)

Definition at line 259 of file Shapes.java.

00259                                                                                                      {
00260  
00261         final XYIntervalSeriesCollection collection = new XYIntervalSeriesCollection();
00262         double xlow = 1000000.0;
00263         double xhigh = -1000000.0;
00264         double ylow = 1000000.0;
00265         double yhigh = -1000000.0;
00266         for (int n=0; n<number; n++){
00267             XYIntervalSeries series = (XYIntervalSeries) seriesMap.get(numberRun+n);
00268             int nitems = series.getItemCount();
00269             for (int nn=0; nn<nitems; nn++){
00270               if(series.getXLowValue(nn) < xlow){ xlow = series.getXLowValue(nn);};     
00271               if(series.getXHighValue(nn) > xhigh){ xhigh = series.getXHighValue(nn);};     
00272               if(series.getYLowValue(nn) < ylow){ ylow = series.getYLowValue(nn);};     
00273               if(series.getYHighValue(nn) > yhigh){ yhigh = series.getYHighValue(nn);};     
00274             }
00275             seriesMap.remove(numberRun+n);
00276             collection.addSeries(series);
00277         }
00278         xlow = xlow - 0.15*(xhigh-xlow);
00279         xhigh = xhigh + 0.15*(xhigh-xlow);
00280         ylow = ylow - 0.15*(yhigh-ylow);
00281         yhigh = yhigh + 0.15*(yhigh-ylow);
00282         if(xlow == xhigh){
00283               xlow = 0.90*xlow;
00284               xhigh= 1.10*xhigh;
00285         }
00286         IntervalXYDataset data1 = collection;
00287  
00288         final XYItemRenderer renderer1 = new XYErrorRenderer();
00289 //        final Range rangex = new Range(xlow,xhigh);
00290         final Range rangey = new Range(ylow,yhigh);
00291 //        final Range rangex = new Range(0.0,1.0);
00292        final NumberAxis rangeAxisX = new NumberAxis();
00293         try {
00294               String xlabel = (String) xLabelMap.get(numberRun);
00295               rangeAxisX.setLabel(xlabel);
00296         } 
00297         catch(Exception e){          
00298            rangeAxisX.setLabel("xaxis label ?");
00299         }
00300 //         final NumberAxis rangeAxisX = new NumberAxis(_yaxis.getDataset().getXAxis(1).getHeader());
00301 //        rangeAxisX.setRange(rangex);
00302         rangeAxisX.setAutoRangeIncludesZero(true);
00303        final NumberAxis rangeAxisY = new NumberAxis(_yaxis.getHeader());
00304 //        final NumberAxis rangeAxisY = new NumberAxis();
00306 //        final LogarithmicAxis rangeAxisY = new LogarithmicAxis(_yaxis.getHeader());
00307         try{
00308             String ylabel = (String) yLabelMap.get(numberRun);
00309             rangeAxisY.setLabel(ylabel);
00310         }
00311         catch (Exception e){
00312              rangeAxisY.setLabel("yaxis label ?");
00313        }
00317         rangeAxisY.setRange(rangey);
00318         final XYPlot subplot1 = new XYPlot(data1, rangeAxisX, rangeAxisY, renderer1);
00319         String titlestring = (String) commentMap.get(numberRun);
00320         final TextTitle title = new TextTitle(titlestring);
00321         final JFreeChart chart = new JFreeChart(subplot1);
00322         chart.addSubtitle(title);
00323         return new StreamResponse(){
00324             public String getContentType(){
00325                 return "image/jpeg";
00326             }
00327             public InputStream getStream() throws IOException {
00328                 BufferedImage image  = chart.createBufferedImage(width, height);
00329                 ByteArrayOutputStream byteArray = new ByteArrayOutputStream() ;
00330                 ChartUtilities.writeBufferedImageAsJPEG(byteArray, image) ;
00331                 return new ByteArrayInputStream(byteArray.toByteArray());
00332             }
00333             public void prepareResponse(Response response){}
00334         };
00335     }


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


Generated on Tue Apr 21 15:55:05 2009 for HepData Web servlets by  doxygen 1.5.5