[HepData-svn] r1291 - in trunk/hepdata-webapp/src/main: java/cedar/hepdata/webapp/pages resources/cedar/hepdata/webapp/pages

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Jul 16 18:56:42 BST 2009


Author: buckley
Date: Thu Jul 16 18:56:41 2009
New Revision: 1291

Log:
Better multi-inline plotting

Modified:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Plot.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/PlotImage.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Search.java
   trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Plot.tml
   trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Search.tml

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Plot.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Plot.java	Thu Jul 16 18:32:30 2009	(r1290)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Plot.java	Thu Jul 16 18:56:41 2009	(r1291)
@@ -24,6 +24,11 @@
 public class Plot extends ViewBase {
 
 
+    private YAxis _yaxis;
+    public YAxis getYAxis() { return _yaxis; }
+    public void setYAxis(YAxis y) { _yaxis = y; }
+
+
     // Decode URL context into the params map
     public StreamResponse onActivate(EventContext context) {
         // Do the basic parsing via the base class
@@ -74,6 +79,12 @@
         for (String c : ctx) {
             rtn += "-" + c;
         }
+        if (!rtn.matches(".*-x.*")) {
+            rtn += "-x1";
+        }
+        if (!rtn.matches(".*-y.*")) {
+            rtn += "-y" + getYAxis().getId().toString();
+        }
         return rtn;
     }
 
@@ -91,18 +102,4 @@
     }
 
 
-    // public Link getChart() {
-    //     Object[] args = { "200", "lin", "lin" };
-    //     return _resources.createEventLink("chart", false, args);
-    // }
-
-    // // Response to "chart" event
-    // public StreamResponse onChart(int size, String xscalestr, String yscalestr) {
-    //     AxisType xscale = AxisType.valueOf(xscalestr.toUpperCase());
-    //     AxisType yscale = AxisType.valueOf(yscalestr.toUpperCase());
-    //     JFreeChart chart = Plotter.makeChart(getXAxis(), getYAxes(), xscale, yscale);
-    //     return Plotter.makeChartStreamResponse(chart, ImageFormat.PNG, size, size);
-    // }
-
-
 }

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/PlotImage.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/PlotImage.java	Thu Jul 16 18:32:30 2009	(r1290)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/PlotImage.java	Thu Jul 16 18:56:41 2009	(r1291)
@@ -80,19 +80,17 @@
 
 
 
-    /// @todo Parse values as comma-separated lists
     public Integer getQueryD() {
         Integer di = null;
         if (getQueryParam("d") != null) di = Integer.parseInt(getQueryParam("d"));
         return di;
     }
-    /// @todo Parse values as comma-separated lists
     public Integer getQueryX() {
         Integer xi = null;
         if (getQueryParam("x") != null) xi = Integer.parseInt(getQueryParam("x"));
         return xi;
     }
-    /// @todo Parse values as comma-separated lists
+    /// @todo Parse values as lists
     public Integer getQueryY() {
         Integer yi = null;
         if (getQueryParam("y") != null) yi = Integer.parseInt(getQueryParam("y"));

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Search.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Search.java	Thu Jul 16 18:32:30 2009	(r1290)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/Search.java	Thu Jul 16 18:56:41 2009	(r1291)
@@ -47,6 +47,9 @@
     public String getSearchString() {
         return query;
     }
+    public String getEscSearchString() {
+        return query.replace(" ", "_");
+    }
 
 
     public String onPassivate() {
@@ -91,9 +94,9 @@
         }
     }
 
-    public Integer getEnding() {
+    public Long getEnding() {
         Integer pagemaxnum = getStarting() + getLength() - 1;
-        Integer absmaxnum = getNumPapers();
+        Long absmaxnum = getNumPapers();
         return Math.min(pagemaxnum, absmaxnum);
     }
 
@@ -160,8 +163,15 @@
     }
 
 
-    public Integer getNumPapers() {
-        return getPapers().size();
+    public Long getNumPapers() {
+        String queryString = getSearchString();
+        Query q = ConstructQueryPaper.mkQueryFromSearchString(queryString, "count", _session);
+        Object result = q.uniqueResult();
+        if (result instanceof BigInteger) {
+            return new Long(((BigInteger)result).longValue());
+        } else {
+            return (Long) result;
+        }
     }
 
 

Modified: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Plot.tml
==============================================================================
--- trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Plot.tml	Thu Jul 16 18:32:30 2009	(r1290)
+++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Plot.tml	Thu Jul 16 18:56:41 2009	(r1291)
@@ -1,55 +1,57 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 <html t:type="layout" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
 
-    <title>HepData data plot</title>
-
-<t:loop source="datasets" value="dataset">    
+  <title>HepData data plot</title>
+  
+  <t:loop source="datasets" value="dataset">    
     <table>
-      <tr>
-        <td width="50%">
-          <!-- TODO: What is this? -->
-          <!-- <t:reactionPlotWords yaxis="yaxis" /> -->
-          <form method="GET" action="plot">
-            Re-plot:
-            <!-- <t:loop source="selects" value="select"> -->
-            <!--   <input type="hidden" name="${getSelect()}" value="on" title="Choose scales"/> -->
-            <!-- </t:loop> -->
-            <!-- <select name="xscale"> -->
-            <!--   <option>x ${getXscale()}</option> -->
-            <!--   <option>x ${getNotXscale()}</option> -->
-            <!-- </select> -->
-            <!-- <select name="yscale"> -->
-            <!--   <option>y ${getYscale()}</option> -->
-            <!--   <option>y ${getNotYscale()}</option> -->
-            <!-- </select>  -->
-            <!-- with systematics -->
-            <!-- <select name="sys"> -->
-            <!--   <option>${getSys()}</option> -->
-            <!--   <option>${getNotSys()}</option> -->
-            <!-- </select>  -->
-            <!-- <input type="submit" value="Re-plot" title="Redo the current plot" /> -->
-
-            <!-- <br/> -->
-            <!-- <br/> -->
-            <!-- <input type="checkbox" name="pdfselect" value="yes"/> + RePlot  -->
-            <!-- to save in  PDF file: <input type="textfield" name="pdfname" value="${getPdfName()}"/> -->
-            <!-- <br/> -->
-          </form>
-
-          <!-- <br/><a href="SavePlot?string=${getQueryString()}&amp;plot=${getHepId()}ds${getDsId()}ya${getYId()}&amp;xscale=${getXscale()}&amp;yscale=${getYscale()}&amp;sys=${getSys()}">Add to selected plot list</a> -->
-          <!-- <br/><a href='SavePlot?list=all&amp;string=${getQueryString()}'>List selected plots</a><br/> -->
-
-          <!-- <br/><a href="view?p=${getHepId()}&amp;string=${getQueryString()}">Go to paper</a><br/> -->
-          <!-- <br/><a href="ReactionQuery?string=${getQueryString()}">Go to search results</a><br/> -->
-        </td>
-        <td width="50%">
-          <!-- The plot -->
-          <a href="#" t:type="pagelink" t:page="plotimage" t:context="${linkimagename}">
-            <img src="${chart}" />
-            <!-- <img src="#" t:type="pagelink" t:page="plotimage" t:context="literal:hepdata-p7521-d2-x1-y1_300.png" /> -->
-          </a>
-        </td>
-      </tr>
+      <t:loop source="dataset.yaxes" value="yaxis">
+        <tr>
+          <td width="50%">
+            <!-- TODO: What is this? -->
+            <!-- <t:reactionPlotWords yaxis="yaxis" /> -->
+            <form method="GET" action="plot">
+              Re-plot:
+              <!-- <t:loop source="selects" value="select"> -->
+              <!--   <input type="hidden" name="${getSelect()}" value="on" title="Choose scales"/> -->
+              <!-- </t:loop> -->
+              <!-- <select name="xscale"> -->
+              <!--   <option>x ${getXscale()}</option> -->
+              <!--   <option>x ${getNotXscale()}</option> -->
+              <!-- </select> -->
+              <!-- <select name="yscale"> -->
+              <!--   <option>y ${getYscale()}</option> -->
+              <!--   <option>y ${getNotYscale()}</option> -->
+              <!-- </select>  -->
+              <!-- with systematics -->
+              <!-- <select name="sys"> -->
+              <!--   <option>${getSys()}</option> -->
+              <!--   <option>${getNotSys()}</option> -->
+              <!-- </select>  -->
+              <!-- <input type="submit" value="Re-plot" title="Redo the current plot" /> -->
+              
+              <!-- <br/> -->
+              <!-- <br/> -->
+              <!-- <input type="checkbox" name="pdfselect" value="yes"/> + RePlot  -->
+              <!-- to save in  PDF file: <input type="textfield" name="pdfname" value="${getPdfName()}"/> -->
+              <!-- <br/> -->
+            </form>
+            
+            <!-- <br/><a href="SavePlot?string=${getQueryString()}&amp;plot=${getHepId()}ds${getDsId()}ya${getYId()}&amp;xscale=${getXscale()}&amp;yscale=${getYscale()}&amp;sys=${getSys()}">Add to selected plot list</a> -->
+            <!-- <br/><a href='SavePlot?list=all&amp;string=${getQueryString()}'>List selected plots</a><br/> -->
+            
+            <!-- <br/><a href="view?p=${getHepId()}&amp;string=${getQueryString()}">Go to paper</a><br/> -->
+            <!-- <br/><a href="ReactionQuery?string=${getQueryString()}">Go to search results</a><br/> -->
+          </td>
+          <td width="50%">
+            <!-- The plot -->
+            <a href="#" t:type="pagelink" t:page="plotimage" t:context="${linkimagename}">
+              <img src="${chart}" />
+              <!-- <img src="#" t:type="pagelink" t:page="plotimage" t:context="literal:hepdata-p7521-d2-x1-y1_300.png" /> -->
+            </a>
+          </td>
+        </tr>
+      </t:loop>
     </table>
 </t:loop>
     

Modified: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Search.tml
==============================================================================
--- trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Search.tml	Thu Jul 16 18:32:30 2009	(r1290)
+++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/Search.tml	Thu Jul 16 18:56:41 2009	(r1291)
@@ -5,11 +5,9 @@
 
   <p>
     Search:&nbsp;<b>${searchstring}</b><br/>
-    <t:if test="papers">
-      Result:&nbsp;<b>${papers.size()}</b> documents found
-      <t:if test="numpapers">
-        (displaying <b>${starting}</b> to <b>${ending}</b>)
-      </t:if>
+    Result:&nbsp;<b>${numpapers}</b> documents found
+    <t:if test="numpapers">
+      (displaying <b>${starting}</b> to <b>${ending}</b>)
     </t:if>
   </p>
   <t:form t:id="searchagain" t:context="query" action="search">
@@ -19,7 +17,7 @@
 
   <p>
     <t:if test="isMultiPage">
-      <a href="#" t:type="pagelink" t:page="search" t:context="${searchstring}?start=10">foo</a>
+      <a href="#" t:type="pagelink" t:page="search" t:context="${escsearchstring}?start=10">foo</a>
       <a href="search/${searchstring}">First</a>&nbsp;|&nbsp;
       <!-- <a href="search/${searchString}${prevQueryParameters}">Previous</a>&nbsp;|&nbsp; -->
       <!-- <a href="search/${searchString}${nextQueryParameters}">Next</a>&nbsp;|&nbsp; -->


More information about the HepData-svn mailing list