Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java @ 681:dda282dcc44f
The min/max W/Q ranges in the panel for calculation4 are written into the DESCRIBE.
flys-artifacts/trunk@2110 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 14 Jun 2011 13:54:19 +0000 |
parents | 627be3ca1ab6 |
children | 90ee95945684 |
comparison
equal
deleted
inserted
replaced
680:bcd62609c936 | 681:dda282dcc44f |
---|---|
119 logger.debug("WQAdapted.createValueItems"); | 119 logger.debug("WQAdapted.createValueItems"); |
120 | 120 |
121 FLYSArtifact flysArtifact = (FLYSArtifact) artifact; | 121 FLYSArtifact flysArtifact = (FLYSArtifact) artifact; |
122 | 122 |
123 double[] dist = flysArtifact.getDistance(); | 123 double[] dist = flysArtifact.getDistance(); |
124 River river = flysArtifact.getRiver(); | |
125 Wst wst = WstFactory.getWst(river); | |
124 List<Gauge> gauges = flysArtifact.getGauges(); | 126 List<Gauge> gauges = flysArtifact.getGauges(); |
125 | 127 |
126 int num = gauges != null ? gauges.size() : 0; | 128 int num = gauges != null ? gauges.size() : 0; |
127 | 129 |
128 if (num == 0) { | 130 if (num == 0) { |
145 double upper = range.getB().doubleValue(); | 147 double upper = range.getB().doubleValue(); |
146 | 148 |
147 double from = lower < rangeFrom ? rangeFrom : lower; | 149 double from = lower < rangeFrom ? rangeFrom : lower; |
148 double to = upper > rangeTo ? rangeTo : upper; | 150 double to = upper > rangeTo ? rangeTo : upper; |
149 | 151 |
152 double[] mmQ = determineMinMaxQ(gauge, wst); | |
153 double[] mmW = gauge.determineMinMaxW(); | |
154 | |
150 elements[idx++] = createItem( | 155 elements[idx++] = createItem( |
151 cr, new String[] { from + ";" + to, ""}); | 156 cr, new String[] { from + ";" + to, ""}, mmQ, mmW); |
152 } | 157 } |
153 } | 158 } |
154 else { | 159 else { |
155 Collections.sort(gauges, GAUGE_DOWN); | 160 Collections.sort(gauges, GAUGE_DOWN); |
156 rangeFrom = dist[1]; | 161 rangeFrom = dist[1]; |
171 return elements; | 176 return elements; |
172 } | 177 } |
173 | 178 |
174 | 179 |
175 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { | 180 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { |
181 return createItem(cr, obj, null, null); | |
182 } | |
183 | |
184 | |
185 protected Element createItem( | |
186 XMLUtils.ElementCreator cr, | |
187 Object obj, | |
188 double[] q, | |
189 double[] w) | |
190 { | |
176 Element item = ProtocolUtils.createArtNode(cr, "item", null, null); | 191 Element item = ProtocolUtils.createArtNode(cr, "item", null, null); |
177 Element label = ProtocolUtils.createArtNode(cr, "label", null, null); | 192 Element label = ProtocolUtils.createArtNode(cr, "label", null, null); |
178 Element value = ProtocolUtils.createArtNode(cr, "value", null, null); | 193 Element value = ProtocolUtils.createArtNode(cr, "value", null, null); |
179 | 194 |
180 String[] arr = (String[]) obj; | 195 String[] arr = (String[]) obj; |
183 value.setTextContent(arr[1]); | 198 value.setTextContent(arr[1]); |
184 | 199 |
185 item.appendChild(label); | 200 item.appendChild(label); |
186 item.appendChild(value); | 201 item.appendChild(value); |
187 | 202 |
203 if (q != null) { | |
204 Element qRange = createRangeElement(cr, q, "Q"); | |
205 item.appendChild(qRange); | |
206 } | |
207 | |
208 if (w != null) { | |
209 Element wRange = createRangeElement(cr, w, "W"); | |
210 item.appendChild(wRange); | |
211 } | |
212 | |
188 return item; | 213 return item; |
214 } | |
215 | |
216 | |
217 protected Element createRangeElement( | |
218 XMLUtils.ElementCreator cr, | |
219 double[] mm, | |
220 String type) | |
221 { | |
222 Element range = ProtocolUtils.createArtNode( | |
223 cr, "range", | |
224 new String[] {"type"}, | |
225 new String[] {type}); | |
226 | |
227 Element min = ProtocolUtils.createArtNode(cr, "min", null, null); | |
228 min.setTextContent(String.valueOf(mm[0])); | |
229 | |
230 Element max = ProtocolUtils.createArtNode(cr, "max", null, null); | |
231 max.setTextContent(String.valueOf(mm[1])); | |
232 | |
233 range.appendChild(min); | |
234 range.appendChild(max); | |
235 | |
236 return range; | |
237 } | |
238 | |
239 | |
240 /** | |
241 * Determines the min and max Q value for the given gauge. If no min and | |
242 * max values could be determined, this method will return | |
243 * [Double.MIN_VALUE, Double.MAX_VALUE]. | |
244 * | |
245 * @param gauge | |
246 * @param wst | |
247 * | |
248 * @return the min and max Q values for the given gauge. | |
249 */ | |
250 protected double[] determineMinMaxQ(Gauge gauge, Wst wst) { | |
251 logger.debug("WQAdapted.determineMinMaxQ"); | |
252 | |
253 double[] minmaxQ = gauge != null | |
254 ? wst.determineMinMaxQ(gauge.getRange()) | |
255 : null; | |
256 | |
257 double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE; | |
258 double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE; | |
259 | |
260 return new double[] { minQ, maxQ }; | |
189 } | 261 } |
190 | 262 |
191 | 263 |
192 @Override | 264 @Override |
193 protected String getUIProvider() { | 265 protected String getUIProvider() { |