comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/stationinfo/GaugeListGrid.java @ 4962:6f6461e07854

Move classes to its own java file
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 04 Feb 2013 14:56:41 +0100
parents 27b4d5d20dc8
children e70ff0a600a3
comparison
equal deleted inserted replaced
4961:27b4d5d20dc8 4962:6f6461e07854
2 2
3 import java.util.ArrayList; 3 import java.util.ArrayList;
4 import java.util.List; 4 import java.util.List;
5 5
6 import com.google.gwt.core.client.GWT; 6 import com.google.gwt.core.client.GWT;
7 import com.google.gwt.event.dom.client.ClickEvent;
8 import com.google.gwt.event.dom.client.ClickHandler;
9 import com.google.gwt.i18n.client.NumberFormat;
10 import com.google.gwt.user.client.ui.Anchor;
11 import com.google.gwt.user.client.ui.Grid;
12 import com.smartgwt.client.types.ListGridFieldType; 7 import com.smartgwt.client.types.ListGridFieldType;
13 import com.smartgwt.client.widgets.Canvas; 8 import com.smartgwt.client.widgets.Canvas;
14 import com.smartgwt.client.widgets.Label;
15 import com.smartgwt.client.widgets.WidgetCanvas; 9 import com.smartgwt.client.widgets.WidgetCanvas;
16 import com.smartgwt.client.widgets.grid.ListGridField; 10 import com.smartgwt.client.widgets.grid.ListGridField;
17 import com.smartgwt.client.widgets.grid.ListGridRecord; 11 import com.smartgwt.client.widgets.grid.ListGridRecord;
18 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; 12 import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
19 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; 13 import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
20 import com.smartgwt.client.widgets.layout.HLayout;
21 import com.smartgwt.client.widgets.layout.VLayout;
22 14
23 import de.intevation.flys.client.client.FLYS; 15 import de.intevation.flys.client.client.FLYS;
24 import de.intevation.flys.client.shared.model.Data; 16 import de.intevation.flys.client.shared.model.Data;
25 import de.intevation.flys.client.shared.model.DataItem; 17 import de.intevation.flys.client.shared.model.DataItem;
26 import de.intevation.flys.client.shared.model.DataList; 18 import de.intevation.flys.client.shared.model.DataList;
84 } 76 }
85 } 77 }
86 78
87 private void addGauge(GaugeInfo gauge) { 79 private void addGauge(GaugeInfo gauge) {
88 this.addData(new GaugeRecord(gauge)); 80 this.addData(new GaugeRecord(gauge));
89 }
90
91
92 class GaugeInfoHead extends HLayout {
93
94 public GaugeInfoHead(FLYS flys, GaugeInfo gauge) {
95 setStyleName("gaugeinfohead");
96 setAutoHeight();
97 setAutoWidth();
98
99 NumberFormat nf = NumberFormat.getDecimalFormat();
100
101 Label label = new Label(gauge.getName());
102 addMember(label);
103
104 Double start;
105 Double end;
106
107 if (!gauge.isKmUp()) {
108 start = gauge.getKmStart();
109 end = gauge.getKmEnd();
110 }
111 else {
112 start = gauge.getKmEnd();
113 end = gauge.getKmStart();
114 }
115
116 String kmtext = "";
117 if (start != null) {
118 kmtext += nf.format(start);
119 kmtext += " - ";
120 }
121 if (end != null) {
122 kmtext += nf.format(end);
123 }
124 if (start != null || end != null) {
125 kmtext += " km";
126 }
127
128 label = new Label(kmtext);
129
130 addMember(label);
131
132 Double station = gauge.getStation();
133 if (station != null) {
134 String stext = nf.format(station);
135 stext += " km";
136 label = new Label(stext);
137 addMember(label);
138 }
139
140 Long number = gauge.getOfficialNumber();
141 String url = number != null ?
142 MSG.gauge_url() + number :
143 MSG.gauge_url();
144 Anchor anchor = new Anchor(MSG.gauge_info_link(), url, "_blank");
145 addMember(anchor);
146
147 addMember(new GaugeCurveAnchor(flys, gauge));
148 }
149 }
150
151 class GaugeCurveAnchor extends Anchor implements ClickHandler {
152
153 private FLYS flys;
154 private GaugeInfo gauge;
155
156 public GaugeCurveAnchor(FLYS flys, GaugeInfo gauge) {
157 super(MSG.gauge_curve_link());
158 this.flys = flys;
159 this.gauge = gauge;
160
161 addClickHandler(this);
162 }
163
164 @Override
165 public void onClick(ClickEvent ev) {
166 GWT.log("GaugeCurveAnchor - onClick " + gauge.getRiverName() +
167 " " + gauge.getOfficialNumber());
168 flys.newGaugeDischargeCurve(gauge.getRiverName(),
169 gauge.getOfficialNumber());
170 }
171 }
172
173 class GaugeInfoPanel extends VLayout {
174
175 public GaugeInfoPanel(GaugeInfo gauge) {
176 setStyleName("gaugeinfopanel");
177 setWidth100();
178
179 Grid grid = new Grid(4, 2);
180
181 NumberFormat nf = NumberFormat.getDecimalFormat();
182
183 Double minw = gauge.getMinW();
184 Double maxw = gauge.getMaxW();
185 if (minw != null && maxw != null) {
186 grid.setText(0, 0, MSG.wq_value_q());
187 grid.setText(0, 1, nf.format(minw) +
188 " - " + nf.format(maxw));
189 }
190
191 Double minq = gauge.getMinQ();
192 Double maxq = gauge.getMaxQ();
193 if (minq != null && maxq != null) {
194 grid.setText(1, 0, MSG.wq_value_w());
195 grid.setText(1, 1, nf.format(minq) +
196 " - " + nf.format(maxq));
197 }
198
199 Double aeo = gauge.getAeo();
200 if (aeo != null) {
201 grid.setText(2, 0, "AEO [kmĀ²]");
202 grid.setText(2, 1, nf.format(aeo));
203 }
204
205 Double datum = gauge.getDatum();
206 if (datum != null) {
207 grid.setText(3, 0, MSG.gauge_zero() + " [" +
208 gauge.getWstUnit() + "]");
209 grid.setText(3, 1, nf.format(datum));
210 }
211
212 addMember(grid);
213 }
214 } 81 }
215 82
216 public void open() { 83 public void open() {
217 ArrayList<Double> locations = new ArrayList<Double>(); 84 ArrayList<Double> locations = new ArrayList<Double>();
218 85

http://dive4elements.wald.intevation.org