changeset 8575:a8048aac8831

Merge of MINFO improvement developments
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 10 Mar 2015 17:01:42 +0100
parents c16d04f2c5bc (current diff) 4dd6d89ce95e (diff)
children 0d711ecbcd49
files gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties
diffstat 8 files changed, 45 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java	Fri Mar 06 12:26:12 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java	Tue Mar 10 17:01:42 2015 +0100
@@ -301,7 +301,13 @@
 
 
     protected void appendMapInformation(Element parent, ElementCreator c) {
-        String mE = GeometryUtils.jtsBoundsToOLBounds(this.maxExtent);
+        String mE;
+        if (this.maxExtent != null) {
+            mE = GeometryUtils.jtsBoundsToOLBounds(this.maxExtent);
+        } else {
+            log.error("Layer without extent. Probably no geometry at all.");
+            mE = "0 0 0 0";
+        }
 
         Element maxExtent = c.create("maxExtent");
         maxExtent.setTextContent(mE);
--- a/artifacts/src/main/java/org/dive4elements/river/jfree/StableXYDifferenceRenderer.java	Fri Mar 06 12:26:12 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/jfree/StableXYDifferenceRenderer.java	Tue Mar 10 17:01:42 2015 +0100
@@ -1640,7 +1640,7 @@
         Object[] l_xValues = x_xValues.toArray();
         Object[] l_yValues = x_yValues.toArray();
 
-        double area = calculateArea(l_xValues, l_yValues)/2d;
+        double area = calculateArea(l_xValues, l_yValues);
         if (x_positive) positiveArea += area;
         else            negativeArea += area;
         updateCentroid(l_xValues, l_yValues);
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java	Fri Mar 06 12:26:12 2015 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java	Tue Mar 10 17:01:42 2015 +0100
@@ -1202,6 +1202,8 @@
 
     String editpoints();
 
+    String manual_date_points_y();
+
     // Manual WaterLine (WSP) Editor.
 
     String addWSPButton();
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Fri Mar 06 12:26:12 2015 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Tue Mar 10 17:01:42 2015 +0100
@@ -658,6 +658,7 @@
 addWSPButton = Add Manual LS
 addWSP = Add Manual LS
 selection = Selection
+manual_date_points_y = Y ([m\u00b3/s]/[cm])
 
 # Reference Curves
 reference_curve = Reference Curve
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Fri Mar 06 12:26:12 2015 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Tue Mar 10 17:01:42 2015 +0100
@@ -658,6 +658,7 @@
 addWSP = Neues WSP Thema anlegen
 addWSPButton = WSP Thema
 selection = Auswahl
+manual_date_points_y = Y ([m\u00b3/s]/[cm])
 
 # Reference Curves
 reference_curve = Bezugslinie
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties	Fri Mar 06 12:26:12 2015 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties	Tue Mar 10 17:01:42 2015 +0100
@@ -633,6 +633,7 @@
 addWSP = Add Manual LS
 addWSPButton = Add Manual LS
 selection = Selection
+manual_date_points_y = Y ([m\u00b3/s]/[cm])
 
 # Reference Curves
 reference_curve = Reference Curve
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ModuleSelection.java	Fri Mar 06 12:26:12 2015 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ModuleSelection.java	Tue Mar 10 17:01:42 2015 +0100
@@ -62,8 +62,7 @@
     /** The ModuleService used to retrieve the available modules of a user.*/
     protected ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
 
-    private List<String> fixRivers;
-    private List<String> minfoRivers;
+    private Map<String, List<String> > modulesRiverMap;
     protected Map<String, HLayout> rivers;
 
     /**
@@ -71,9 +70,7 @@
      */
     public ModuleSelection() {
         rivers = null;
-        //TODO: put all the rivers into a config file, or something.
-        fixRivers = new ArrayList<String>();
-        minfoRivers = new ArrayList<String>();
+        modulesRiverMap = new LinkedHashMap<String, List<String> >();
 
         readModules();
     }
@@ -123,6 +120,29 @@
         });
     }
 
+    private void checkRivers(String selected) {
+        if (selected == null) {
+            selected = getSelectedModule();
+        }
+        if (rivers != null && !rivers.isEmpty() && modules != null && selected != null) {
+            List<String> allowedRivers = modulesRiverMap.get(selected);
+            if ( allowedRivers == null ) {
+                GWT.log("No configured rivers for module: " + selected);
+            }
+            for (Map.Entry<String, HLayout> s: rivers.entrySet()) {
+                if ( allowedRivers == null ) {
+                    s.getValue().hide();
+                    continue;
+                }
+                if (!allowedRivers.contains(s.getKey())) {
+                    s.getValue().hide();
+                } else {
+                    s.getValue().show();
+                }
+            }
+        }
+    }
+
     private void setModules() {
         LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
 
@@ -135,21 +155,13 @@
                         radio.setDefaultValue(module.getName());
                     }
                 }
-                if (module.getName().equals("fixanalysis")) {
-                    for (String river: module.getRivers()) {
-                        fixRivers.add(river);
-                    }
-                }
-                if (module.getName().equals("minfo")) {
-                    for (String river: module.getRivers()) {
-                        minfoRivers.add(river);
-                    }
-                }
+                modulesRiverMap.put(module.getName(), module.getRivers());
             }
         }
         if (radio != null) {
             radio.setValueMap(values);
         }
+        checkRivers(null);
     }
 
     /**
@@ -167,20 +179,7 @@
         radio.addChangeHandler(new ChangeHandler() {
             @Override
             public void onChange(ChangeEvent event) {
-                String selected = (String)event.getValue();
-                if (!rivers.isEmpty()) {
-                    for (Map.Entry<String, HLayout> s: rivers.entrySet()) {
-                        if (selected.equals("minfo") && !minfoRivers.contains(s.getKey())) {
-                            s.getValue().hide();
-                        }
-                        else if (selected.equals("fixanalysis") && !fixRivers.contains(s.getKey())) {
-                            s.getValue().hide();
-                        }
-                        else {
-                            s.getValue().show();
-                        }
-                    }
-                }
+                checkRivers((String)event.getValue());
             }
         });
 
@@ -232,6 +231,9 @@
     }-*/;
 
     private static String getSelectedModule() {
+        if (radio == null) {
+            return null;
+        }
         return radio.getValueAsString();
     }
 }
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/chart/ManualDatePointsEditor.java	Fri Mar 06 12:26:12 2015 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/chart/ManualDatePointsEditor.java	Tue Mar 10 17:01:42 2015 +0100
@@ -180,9 +180,7 @@
                     xAxis = name.getValue();
                 }
                 else if (yAxis.equals("Y")) {
-                    StringProperty name =
-                        (StringProperty)pg.getPropertyByName("label");
-                    yAxis = name.getValue();
+                    yAxis = MSG.manual_date_points_y();
                 }
             }
         }

http://dive4elements.wald.intevation.org