changeset 3842:44c1beb78ad1

Move GaugeTree to its own java file flys-client/trunk@5557 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 21 Sep 2012 13:44:56 +0000
parents 5877d6900e34
children 8e169e4e1b57
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java
diffstat 3 files changed, 421 insertions(+), 394 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Sep 21 13:19:21 2012 +0000
+++ b/flys-client/ChangeLog	Fri Sep 21 13:44:56 2012 +0000
@@ -1,3 +1,11 @@
+2012-09-21	Björn Ricks	<bjoern.ricks@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java,
+	  src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java:
+	  Refactor GaugeTree into its own java file. Due to the folding logic in the
+	  GaugeTree the code became quite lage. Therefore it is better preserved in
+	  its own file.
+
 2012-09-21	Björn Ricks	<bjoern.ricks@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java	Fri Sep 21 13:19:21 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java	Fri Sep 21 13:44:56 2012 +0000
@@ -1,41 +1,30 @@
 package de.intevation.flys.client.client.ui;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.i18n.client.NumberFormat;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.DecoratorPanel;
-import com.google.gwt.user.client.ui.Grid;
 import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.ScrollPanel;
-import com.google.gwt.user.client.ui.Tree;
-import com.google.gwt.user.client.ui.TreeItem;
 
 import com.smartgwt.client.types.Overflow;
 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.SectionStackSection;
 import com.smartgwt.client.widgets.layout.VLayout;
 
 import de.intevation.flys.client.client.FLYSConstants;
 import de.intevation.flys.client.client.services.GaugeOverviewInfoService;
 import de.intevation.flys.client.client.services.GaugeOverviewInfoServiceAsync;
-import de.intevation.flys.client.shared.model.Data;
-import de.intevation.flys.client.shared.model.DataItem;
 import de.intevation.flys.client.shared.model.DataList;
-import de.intevation.flys.client.shared.model.GaugeInfo;
 import de.intevation.flys.client.shared.model.RiverInfo;
 
 /**
  * The GaugePanel is intendet to be used within a SectionStackSection
  * It extends the VLayout by two methods to show and hide the
  * section stack section.
+ *
+ * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a>
  */
 public class GaugePanel extends VLayout implements ResizedHandler {
 
@@ -146,273 +135,6 @@
         this.sectionStack.setHidden(false);
     }
 
-    class GaugeTree extends ScrollPanel {
-
-        private Tree tree;
-        private DataList[] data;
-
-        public GaugeTree() {
-            tree = new Tree();
-            setWidget(tree);
-        }
-
-        /**
-         * Resets the items of the tree.
-         * If the list of gauges is empty or null the tree will be empty.
-         */
-        public void setGauges(RiverInfo riverinfo) {
-            tree.clear();
-
-            List<GaugeInfo> gauges = riverinfo.getGauges();
-
-            if (gauges != null && !gauges.isEmpty()) {
-
-                ArrayList<GaugeInfo> emptygauges = new ArrayList<GaugeInfo>();
-
-                if (!riverinfo.isKmUp()) {
-                    for (GaugeInfo gauge : gauges) {
-                        addGauge(gauge, emptygauges);
-                    }
-                }
-                else {
-                    for (int i = gauges.size()-1; i >= 0; i--) {
-                        GaugeInfo gauge = gauges.get(i);
-                        addGauge(gauge, emptygauges);
-                    }
-                }
-
-                // put empty gauges to the end
-                for (GaugeInfo gauge : emptygauges) {
-                    addGauge(gauge);
-                }
-
-                open();
-            }
-        }
-
-        private void addGauge(GaugeInfo gauge, List<GaugeInfo> empty) {
-            if (gauge.getKmStart() != null && gauge.getKmEnd() != null) {
-                addGauge(gauge);
-            }
-            else {
-                empty.add(gauge);
-            }
-        }
-
-        private void addGauge(GaugeInfo gauge) {
-            GaugeInfoItem gaugeitem = new GaugeInfoItem(gauge);
-            tree.addItem(gaugeitem);
-        }
-
-        public void openAll() {
-            GWT.log("GaugeTree - openAll");
-            for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
-                TreeItem item = it.next();
-                item.setState(true);
-            }
-        }
-
-        public void setData(DataList[] data) {
-            this.data = data;
-            if (tree.getItemCount() > 0) {
-                open();
-            }
-        }
-
-        public void open() {
-            ArrayList<Double> locations = new ArrayList<Double>();
-
-            if (data != null && data.length > 0) {
-                for (int i = 0; i < data.length; i++) {
-                    DataList dl = data[i];
-                    String state = dl.getState();
-                    GWT.log("GaugeTree - setData " + state);
-                    if (state.equals("state.winfo.location_distance")) {
-                        Double ldfrom = null;
-                        Double ldto = null;
-
-                        for (int j = dl.size()-1; j >= 0; --j) {
-                            Data d = dl.get(j);
-                            String label = d.getLabel();
-                            GWT.log("GaugeTree - setData - label " + label + " " + d.getStringValue());
-                            if (label.equals("ld_from")) {
-                                ldfrom = getDoubleValue(d);
-                            }
-                            else if (label.equals("ld_to")) {
-                                ldto = getDoubleValue(d);
-                            }
-                            else if (label.equals("ld_locations")) {
-                                getLocationsFromData(locations, d);
-                                openOnLocations(locations);
-                                return;
-                            }
-                        }
-                        if (ldfrom != null) {
-                            openOnDistance(ldfrom, ldto);
-                            return;
-                        }
-                    }
-                    else if(state.equals("state.winfo.distance_only") ||
-                            state.equals("state.winfo.distance")) {
-                        Double ldfrom = null;
-                        Double ldto = null;
-
-                        for (int j = dl.size()-1; j >= 0; --j) {
-                            Data d = dl.get(j);
-                            String label = d.getLabel();
-                            GWT.log("GaugeTree - setData - label " + label + " " + d.getStringValue());
-                            if (label.equals("ld_from")) {
-                                ldfrom = getDoubleValue(d);
-                            }
-                            else if (label.equals("ld_to")) {
-                                ldto = getDoubleValue(d);
-                            }
-                        }
-
-                        if (ldfrom != null) {
-                            openOnDistance(ldfrom, ldto);
-                            return;
-                        }
-                    }
-                    else if (state.equals("state.winfo.location")) {
-                        getLocations("ld_locations", locations, dl);
-                        openOnLocations(locations);
-                        return;
-                    }
-                    else if (state.equals("state.winfo.reference.curve.input.start")) {
-                        getLocations("reference_startpoint", locations, dl);
-                    }
-                    else if (state.equals("state.winfo.reference.curve.input.end")) {
-                        getLocations("reference_endpoint", locations, dl);
-                    }
-                    else if (state.equals("state.winfo.historicalq.reference_gauge")) {
-                        for (int j = dl.size()-1; j >= 0; --j) {
-                            Data d = dl.get(j);
-                            String label = d.getLabel();
-                            if (label.equals("reference_gauge")) {
-                                String tmp = d.getStringValue();
-                                if (tmp != null) {
-                                    Integer gaugereference = Integer.valueOf(tmp);
-                                    if (gaugereference != null) {
-                                        //TODO
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-            if (!locations.isEmpty()) {
-                openOnLocations(locations);
-            }
-            else {
-                openAll();
-            }
-        }
-
-        private void getLocations(String labelname, List<Double> locations, DataList dl) {
-            for (int j = dl.size()-1; j >= 0; --j) {
-                Data d = dl.get(j);
-                String label = d.getLabel();
-                if (label.equals(labelname)) {
-                    getLocationsFromData(locations, d);
-                }
-            }
-        }
-
-        private void getLocationsFromData(List<Double> locations, Data data) {
-            DataItem[] items = data.getItems();
-            for (int k = 0; k < items.length; k++) {
-                String tmp = items[k].getStringValue();
-                GWT.log("GaugeTree - getLocationsFromData " + tmp);
-                if (tmp != null) {
-                    if (tmp.contains(" ")) {
-                        // string contains several values ...
-                        String[] values = tmp.split(" ");
-                        for(int i=0; i < values.length; i++) {
-                            Double value = Double.valueOf(values[i]);
-                            if (value != null) {
-                                locations.add(value);
-                            }
-                        }
-                    }
-                    else {
-                        Double value = Double.valueOf(tmp);
-                        if (value != null) {
-                            locations.add(value);
-                        }
-                    }
-                }
-            }
-        }
-
-        private Double getDoubleValue(Data d) {
-            String tmp = d.getStringValue();
-            if (tmp != null) {
-                return Double.valueOf(tmp);
-            }
-            return null;
-        }
-
-        public void openOnDistance(Double start, Double end) {
-            GWT.log("GaugeTree - openOnDistance " + start + " " + end + " " +
-                    tree.getItemCount());
-
-            for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
-                TreeItem item = it.next();
-                /* Strange stuff is happening here:
-                 * GWT Tree.treeItemIterator returns another TreeItem for each
-                 * GaugeInfoItem */
-                if (item instanceof GaugeInfoItem) {
-                    boolean setstate = false;
-                    GaugeInfoItem gitem = (GaugeInfoItem)item;
-                    if (end == null) {
-                        if (gitem.getStart() >= start) {
-                            setstate = true;
-                        }
-                    }
-                    else {
-                        GWT.log("GaugeTree - openOnDistance gitem " + gitem.getStart() + " " + gitem.getEnd());
-                        if ((start >= gitem.getStart() && start <= gitem.getEnd()) ||
-                                (end >= gitem.getStart() && end <= gitem.getEnd()) ||
-                                (start <= gitem.getStart() && end >= gitem.getEnd())) {
-                            setstate = true;
-                        }
-                    }
-                    item.setState(setstate);
-                }
-            }
-        }
-
-        public void openOnLocations(List<Double> locations) {
-            GWT.log("GaugeTree - openOnLocations " + locations + " " +
-                    tree.getItemCount());
-
-            if (locations == null || locations.isEmpty()) {
-                return;
-            }
-
-            for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
-                TreeItem item = it.next();
-                if (item instanceof GaugeInfoItem) {
-                    GaugeInfoItem gitem = (GaugeInfoItem)item;
-                    boolean isset = false;
-                    for (Double location: locations) {
-                        if (locations == null) {
-                            continue;
-                        }
-                        if (location >= gitem.getStart() &&
-                                location <= gitem.getEnd()) {
-                            isset = true;
-                            break;
-                        }
-                    }
-                    item.setState(isset);
-                }
-            }
-        }
-    }
-
     class RiverInfoPanel extends HorizontalPanel {
 
         public final static int HEIGHT = 30;
@@ -474,118 +196,4 @@
             setCellHeight(label, "" + HEIGHT + "px");
         }
     }
-
-    class GaugeInfoItem extends TreeItem {
-
-        private GaugeInfo gauge;
-
-        public GaugeInfoItem(GaugeInfo gauge) {
-            GaugeInfoHead gaugeinfohead = new GaugeInfoHead(gauge);
-            GaugeInfoPanel gaugeinfopanel = new GaugeInfoPanel(gauge);
-            setWidget(gaugeinfohead);
-            addItem(gaugeinfopanel);
-            this.gauge = gauge;
-        }
-
-        public Double getStart() {
-            return gauge.getKmStart();
-        }
-
-        public Double getEnd() {
-            return gauge.getKmEnd();
-        }
-    }
-
-    class GaugeInfoHead extends HLayout {
-
-        public GaugeInfoHead(GaugeInfo gauge) {
-            setStyleName("gaugeinfohead");
-            setAutoHeight();
-            setAutoWidth();
-
-            NumberFormat nf = NumberFormat.getDecimalFormat();
-
-            Label label = new Label(gauge.getName(), true);
-            addMember(label);
-
-            Double start;
-            Double end;
-
-            if (!gauge.isKmUp()) {
-                start = gauge.getKmStart();
-                end   = gauge.getKmEnd();
-            }
-            else {
-                start = gauge.getKmEnd();
-                end   = gauge.getKmStart();
-            }
-
-            String kmtext = "";
-            if (start != null) {
-                kmtext += nf.format(start);
-                kmtext += " - ";
-            }
-            if (end != null) {
-                kmtext += nf.format(end);
-            }
-            if (start != null || end != null) {
-                kmtext += " km";
-            }
-
-            label = new Label(kmtext);
-
-            addMember(label);
-
-            Double station = gauge.getStation();
-            if (station != null) {
-                String stext = nf.format(station);
-                stext += " km";
-                label = new Label(stext);
-                addMember(label);
-            }
-
-            addMember(new Anchor(MSG.gauge_info_link(), gauge.getInfoURL()));
-        }
-    }
-
-    class GaugeInfoPanel extends DecoratorPanel {
-
-        public GaugeInfoPanel(GaugeInfo gauge) {
-            setStyleName("gaugeinfopanel");
-            Grid grid = new Grid(4, 2);
-
-            NumberFormat nf = NumberFormat.getDecimalFormat();
-
-            Double minw = gauge.getMinW();
-            Double maxw = gauge.getMaxW();
-            if (minw != null && maxw != null) {
-                grid.setText(0, 0, MSG.wq_value_q());
-                grid.setText(0, 1, "" + nf.format(minw) +
-                        " - " + nf.format(maxw));
-            }
-
-            Double minq = gauge.getMinQ();
-            Double maxq = gauge.getMaxQ();
-            if (minq != null && maxq != null) {
-                grid.setText(1, 0, MSG.wq_value_w());
-                grid.setText(1, 1, "" + nf.format(minq) +
-                        " - " + nf.format(maxq));
-            }
-
-            Double aeo = gauge.getAeo();
-            if (aeo != null) {
-                grid.setText(2, 0, "AEO [km²]");
-                grid.setText(2, 1, "" + nf.format(aeo));
-            }
-
-            Double datum = gauge.getDatum();
-            if (datum != null) {
-                grid.setText(3, 0, MSG.gauge_zero() + " [" +
-                        gauge.getWstUnit() + "]");
-                grid.setText(3, 1, "" + nf.format(datum));
-            }
-
-            setWidget(grid);
-        }
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java	Fri Sep 21 13:44:56 2012 +0000
@@ -0,0 +1,411 @@
+package de.intevation.flys.client.client.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Iterator;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.i18n.client.NumberFormat;
+import com.google.gwt.user.client.ui.Anchor;
+import com.google.gwt.user.client.ui.DecoratorPanel;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.ScrollPanel;
+import com.google.gwt.user.client.ui.Tree;
+import com.google.gwt.user.client.ui.TreeItem;
+
+import com.smartgwt.client.widgets.layout.HLayout;
+
+import de.intevation.flys.client.client.FLYSConstants;
+
+import de.intevation.flys.client.shared.model.Data;
+import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
+import de.intevation.flys.client.shared.model.GaugeInfo;
+import de.intevation.flys.client.shared.model.RiverInfo;
+
+
+public class GaugeTree extends ScrollPanel {
+
+    private Tree tree;
+    private DataList[] data;
+
+    /** The message class that provides i18n strings.*/
+    protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
+
+    public GaugeTree() {
+        tree = new Tree();
+        setWidget(tree);
+    }
+
+    /**
+     * Resets the items of the tree.
+     * If the list of gauges is empty or null the tree will be empty.
+     */
+    public void setGauges(RiverInfo riverinfo) {
+        tree.clear();
+
+        List<GaugeInfo> gauges = riverinfo.getGauges();
+
+        if (gauges != null && !gauges.isEmpty()) {
+
+            ArrayList<GaugeInfo> emptygauges = new ArrayList<GaugeInfo>();
+
+            if (!riverinfo.isKmUp()) {
+                for (GaugeInfo gauge : gauges) {
+                    addGauge(gauge, emptygauges);
+                }
+            }
+            else {
+                for (int i = gauges.size()-1; i >= 0; i--) {
+                    GaugeInfo gauge = gauges.get(i);
+                    addGauge(gauge, emptygauges);
+                }
+            }
+
+            // put empty gauges to the end
+            for (GaugeInfo gauge : emptygauges) {
+                addGauge(gauge);
+            }
+
+            open();
+        }
+    }
+
+    private void addGauge(GaugeInfo gauge, List<GaugeInfo> empty) {
+        if (gauge.getKmStart() != null && gauge.getKmEnd() != null) {
+            addGauge(gauge);
+        }
+        else {
+            empty.add(gauge);
+        }
+    }
+
+    private void addGauge(GaugeInfo gauge) {
+        GaugeInfoItem gaugeitem = new GaugeInfoItem(gauge);
+        tree.addItem(gaugeitem);
+    }
+
+    public void openAll() {
+        GWT.log("GaugeTree - openAll");
+        for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
+            TreeItem item = it.next();
+            item.setState(true);
+        }
+    }
+
+    public void setData(DataList[] data) {
+        this.data = data;
+        if (tree.getItemCount() > 0) {
+            open();
+        }
+    }
+
+    public void open() {
+        ArrayList<Double> locations = new ArrayList<Double>();
+
+        if (data != null && data.length > 0) {
+            for (int i = 0; i < data.length; i++) {
+                DataList dl = data[i];
+                String state = dl.getState();
+                GWT.log("GaugeTree - setData " + state);
+                if (state.equals("state.winfo.location_distance")) {
+                    Double ldfrom = null;
+                    Double ldto = null;
+
+                    for (int j = dl.size()-1; j >= 0; --j) {
+                        Data d = dl.get(j);
+                        String label = d.getLabel();
+                        GWT.log("GaugeTree - setData - label " + label + " " + d.getStringValue());
+                        if (label.equals("ld_from")) {
+                            ldfrom = getDoubleValue(d);
+                        }
+                        else if (label.equals("ld_to")) {
+                            ldto = getDoubleValue(d);
+                        }
+                        else if (label.equals("ld_locations")) {
+                            getLocationsFromData(locations, d);
+                            openOnLocations(locations);
+                            return;
+                        }
+                    }
+                    if (ldfrom != null) {
+                        openOnDistance(ldfrom, ldto);
+                        return;
+                    }
+                }
+                else if(state.equals("state.winfo.distance_only") ||
+                        state.equals("state.winfo.distance")) {
+                    Double ldfrom = null;
+                    Double ldto = null;
+
+                    for (int j = dl.size()-1; j >= 0; --j) {
+                        Data d = dl.get(j);
+                        String label = d.getLabel();
+                        GWT.log("GaugeTree - setData - label " + label + " " + d.getStringValue());
+                        if (label.equals("ld_from")) {
+                            ldfrom = getDoubleValue(d);
+                        }
+                        else if (label.equals("ld_to")) {
+                            ldto = getDoubleValue(d);
+                        }
+                    }
+
+                    if (ldfrom != null) {
+                        openOnDistance(ldfrom, ldto);
+                        return;
+                    }
+                        }
+                else if (state.equals("state.winfo.location")) {
+                    getLocations("ld_locations", locations, dl);
+                    openOnLocations(locations);
+                    return;
+                }
+                else if (state.equals("state.winfo.reference.curve.input.start")) {
+                    getLocations("reference_startpoint", locations, dl);
+                }
+                else if (state.equals("state.winfo.reference.curve.input.end")) {
+                    getLocations("reference_endpoint", locations, dl);
+                }
+                else if (state.equals("state.winfo.historicalq.reference_gauge")) {
+                    for (int j = dl.size()-1; j >= 0; --j) {
+                        Data d = dl.get(j);
+                        String label = d.getLabel();
+                        if (label.equals("reference_gauge")) {
+                            String tmp = d.getStringValue();
+                            if (tmp != null) {
+                                Integer gaugereference = Integer.valueOf(tmp);
+                                if (gaugereference != null) {
+                                    //TODO
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        if (!locations.isEmpty()) {
+            openOnLocations(locations);
+        }
+        else {
+            openAll();
+        }
+    }
+
+    private void getLocations(String labelname, List<Double> locations, DataList dl) {
+        for (int j = dl.size()-1; j >= 0; --j) {
+            Data d = dl.get(j);
+            String label = d.getLabel();
+            if (label.equals(labelname)) {
+                getLocationsFromData(locations, d);
+            }
+        }
+    }
+
+    private void getLocationsFromData(List<Double> locations, Data data) {
+        DataItem[] items = data.getItems();
+        for (int k = 0; k < items.length; k++) {
+            String tmp = items[k].getStringValue();
+            GWT.log("GaugeTree - getLocationsFromData " + tmp);
+            if (tmp != null) {
+                if (tmp.contains(" ")) {
+                    // string contains several values ...
+                    String[] values = tmp.split(" ");
+                    for(int i=0; i < values.length; i++) {
+                        Double value = Double.valueOf(values[i]);
+                        if (value != null) {
+                            locations.add(value);
+                        }
+                    }
+                }
+                else {
+                    Double value = Double.valueOf(tmp);
+                    if (value != null) {
+                        locations.add(value);
+                    }
+                }
+            }
+        }
+    }
+
+    private Double getDoubleValue(Data d) {
+        String tmp = d.getStringValue();
+        if (tmp != null) {
+            return Double.valueOf(tmp);
+        }
+        return null;
+    }
+
+    public void openOnDistance(Double start, Double end) {
+        GWT.log("GaugeTree - openOnDistance " + start + " " + end + " " +
+                tree.getItemCount());
+
+        for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
+            TreeItem item = it.next();
+            /* Strange stuff is happening here:
+             * GWT Tree.treeItemIterator returns another TreeItem for each
+             * GaugeInfoItem */
+            if (item instanceof GaugeInfoItem) {
+                boolean setstate = false;
+                GaugeInfoItem gitem = (GaugeInfoItem)item;
+                if (end == null) {
+                    if (gitem.getStart() >= start) {
+                        setstate = true;
+                    }
+                }
+                else {
+                    GWT.log("GaugeTree - openOnDistance gitem " + gitem.getStart() + " " + gitem.getEnd());
+                    if ((start >= gitem.getStart() && start <= gitem.getEnd()) ||
+                            (end >= gitem.getStart() && end <= gitem.getEnd()) ||
+                            (start <= gitem.getStart() && end >= gitem.getEnd())) {
+                        setstate = true;
+                            }
+                }
+                item.setState(setstate);
+            }
+        }
+    }
+
+    public void openOnLocations(List<Double> locations) {
+        GWT.log("GaugeTree - openOnLocations " + locations + " " +
+                tree.getItemCount());
+
+        if (locations == null || locations.isEmpty()) {
+            return;
+        }
+
+        for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
+            TreeItem item = it.next();
+            if (item instanceof GaugeInfoItem) {
+                GaugeInfoItem gitem = (GaugeInfoItem)item;
+                boolean isset = false;
+                for (Double location: locations) {
+                    if (locations == null) {
+                        continue;
+                    }
+                    if (location >= gitem.getStart() &&
+                            location <= gitem.getEnd()) {
+                        isset = true;
+                        break;
+                            }
+                }
+                item.setState(isset);
+            }
+        }
+    }
+
+    class GaugeInfoItem extends TreeItem {
+
+        private GaugeInfo gauge;
+
+        public GaugeInfoItem(GaugeInfo gauge) {
+            GaugeInfoHead gaugeinfohead = new GaugeInfoHead(gauge);
+            GaugeInfoPanel gaugeinfopanel = new GaugeInfoPanel(gauge);
+            setWidget(gaugeinfohead);
+            addItem(gaugeinfopanel);
+            this.gauge = gauge;
+        }
+
+        public Double getStart() {
+            return gauge.getKmStart();
+        }
+
+        public Double getEnd() {
+            return gauge.getKmEnd();
+        }
+    }
+
+    class GaugeInfoHead extends HLayout {
+
+        public GaugeInfoHead(GaugeInfo gauge) {
+            setStyleName("gaugeinfohead");
+            setAutoHeight();
+            setAutoWidth();
+
+            NumberFormat nf = NumberFormat.getDecimalFormat();
+
+            Label label = new Label(gauge.getName(), true);
+            addMember(label);
+
+            Double start;
+            Double end;
+
+            if (!gauge.isKmUp()) {
+                start = gauge.getKmStart();
+                end   = gauge.getKmEnd();
+            }
+            else {
+                start = gauge.getKmEnd();
+                end   = gauge.getKmStart();
+            }
+
+            String kmtext = "";
+            if (start != null) {
+                kmtext += nf.format(start);
+                kmtext += " - ";
+            }
+            if (end != null) {
+                kmtext += nf.format(end);
+            }
+            if (start != null || end != null) {
+                kmtext += " km";
+            }
+
+            label = new Label(kmtext);
+
+            addMember(label);
+
+            Double station = gauge.getStation();
+            if (station != null) {
+                String stext = nf.format(station);
+                stext += " km";
+                label = new Label(stext);
+                addMember(label);
+            }
+
+            addMember(new Anchor(MSG.gauge_info_link(), gauge.getInfoURL()));
+        }
+    }
+
+    class GaugeInfoPanel extends DecoratorPanel {
+
+        public GaugeInfoPanel(GaugeInfo gauge) {
+            setStyleName("gaugeinfopanel");
+            Grid grid = new Grid(4, 2);
+
+            NumberFormat nf = NumberFormat.getDecimalFormat();
+
+            Double minw = gauge.getMinW();
+            Double maxw = gauge.getMaxW();
+            if (minw != null && maxw != null) {
+                grid.setText(0, 0, MSG.wq_value_q());
+                grid.setText(0, 1, "" + nf.format(minw) +
+                        " - " + nf.format(maxw));
+            }
+
+            Double minq = gauge.getMinQ();
+            Double maxq = gauge.getMaxQ();
+            if (minq != null && maxq != null) {
+                grid.setText(1, 0, MSG.wq_value_w());
+                grid.setText(1, 1, "" + nf.format(minq) +
+                        " - " + nf.format(maxq));
+            }
+
+            Double aeo = gauge.getAeo();
+            if (aeo != null) {
+                grid.setText(2, 0, "AEO [km²]");
+                grid.setText(2, 1, "" + nf.format(aeo));
+            }
+
+            Double datum = gauge.getDatum();
+            if (datum != null) {
+                grid.setText(3, 0, MSG.gauge_zero() + " [" +
+                        gauge.getWstUnit() + "]");
+                grid.setText(3, 1, "" + nf.format(datum));
+            }
+
+            setWidget(grid);
+        }
+    }
+
+}

http://dive4elements.wald.intevation.org