annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java @ 3840:cf64f54aa39c

Refactor to avoid code duplication flys-client/trunk@5555 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 21 Sep 2012 11:34:28 +0000
parents 509ef6ec93af
children 5877d6900e34
rev   line source
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
2
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
3 import java.util.ArrayList;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
4 import java.util.Iterator;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
5 import java.util.List;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
6
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
7 import com.google.gwt.core.client.GWT;
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
8 import com.google.gwt.i18n.client.NumberFormat;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
9 import com.google.gwt.user.client.rpc.AsyncCallback;
3839
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
10 import com.google.gwt.user.client.ui.Anchor;
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
11 import com.google.gwt.user.client.ui.DecoratorPanel;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
12 import com.google.gwt.user.client.ui.Grid;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
13 import com.google.gwt.user.client.ui.HorizontalPanel;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
14 import com.google.gwt.user.client.ui.Label;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
15 import com.google.gwt.user.client.ui.ScrollPanel;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
16 import com.google.gwt.user.client.ui.Tree;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
17 import com.google.gwt.user.client.ui.TreeItem;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
18
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
19 import com.smartgwt.client.types.Overflow;
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
20 import com.smartgwt.client.widgets.events.ResizedEvent;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
21 import com.smartgwt.client.widgets.events.ResizedHandler;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
22 import com.smartgwt.client.widgets.layout.HLayout;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
23 import com.smartgwt.client.widgets.layout.SectionStackSection;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
24 import com.smartgwt.client.widgets.layout.VLayout;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
25
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
26 import de.intevation.flys.client.client.FLYSConstants;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
27 import de.intevation.flys.client.client.services.GaugeOverviewInfoService;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
28 import de.intevation.flys.client.client.services.GaugeOverviewInfoServiceAsync;
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
29 import de.intevation.flys.client.shared.model.Data;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
30 import de.intevation.flys.client.shared.model.DataItem;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
31 import de.intevation.flys.client.shared.model.DataList;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
32 import de.intevation.flys.client.shared.model.GaugeInfo;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
33 import de.intevation.flys.client.shared.model.RiverInfo;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
34
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
35 /**
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
36 * The GaugePanel is intendet to be used within a SectionStackSection
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
37 * It extends the VLayout by two methods to show and hide the
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
38 * section stack section.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
39 */
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
40 public class GaugePanel extends VLayout implements ResizedHandler {
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
41
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
42 /** SectionStackSection where this GaugePanel belongs in*/
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
43 private SectionStackSection sectionStack;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
44
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
45 /** Name of the river */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
46 private String river;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
47
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
48 /** The message class that provides i18n strings.*/
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
49 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
50
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
51 protected GaugeOverviewInfoServiceAsync gaugeOverviewInfoService =
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
52 GWT.create(GaugeOverviewInfoService.class);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
53
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
54 protected GaugeTree gaugetree = new GaugeTree();
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
55
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
56 protected RiverInfoPanel riverinfopanel;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
57
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
58 /**
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
59 * Creates a new VLayout with a SectionStackSection
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
60 * The GaugePanel's SectionStackSection is hidden by default.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
61 * @param sectionStack The section stack section to place the VLayout in.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
62 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
63 public GaugePanel(SectionStackSection sectionStack) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
64 setOverflow(Overflow.HIDDEN);
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
65 sectionStack.setHidden(true);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
66 sectionStack.setItems(this);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
67 this.sectionStack = sectionStack;
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
68 setStyleName("gaugepanel");
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
69 addResizedHandler(this);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
70 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
71
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
72 /**
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
73 * Sets and loads the river data if river is not the current set river
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
74 */
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
75 public void setRiver(String river) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
76 if (!river.equals(this.river)) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
77 this.river = river;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
78 this.refresh();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
79 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
80 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
81
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
82 /**
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
83 * Sets the data and closes not corresponding folds in the gauge tree
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
84 */
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
85 public void setData(DataList[] data) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
86 gaugetree.setData(data);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
87 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
88
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
89 /**
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
90 * Loads the river info and renders it afterwards
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
91 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
92 public void refresh() {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
93 gaugeOverviewInfoService.getRiverInfo(this.river, new AsyncCallback<RiverInfo>() {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
94 public void onFailure(Throwable e) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
95 GWT.log("Could not load the river info." + e);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
96 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
97
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
98 public void onSuccess(RiverInfo riverinfo) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
99 GWT.log("Loaded river info");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
100 renderGaugeOverviewInfo(riverinfo);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
101 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
102 });
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
103 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
104
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
105 public void renderGaugeOverviewInfo(RiverInfo riverinfo) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
106 removeMembers(getMembers());
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
107
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
108 riverinfopanel = new RiverInfoPanel(riverinfo);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
109 addMember(riverinfopanel);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
110 addMember(gaugetree);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
111
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
112 gaugetree.setGauges(riverinfo);
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
113 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
114
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
115 @Override
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
116 public void onResized(ResizedEvent event) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
117 /* this height calculation is only an approximation and doesn't reflect
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
118 * the real height of the the gaugetree. */
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
119 int height = getInnerContentHeight() -
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
120 (RiverInfoPanel.HEIGHT +
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
121 (2 * RiverInfoPanel.BORDER_WIDTH) +
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
122 (2 * RiverInfoPanel.PADDING) +
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
123 (2 * RiverInfoPanel.MARGIN));
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
124
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
125 if (height < 0) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
126 height = 0;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
127 }
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
128
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
129 gaugetree.setHeight("" + height + "px");
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
130 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
131
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
132
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
133 /**
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
134 * Hide the section stack section.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
135 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
136 public void hide() {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
137 GWT.log("GaugePanel - hide");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
138 this.sectionStack.setHidden(true);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
139 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
140
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
141 /**
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
142 * Show the section stack section.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
143 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
144 public void show() {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
145 GWT.log("GaugePanel - show");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
146 this.sectionStack.setHidden(false);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
147 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
148
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
149 class GaugeTree extends ScrollPanel {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
150
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
151 private Tree tree;
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
152 private DataList[] data;
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
153
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
154 public GaugeTree() {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
155 tree = new Tree();
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
156 setWidget(tree);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
157 }
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
158
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
159 /**
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
160 * Resets the items of the tree.
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
161 * If the list of gauges is empty or null the tree will be empty.
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
162 */
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
163 public void setGauges(RiverInfo riverinfo) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
164 tree.clear();
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
165
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
166 List<GaugeInfo> gauges = riverinfo.getGauges();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
167
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
168 if (gauges != null && !gauges.isEmpty()) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
169
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
170 ArrayList<GaugeInfo> emptygauges = new ArrayList<GaugeInfo>();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
171
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
172 if (!riverinfo.isKmUp()) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
173 for (GaugeInfo gauge : gauges) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
174 addGauge(gauge, emptygauges);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
175 }
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
176 }
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
177 else {
3834
52109c4bc5de Prevent AIOOB exception.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3833
diff changeset
178 for (int i = gauges.size()-1; i >= 0; i--) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
179 GaugeInfo gauge = gauges.get(i);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
180 addGauge(gauge, emptygauges);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
181 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
182 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
183
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
184 // put empty gauges to the end
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
185 for (GaugeInfo gauge : emptygauges) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
186 addGauge(gauge);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
187 }
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
188
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
189 open();
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
190 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
191 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
192
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
193 private void addGauge(GaugeInfo gauge, List<GaugeInfo> empty) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
194 if (gauge.getKmStart() != null && gauge.getKmEnd() != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
195 addGauge(gauge);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
196 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
197 else {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
198 empty.add(gauge);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
199 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
200 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
201
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
202 private void addGauge(GaugeInfo gauge) {
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
203 GaugeInfoItem gaugeitem = new GaugeInfoItem(gauge);
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
204 tree.addItem(gaugeitem);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
205 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
206
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
207 public void openAll() {
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
208 GWT.log("GaugeTree - openAll");
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
209 for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
210 TreeItem item = it.next();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
211 item.setState(true);
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
212 }
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
213 }
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
214
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
215 public void setData(DataList[] data) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
216 this.data = data;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
217 if (tree.getItemCount() > 0) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
218 open();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
219 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
220 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
221
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
222 public void open() {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
223 ArrayList<Double> curvelocations = new ArrayList<Double>();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
224
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
225 if (data != null && data.length > 0) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
226 for (int i = 0; i < data.length; i++) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
227 DataList dl = data[i];
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
228 String state = dl.getState();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
229 GWT.log("GaugeTree - setData " + state);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
230 if (state.equals("state.winfo.distance") ||
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
231 state.equals("state.winfo.distance_only") ||
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
232 state.equals("state.winfo.location_distance")) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
233 Double ldfrom = null;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
234 Double ldto = null;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
235
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
236 for (int j = dl.size()-1; j >= 0; --j) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
237 Data d = dl.get(j);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
238 String label = d.getLabel();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
239 GWT.log("GaugeTree - setData - label " + label + " " + d.getStringValue());
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
240 if (label.equals("ld_from")) {
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
241 ldfrom = getDoubleValue(d);
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
242 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
243 else if (label.equals("ld_to")) {
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
244 ldto = getDoubleValue(d);
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
245 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
246 else if (label.equals("ld_mode")) {
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
247 GWT.log("GaugeTree - setData - ld_mode " + d.getStringValue());
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
248 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
249 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
250
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
251 if (ldfrom != null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
252 openOnDistance(ldfrom, ldto);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
253 return;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
254 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
255 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
256 else if (state.equals("state.winfo.location")) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
257 ArrayList<Double> locations = new ArrayList<Double>();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
258 for (int j = dl.size()-1; j >= 0; --j) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
259 Data d = dl.get(j);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
260 String label = d.getLabel();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
261 GWT.log("GaugeTree - setData - location label " +
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
262 label + " " + d.getStringValue());
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
263 if (label.equals("ld_locations")) {
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
264 getLocations(locations, d.getItems());
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
265 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
266 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
267 openOnLocations(locations);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
268 return;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
269 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
270 else if (state.equals("state.winfo.reference.curve.input.start")) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
271 for (int j = dl.size()-1; j >= 0; --j) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
272 Data d = dl.get(j);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
273 String label = d.getLabel();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
274 if (label.equals("reference_startpoint")) {
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
275 getLocations(curvelocations, d.getItems());
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
276 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
277 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
278 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
279 else if (state.equals("state.winfo.reference.curve.input.end")) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
280 for (int j = dl.size()-1; j >= 0; --j) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
281 Data d = dl.get(j);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
282 String label = d.getLabel();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
283 if (label.equals("reference_endpoint")) {
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
284 getLocations(curvelocations, d.getItems());
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
285 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
286 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
287 }
3839
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
288 else if (state.equals("state.winfo.historicalq.reference_gauge")) {
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
289 for (int j = dl.size()-1; j >= 0; --j) {
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
290 Data d = dl.get(j);
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
291 String label = d.getLabel();
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
292 if (label.equals("reference_gauge")) {
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
293 String tmp = d.getStringValue();
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
294 if (tmp != null) {
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
295 Integer gaugereference = Integer.valueOf(tmp);
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
296 if (gaugereference != null) {
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
297 }
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
298 }
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
299 }
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
300 }
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
301 }
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
302 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
303 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
304 if (!curvelocations.isEmpty()) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
305 openOnLocations(curvelocations);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
306 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
307 else {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
308 openAll();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
309 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
310 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
311
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
312 private void getLocations(List<Double> locations, DataItem[] items) {
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
313 for (int k = 0; k < items.length; k++) {
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
314 String tmp = items[k].getStringValue();
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
315 if (tmp != null) {
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
316 Double value = Double.valueOf(tmp);
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
317 if (value != null) {
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
318 locations.add(value);
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
319 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
320 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
321 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
322 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
323 private Double getDoubleValue(Data d) {
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
324 String tmp = d.getStringValue();
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
325 if (tmp != null) {
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
326 return Double.valueOf(tmp);
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
327 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
328 return null;
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
329 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
330
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
331 public void openOnDistance(Double start, Double end) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
332 GWT.log("GaugeTree - openOnDistance " + start + " " + end + " " +
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
333 tree.getItemCount());
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
334
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
335 for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
336 TreeItem item = it.next();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
337 /* Strange stuff is happening here:
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
338 * GWT Tree.treeItemIterator returns another TreeItem for each
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
339 * GaugeInfoItem */
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
340 if (item instanceof GaugeInfoItem) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
341 boolean setstate = false;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
342 GaugeInfoItem gitem = (GaugeInfoItem)item;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
343 if (end == null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
344 if (gitem.getStart() >= start) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
345 setstate = true;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
346 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
347 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
348 else {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
349 if ((gitem.getStart() >= start && gitem.getStart() <= end) ||
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
350 (gitem.getEnd() >= start && gitem.getEnd() <= end)) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
351 setstate = true;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
352 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
353 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
354 item.setState(setstate);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
355 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
356 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
357 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
358
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
359 public void openOnLocations(List<Double> locations) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
360 GWT.log("GaugeTree - openOnLocations " + locations + " " +
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
361 tree.getItemCount());
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
362
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
363 if (locations == null || locations.isEmpty()) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
364 return;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
365 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
366
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
367 for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
368 TreeItem item = it.next();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
369 if (item instanceof GaugeInfoItem) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
370 GaugeInfoItem gitem = (GaugeInfoItem)item;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
371 boolean isset = false;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
372 for (Double location: locations) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
373 if (locations == null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
374 continue;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
375 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
376 if (location >= gitem.getStart() &&
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
377 location <= gitem.getEnd()) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
378 isset = true;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
379 break;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
380 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
381 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
382 item.setState(isset);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
383 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
384 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
385 }
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
386 }
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
387
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
388 class RiverInfoPanel extends HorizontalPanel {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
389
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
390 public final static int HEIGHT = 30;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
391 public final static int BORDER_WIDTH = 3;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
392 public final static int PADDING = 8;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
393 public final static int MARGIN = 10;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
394
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
395 public RiverInfoPanel(RiverInfo riverinfo) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
396 setStyleName("riverinfopanel");
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
397 setHeight("" + HEIGHT + "px");
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
398 setVerticalAlignment(ALIGN_MIDDLE);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
399
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
400 NumberFormat nf = NumberFormat.getDecimalFormat();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
401
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
402 addLabel(riverinfo.getName(), false);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
403
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
404 String kmtext = "";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
405 Double start = riverinfo.getKmStart();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
406 Double end = riverinfo.getKmEnd();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
407
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
408 if (!riverinfo.isKmUp()) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
409 Double tmp = end;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
410 end = start;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
411 start = tmp;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
412 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
413 if (end != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
414 kmtext += nf.format(end);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
415 kmtext += " - ";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
416 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
417 if (start != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
418 kmtext += nf.format(start);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
419 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
420 kmtext += " km";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
421
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
422 addLabel(kmtext, false);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
423
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
424 String qtext = "";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
425 Double qmin = riverinfo.getMinQ();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
426 Double qmax = riverinfo.getMaxQ();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
427 if (qmin != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
428 qtext += nf.format(qmin);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
429 qtext += " " + MSG.gauge_q_unit();
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
430 qtext += " - ";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
431 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
432 if (qmax != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
433 qtext += nf.format(qmax);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
434 qtext += " " + MSG.gauge_q_unit();
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
435 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
436
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
437 addLabel(qtext, false);
3839
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
438
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
439 Anchor anchor = new Anchor(MSG.gauge_river_info_link(), riverinfo.getInfoURL());
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
440 add(anchor);
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
441 }
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
442
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
443 private void addLabel(String text, boolean wordwrap) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
444 Label label = new Label(text, wordwrap);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
445 add(label);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
446 setCellHeight(label, "" + HEIGHT + "px");
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
447 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
448 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
449
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
450 class GaugeInfoItem extends TreeItem {
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
451
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
452 private GaugeInfo gauge;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
453
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
454 public GaugeInfoItem(GaugeInfo gauge) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
455 GaugeInfoHead gaugeinfohead = new GaugeInfoHead(gauge);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
456 GaugeInfoPanel gaugeinfopanel = new GaugeInfoPanel(gauge);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
457 setWidget(gaugeinfohead);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
458 addItem(gaugeinfopanel);
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
459 this.gauge = gauge;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
460 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
461
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
462 public Double getStart() {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
463 return gauge.getKmStart();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
464 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
465
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
466 public Double getEnd() {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
467 return gauge.getKmEnd();
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
468 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
469 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
470
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
471 class GaugeInfoHead extends HLayout {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
472
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
473 public GaugeInfoHead(GaugeInfo gauge) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
474 setStyleName("gaugeinfohead");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
475 setAutoHeight();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
476 setAutoWidth();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
477
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
478 NumberFormat nf = NumberFormat.getDecimalFormat();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
479
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
480 Label label = new Label(gauge.getName(), true);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
481 addMember(label);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
482
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
483 Double start;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
484 Double end;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
485
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
486 if (!gauge.isKmUp()) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
487 start = gauge.getKmStart();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
488 end = gauge.getKmEnd();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
489 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
490 else {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
491 start = gauge.getKmEnd();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
492 end = gauge.getKmStart();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
493 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
494
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
495 String kmtext = "";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
496 if (start != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
497 kmtext += nf.format(start);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
498 kmtext += " - ";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
499 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
500 if (end != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
501 kmtext += nf.format(end);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
502 }
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
503 if (start != null || end != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
504 kmtext += " km";
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
505 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
506
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
507 label = new Label(kmtext);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
508
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
509 addMember(label);
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
510
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
511 Double station = gauge.getStation();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
512 if (station != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
513 String stext = nf.format(station);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
514 stext += " km";
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
515 label = new Label(stext);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
516 addMember(label);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
517 }
3839
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
518
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
519 addMember(new Anchor(MSG.gauge_info_link(), gauge.getInfoURL()));
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
520 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
521 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
522
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
523 class GaugeInfoPanel extends DecoratorPanel {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
524
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
525 public GaugeInfoPanel(GaugeInfo gauge) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
526 setStyleName("gaugeinfopanel");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
527 Grid grid = new Grid(4, 2);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
528
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
529 NumberFormat nf = NumberFormat.getDecimalFormat();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
530
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
531 Double minw = gauge.getMinW();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
532 Double maxw = gauge.getMaxW();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
533 if (minw != null && maxw != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
534 grid.setText(0, 0, MSG.wq_value_q());
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
535 grid.setText(0, 1, "" + nf.format(minw) +
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
536 " - " + nf.format(maxw));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
537 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
538
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
539 Double minq = gauge.getMinQ();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
540 Double maxq = gauge.getMaxQ();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
541 if (minq != null && maxq != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
542 grid.setText(1, 0, MSG.wq_value_w());
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
543 grid.setText(1, 1, "" + nf.format(minq) +
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
544 " - " + nf.format(maxq));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
545 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
546
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
547 Double aeo = gauge.getAeo();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
548 if (aeo != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
549 grid.setText(2, 0, "AEO [kmĀ²]");
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
550 grid.setText(2, 1, "" + nf.format(aeo));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
551 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
552
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
553 Double datum = gauge.getDatum();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
554 if (datum != null) {
3831
dc505433173f Use the wstunit from the river as unit for the Pegelnullpunkt
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3828
diff changeset
555 grid.setText(3, 0, MSG.gauge_zero() + " [" +
dc505433173f Use the wstunit from the river as unit for the Pegelnullpunkt
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3828
diff changeset
556 gauge.getWstUnit() + "]");
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
557 grid.setText(3, 1, "" + nf.format(datum));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
558 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
559
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
560 setWidget(grid);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
561 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
562 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
563 }

http://dive4elements.wald.intevation.org