changeset 7808:ea6b441b4872 minfo-opt

Calculate the zoom dependent radius and add the informations to chart subtitle.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 07 Mar 2014 11:15:38 +0100
parents ad4a3980092f
children 521865ad8512
files artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/WDiffProcessor.java
diffstat 3 files changed, 81 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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;
 
--- 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) {

http://dive4elements.wald.intevation.org