Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java @ 3833:611cb0f1761e
Removed superfluous import.
flys-client/trunk@5537 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 20 Sep 2012 09:34:05 +0000 |
parents | dc505433173f |
children | 52109c4bc5de |
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; |
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.shared.model.GaugeInfo; |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
29 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
|
30 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
31 /** |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
32 * 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
|
33 * 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
|
34 * section stack section. |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
35 */ |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
36 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
|
37 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
38 /** 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
|
39 private SectionStackSection sectionStack; |
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 /** Name of the river */ |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
42 private String river; |
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 /** 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
|
45 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
|
46 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
47 protected GaugeOverviewInfoServiceAsync gaugeOverviewInfoService = |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
48 GWT.create(GaugeOverviewInfoService.class); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
49 |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
50 protected GaugeTree gaugetree = new GaugeTree(); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
51 |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
52 protected RiverInfoPanel riverinfopanel; |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
53 |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
54 /** |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
55 * 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
|
56 * 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
|
57 * @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
|
58 */ |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
59 public GaugePanel(SectionStackSection sectionStack) { |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
60 setOverflow(Overflow.HIDDEN); |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
61 sectionStack.setHidden(true); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
62 sectionStack.setItems(this); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
63 this.sectionStack = sectionStack; |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
64 setStyleName("gaugepanel"); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
65 addResizedHandler(this); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
66 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
67 |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
68 /** |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
69 * 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
|
70 */ |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
71 public void setRiver(String river) { |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
72 if (!river.equals(this.river)) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
73 this.river = river; |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
74 this.refresh(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
75 } |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
76 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
77 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
78 /** |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
79 * 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
|
80 */ |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
81 public void refresh() { |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
82 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
|
83 public void onFailure(Throwable e) { |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
84 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
|
85 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
86 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
87 public void onSuccess(RiverInfo riverinfo) { |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
88 GWT.log("Loaded river info"); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
89 renderGaugeOverviewInfo(riverinfo); |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
90 gaugetree.openAll(); |
3715
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 }); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
93 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
94 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
95 public void renderGaugeOverviewInfo(RiverInfo riverinfo) { |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
96 removeMembers(getMembers()); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
97 |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
98 riverinfopanel = new RiverInfoPanel(riverinfo); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
99 addMember(riverinfopanel); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
100 addMember(gaugetree); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
101 |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
102 gaugetree.setGauges(riverinfo); |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
103 } |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
104 |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
105 @Override |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
106 public void onResized(ResizedEvent event) { |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
107 /* 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
|
108 * the real height of the the gaugetree. */ |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
109 int height = getInnerContentHeight() - |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
110 (RiverInfoPanel.HEIGHT + |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
111 (2 * RiverInfoPanel.BORDER_WIDTH) + |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
112 (2 * RiverInfoPanel.PADDING) + |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
113 (2 * RiverInfoPanel.MARGIN)); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
114 |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
115 if (height < 0) { |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
116 height = 0; |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
117 } |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
118 |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
119 gaugetree.setHeight("" + height + "px"); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
120 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
121 |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
122 |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
123 /** |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
124 * Hide the section stack section. |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
125 */ |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
126 public void hide() { |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
127 GWT.log("GaugePanel - hide"); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
128 this.sectionStack.setHidden(true); |
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 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
131 /** |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
132 * Show the section stack section. |
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 public void show() { |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
135 GWT.log("GaugePanel - show"); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
136 this.sectionStack.setHidden(false); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
137 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
138 |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
139 class GaugeTree extends ScrollPanel { |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
140 |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
141 private Tree tree; |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
142 |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
143 public GaugeTree() { |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
144 tree = new Tree(); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
145 setWidget(tree); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
146 } |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
147 |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
148 /** |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
149 * Resets the items of the tree. |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
150 * 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
|
151 */ |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
152 public void setGauges(RiverInfo riverinfo) { |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
153 tree.clear(); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
154 |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
155 List<GaugeInfo> gauges = riverinfo.getGauges(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
156 |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
157 if (gauges != null && !gauges.isEmpty()) { |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
158 |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
159 ArrayList<GaugeInfo> emptygauges = new ArrayList<GaugeInfo>(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
160 |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
161 if (!riverinfo.isKmUp()) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
162 for (GaugeInfo gauge : gauges) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
163 addGauge(gauge, emptygauges); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
164 } |
3825
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 else { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
167 for (int i = gauges.size(); i >= 0; i--) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
168 GaugeInfo gauge = gauges.get(i); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
169 addGauge(gauge, emptygauges); |
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 } |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
172 |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
173 // put empty gauges to the end |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
174 for (GaugeInfo gauge : emptygauges) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
175 addGauge(gauge); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
176 } |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
177 } |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
178 } |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
179 |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
180 private void addGauge(GaugeInfo gauge, List<GaugeInfo> empty) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
181 if (gauge.getKmStart() != null && gauge.getKmEnd() != null) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
182 addGauge(gauge); |
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 else { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
185 empty.add(gauge); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
186 } |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
187 } |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
188 |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
189 private void addGauge(GaugeInfo gauge) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
190 TreeItem gaugeitem = new GaugeInfoItem(gauge); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
191 tree.addItem(gaugeitem); |
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 |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
194 public void openAll() { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
195 for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
196 TreeItem item = it.next(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
197 item.setState(true); |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
198 } |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
199 } |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
200 } |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
201 |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
202 class RiverInfoPanel extends HorizontalPanel { |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
203 |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
204 public final static int HEIGHT = 30; |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
205 public final static int BORDER_WIDTH = 3; |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
206 public final static int PADDING = 8; |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
207 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
|
208 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
209 public RiverInfoPanel(RiverInfo riverinfo) { |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
210 setStyleName("riverinfopanel"); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
211 setHeight("" + HEIGHT + "px"); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
212 setVerticalAlignment(ALIGN_MIDDLE); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
213 |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
214 NumberFormat nf = NumberFormat.getDecimalFormat(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
215 |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
216 addLabel(riverinfo.getName(), false); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
217 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
218 String kmtext = ""; |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
219 Double start = riverinfo.getKmStart(); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
220 Double end = riverinfo.getKmEnd(); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
221 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
222 if (!riverinfo.isKmUp()) { |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
223 Double tmp = end; |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
224 end = start; |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
225 start = tmp; |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
226 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
227 if (end != null) { |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
228 kmtext += nf.format(end); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
229 kmtext += " - "; |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
230 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
231 if (start != null) { |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
232 kmtext += nf.format(start); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
233 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
234 kmtext += " km"; |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
235 |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
236 addLabel(kmtext, false); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
237 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
238 String qtext = ""; |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
239 Double qmin = riverinfo.getMinQ(); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
240 Double qmax = riverinfo.getMaxQ(); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
241 if (qmin != null) { |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
242 qtext += nf.format(qmin); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
243 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
|
244 qtext += " - "; |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
245 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
246 if (qmax != null) { |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
247 qtext += nf.format(qmax); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
248 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
|
249 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
250 |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
251 addLabel(qtext, false); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
252 } |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
253 |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
254 private void addLabel(String text, boolean wordwrap) { |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
255 Label label = new Label(text, wordwrap); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
256 add(label); |
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
257 setCellHeight(label, "" + HEIGHT + "px"); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
258 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
259 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
260 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
261 class GaugeInfoItem extends TreeItem { |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
262 public GaugeInfoItem(GaugeInfo gauge) { |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
263 GaugeInfoHead gaugeinfohead = new GaugeInfoHead(gauge); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
264 GaugeInfoPanel gaugeinfopanel = new GaugeInfoPanel(gauge); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
265 setWidget(gaugeinfohead); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
266 addItem(gaugeinfopanel); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
267 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
268 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
269 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
270 class GaugeInfoHead extends HLayout { |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
271 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
272 public GaugeInfoHead(GaugeInfo gauge) { |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
273 setStyleName("gaugeinfohead"); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
274 setAutoHeight(); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
275 setAutoWidth(); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
276 |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
277 NumberFormat nf = NumberFormat.getDecimalFormat(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
278 |
3825
e91c5112d67c
Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3716
diff
changeset
|
279 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
|
280 addMember(label); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
281 |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
282 Double start; |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
283 Double end; |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
284 |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
285 if (!gauge.isKmUp()) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
286 start = gauge.getKmStart(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
287 end = gauge.getKmEnd(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
288 } |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
289 else { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
290 start = gauge.getKmEnd(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
291 end = gauge.getKmStart(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
292 } |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
293 |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
294 String kmtext = ""; |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
295 if (start != null) { |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
296 kmtext += nf.format(start); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
297 kmtext += " - "; |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
298 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
299 if (end != null) { |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
300 kmtext += nf.format(end); |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
301 } |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
302 if (start != null || end != null) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
303 kmtext += " km"; |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
304 } |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
305 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
306 label = new Label(kmtext); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
307 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
308 addMember(label); |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
309 |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
310 Double station = gauge.getStation(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
311 if (station != null) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
312 String stext = nf.format(station); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
313 stext += " km"; |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
314 label = new Label(stext); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
315 addMember(label); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
316 } |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
317 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
318 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
319 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
320 class GaugeInfoPanel extends DecoratorPanel { |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
321 |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
322 public GaugeInfoPanel(GaugeInfo gauge) { |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
323 setStyleName("gaugeinfopanel"); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
324 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
|
325 |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
326 NumberFormat nf = NumberFormat.getDecimalFormat(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
327 |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
328 Double minw = gauge.getMinW(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
329 Double maxw = gauge.getMaxW(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
330 if (minw != null && maxw != null) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
331 grid.setText(0, 0, MSG.wq_value_q()); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
332 grid.setText(0, 1, "" + nf.format(minw) + |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
333 " - " + nf.format(maxw)); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
334 } |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
335 |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
336 Double minq = gauge.getMinQ(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
337 Double maxq = gauge.getMaxQ(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
338 if (minq != null && maxq != null) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
339 grid.setText(1, 0, MSG.wq_value_w()); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
340 grid.setText(1, 1, "" + nf.format(minq) + |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
341 " - " + nf.format(maxq)); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
342 } |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
343 |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
344 Double aeo = gauge.getAeo(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
345 if (aeo != null) { |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
346 grid.setText(2, 0, "AEO [kmĀ²]"); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
347 grid.setText(2, 1, "" + nf.format(aeo)); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
348 } |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
349 |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
350 Double datum = gauge.getDatum(); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
351 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
|
352 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
|
353 gauge.getWstUnit() + "]"); |
3828
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
354 grid.setText(3, 1, "" + nf.format(datum)); |
9cbc8311e820
Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3825
diff
changeset
|
355 } |
3715
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
356 |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
357 setWidget(grid); |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
358 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
359 } |
8d3e48f189d2
Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
360 } |