comparison artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java @ 9354:13bbc75ed0bc

Change theme legend label if interpolated
author gernotbelger
date Tue, 31 Jul 2018 18:12:19 +0200
parents a3f318347707
children ddcd52d239cd
comparison
equal deleted inserted replaced
9353:217e8e59c386 9354:13bbc75ed0bc
322 double factor = atGauge ? 100d : 1d; 322 double factor = atGauge ? 100d : 1d;
323 323
324 double w = factor*(qwd.getW()-gaugeDatum); 324 double w = factor*(qwd.getW()-gaugeDatum);
325 325
326 final ThemeDocument theme = configureThemeInterpolated(doc, qwd); 326 final ThemeDocument theme = configureThemeInterpolated(doc, qwd);
327 327 final XYSeries series = createQWDSeries(aaf, theme, qwd, qwd.getQ(), qwd.getQ());
328 final XYSeries series = new StyledXYSeries( aaf.getFacetDescription(), theme, getWQDShape(qwd));
329 series.add(qwd.getQ(), w);
330 328
331 addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible); 329 addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible);
332 330
333 if (visible && theme.parseShowPointLabel()) { 331 if (visible && theme.parseShowPointLabel()) {
334 332
360 if (qwd == null) { 358 if (qwd == null) {
361 log.debug("doReferenceEventsOut: qwds == null"); 359 log.debug("doReferenceEventsOut: qwds == null");
362 return; 360 return;
363 } 361 }
364 362
365 // Force empty symbol.
366 final ThemeDocument theme = configureThemeInterpolated(doc, qwd);
367
368 XYSeries series = new StyledXYSeries(
369 aaf.getFacetDescription(),
370 false, true, theme, getWQDShape(qwd));
371
372 double gaugeDatum = getCurrentGaugeDatum(); 363 double gaugeDatum = getCurrentGaugeDatum();
373 364
374 boolean atGauge = gaugeDatum != 0d; 365 boolean atGauge = gaugeDatum != 0d;
375 366
376 double factor = atGauge ? 100d : 1d; 367 double factor = atGauge ? 100d : 1d;
377 double w = factor*(qwd.getW()-gaugeDatum); 368 double w = factor*(qwd.getW()-gaugeDatum);
378 369
370 final ThemeDocument theme = configureThemeInterpolated(doc, qwd);
371 final XYSeries series = createQWDSeries(aaf, theme, qwd, qwd.getQ(), w);
379 series.add(qwd.getQ(), w, false); 372 series.add(qwd.getQ(), w, false);
380 373
381 if (visible && theme.parseShowPointLabel()) { 374 if (visible && theme.parseShowPointLabel()) {
382 DateFormat dateFormat = DateFormat.getDateInstance( 375 DateFormat dateFormat = DateFormat.getDateInstance(
383 DateFormat.SHORT); 376 DateFormat.SHORT);
396 } 389 }
397 390
398 addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible); 391 addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible);
399 } 392 }
400 393
394
395 public static XYSeries createQWDSeries(final ArtifactAndFacet bundle, final ThemeDocument theme, final QWI qwd) {
396 return createQWDSeries(bundle, theme, qwd, qwd.getQ(), qwd.getW());
397 }
398
399 public static XYSeries createQWDSeries(final ArtifactAndFacet bundle, final ThemeDocument theme, final QWI qwd, double q, double w) {
400
401 final String description = buildQWDSeriesLabel(qwd, bundle.getFacetDescription());
402
403 final XYSeries series = new StyledXYSeries( description, theme, FixWQCurveGenerator.getWQDShape(qwd) );
404
405 series.add(q, w, false);
406
407 return series;
408 }
409
401 public static Shape getWQDShape(final QWI qwd) { 410 public static Shape getWQDShape(final QWI qwd) {
402 final boolean isOutlier = qwd instanceof QWD ? ((QWD) qwd).isOutlier() : false; 411 final boolean isOutlier = qwd instanceof QWD ? ((QWD) qwd).isOutlier() : false;
403 412
404 // if( isOutlier) 413 // if( isOutlier)
405 // return ShapeUtils.DIGITIZED_SHAPE; 414 // return ShapeUtils.DIGITIZED_SHAPE;
428 437
429 newTheme.setValue(ThemeDocument.SHOW_POINTS, Boolean.toString(doFill)); 438 newTheme.setValue(ThemeDocument.SHOW_POINTS, Boolean.toString(doFill));
430 newTheme.setValue(ThemeDocument.SHOW_POINTS_OUTLINE, Boolean.toString(doOutline)); 439 newTheme.setValue(ThemeDocument.SHOW_POINTS_OUTLINE, Boolean.toString(doOutline));
431 440
432 return newTheme; 441 return newTheme;
442 }
443
444 public static String buildQWDSeriesLabel(final QWI qwd, final String facetDescription) {
445
446 StringBuilder buffer = new StringBuilder( facetDescription );
447
448 final boolean isOutlier = qwd instanceof QWD ? ((QWD) qwd).isOutlier() : false;
449 boolean isInterpolated = qwd.getInterpolated();
450
451 if( !isOutlier && !isInterpolated )
452 return buffer.toString();
453
454 buffer.append(" (");
455 if( isInterpolated )
456 {
457 buffer.append("interpoliert");
458 if( isOutlier )
459 buffer.append(", ");
460 }
461
462 if( isOutlier )
463 buffer.append("Ausreißer");
464
465 buffer.append(")");
466
467 return buffer.toString();
433 } 468 }
434 469
435 private void addPointFromWQKms(WQKms wqkms, 470 private void addPointFromWQKms(WQKms wqkms,
436 String title, 471 String title,
437 ThemeDocument theme, 472 ThemeDocument theme,

http://dive4elements.wald.intevation.org