[PATCH 1 of 2] Change theme legend label if interpolated

Wald Commits scm-commit at wald.intevation.org
Tue Jul 31 18:12:42 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1533053539 -7200
# Node ID 13bbc75ed0bc00bf74fafd023a6bc322ac52aa0c
# Parent  217e8e59c3867ae44779f7c55520cfe66da3e54e
Change theme legend label if interpolated

diff -r 217e8e59c386 -r 13bbc75ed0bc artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java	Tue Jul 31 17:53:41 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java	Tue Jul 31 18:12:19 2018 +0200
@@ -326,6 +326,7 @@
         }
 
         final ThemeDocument themeInterpolated = FixWQCurveGenerator.configureThemeInterpolated(theme, qwd);
+        final String label = FixWQCurveGenerator.buildQWDSeriesLabel(qwd, desc);
         
         final Map<Integer, int[]> annoIdxMap = new HashMap<>();
  
@@ -333,7 +334,7 @@
         final RegularTimePeriod rtp = new FixedMillisecond(time);
         final double value =  qwd.getDeltaW();
 
-        final TimeSeries series = new StyledTimeSeries(desc, themeInterpolated);
+        final TimeSeries series = new StyledTimeSeries(label, themeInterpolated);
         series.addOrUpdate(rtp, value);
 
         tsc.addSeries(series);
diff -r 217e8e59c386 -r 13bbc75ed0bc artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java	Tue Jul 31 17:53:41 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java	Tue Jul 31 18:12:19 2018 +0200
@@ -324,9 +324,7 @@
         double w = factor*(qwd.getW()-gaugeDatum);
 
         final ThemeDocument theme = configureThemeInterpolated(doc, qwd);
-
-        final XYSeries series = new StyledXYSeries( aaf.getFacetDescription(), theme, getWQDShape(qwd));
-        series.add(qwd.getQ(), w);
+        final XYSeries series = createQWDSeries(aaf, theme, qwd, qwd.getQ(), qwd.getQ());
 
         addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible);
 
@@ -362,20 +360,15 @@
             return;
         }
 
-        // Force empty symbol.
-        final ThemeDocument theme = configureThemeInterpolated(doc, qwd);
-
-        XYSeries series = new StyledXYSeries(
-            aaf.getFacetDescription(),
-            false, true, theme, getWQDShape(qwd));
-
         double gaugeDatum = getCurrentGaugeDatum();
-
+        
         boolean atGauge = gaugeDatum != 0d;
-
+        
         double factor = atGauge ? 100d : 1d;
         double w = factor*(qwd.getW()-gaugeDatum);
-
+        
+        final ThemeDocument theme = configureThemeInterpolated(doc, qwd);
+        final XYSeries series = createQWDSeries(aaf, theme, qwd, qwd.getQ(), w);
         series.add(qwd.getQ(), w, false);
 
         if (visible && theme.parseShowPointLabel()) {
@@ -398,6 +391,22 @@
         addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible);
     }
 
+        
+    public static XYSeries createQWDSeries(final ArtifactAndFacet bundle, final ThemeDocument theme, final QWI qwd) {
+        return createQWDSeries(bundle, theme, qwd, qwd.getQ(), qwd.getW());
+    }
+    
+    public static XYSeries createQWDSeries(final ArtifactAndFacet bundle, final ThemeDocument theme, final QWI qwd, double q, double w) {
+        
+        final String description = buildQWDSeriesLabel(qwd, bundle.getFacetDescription());
+        
+        final XYSeries series = new StyledXYSeries( description, theme, FixWQCurveGenerator.getWQDShape(qwd) );
+
+        series.add(q, w, false);
+
+        return series;
+    }
+
     public static Shape getWQDShape(final QWI qwd) {
         final boolean isOutlier = qwd instanceof QWD ? ((QWD) qwd).isOutlier() : false;
 
@@ -430,6 +439,32 @@
         newTheme.setValue(ThemeDocument.SHOW_POINTS_OUTLINE, Boolean.toString(doOutline));
 
         return newTheme;
+    }    
+    
+    public static String buildQWDSeriesLabel(final QWI qwd, final String facetDescription) {
+
+        StringBuilder buffer = new StringBuilder( facetDescription );
+        
+        final boolean isOutlier = qwd instanceof QWD ? ((QWD) qwd).isOutlier() : false;
+        boolean isInterpolated = qwd.getInterpolated();
+        
+        if( !isOutlier && !isInterpolated )
+            return buffer.toString();
+
+        buffer.append(" (");
+        if( isInterpolated )
+        {
+            buffer.append("interpoliert");
+            if( isOutlier )
+                buffer.append(", ");
+        }
+
+        if( isOutlier )
+            buffer.append("Ausreißer");
+        
+        buffer.append(")");
+        
+        return buffer.toString();
     }
 
     private void addPointFromWQKms(WQKms wqkms,
diff -r 217e8e59c386 -r 13bbc75ed0bc artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java	Tue Jul 31 17:53:41 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java	Tue Jul 31 18:12:19 2018 +0200
@@ -163,9 +163,7 @@
 
         // prevent potential side effects
         final ThemeDocument themeInterpolated = FixWQCurveGenerator.configureThemeInterpolated(theme, qwd);
-
-        final XYSeries series = new StyledXYSeries( bundle.getFacetDescription(), themeInterpolated, FixWQCurveGenerator.getWQDShape(qwd));
-        series.add(qwd.getQ(), qwd.getW());
+        final XYSeries series = FixWQCurveGenerator.createQWDSeries(bundle, themeInterpolated, qwd);
 
         generator.addAxisSeries(series, axisName, visible);
 
@@ -202,9 +200,9 @@
             return;
         }
 
+        
         final ThemeDocument themeInterpolated = FixWQCurveGenerator.configureThemeInterpolated(theme, qwd);
-
-        final XYSeries series = new StyledXYSeries( bundle.getFacetDescription(), false, true, themeInterpolated, FixWQCurveGenerator.getWQDShape(qwd) );
+        final XYSeries series = FixWQCurveGenerator.createQWDSeries(bundle, themeInterpolated, qwd);
         series.add(qwd.getQ(), qwd.getW(), false);
 
         if (visible && themeInterpolated.parseShowPointLabel()) {


More information about the Dive4Elements-commits mailing list