changeset 2517:8f528f5ae137

Added filter object class and scrollable chart to helper panel. flys-client/trunk@4392 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 11 May 2012 12:42:29 +0000
parents 5d62aa5a57e3
children b3bf9e5ce9e6
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/fixation/FixEventSelect.java flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixGaugeSelectPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixLocationPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixPeriodPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixQSelectPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java
diffstat 11 files changed, 350 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri May 11 08:47:48 2012 +0000
+++ b/flys-client/ChangeLog	Fri May 11 12:42:29 2012 +0000
@@ -1,3 +1,21 @@
+2012-05-11  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java:
+	  Added scrollable chart to helperpanel and added filter object class.
+
+	* src/main/java/de/intevation/flys/client/client/ui/fixation/FixLocationPanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/fixation/FixGaugeSelectPanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/fixation/FixQSelectPanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/fixation/FixEventSelect.java,
+	  src/main/java/de/intevation/flys/client/client/ui/fixation/FixPeriodPanel.java:
+	  Added getter and setter for filter object.
+
+	* src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.java,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties:
+	  Added i18n strings.
+
 2012-05-11	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri May 11 08:47:48 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri May 11 12:42:29 2012 +0000
@@ -328,6 +328,10 @@
 
     String eventselect();
 
+    String events();
+
+    String kmchart();
+
     // Elevation window
 
     String ele_window_title();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri May 11 08:47:48 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri May 11 12:42:29 2012 +0000
@@ -203,6 +203,8 @@
 computed_dischargecurve_at_export = AT Export
 gauge_class = Gauge Class
 eventselect = Eventselection
+events = Events
+kmchart = Chart
 
 chart_themepanel_header_themes = Theme
 chart_themepanel_header_actions = Actions
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri May 11 08:47:48 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri May 11 12:42:29 2012 +0000
@@ -203,6 +203,8 @@
 computed_dischargecurve_at_export = AT Export
 gauge_class = Abflussklasse
 eventselect = Ereignisauswahl
+events = Ereignisse
+kmchart = Diagramm
 
 chart_themepanel_header_themes = Thema
 chart_themepanel_header_actions = Aktionen
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri May 11 08:47:48 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri May 11 12:42:29 2012 +0000
@@ -204,6 +204,8 @@
 computed_dischargecurve_at_export = AT Export
 gauge_class = Gauge Class
 eventselect = Eventselection
+events = Events
+kmchart = Chart
 
 chart_themepanel_header_themes = Theme
 chart_themepanel_header_actions = Actions
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixEventSelect.java	Fri May 11 08:47:48 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixEventSelect.java	Fri May 11 12:42:29 2012 +0000
@@ -94,6 +94,16 @@
     }
 
 
+    public void setFilter(FixFilter filter) {
+        this.fixFilter = filter;
+    }
+
+
+    public FixFilter getFilter() {
+        return this.fixFilter;
+    }
+
+
     public void dumpGWT(String cid) {
         GWT.log("Setting values for cId: " + cid);
         GWT.log("River: " + fixInfo.getRiver());
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixGaugeSelectPanel.java	Fri May 11 08:47:48 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixGaugeSelectPanel.java	Fri May 11 12:42:29 2012 +0000
@@ -155,6 +155,16 @@
     }
 
 
+    public void setFilter(FixFilter filter) {
+        this.fixFilter = filter;
+    }
+
+
+    public FixFilter getFilter() {
+        return this.fixFilter;
+    }
+
+
     protected boolean saveClassValues() {
         String v1 = from.getValueAsString();
         String v2 = to.getValueAsString();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixLocationPanel.java	Fri May 11 08:47:48 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixLocationPanel.java	Fri May 11 12:42:29 2012 +0000
@@ -164,6 +164,16 @@
     }
 
 
+    public void setFilter(FixFilter filter) {
+        this.fixFilter = filter;
+    }
+
+
+    public FixFilter getFilter() {
+        return this.fixFilter;
+    }
+
+
     /**
      * This method is used to validate the inserted data in the form fields.
      *
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixPeriodPanel.java	Fri May 11 08:47:48 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixPeriodPanel.java	Fri May 11 12:42:29 2012 +0000
@@ -140,6 +140,16 @@
     }
 
 
+    public void setFilter(FixFilter filter) {
+        this.fixFilter = filter;
+    }
+
+
+    public FixFilter getFilter() {
+        return this.fixFilter;
+    }
+
+
     protected boolean saveDateValues() {
         Date st = inputPanel.getFromDate();
         Date en = inputPanel.getToDate();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixQSelectPanel.java	Fri May 11 08:47:48 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixQSelectPanel.java	Fri May 11 12:42:29 2012 +0000
@@ -62,4 +62,14 @@
         // No selection, return false.
         return false;
     }
+
+
+    public void setFilter(FixFilter filter) {
+        this.fixFilter = filter;
+    }
+
+
+    public FixFilter getFilter() {
+        return this.fixFilter;
+    }
 }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java	Fri May 11 08:47:48 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java	Fri May 11 12:42:29 2012 +0000
@@ -1,6 +1,10 @@
 package de.intevation.flys.client.client.ui.fixation;
 
 import java.util.HashMap;
+import java.util.Date;
+import java.lang.Math;
+
+import java.lang.NumberFormatException;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -8,9 +12,24 @@
 import com.smartgwt.client.util.SC;
 
 import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Button;
 import com.smartgwt.client.widgets.form.DynamicForm;
 import com.smartgwt.client.widgets.HTMLPane;
 import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ResizedHandler;
+import com.smartgwt.client.widgets.events.ResizedEvent;
+import com.smartgwt.client.widgets.form.validator.IsFloatValidator;
+import com.smartgwt.client.types.Alignment;
+
+import com.smartgwt.client.widgets.tab.Tab;
+import com.smartgwt.client.widgets.tab.TabSet;
+import com.smartgwt.client.widgets.Img;
 
 import de.intevation.flys.client.client.FLYSConstants;
 import de.intevation.flys.client.client.ui.AbstractUIProvider;
@@ -32,7 +51,8 @@
  * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
  */
 public abstract class FixationPanel
-extends      AbstractUIProvider
+extends               AbstractUIProvider
+implements            ResizedHandler
 {
     protected static HashMap<String, FixationPanel> instances = new HashMap<String, FixationPanel>();
 
@@ -44,8 +64,16 @@
 
     protected String   htmlOverview;
     protected FixingsOverviewInfo fixInfo;
+    protected FixFilter fixFilter;
+    protected TabSet tabs;
+    protected Tab events;
+    protected Tab chart;
+    protected VLayout chartContainer;
+    protected Img chartImg;
 
     public FixationPanel() {
+        fixFilter = new FixFilter();
+        chartImg = new Img();
         htmlOverview = "";
     }
 
@@ -83,7 +111,21 @@
         Config config    = Config.getInstance();
         String locale    = config.getLocale ();
 
-        final HTMLPane helper = new HTMLPane();
+        tabs = new TabSet();
+        events = new Tab(MESSAGES.events());
+        chart = new Tab(MESSAGES.kmchart());
+
+        chartContainer = new VLayout();
+        Canvas scroll = createChartHelper();
+
+        VLayout layout = new VLayout();
+        layout.addResizedHandler(this);
+        layout.addMember(chartContainer);
+        layout.addMember(scroll);
+        layout.setAlign(Alignment.CENTER);
+        chart.setPane(layout);
+
+        final HTMLPane eventPane = new HTMLPane();
 
         String river = artifact.getArtifactDescription().getRiver();
 
@@ -109,17 +151,121 @@
                     GWT.log("Successfully loaded overview.");
                     fixInfo = info;
                     htmlOverview = info.getHTML();
-                    GWT.log("html: " + info.getHTML());
-                    helper.setContents(htmlOverview);
-
+                    fixFilter.setRiver(info.getRiver());
+                    fixFilter.setCurrentKm(1d);
+                    fixFilter.setFromKm(info.getFrom());
+                    fixFilter.setToKm(info.getTo());
+                    eventPane.setContents(htmlOverview);
+                    updateChartTab(fixInfo.getFrom());
+                    events.setPane(eventPane);
                 }
             });
 
-        this.helperContainer.addMember(helper);
+        tabs.addTab(events);
+        tabs.addTab(chart);
 
-        return helper;
+        return tabs;
     }
 
+
+    protected Canvas createChartHelper() {
+
+
+        DynamicForm form = new DynamicForm();
+        Button lower = new Button("<<");
+        lower.setWidth(30);
+        Button upper = new Button(">>");
+        upper.setWidth(30);
+        final TextItem currentkm = new TextItem();
+        currentkm.setWidth(60);
+        currentkm.setShowTitle(false);
+        currentkm.setValidators(new IsFloatValidator());
+
+        form.setFields(currentkm);
+        form.setWidth(60);
+        lower.addClickHandler(new ClickHandler() {
+            public void onClick(ClickEvent ce) {
+                updateChartTabLow();
+                currentkm.setValue(fixFilter.getCurrentKm());
+            }
+        });
+
+        upper.addClickHandler(new ClickHandler() {
+            public void onClick(ClickEvent ce) {
+                updateChartTabUp();
+                currentkm.setValue(fixFilter.getCurrentKm());
+            }
+        });
+
+        currentkm.addChangedHandler(new ChangedHandler() {
+            public void onChanged(ChangedEvent ce) {
+                //TODO: get current value.
+                if(ce.getForm().validate() && ce.getItem().getValue() != null) {
+                    try {
+                        String s = ce.getItem().getValue().toString();
+                        Double d = new Double(s);
+                        updateChartTab(d.doubleValue());
+                    }
+                    catch(NumberFormatException nfe) {
+                        // Do nothing.
+                    }
+                }
+            }
+        });
+
+        HLayout layout = new HLayout();
+        layout.setAlign(Alignment.CENTER);
+
+        layout.addMember(lower);
+        layout.addMember(form);
+        layout.addMember(upper);
+        return layout;
+    }
+
+    protected void updateChartTab(double km) {
+        Config config    = Config.getInstance();
+        String locale    = config.getLocale ();
+
+        fixFilter.setCurrentKm(km);
+        chartContainer.removeMember(chartImg);
+        String imgUrl = GWT.getModuleBaseURL();
+        imgUrl += "fixings-km-chart";
+        imgUrl += "?locale=" + locale;
+        imgUrl += "&filter=" + fixFilter.getChartFilter(helperContainer.getWidth() - 12, (int)(helperContainer.getWidth()*3/4) - 12);
+
+        chartImg = new Img(imgUrl, helperContainer.getWidth() - 12, (int)(helperContainer.getWidth()*3/4) - 12);
+        chartContainer.addMember(chartImg);
+
+    }
+
+
+    protected void updateChartTabLow() {
+        double curr = fixFilter.getCurrentKm();
+        if (curr > fixFilter.getFromKm()) {
+            double newVal = (curr - 0.1) * 10;
+            long round = Math.round(newVal);
+            updateChartTab(((double)round) / 10);
+        }
+        return;
+    }
+
+
+    protected void updateChartTabUp() {
+        double curr = fixFilter.getCurrentKm();
+        if (curr < fixFilter.getToKm()) {
+            double newVal = (curr + 0.1) * 10;
+            long round = Math.round(newVal);
+            updateChartTab(((double)round) / 10);
+        }
+        return;
+    }
+
+
+    public void onResized(ResizedEvent re) {
+        updateChartTab(fixFilter.getCurrentKm());
+    }
+
+
     private native void createCallback() /*-{
         $wnd.fixationCallback = @de.intevation.flys.client.client.ui.fixation.FixationPanel::helperCallback(ZLjava/lang/String;);
     }-*/;
@@ -146,4 +292,123 @@
     public abstract Canvas createWidget(DataList data);
     public abstract void setValues(String cid, boolean checked);
     public abstract boolean renderCheckboxes();
+    public abstract FixFilter getFilter();
+    public abstract void setFilter(FixFilter filter);
+
+
+    public static class FixFilter {
+        protected String river;
+        protected double fromKm;
+        protected double toKm;
+        protected double currentKm;
+        protected int fromClass;
+        protected int toClass;
+        protected Date fromDate;
+        protected Date toDate;
+        protected int[] events;
+
+        public FixFilter() {}
+
+        public void setRiver(String river) {
+            this.river = river;
+        }
+
+        public void setFromKm(double from) {
+            this.fromKm = from;
+        }
+
+        public void setToKm(double to) {
+            this.toKm = to;
+        }
+
+        public void setCurrentKm(double km) {
+            this.currentKm = km;
+        }
+
+        public void setFromClass(int from) {
+            this.fromClass = from;
+        }
+
+        public void setToClass(int to) {
+            this.toClass = to;
+        }
+
+        public void setFromDate(Date from) {
+            this.fromDate = from;
+        }
+
+        public void setToDate(Date to) {
+            this.toDate = to;
+        }
+
+        public void setEvents(int[] ev) {
+            this.events = ev;
+        }
+
+        public String getRiver() {
+            return this.river;
+        }
+
+        public double getFromKm() {
+            return this.fromKm;
+        }
+
+        public double getToKm() {
+            return this.toKm;
+        }
+
+        public double getCurrentKm() {
+            return this.currentKm;
+        }
+
+        public int getFromClass() {
+            return this.fromClass;
+        }
+
+        public int getToClass() {
+            return this.toClass;
+        }
+
+        public Date getFromDate() {
+            return this.fromDate;
+        }
+
+        public Date getToDate() {
+            return this.toDate;
+        }
+
+        public int[] getEvents() {
+            return this.events;
+        }
+
+        public String getOverviewFilter() {
+            String filter = "";
+            if (river != null && river.length() > 0) {
+                filter = "{\"fixings\": {\"river\": {\"name\": \"" + river + "\"}}";
+                filter += createFilter();
+                filter += "}";
+            }
+            return filter;
+        }
+
+        public String getChartFilter(int width, int height) {
+            String filter = "";
+            if (river != null && river.length() > 0 &&
+                currentKm >= fromKm && currentKm <= toKm)
+            {
+                filter = "{\"fixings\": "+
+                    "{\"river\": {\"name\": \"" + river + "\"}," +
+                    "\"km\": {\"value\": \"" + currentKm + "\"}," +
+                    "\"extent\": {\"width\": \"" + width + "\", \"height\": \"" + height + "\"}}";
+                filter += createFilter();
+                filter += "}";
+            }
+            return filter;
+        }
+
+        protected String createFilter() {
+            //TODO create filter...
+           return "";
+        }
+    }
 }

http://dive4elements.wald.intevation.org