changeset 2977:5161e25392ea

Added chart overview to sq relation in minfo module. flys-client/trunk@4974 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 13 Jul 2012 08:54:57 +0000
parents e0c6de3a9803
children 98514ab2c9ba
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/OverviewOutputTab.java flys-client/src/main/java/de/intevation/flys/client/server/CollectionHelper.java flys-client/src/main/java/de/intevation/flys/client/shared/model/ChartMode.java flys-client/src/main/java/de/intevation/flys/client/shared/model/OverviewMode.java
diffstat 9 files changed, 280 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Jul 13 08:08:46 2012 +0000
+++ b/flys-client/ChangeLog	Fri Jul 13 08:54:57 2012 +0000
@@ -1,3 +1,23 @@
+2012-07-13  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* main/java/de/intevation/flys/client/server/CollectionHelper.java:
+	  Added new output mode 'overview' and added type to chart mode.
+
+	* main/java/de/intevation/flys/client/shared/model/ChartMode.java:
+	  Added type to constructor.
+
+	* main/java/de/intevation/flys/client/shared/model/OverviewMode.java:
+	  New. Output mode for chart overviews.
+
+	* main/java/de/intevation/flys/client/client/ui/chart/OverviewOutputTab.java:
+	  New. Output tab for chart overviews.
+
+	* main/java/de/intevation/flys/client/client/FLYSConstants.java,
+	  main/java/de/intevation/flys/client/client/FLYSConstants.properties,
+	  main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
+	  main/java/de/intevation/flys/client/client/FLYSConstants_de.properties:
+	  Added i18n strings.
+
 2012-07-13	Björn Ricks	<bjoern.ricks@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/auth/was/Request.java:
@@ -93,6 +113,7 @@
 	  Add showpointlabel stlye attribute.
 
 
+>>>>>>> .r4973
 2012-07-11	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/auth/plain/Authenticator.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri Jul 13 08:08:46 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri Jul 13 08:54:57 2012 +0000
@@ -936,5 +936,7 @@
     String fix_parameters_export();
 
     String fix_parameters();
+
+    String sq_overview();
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri Jul 13 08:08:46 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri Jul 13 08:54:57 2012 +0000
@@ -486,3 +486,5 @@
 
 fix_parameters_export = Adjusted coefficient
 fix_parameters = CSV
+
+sq_overview=Overview
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri Jul 13 08:08:46 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri Jul 13 08:54:57 2012 +0000
@@ -486,3 +486,4 @@
 
 fix_parameters_export = Angepasste Koeffizienten
 fix_parameters = CSV
+sq_overview=\u00dcbersicht
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri Jul 13 08:08:46 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri Jul 13 08:54:57 2012 +0000
@@ -488,3 +488,4 @@
 
 fix_parameters_export = Adjusted coefficient
 fix_parameters = CSV
+sq_overview=Overview
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/OverviewOutputTab.java	Fri Jul 13 08:54:57 2012 +0000
@@ -0,0 +1,200 @@
+package de.intevation.flys.client.client.ui.chart;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import com.google.gwt.core.client.GWT;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.events.ResizedEvent;
+import com.smartgwt.client.widgets.events.ResizedHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import de.intevation.flys.client.client.Config;
+import de.intevation.flys.client.client.ui.CollectionView;
+import de.intevation.flys.client.client.ui.OutputTab;
+
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.shared.model.OutputMode;
+
+
+/**
+ * An overview output tab. This tab displays an overview of all charts
+ * integrated in the current calculation mode.
+ *
+ * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public class OverviewOutputTab
+extends OutputTab
+implements   ResizedHandler
+{
+    /** The collection view.*/
+    protected CollectionView view;
+
+    /** The root layout. */
+    protected HLayout root;
+
+    /** The columns */
+    protected VLayout[] columns;
+
+    /** The chart container.*/
+    protected Canvas[][] charts;
+
+    /** All relevant output modes. */
+    protected Map<String, OutputMode> relModes;
+
+
+    public OverviewOutputTab(
+        String title,
+        Collection collection,
+        OutputMode mode,
+        CollectionView collectionView)
+    {
+        super(title, collection, collectionView, mode);
+
+        relModes = new HashMap<String, OutputMode>();
+
+        Map<String, OutputMode> modes = collection.getOutputModes();
+        Set<String> keys = modes.keySet();
+
+        // Get all relevant outputs.
+        for (String key: keys) {
+            OutputMode m = modes.get(key);
+            if (m.getType().equals("chart")) {
+                relModes.put(key, m);
+            }
+        }
+
+        root = new HLayout();
+        setPane(root);
+        root.addResizedHandler(this);
+
+        // Get the column and row count and initialize the grid.
+        int width = getColumnCount(relModes.size());
+        int height = getRowCount(relModes.size());
+        charts = new Canvas[width][height];
+        columns = new VLayout[width];
+
+        for (int i = 0; i < width; i++) {
+            columns[i] = new VLayout();
+            root.addMember(columns[i]);
+
+            for (int j = 0; j < height; j++) {
+                charts[i][j] = new Canvas();
+
+                // This is for 3, 6 or 9 charts only! 
+                // TODO: Calculate the height.
+                charts[i][j].setHeight("30%");
+
+                String type =
+                    ((OutputMode)relModes.values()
+                        .toArray()[j + i * height]).getName();
+                columns[i].addMember(charts[i][j]);
+                charts[i][j].addChild(
+                    new Img(getImgUrl(
+                        charts[i][j].getWidth(),
+                        charts[i][j].getHeight(), type)));
+
+            }
+        }
+    }
+
+
+    /**
+     * Resize handler.
+     * 
+     * @param event The resize event.
+     */
+    @Override
+    public void onResized(ResizedEvent event) {
+        for (int i = 0; i < charts.length; i++) {
+            columns[i].setWidth(root.getWidth()/2);
+            for (int j = 0; j < charts[i].length; j++) {
+                String type =
+                    ((OutputMode)relModes.values()
+                        .toArray()[j + i * charts[i].length]).getName();
+                Canvas[] children = charts[i][j].getChildren();
+                for (int k = 0; k < children.length; k++) {
+                    charts[i][j].removeChild(children[k]);
+                }
+                charts[i][j].addChild(new Img(
+                        getImgUrl(
+                            charts[i][j].getWidth(),
+                            charts[i][j].getHeight(),
+                            type),
+                        charts[i][j].getWidth(),
+                        charts[i][j].getHeight()
+                        ));
+            }
+        }
+    }
+
+
+    /**
+     * Returns the column count for the grid.
+     *
+     * @param count all fields
+     * @return the column count
+     */
+    protected int getColumnCount(int count) {
+        if (count <= 3) {
+            return 1;
+        }
+        else if (count > 3 && count < 9) {
+            return 2;
+        }
+        else {
+            return 3;
+        }
+    }
+
+
+    /**
+     * Returns the row count for the grid.
+     *
+     * @param count all fields
+     * @return the row count
+     */
+    protected int getRowCount(int count) {
+        if(count <= 3) {
+            return count;
+        }
+        else if(count > 3 && count < 9) {
+            return ((count + (count % 2))/getColumnCount(count));
+        }
+        else {
+            return (count + (3 - (count % 3))/getColumnCount(count));
+        }
+    }
+
+
+    /**
+     * Builds the URL that points to the chart image.
+     *
+     * @param width The width of the requested chart.
+     * @param height The height of the requested chart.
+     * @param xr Optional x range (used for zooming).
+     * @param yr Optional y range (used for zooming).
+     *
+     * @return the URL to the chart image.
+     */
+    protected String getImgUrl(int width, int height, String type) {
+        Config config = Config.getInstance();
+
+        String imgUrl = GWT.getModuleBaseURL();
+        imgUrl += "chart";
+        imgUrl += "?uuid=" + collection.identifier();
+        imgUrl += "&type=" + type;
+        imgUrl += "&locale=" + config.getLocale();
+        imgUrl += "&timestamp=" + new Date().getTime();
+        imgUrl += "&width=" + Integer.toString(width);
+        imgUrl += "&height=" + Integer.toString(height);
+
+        return imgUrl;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/server/CollectionHelper.java	Fri Jul 13 08:08:46 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/CollectionHelper.java	Fri Jul 13 08:54:57 2012 +0000
@@ -39,6 +39,7 @@
 import de.intevation.flys.client.shared.model.Facet;
 import de.intevation.flys.client.shared.model.MapMode;
 import de.intevation.flys.client.shared.model.OutputMode;
+import de.intevation.flys.client.shared.model.OverviewMode;
 import de.intevation.flys.client.shared.model.ReportMode;
 import de.intevation.flys.client.shared.model.Recommendation;
 import de.intevation.flys.client.shared.model.Theme;
@@ -815,11 +816,14 @@
                 outmode = new ReportMode(name, desc, mime, fs);
             }
             else if (type.equals("chart")){
-                outmode = new ChartMode(name, desc, mime, fs);
+                outmode = new ChartMode(name, desc, mime, fs, type);
             }
             else if (type.equals("map")){
                 outmode = new MapMode(name, desc, mime, fs);
             }
+            else if (type.equals("overview")) {
+                outmode = new OverviewMode(name, desc, mime, fs, type);
+            }
             else {
                 logger.warn("Broken Output mode without type found.");
                 continue;
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/ChartMode.java	Fri Jul 13 08:08:46 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/ChartMode.java	Fri Jul 13 08:54:57 2012 +0000
@@ -26,9 +26,11 @@
         String name,
         String descrition,
         String mimeType,
-        List<Facet> facets)
+        List<Facet> facets,
+        String type)
     {
         super(name, descrition, mimeType, facets);
+        this.type = type;
     }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/OverviewMode.java	Fri Jul 13 08:54:57 2012 +0000
@@ -0,0 +1,45 @@
+package de.intevation.flys.client.shared.model;
+
+import java.util.List;
+
+import de.intevation.flys.client.client.ui.CollectionView;
+import de.intevation.flys.client.client.ui.OutputTab;
+import de.intevation.flys.client.client.ui.chart.OverviewOutputTab;
+
+
+/**
+ * Output mode for chart overviews.
+ *
+ * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public class OverviewMode
+extends
+DefaultOutputMode {
+
+    public OverviewMode() {
+    }
+
+
+    public OverviewMode(String name, String desc, String mimeType) {
+        super(name, desc, mimeType);
+    }
+
+
+    public OverviewMode(
+        String name,
+        String descrition,
+        String mimeType,
+        List<Facet> facets,
+        String type)
+    {
+        super(name, descrition, mimeType, facets);
+        this.type = type;
+    }
+
+
+    @Override
+    public OutputTab createOutputTab(String t, Collection c, CollectionView p) {
+        return new OverviewOutputTab(t, c, this, p);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org