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