changeset 569:9a5e50e7afaa

Added action and jsp for rendering histograms. gnv/trunk@687 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 15 Feb 2010 11:42:29 +0000
parents f21ad239c748
children cbd397712ecf
files gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java gnv/src/main/java/de/intevation/gnv/action/CreateHistogramAction.java gnv/src/main/resources/applicationMessages.properties gnv/src/main/resources/applicationMessages_en.properties gnv/src/main/webapp/WEB-INF/config/struts-config.xml gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/index.jsp gnv/src/main/webapp/images/chart_bar.png gnv/src/main/webapp/styles/default.css
diffstat 11 files changed, 128 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/ChangeLog	Fri Feb 12 11:16:33 2010 +0000
+++ b/gnv/ChangeLog	Mon Feb 15 11:42:29 2010 +0000
@@ -1,3 +1,35 @@
+2010-02-15  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/webapp/WEB-INF/config/struts-config.xml: Added an action
+	  'histogram' to render histograms.
+
+	* src/main/java/de/intevation/gnv/action/CreateHistogramAction.java: Added a
+	  new action for rendering histograms.
+	
+	* src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp: Display an
+	  icon for histograms if this output mode is present for this artifact.
+
+	* src/main/webapp/images/chart_bar.png: Icon for histograms from famfamfam
+	  iconset.
+
+	* src/main/webapp/WEB-INF/jsp/includes/display_histogram_inc.jsp: JSP for
+	  rendering histograms.
+
+	* src/main/webapp/styles/default.css: Added a style class for adapting
+	  histogram div.
+
+	* src/main/webapp/WEB-INF/jsp/index.jsp: Include display_histogram_inc if
+	  histogram action have been chosen by user.
+	
+	* src/main/resources/applicationMessages_en.properties,
+	  src/main/resources/applicationMessages.properties: Button label and
+	  alternative image text for histograms.
+
+	* src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java: Removed
+	  comment lines at the beginning of the file. These empty comment lines 
+	  would cause trouble later, when inserting GPL text automatically with a
+	  script.
+
 2010-02-12  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/webapp/WEB-INF/config/templates/describe-ui-static.xsl: Render an
--- a/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Fri Feb 12 11:16:33 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Mon Feb 15 11:42:29 2010 +0000
@@ -1,6 +1,3 @@
-/**
- *
- */
 package de.intevation.gnv.action;
 
 import java.util.Collection;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/CreateHistogramAction.java	Mon Feb 15 11:42:29 2010 +0000
@@ -0,0 +1,40 @@
+package de.intevation.gnv.action;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
+
+/**
+ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ */
+public class CreateHistogramAction extends DescribeUIAction {
+
+    private static Logger logger = Logger.getLogger(CreateHistogramAction.class);
+
+
+    public CreateHistogramAction() {
+        super();
+    }
+
+
+    @Override
+    public ActionForward execute(
+        ActionMapping       mapping,
+        ActionForm          form,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+    throws Exception {
+        logger.debug("Create histogram.");
+
+        request.setAttribute("histogram", true);
+
+        return super.execute(mapping, form, request, response);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv/src/main/resources/applicationMessages.properties	Fri Feb 12 11:16:33 2010 +0000
+++ b/gnv/src/main/resources/applicationMessages.properties	Mon Feb 15 11:42:29 2010 +0000
@@ -56,12 +56,16 @@
 gnviewer.statistics.descriptive.slope=Steigung
 gnviewer.statistic.button = Statistik
 
+# Histogramm
+gnviewer.histogram.button=Histogramm
+
 # diagram options dialog
 gnviewer.diagram.options.header.title=Diagrammoptionen
 
 
 # attachedOutputOptions
 gnviewer.output.options.diagramm.alt=Diagramm
+gnviewer.output.options.histogram.alt=Histogramm
 gnviewer.output.options.save.title=Diagramm speichern
 gnviewer.output.options.export.csv.title=Daten als CSV exportieren
 gnviewer.output.options.export.odv.title=Daten als ODV exportieren
--- a/gnv/src/main/resources/applicationMessages_en.properties	Fri Feb 12 11:16:33 2010 +0000
+++ b/gnv/src/main/resources/applicationMessages_en.properties	Mon Feb 15 11:42:29 2010 +0000
@@ -56,12 +56,16 @@
 gnviewer.statistics.descriptive.slope=Increase
 gnviewer.statistic.button = Statistic
 
+# Histogramm
+gnviewer.histogram.button=Histogram
+
 # diagram options dialog
 gnviewer.diagram.options.header.title=Diagram options
 
 
 # attachedOutputOptions
 gnviewer.output.options.diagramm.alt=Diagram
+gnviewer.output.options.histogram.alt=Histogram
 gnviewer.output.options.save.title=Save Diagram
 gnviewer.output.options.export.csv.title=Export Data as CSV
 gnviewer.output.options.export.odv.title=Export Data as ODV
--- a/gnv/src/main/webapp/WEB-INF/config/struts-config.xml	Fri Feb 12 11:16:33 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/config/struts-config.xml	Mon Feb 15 11:42:29 2010 +0000
@@ -112,6 +112,20 @@
                 name="selectfis"
                 path="/gnv/selectFis.do"/>
         </action>
+        <action path="/histogram" 
+                type="de.intevation.gnv.action.CreateHistogramAction"
+                scope="request"
+                validate="false">
+            <forward
+                name="success"
+                path="/WEB-INF/jsp/mainlayout.jsp"/>
+            <forward
+                name="back"
+                path="/gnv/back.do"/>
+            <forward
+                name="selectfis"
+                path="/gnv/selectFis.do"/>
+        </action>
         <action path="/statistic"
                 type="de.intevation.gnv.action.ShowStatisticAction"
                 scope="request"
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp	Fri Feb 12 11:16:33 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp	Mon Feb 15 11:42:29 2010 +0000
@@ -19,6 +19,7 @@
     String targetZIP = "zip";
     String targetWMS = "wms";
     String targetSta = "statistics";
+    String targetHis = "histogram";
 
     boolean supportChart = sm.getOutputMode(target)    != null;
     boolean supportCSV   = sm.getOutputMode(targetCSV) != null;
@@ -28,6 +29,7 @@
     boolean supportZIP   = sm.getOutputMode(targetZIP) != null;
     boolean supportWMS   = sm.getOutputMode(targetWMS) != null;
     boolean supportSta   = sm.getOutputMode(targetSta) != null;
+    boolean supportHis   = sm.getOutputMode(targetHis) != null;
 
     if (supportChart){
         mimeType = sm.getOutputMode(target).getMimeType();
@@ -119,6 +121,12 @@
                     <img src="images/statistics.png" border="0"/>
                 </a>
             <%}%>
+
+            <%if (supportHis) { %>
+                <a href="<%=response.encodeURL("histogram.do")%>" title="<bean:message key="gnviewer.histogram.button"/>">
+                    <img src="images/chart_bar.png" border="0"/>
+                </a>
+            <%}%>
         </fieldset>
     </div>
 <%}%>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_inc.jsp	Mon Feb 15 11:42:29 2010 +0000
@@ -0,0 +1,14 @@
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean-el" prefix="bean-el" %>
+<%@page import="de.intevation.gnv.action.sessionmodel.SessionModel"%>
+<%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%>
+<%
+    SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
+
+    String target   = "histogram";
+    String mimeType = sm.getOutputMode(target).getMimeType();
+%>
+
+<div class="histogram">
+    <img src='<%=response.encodeURL("out.do?mimetype="+mimeType+"&amp;target=histogram&amp;uid="+System.currentTimeMillis())%>' alt='<bean:message key="gnviewer.output.options.histogram.alt"/>'/>
+</div>
--- a/gnv/src/main/webapp/WEB-INF/jsp/index.jsp	Fri Feb 12 11:16:33 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/index.jsp	Mon Feb 15 11:42:29 2010 +0000
@@ -7,6 +7,7 @@
 <%  Object ui              = request.getAttribute("ui");
     Object staticui        = request.getAttribute("staticui");
     Object statistic       = request.getAttribute("statistic");
+    Object histogram       = request.getAttribute("histogram");
     boolean furthertargets = true;
       
     Object furthertargetsObject = request.getAttribute("furthertargets");
@@ -52,3 +53,8 @@
     <%if (statistic != null) {%>
         <jsp:include page="includes/display_diagramm_statistics_inc.jsp"></jsp:include>
     <%}%>
+
+    <%-- render histogram --%>
+    <%if (histogram != null) {%>
+        <jsp:include page="includes/display_histogram_inc.jsp"></jsp:include>
+    <%}%>
Binary file gnv/src/main/webapp/images/chart_bar.png has changed
--- a/gnv/src/main/webapp/styles/default.css	Fri Feb 12 11:16:33 2010 +0000
+++ b/gnv/src/main/webapp/styles/default.css	Mon Feb 15 11:42:29 2010 +0000
@@ -261,6 +261,12 @@
     left: 350px;
 }
 
+div.histogram {
+    position: absolute;
+    top: 33px;
+    left: 350px;
+}
+
 div#export {
     width:        325px;
 }

http://dive4elements.wald.intevation.org