comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java @ 4202:1fa244f70ad5

Move RiverInfoPanel to its own java file in refactor it Allow to change the riverinfo without having to create a new instace of the RiverInfoPanel.
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 22 Oct 2012 15:23:00 +0200
parents 9be8d7942284
children de795c13dcfb
comparison
equal deleted inserted replaced
4201:221d255f7ec2 4202:1fa244f70ad5
140 @Override 140 @Override
141 public void show() { 141 public void show() {
142 GWT.log("GaugePanel - show"); 142 GWT.log("GaugePanel - show");
143 this.sectionStack.setHidden(false); 143 this.sectionStack.setHidden(false);
144 } 144 }
145
146 class RiverInfoPanel extends HorizontalPanel {
147
148 public final static int HEIGHT = 30;
149 public final static int BORDER_WIDTH = 3;
150 public final static int PADDING = 8;
151 public final static int MARGIN = 10;
152
153 public RiverInfoPanel(RiverInfo riverinfo) {
154 setStyleName("riverinfopanel");
155 setHeight("" + HEIGHT + "px");
156 setVerticalAlignment(ALIGN_MIDDLE);
157
158 NumberFormat nf = NumberFormat.getDecimalFormat();
159
160 addLabel(riverinfo.getName(), false);
161
162 String kmtext = "";
163 Double start = riverinfo.getKmStart();
164 Double end = riverinfo.getKmEnd();
165
166 if (!riverinfo.isKmUp()) {
167 Double tmp = end;
168 end = start;
169 start = tmp;
170 }
171 if (end != null) {
172 kmtext += nf.format(end);
173 kmtext += " - ";
174 }
175 if (start != null) {
176 kmtext += nf.format(start);
177 }
178 kmtext += " km";
179
180 addLabel(kmtext, false);
181
182 String qtext = "";
183 Double qmin = riverinfo.getMinQ();
184 Double qmax = riverinfo.getMaxQ();
185 if (qmin != null) {
186 qtext += nf.format(qmin);
187 qtext += " " + MSG.gauge_q_unit();
188 qtext += " - ";
189 }
190 if (qmax != null) {
191 qtext += nf.format(qmax);
192 qtext += " " + MSG.gauge_q_unit();
193 }
194
195 addLabel(qtext, false);
196
197 Long number = riverinfo.getOfficialNumber();
198 String url = number != null ?
199 MSG.gauge_river_url() + number :
200 MSG.gauge_river_url();
201 Anchor anchor = new Anchor(MSG.gauge_river_info_link(), url, "_blank");
202 add(anchor);
203 }
204
205 private void addLabel(String text, boolean wordwrap) {
206 Label label = new Label(text, wordwrap);
207 add(label);
208 setCellHeight(label, "" + HEIGHT + "px");
209 }
210 }
211 } 145 }

http://dive4elements.wald.intevation.org