comparison artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java @ 9325:094ed9d1f2ad

Fixed: change of point style of interpolated data did not change in WQ chart of fixanalysis Fixed: change of point style of interpolated data did not change in dWt chart of fixanalysis; also had duplicate legend entries
author gernotbelger
date Fri, 27 Jul 2018 14:33:41 +0200
parents 1cc7653ca84f
children 13bbc75ed0bc
comparison
equal deleted inserted replaced
9324:058701d91552 9325:094ed9d1f2ad
173 173
174 final CallContext context = getContext(); 174 final CallContext context = getContext();
175 175
176 if (name.contains(FIX_SECTOR_AVERAGE_DWT)) { 176 if (name.contains(FIX_SECTOR_AVERAGE_DWT)) {
177 doSectorAverageOut( 177 doSectorAverageOut(
178 (D4EArtifact) artifactFacet.getArtifact(),
179 artifactFacet.getData(context), 178 artifactFacet.getData(context),
180 artifactFacet.getFacetDescription(), 179 artifactFacet.getFacetDescription(),
181 theme, 180 theme,
182 visible); 181 visible);
183 } 182 }
184 else if (name.equals(FIX_REFERENCE_EVENTS_DWT)) { 183 else if (name.equals(FIX_REFERENCE_EVENTS_DWT)) {
185 doReferenceEventsOut( 184 doReferenceEventsOut(
186 (D4EArtifact) artifactFacet.getArtifact(),
187 artifactFacet.getData(context), 185 artifactFacet.getData(context),
188 artifactFacet.getFacetDescription(), 186 artifactFacet.getFacetDescription(),
189 theme, 187 theme,
190 visible); 188 visible);
191 } 189 }
192 else if (name.equals(FIX_ANALYSIS_EVENTS_DWT)) { 190 else if (name.equals(FIX_ANALYSIS_EVENTS_DWT)) {
193 doAnalysisEventsOut( 191 doAnalysisEventsOut(
194 (D4EArtifact) artifactFacet.getArtifact(),
195 artifactFacet.getData(context), 192 artifactFacet.getData(context),
196 artifactFacet.getFacetDescription(), 193 artifactFacet.getFacetDescription(),
197 theme, 194 theme,
198 visible); 195 visible);
199 } 196 }
200 else if (name.equals(FIX_DEVIATION_DWT)) { 197 else if (name.equals(FIX_DEVIATION_DWT)) {
201 doDeviationOut( 198 doDeviationOut(
202 (D4EArtifact) artifactFacet.getArtifact(),
203 artifactFacet.getData(context), 199 artifactFacet.getData(context),
204 artifactFacet.getFacetDescription(), 200 artifactFacet.getFacetDescription(),
205 theme, 201 theme,
206 visible); 202 visible);
207 } 203 }
208 else if (name.equals(FIX_ANALYSIS_PERIODS_DWT)) { 204 else if (name.equals(FIX_ANALYSIS_PERIODS_DWT)) {
209 doAnalysisPeriodsOut( 205 doAnalysisPeriodsOut(
210 (D4EArtifact) artifactFacet.getArtifact(),
211 artifactFacet.getData(context), 206 artifactFacet.getData(context),
212 artifactFacet.getFacetDescription(),
213 theme, 207 theme,
214 visible); 208 visible);
215 } 209 }
216 else if (name.equals(FIX_REFERENCE_PERIOD_DWT)) { 210 else if (name.equals(FIX_REFERENCE_PERIOD_DWT)) {
217 doReferencePeriodsOut( 211 doReferencePeriodsOut(
218 (D4EArtifact) artifactFacet.getArtifact(), 212 (D4EArtifact) artifactFacet.getArtifact(),
219 artifactFacet.getData(context),
220 artifactFacet.getFacetDescription(),
221 theme, 213 theme,
222 visible); 214 visible);
223 } 215 }
224 else if (FacetTypes.IS.MANUALPOINTS(name)) { 216 else if (FacetTypes.IS.MANUALPOINTS(name)) {
225 doPoints (artifactFacet.getData(context), 217 doPoints (artifactFacet.getData(context),
233 } 225 }
234 226
235 227
236 protected void doReferencePeriodsOut( 228 protected void doReferencePeriodsOut(
237 D4EArtifact artifact, 229 D4EArtifact artifact,
238 Object data,
239 String desc,
240 ThemeDocument theme, 230 ThemeDocument theme,
241 boolean visible) 231 boolean visible)
242 { 232 {
243 log.debug("doReferencePeriodsOut()"); 233 log.debug("doReferencePeriodsOut()");
244 234
262 : uniqueDate(date+30L*1000L); // add 30secs. 252 : uniqueDate(date+30L*1000L); // add 30secs.
263 } 253 }
264 254
265 255
266 protected void doSectorAverageOut( 256 protected void doSectorAverageOut(
267 D4EArtifact artifact,
268 Object data, 257 Object data,
269 String desc, 258 String desc,
270 ThemeDocument theme, 259 ThemeDocument theme,
271 boolean visible) 260 boolean visible)
272 { 261 {
292 tsc.addSeries(series); 281 tsc.addSeries(series);
293 282
294 addAxisDataset(tsc, 0, visible); 283 addAxisDataset(tsc, 0, visible);
295 284
296 if (visible && theme.parseShowLineLabel()) { 285 if (visible && theme.parseShowLineLabel()) {
297 List<XYTextAnnotation> textAnnos = 286 List<XYTextAnnotation> textAnnos = new ArrayList<>();
298 new ArrayList<XYTextAnnotation>();
299 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( 287 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
300 "\u0394 W(t) [cm] " 288 "\u0394 W(t) [cm] "
301 + (float)Math.round(qwd.qwd.getDeltaW() * 10000) / 10000, 289 + (float)Math.round(qwd.qwd.getDeltaW() * 10000) / 10000,
302 tsc.getXValue(0, 0), 290 tsc.getXValue(0, 0),
303 qwd.qwd.getDeltaW()); 291 qwd.qwd.getDeltaW());
310 } 298 }
311 } 299 }
312 300
313 301
314 protected void doAnalysisEventsOut( 302 protected void doAnalysisEventsOut(
315 D4EArtifact artifact,
316 Object data, 303 Object data,
317 String desc, 304 String desc,
318 ThemeDocument theme, 305 ThemeDocument theme,
319 boolean visible 306 boolean visible
320 ) { 307 ) {
329 QWD qwd, 316 QWD qwd,
330 String desc, 317 String desc,
331 ThemeDocument theme, 318 ThemeDocument theme,
332 boolean visible 319 boolean visible
333 ) { 320 ) {
334 TimeSeriesCollection tsc = new TimeSeriesCollection(); 321 final TimeSeriesCollection tsc = new TimeSeriesCollection();
335
336 TimeSeries series = new StyledTimeSeries(desc, theme);
337 TimeSeries interpol = new StyledTimeSeries(desc + "interpol", theme);
338 322
339 if (qwd == null) { 323 if (qwd == null) {
340 log.debug("doQWDEventsOut: qwd == null"); 324 log.debug("doQWDEventsOut: qwd == null");
341 return; 325 return;
342 } 326 }
343 327
344 Map<Integer, int[]> annoIdxMap = new HashMap<Integer, int[]>(); 328 final ThemeDocument themeInterpolated = FixWQCurveGenerator.configureThemeInterpolated(theme, qwd);
345 329
346 int idxInterpol = 0; 330 final Map<Integer, int[]> annoIdxMap = new HashMap<>();
347 int idxRegular = 0; 331
348 long time = uniqueDate(qwd.getDate().getTime()); 332 final long time = uniqueDate(qwd.getDate().getTime());
349 RegularTimePeriod rtp = new FixedMillisecond(time); 333 final RegularTimePeriod rtp = new FixedMillisecond(time);
350 double value = qwd.getDeltaW(); 334 final double value = qwd.getDeltaW();
351 boolean interpolate = qwd.getInterpolated(); 335
352 if (interpolate) { 336 final TimeSeries series = new StyledTimeSeries(desc, themeInterpolated);
353 if(interpol.addOrUpdate(rtp, value) == null) { 337 series.addOrUpdate(rtp, value);
354 annoIdxMap.put(
355 0,
356 new int[]{1, idxInterpol});
357 idxInterpol++;
358 }
359 }
360 else {
361 if(series.addOrUpdate(rtp, value) == null) {
362 annoIdxMap.put(
363 0,
364 new int[]{0, idxRegular});
365 idxRegular++;
366 }
367 }
368 338
369 tsc.addSeries(series); 339 tsc.addSeries(series);
370 tsc.addSeries(interpol); 340
371 addAxisDataset(tsc, 0, visible); 341 addAxisDataset(tsc, 0, visible);
372 addAttribute(desc + "interpol", "interpolate");
373 addAttribute(desc, "outline");
374 342
375 doQWDTextAnnotations(annoIdxMap, tsc, qwd, theme, visible); 343 doQWDTextAnnotations(annoIdxMap, tsc, qwd, theme, visible);
376 } 344 }
377
378 345
379 /** 346 /**
380 * @param annoIdxMap map of index in qwds to series/data item indices 347 * @param annoIdxMap map of index in qwds to series/data item indices
381 * in tsc. 348 * in tsc.
382 */ 349 */
383 protected void doQWDTextAnnotations(Map<Integer, int[]> annoIdxMap, 350 private void doQWDTextAnnotations(Map<Integer, int[]> annoIdxMap,
384 TimeSeriesCollection tsc, QWD qwd, ThemeDocument theme, 351 TimeSeriesCollection tsc, QWD qwd, ThemeDocument theme,
385 boolean visible) { 352 boolean visible) {
386 log.debug("doQWDTextAnnotation()"); 353 log.debug("doQWDTextAnnotation()");
387 354
388 if (!visible || !theme.parseShowPointLabel()) { 355 if (!visible || !theme.parseShowPointLabel()) {
393 Locale locale = Resources.getLocale(getContext().getMeta()); 360 Locale locale = Resources.getLocale(getContext().getMeta());
394 NumberFormat nf = NumberFormat.getInstance(locale); 361 NumberFormat nf = NumberFormat.getInstance(locale);
395 362
396 List<XYTextAnnotation> textAnnos = new ArrayList<>(); 363 List<XYTextAnnotation> textAnnos = new ArrayList<>();
397 364
398 for (int[] idxs: annoIdxMap.values()) { 365 final double x = tsc.getXValue(0, 0);
399 366
400 double x = tsc.getXValue(idxs[0], idxs[1]); 367 String text = nf.format(qwd.getQ()) + " m\u00B3/s";
401 368 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( text, x, qwd.getDeltaW());
402 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( 369 textAnnos.add(anno);
403 nf.format(qwd.getQ()) + " m\u00B3/s",
404 x,
405 qwd.getDeltaW());
406 textAnnos.add(anno);
407 }
408 370
409 RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme); 371 RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme);
410 flysAnno.setTextAnnotations(textAnnos); 372 flysAnno.setTextAnnotations(textAnnos);
411 addAnnotations(flysAnno); 373 addAnnotations(flysAnno);
412 } 374 }
413 375
414
415 protected void doReferenceEventsOut( 376 protected void doReferenceEventsOut(
416 D4EArtifact artifact,
417 Object data, 377 Object data,
418 String desc, 378 String desc,
419 ThemeDocument theme, 379 ThemeDocument theme,
420 boolean visible 380 boolean visible
421 ) { 381 ) {
425 doQWDEventsOut(qwd, desc, theme, visible); 385 doQWDEventsOut(qwd, desc, theme, visible);
426 } 386 }
427 387
428 388
429 protected void doDeviationOut( 389 protected void doDeviationOut(
430 D4EArtifact artifact,
431 Object data, 390 Object data,
432 String desc, 391 String desc,
433 ThemeDocument theme, 392 ThemeDocument theme,
434 boolean visible 393 boolean visible
435 ) { 394 ) {
449 valueMarker.add(upper); 408 valueMarker.add(upper);
450 } 409 }
451 410
452 411
453 protected void doAnalysisPeriodsOut( 412 protected void doAnalysisPeriodsOut(
454 D4EArtifact artifact,
455 Object data, 413 Object data,
456 String desc,
457 ThemeDocument theme, 414 ThemeDocument theme,
458 boolean visible) 415 boolean visible)
459 { 416 {
460 DateRange[] ranges = (DateRange[]) data; 417 DateRange[] ranges = (DateRange[]) data;
461 if (ranges == null || !visible) { 418 if (ranges == null || !visible) {
496 StyledValueMarker marker = 453 StyledValueMarker marker =
497 new StyledValueMarker(0, new ThemeDocument(request)); 454 new StyledValueMarker(0, new ThemeDocument(request));
498 valueMarker.add(marker); 455 valueMarker.add(marker);
499 } 456 }
500 } 457 }
501 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org