[PATCH 4 of 5] Calculate the zoom dependent radius and add the informations to chart subtitle

Wald Commits scm-commit at wald.intevation.org
Fri Mar 7 11:17:17 CET 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1394187338 -3600
# Branch minfo-opt
# Node ID ea6b441b48728a0ac26d2df40f8cba70a1cb4c9b
# Parent  ad4a3980092f09ffd89715734721bbba85382b10
Calculate the zoom dependent radius and add the informations to chart subtitle.

diff -r ad4a3980092f -r ea6b441b4872 artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java	Fri Mar 07 11:12:59 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java	Fri Mar 07 11:15:38 2014 +0100
@@ -13,8 +13,13 @@
 
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
+import org.dive4elements.river.artifacts.context.RiverContext;
 import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.ZoomScale;
 import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.exports.StyledSeriesBuilder;
 import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.exports.XYChartGenerator;
@@ -34,6 +39,8 @@
         "chart.beddifference.height.yaxis.label";
     public static final String I18N_AXIS_LABEL_DEFAULT =
         "delta S [cm / Jahr]";
+    public static final String I18N_SUBTITLE_RADIUS =
+        "chart.subtitle.radius";
 
     @Override
     public void doOut(
@@ -49,7 +56,22 @@
             logger.error("Can't process " + data.getClass().getName() + " objects");
             return;
         }
+        Double start = (Double)context.getContextValue("startkm");
+        Double end = (Double)context.getContextValue("endkm");
+        if (start != null && end != null) {
+            D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
+            RiverContext fc = (RiverContext)context.globalContext();
+            // Adaptive smoothing, based on zoom factor/diagram extents.
+            ZoomScale scales = (ZoomScale)fc.get("zoomscale");
+            RiverAccess access = new RiverAccess((D4EArtifact)artifact);
+            String river = access.getRiverName();
 
+            double radius = scales.getRadius(river, start, end);
+            generator.addSubtitle(Resources.getMsg(
+                context.getMeta(),
+                I18N_SUBTITLE_RADIUS,
+                new Object[] { radius }));
+        }
         BedDiffYearResult bData = (BedDiffYearResult) data;
         XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
         StyledSeriesBuilder.addPoints(series, bData.getHeightPerYearData(), false, GAP_TOLERANCE);
diff -r ad4a3980092f -r ea6b441b4872 artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java	Fri Mar 07 11:12:59 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java	Fri Mar 07 11:15:38 2014 +0100
@@ -13,8 +13,13 @@
 
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
+import org.dive4elements.river.artifacts.context.RiverContext;
 import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.ZoomScale;
 import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.exports.StyledSeriesBuilder;
 import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.jfree.StyledXYSeries;
@@ -33,6 +38,8 @@
         "chart.beddifference.yaxis.label.diff";
     public static final String I18N_AXIS_LABEL_DEFAULT =
         "delta S [cm]";
+    public static final String I18N_SUBTITLE_RADIUS =
+        "chart.subtitle.radius";
 
     @Override
     public void doOut(
@@ -43,6 +50,22 @@
         CallContext context = generator.getCallContext();
         Object data = bundle.getData(context);
         if (data instanceof BedDiffYearResult) {
+            Double start = (Double)context.getContextValue("startkm");
+            Double end = (Double)context.getContextValue("endkm");
+            if (start != null && end != null) {
+                D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
+                RiverContext fc = (RiverContext)context.globalContext();
+                // Adaptive smoothing, based on zoom factor/diagram extents.
+                ZoomScale scales = (ZoomScale)fc.get("zoomscale");
+                RiverAccess access = new RiverAccess((D4EArtifact)artifact);
+                String river = access.getRiverName();
+
+                double radius = scales.getRadius(river, start, end);
+                generator.addSubtitle(Resources.getMsg(
+                    context.getMeta(),
+                    I18N_SUBTITLE_RADIUS,
+                    new Object[] { radius }));
+            }
             String facetType = bundle.getFacetName();
             BedDiffYearResult bData = (BedDiffYearResult) data;
 
diff -r ad4a3980092f -r ea6b441b4872 artifacts/src/main/java/org/dive4elements/river/exports/process/WDiffProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/WDiffProcessor.java	Fri Mar 07 11:12:59 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/WDiffProcessor.java	Fri Mar 07 11:15:38 2014 +0100
@@ -8,8 +8,16 @@
 
 package org.dive4elements.river.exports.process;
 
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
+import org.dive4elements.river.artifacts.context.RiverContext;
 import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.ZoomScale;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.themes.ThemeDocument;
 
 public class WDiffProcessor extends WOutProcessor {
 
@@ -18,6 +26,34 @@
 
     public final static String I18N_WDIFF_YAXIS_LABEL_DEFAULT = "m";
 
+    public static final String I18N_SUBTITLE_RADIUS =
+        "chart.subtitle.radius";
+
+    @Override
+    public void doOut(
+            DiagramGenerator generator,
+            ArtifactAndFacet bundle,
+            ThemeDocument    theme,
+            boolean          visible) {
+        CallContext context = generator.getCallContext();
+        Double start = (Double)context.getContextValue("startkm");
+        Double end = (Double)context.getContextValue("endkm");
+        if (start != null && end != null) {
+            D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
+            RiverContext fc = (RiverContext)context.globalContext();
+            // Adaptive smoothing, based on zoom factor/diagram extents.
+            ZoomScale scales = (ZoomScale)fc.get("zoomscale");
+            RiverAccess access = new RiverAccess((D4EArtifact)artifact);
+            String river = access.getRiverName();
+
+            double radius = scales.getRadius(river, start, end);
+            generator.addSubtitle(Resources.getMsg(
+                context.getMeta(),
+                I18N_SUBTITLE_RADIUS,
+                new Object[] { radius }));
+        }
+        super.doOut(generator, bundle, theme, visible);
+    }
     @Override
     public boolean canHandle(String facetType) {
         if (facetType == null) {


More information about the Dive4elements-commits mailing list