Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java @ 3610:66f539df4e8b
Issue 716.
FixA: Spilt reference and analysis period themes into one theme for each event.
flys-artifacts/trunk@5239 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 23 Aug 2012 08:49:37 +0000 |
parents | 988ec06c400a |
children | a74bdd032cf7 |
comparison
equal
deleted
inserted
replaced
3609:a16837d73130 | 3610:66f539df4e8b |
---|---|
241 | 241 |
242 addAxisDataset(tsc, 0, visible); | 242 addAxisDataset(tsc, 0, visible); |
243 addAttribute(desc, "outline"); | 243 addAttribute(desc, "outline"); |
244 Map<Integer, int[]> annoIdxMap = new HashMap<Integer, int[]>(); | 244 Map<Integer, int[]> annoIdxMap = new HashMap<Integer, int[]>(); |
245 annoIdxMap.put (0, new int[]{0,0}); | 245 annoIdxMap.put (0, new int[]{0,0}); |
246 doQWDTextAnnotations(annoIdxMap, tsc, new QWD[]{qwd.qwd}, theme, visible); | 246 doQWDTextAnnotations(annoIdxMap, tsc, qwd.qwd, theme, visible); |
247 } | 247 } |
248 | 248 |
249 | 249 |
250 protected void doAnalysisEventsOut( | 250 protected void doAnalysisEventsOut( |
251 FLYSArtifact artifact, | 251 FLYSArtifact artifact, |
254 Document theme, | 254 Document theme, |
255 boolean visible | 255 boolean visible |
256 ) { | 256 ) { |
257 logger.debug("doAnalysisEventsOut: desc = " + desc); | 257 logger.debug("doAnalysisEventsOut: desc = " + desc); |
258 | 258 |
259 QWD[] qwds = (QWD[]) data; | 259 QWD qwd = (QWD) data; |
260 doQWDEventsOut(qwds, desc, theme, visible); | 260 doQWDEventsOut(qwd, desc, theme, visible); |
261 } | 261 } |
262 | 262 |
263 | 263 |
264 protected void doQWDEventsOut(QWD[] qwds, String desc, Document theme, boolean visible) | 264 protected void doQWDEventsOut(QWD qwd, String desc, Document theme, boolean visible) |
265 { | 265 { |
266 TimeSeriesCollection tsc = new TimeSeriesCollection(); | 266 TimeSeriesCollection tsc = new TimeSeriesCollection(); |
267 | 267 |
268 TimeSeries series = new StyledTimeSeries(desc, theme); | 268 TimeSeries series = new StyledTimeSeries(desc, theme); |
269 TimeSeries interpol = new StyledTimeSeries(desc + "interpol", theme); | 269 TimeSeries interpol = new StyledTimeSeries(desc + "interpol", theme); |
270 | 270 |
271 if (qwds == null) { | 271 if (qwd == null) { |
272 logger.debug("doQWDEventsOut: qwds == null"); | 272 logger.debug("doQWDEventsOut: qwd == null"); |
273 return; | |
274 } | |
275 | |
276 if (qwds.length == 0) { | |
277 logger.debug("doQWDEventsOut: qwds.length == 0"); | |
278 return; | 273 return; |
279 } | 274 } |
280 | 275 |
281 Map<Integer, int[]> annoIdxMap = new HashMap<Integer, int[]>(); | 276 Map<Integer, int[]> annoIdxMap = new HashMap<Integer, int[]>(); |
282 | 277 |
283 int idxInterpol = 0; | 278 int idxInterpol = 0; |
284 int idxRegular = 0; | 279 int idxRegular = 0; |
285 for (int i = 0; i < qwds.length; i++) { | 280 RegularTimePeriod rtp = new Day(qwd.getDate()); |
286 if (qwds[i] == null) { | 281 double value = qwd.getDeltaW(); |
287 logger.debug("doQWDEventsOut: qwds[" + i + "] == null"); | 282 boolean interpolate = qwd.getInterpolated(); |
288 continue; | 283 if (interpolate) { |
284 if(interpol.addOrUpdate(rtp, value) == null) { | |
285 annoIdxMap.put( | |
286 0, | |
287 new int[]{1, idxInterpol}); | |
288 idxInterpol++; | |
289 } | 289 } |
290 RegularTimePeriod rtp = new Day(qwds[i].getDate()); | 290 } |
291 double value = qwds[i].getDeltaW(); | 291 else { |
292 boolean interpolate = qwds[i].getInterpolated(); | 292 if(series.addOrUpdate(rtp, value) == null) { |
293 if (interpolate) { | 293 annoIdxMap.put( |
294 if(interpol.addOrUpdate(rtp, value) == null) { | 294 0, |
295 annoIdxMap.put( | 295 new int[]{0, idxRegular}); |
296 i, | 296 idxRegular++; |
297 new int[]{1, idxInterpol}); | |
298 idxInterpol++; | |
299 } | |
300 } | 297 } |
301 else { | 298 } |
302 if(series.addOrUpdate(rtp, value) == null) { | 299 |
303 annoIdxMap.put( | |
304 i, | |
305 new int[]{0, idxRegular}); | |
306 idxRegular++; | |
307 } | |
308 } | |
309 } | |
310 tsc.addSeries(series); | 300 tsc.addSeries(series); |
311 tsc.addSeries(interpol); | 301 tsc.addSeries(interpol); |
312 addAxisDataset(tsc, 0, visible); | 302 addAxisDataset(tsc, 0, visible); |
313 addAttribute(desc + "interpol", "interpolate"); | 303 addAttribute(desc + "interpol", "interpolate"); |
314 addAttribute(desc, "outline"); | 304 addAttribute(desc, "outline"); |
315 | 305 |
316 doQWDTextAnnotations(annoIdxMap, tsc, qwds, theme, visible); | 306 doQWDTextAnnotations(annoIdxMap, tsc, qwd, theme, visible); |
317 } | 307 } |
318 | 308 |
319 | 309 |
320 /** | 310 /** |
321 * @param annoIdxMap map of index in qwds to series/data item indices in tsc. | 311 * @param annoIdxMap map of index in qwds to series/data item indices in tsc. |
322 */ | 312 */ |
323 protected void doQWDTextAnnotations(Map<Integer, int[]> annoIdxMap, | 313 protected void doQWDTextAnnotations(Map<Integer, int[]> annoIdxMap, |
324 TimeSeriesCollection tsc, QWD[] qwds, Document theme, | 314 TimeSeriesCollection tsc, QWD qwd, Document theme, |
325 boolean visible) { | 315 boolean visible) { |
326 logger.debug("doQWDTextAnnotation()"); | 316 logger.debug("doQWDTextAnnotation()"); |
327 | 317 |
328 if (!visible || !ThemeUtil.parseShowPointLabel(theme)) { | 318 if (!visible || !ThemeUtil.parseShowPointLabel(theme)) { |
329 logger.debug("doQWDTextAnnotation: annotation not visible"); | 319 logger.debug("doQWDTextAnnotation: annotation not visible"); |
332 | 322 |
333 List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>(); | 323 List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>(); |
334 Set<Map.Entry<Integer, int[]>> entries = annoIdxMap.entrySet(); | 324 Set<Map.Entry<Integer, int[]>> entries = annoIdxMap.entrySet(); |
335 | 325 |
336 for(Map.Entry<Integer, int[]> entry : entries) { | 326 for(Map.Entry<Integer, int[]> entry : entries) { |
337 QWD qwd = qwds[entry.getKey()]; | |
338 int[] idxs = entry.getValue(); | 327 int[] idxs = entry.getValue(); |
339 double x = tsc.getXValue(idxs[0], idxs[1]); | 328 double x = tsc.getXValue(idxs[0], idxs[1]); |
340 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( | 329 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( |
341 qwd.getQ() + " m\u00B3/s", | 330 qwd.getQ() + " m\u00B3/s", |
342 x, | 331 x, |
357 Document theme, | 346 Document theme, |
358 boolean visible | 347 boolean visible |
359 ) { | 348 ) { |
360 logger.debug("doReferenceEventsOut: desc = " + desc); | 349 logger.debug("doReferenceEventsOut: desc = " + desc); |
361 | 350 |
362 QWD[] qwds = (QWD[]) data; | 351 QWD qwd = (QWD) data; |
363 doQWDEventsOut(qwds, desc, theme, visible); | 352 doQWDEventsOut(qwd, desc, theme, visible); |
364 } | 353 } |
365 | 354 |
366 | 355 |
367 protected void doDeviationOut( | 356 protected void doDeviationOut( |
368 FLYSArtifact artifact, | 357 FLYSArtifact artifact, |