annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java @ 3837:6b2ae2ec5b01

Open and close gauge tree folds that correspond to the selected WINFO calculation flys-client/trunk@5546 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 21 Sep 2012 08:57:18 +0000
parents 52109c4bc5de
children 509ef6ec93af
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;
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
10 import com.google.gwt.user.client.ui.DecoratorPanel;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
11 import com.google.gwt.user.client.ui.Grid;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
12 import com.google.gwt.user.client.ui.HorizontalPanel;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
13 import com.google.gwt.user.client.ui.Label;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
14 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
15 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
16 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
17
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
18 import com.smartgwt.client.types.Overflow;
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
19 import com.smartgwt.client.widgets.events.ResizedEvent;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
20 import com.smartgwt.client.widgets.events.ResizedHandler;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
21 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
22 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
23 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
24
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
25 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
26 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
27 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
28 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
29 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
30 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
31 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
32 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
33
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 * 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
36 * 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
37 * section stack section.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
38 */
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
39 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
40
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
41 /** 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
42 private SectionStackSection sectionStack;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
43
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
44 /** Name of the river */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
45 private String river;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
46
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
47 /** 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
48 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
49
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
50 protected GaugeOverviewInfoServiceAsync gaugeOverviewInfoService =
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
51 GWT.create(GaugeOverviewInfoService.class);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
52
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
53 protected GaugeTree gaugetree = new GaugeTree();
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
54
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
55 protected RiverInfoPanel riverinfopanel;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
56
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
57 /**
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
58 * 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
59 * 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
60 * @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
61 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
62 public GaugePanel(SectionStackSection sectionStack) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
63 setOverflow(Overflow.HIDDEN);
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
64 sectionStack.setHidden(true);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
65 sectionStack.setItems(this);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
66 this.sectionStack = sectionStack;
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
67 setStyleName("gaugepanel");
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
68 addResizedHandler(this);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
69 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
70
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
71 /**
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
72 * 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
73 */
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
74 public void setRiver(String river) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
75 if (!river.equals(this.river)) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
76 this.river = river;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
77 this.refresh();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
78 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
79 }
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 /**
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
82 * 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
83 */
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
84 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
85 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
86 }
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 /**
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
89 * 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
90 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
91 public void refresh() {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
92 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
93 public void onFailure(Throwable e) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
94 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
95 }
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 public void onSuccess(RiverInfo riverinfo) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
98 GWT.log("Loaded river info");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
99 renderGaugeOverviewInfo(riverinfo);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
100 }
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 public void renderGaugeOverviewInfo(RiverInfo riverinfo) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
105 removeMembers(getMembers());
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
106
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
107 riverinfopanel = new RiverInfoPanel(riverinfo);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
108 addMember(riverinfopanel);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
109 addMember(gaugetree);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
110
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
111 gaugetree.setGauges(riverinfo);
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
112 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
113
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
114 @Override
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
115 public void onResized(ResizedEvent event) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
116 /* 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
117 * the real height of the the gaugetree. */
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
118 int height = getInnerContentHeight() -
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
119 (RiverInfoPanel.HEIGHT +
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
120 (2 * RiverInfoPanel.BORDER_WIDTH) +
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
121 (2 * RiverInfoPanel.PADDING) +
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
122 (2 * RiverInfoPanel.MARGIN));
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
123
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
124 if (height < 0) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
125 height = 0;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
126 }
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
127
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
128 gaugetree.setHeight("" + height + "px");
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
129 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
130
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
131
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
132 /**
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
133 * Hide the section stack section.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
134 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
135 public void hide() {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
136 GWT.log("GaugePanel - hide");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
137 this.sectionStack.setHidden(true);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
138 }
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 * Show the section stack section.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
142 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
143 public void show() {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
144 GWT.log("GaugePanel - show");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
145 this.sectionStack.setHidden(false);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
146 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
147
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
148 class GaugeTree extends ScrollPanel {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
149
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
150 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
151 private DataList[] data;
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
152
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
153 public GaugeTree() {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
154 tree = new Tree();
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
155 setWidget(tree);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
156 }
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 * Resets the items of the tree.
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
160 * 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
161 */
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
162 public void setGauges(RiverInfo riverinfo) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
163 tree.clear();
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
164
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
165 List<GaugeInfo> gauges = riverinfo.getGauges();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
166
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
167 if (gauges != null && !gauges.isEmpty()) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
168
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
169 ArrayList<GaugeInfo> emptygauges = new ArrayList<GaugeInfo>();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
170
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
171 if (!riverinfo.isKmUp()) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
172 for (GaugeInfo gauge : gauges) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
173 addGauge(gauge, emptygauges);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
174 }
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
175 }
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
176 else {
3834
52109c4bc5de Prevent AIOOB exception.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3833
diff changeset
177 for (int i = gauges.size()-1; i >= 0; i--) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
178 GaugeInfo gauge = gauges.get(i);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
179 addGauge(gauge, emptygauges);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
180 }
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 // put empty gauges to the end
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
184 for (GaugeInfo gauge : emptygauges) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
185 addGauge(gauge);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
186 }
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
187
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
188 open();
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
189 }
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 private void addGauge(GaugeInfo gauge, List<GaugeInfo> empty) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
193 if (gauge.getKmStart() != null && gauge.getKmEnd() != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
194 addGauge(gauge);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
195 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
196 else {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
197 empty.add(gauge);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
198 }
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 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
202 GaugeInfoItem gaugeitem = new GaugeInfoItem(gauge);
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
203 tree.addItem(gaugeitem);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
204 }
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 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
207 GWT.log("GaugeTree - openAll");
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
208 for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
209 TreeItem item = it.next();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
210 item.setState(true);
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
211 }
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
212 }
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
213
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
214 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
215 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
216 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
217 open();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
218 }
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 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
222 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
223
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
224 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
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
235 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
236 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
237 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
238 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
239 if (label.equals("ld_from")) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
240 String strfrom = 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
241 if (strfrom != null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
242 ldfrom = Double.valueOf(strfrom);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
243 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
244 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
245 else if (label.equals("ld_to")) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
246 String strto = 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
247 if (strto != null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
248 ldto = Double.valueOf(strto);
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 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
252
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
253 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
254 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
255 return;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
256 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
257 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 if (label.equals("ld_locations")) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
266 DataItem[] items = d.getItems();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
267 for (int k = 0; k < items.length; k++) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
268 String tmp = items[k].getStringValue();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
269 if (tmp != null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
270 Double value = Double.valueOf(tmp);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
271 if (value != null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
272 locations.add(value);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
273 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
274 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
275 }
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 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
279 return;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
280 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
281 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
282 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
283 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
284 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
285 if (label.equals("reference_startpoint")) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
286 DataItem[] items = d.getItems();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
287 for (int k = 0; k < items.length; k++) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
288 String tmp = items[k].getStringValue();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
289 if (tmp != null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
290 Double value = Double.valueOf(tmp);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
291 if (value != null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
292 curvelocations.add(value);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
293 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
294 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
295 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
296 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
297 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
298 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
299 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
300 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
301 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
302 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
303 if (label.equals("reference_endpoint")) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
304 DataItem[] items = d.getItems();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
305 for (int k = 0; k < items.length; k++) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
306 String tmp = items[k].getStringValue();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
307 if (tmp != null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
308 Double value = Double.valueOf(tmp);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
309 if (value != null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
310 curvelocations.add(value);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
311 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
312 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
313 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
314 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
315 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
316 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
317 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
318 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
319 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
320 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
321 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
322 else {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
323 openAll();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
324 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
325 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
326
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
327 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
328 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
329 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
330
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
331 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
332 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
333 /* 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
334 * 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
335 * GaugeInfoItem */
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
336 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
337 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
338 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
339 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
340 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
341 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
342 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
343 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
344 else {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
345 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
346 (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
347 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
348 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
349 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
350 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
351 }
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
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
355 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
356 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
357 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
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 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
360 return;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
361 }
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 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
364 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
365 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
366 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
367 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
368 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
369 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
370 continue;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
371 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
372 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
373 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
374 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
375 break;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
376 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
377 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
378 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
379 }
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 }
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
382 }
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
383
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
384 class RiverInfoPanel extends HorizontalPanel {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
385
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
386 public final static int HEIGHT = 30;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
387 public final static int BORDER_WIDTH = 3;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
388 public final static int PADDING = 8;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
389 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
390
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
391 public RiverInfoPanel(RiverInfo riverinfo) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
392 setStyleName("riverinfopanel");
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
393 setHeight("" + HEIGHT + "px");
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
394 setVerticalAlignment(ALIGN_MIDDLE);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
395
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
396 NumberFormat nf = NumberFormat.getDecimalFormat();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
397
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
398 addLabel(riverinfo.getName(), false);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
399
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
400 String kmtext = "";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
401 Double start = riverinfo.getKmStart();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
402 Double end = riverinfo.getKmEnd();
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 if (!riverinfo.isKmUp()) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
405 Double tmp = end;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
406 end = start;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
407 start = tmp;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
408 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
409 if (end != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
410 kmtext += nf.format(end);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
411 kmtext += " - ";
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 (start != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
414 kmtext += nf.format(start);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
415 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
416 kmtext += " km";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
417
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
418 addLabel(kmtext, false);
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 String qtext = "";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
421 Double qmin = riverinfo.getMinQ();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
422 Double qmax = riverinfo.getMaxQ();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
423 if (qmin != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
424 qtext += nf.format(qmin);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
425 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
426 qtext += " - ";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
427 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
428 if (qmax != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
429 qtext += nf.format(qmax);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
430 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
431 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
432
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
433 addLabel(qtext, false);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
434 }
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
435
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
436 private void addLabel(String text, boolean wordwrap) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
437 Label label = new Label(text, wordwrap);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
438 add(label);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
439 setCellHeight(label, "" + HEIGHT + "px");
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
440 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
441 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
442
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
443 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
444
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
445 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
446
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
447 public GaugeInfoItem(GaugeInfo gauge) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
448 GaugeInfoHead gaugeinfohead = new GaugeInfoHead(gauge);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
449 GaugeInfoPanel gaugeinfopanel = new GaugeInfoPanel(gauge);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
450 setWidget(gaugeinfohead);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
451 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
452 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
453 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
454
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
455 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
456 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
457 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
458
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
459 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
460 return gauge.getKmEnd();
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
461 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
462 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
463
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
464 class GaugeInfoHead extends HLayout {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
465
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
466 public GaugeInfoHead(GaugeInfo gauge) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
467 setStyleName("gaugeinfohead");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
468 setAutoHeight();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
469 setAutoWidth();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
470
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
471 NumberFormat nf = NumberFormat.getDecimalFormat();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
472
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
473 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
474 addMember(label);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
475
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
476 Double start;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
477 Double end;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
478
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
479 if (!gauge.isKmUp()) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
480 start = gauge.getKmStart();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
481 end = gauge.getKmEnd();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
482 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
483 else {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
484 start = gauge.getKmEnd();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
485 end = gauge.getKmStart();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
486 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
487
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
488 String kmtext = "";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
489 if (start != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
490 kmtext += nf.format(start);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
491 kmtext += " - ";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
492 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
493 if (end != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
494 kmtext += nf.format(end);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
495 }
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
496 if (start != null || end != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
497 kmtext += " km";
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
498 }
3715
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 label = new Label(kmtext);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
501
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
502 addMember(label);
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
503
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
504 Double station = gauge.getStation();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
505 if (station != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
506 String stext = nf.format(station);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
507 stext += " km";
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
508 label = new Label(stext);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
509 addMember(label);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
510 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
511 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
512 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
513
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
514 class GaugeInfoPanel extends DecoratorPanel {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
515
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
516 public GaugeInfoPanel(GaugeInfo gauge) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
517 setStyleName("gaugeinfopanel");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
518 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
519
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
520 NumberFormat nf = NumberFormat.getDecimalFormat();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
521
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
522 Double minw = gauge.getMinW();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
523 Double maxw = gauge.getMaxW();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
524 if (minw != null && maxw != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
525 grid.setText(0, 0, MSG.wq_value_q());
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
526 grid.setText(0, 1, "" + nf.format(minw) +
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
527 " - " + nf.format(maxw));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
528 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
529
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
530 Double minq = gauge.getMinQ();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
531 Double maxq = gauge.getMaxQ();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
532 if (minq != null && maxq != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
533 grid.setText(1, 0, MSG.wq_value_w());
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
534 grid.setText(1, 1, "" + nf.format(minq) +
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
535 " - " + nf.format(maxq));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
536 }
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 Double aeo = gauge.getAeo();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
539 if (aeo != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
540 grid.setText(2, 0, "AEO [kmĀ²]");
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
541 grid.setText(2, 1, "" + nf.format(aeo));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
542 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
543
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
544 Double datum = gauge.getDatum();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
545 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
546 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
547 gauge.getWstUnit() + "]");
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
548 grid.setText(3, 1, "" + nf.format(datum));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
549 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
550
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
551 setWidget(grid);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
552 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
553 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
554 }

http://dive4elements.wald.intevation.org