changeset 7892:e844be34a606 facet-metadata

Add metadata to chart series and datasets.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 21 May 2014 11:40:14 +0200
parents 4fe290eddb43
children 56e7e6c18c26
files artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java 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/BedHeightProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/BedQualityDensityProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/BedQualityDiameterProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/BedQualityPorosityProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/FlowVelocityProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/MiddleBedHeightProcessor.java
diffstat 10 files changed, 103 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Wed May 21 11:36:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Wed May 21 11:40:14 2014 +0200
@@ -44,6 +44,7 @@
 import org.dive4elements.river.jfree.Bounds;
 import org.dive4elements.river.jfree.DoubleBounds;
 import org.dive4elements.river.jfree.StyledAreaSeriesCollection;
+import org.dive4elements.river.jfree.XYMetaSeriesCollection;
 
 import org.dive4elements.river.themes.ThemeDocument;
 import org.dive4elements.river.utils.RiverUtils;
@@ -494,7 +495,7 @@
         logger.debug("Y Range of XYSeries: " +
             series.getMinY() + " | " + series.getMaxY());
 
-        addAxisDataset(new XYSeriesCollection(series), index, visible);
+        addAxisDataset(new XYMetaSeriesCollection(series), index, visible);
     }
 
     /**
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java	Wed May 21 11:36:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java	Wed May 21 11:40:14 2014 +0200
@@ -8,6 +8,8 @@
 
 package org.dive4elements.river.exports.process;
 
+import java.util.Map;
+
 import org.apache.log4j.Logger;
 import org.jfree.data.xy.XYSeries;
 
@@ -50,6 +52,8 @@
             boolean          visible) {
         CallContext context = generator.getCallContext();
         Object data = bundle.getData(context);
+        Map<String, String> metaData = bundle.getFacet().getMetaData(
+            bundle.getArtifact(), context);
 
         if (!(data instanceof BedDiffYearResult)) {
             // Should not happen if canHandle is correct
@@ -73,7 +77,8 @@
                 new Object[] { radius }));
         }
         BedDiffYearResult bData = (BedDiffYearResult) data;
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+        StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+        series.putMetaData(metaData, bundle.getArtifact(), context);
         StyledSeriesBuilder.addPoints(series, bData.getHeightPerYearData(), false, GAP_TOLERANCE);
 
         generator.addAxisSeries(series, axisName, visible);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java	Wed May 21 11:36:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java	Wed May 21 11:40:14 2014 +0200
@@ -8,6 +8,8 @@
 
 package org.dive4elements.river.exports.process;
 
+import java.util.Map;
+
 import org.apache.log4j.Logger;
 import org.jfree.data.xy.XYSeries;
 
@@ -34,6 +36,8 @@
 
     protected static double GAP_TOLERANCE = 0.101d;
 
+    protected String yAxisLabel;
+
     public static final String I18N_AXIS_LABEL =
         "chart.beddifference.yaxis.label.diff";
     public static final String I18N_AXIS_LABEL_DEFAULT =
@@ -49,6 +53,9 @@
             boolean          visible) {
         CallContext context = generator.getCallContext();
         Object data = bundle.getData(context);
+        Map<String, String> metaData =
+            bundle.getFacet().getMetaData(bundle.getArtifact(), context);
+        yAxisLabel = metaData.get("Y");
         if (data instanceof BedDiffYearResult) {
             Double start = (Double)context.getContextValue("startkm");
             Double end = (Double)context.getContextValue("endkm");
@@ -66,10 +73,10 @@
                     I18N_SUBTITLE_RADIUS,
                     new Object[] { radius }));
             }
-            String facetType = bundle.getFacetName();
             BedDiffYearResult bData = (BedDiffYearResult) data;
 
-            XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+            StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+            series.putMetaData(metaData, bundle.getArtifact(), context);
             StyledSeriesBuilder.addPointsFactorY(series,
                 bData.getDifferencesData(),
                 false,
@@ -91,9 +98,12 @@
 
     @Override
     public String getAxisLabel(DiagramGenerator generator) {
+        if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
+            return generator.msg(yAxisLabel, I18N_AXIS_LABEL_DEFAULT);
+        }
         return generator.msg(
-                I18N_AXIS_LABEL,
-                I18N_AXIS_LABEL_DEFAULT);
+            I18N_AXIS_LABEL,
+            I18N_AXIS_LABEL_DEFAULT);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java	Wed May 21 11:36:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java	Wed May 21 11:40:14 2014 +0200
@@ -9,6 +9,7 @@
 package org.dive4elements.river.exports.process;
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.log4j.Logger;
 import org.jfree.data.xy.XYSeries;
@@ -39,6 +40,8 @@
 
     protected static final double GAP_TOLERANCE = 0.101d;
 
+    protected String yAxisLabel;
+
     @Override
     public void doOut(
             DiagramGenerator generator,
@@ -65,8 +68,12 @@
     private XYSeries prepareSeries(ArtifactAndFacet bundle,
         ThemeDocument theme, CallContext context) {
         Object data = bundle.getData(context);
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+        Map<String, String> metaData = bundle.getFacet().getMetaData(
+            bundle.getArtifact(), context);
+        StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
                 theme);
+        series.putMetaData(metaData, bundle.getArtifact(), context);
+        yAxisLabel = metaData.get("Y");
         if (data instanceof BedDiffYearResult) {
             BedDiffYearResult bData = (BedDiffYearResult) data;
 
@@ -135,6 +142,12 @@
 
         String unit = RiverUtils.getRiver(flys).getWstUnit().getName();
 
+        if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
+            return generator.msg(
+                yAxisLabel,
+                I18N_AXIS_LABEL_DEFAULT,
+                new Object[] {unit});
+        }
         return generator.msg(
                 I18N_AXIS_LABEL,
                 I18N_AXIS_LABEL_DEFAULT,
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedQualityDensityProcessor.java	Wed May 21 11:36:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedQualityDensityProcessor.java	Wed May 21 11:40:14 2014 +0200
@@ -8,6 +8,8 @@
 
 package org.dive4elements.river.exports.process;
 
+import java.util.Map;
+
 import org.apache.log4j.Logger;
 import org.jfree.data.xy.XYSeries;
 
@@ -31,6 +33,7 @@
     public static final String I18N_AXIS_LABEL =
         "chart.bedquality.yaxis.label.density";
 
+    protected String yAxisLabel;
     @Override
     public void doOut(
             DiagramGenerator generator,
@@ -38,9 +41,12 @@
             ThemeDocument    theme,
             boolean          visible) {
         CallContext context = generator.getCallContext();
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+        StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
                 theme);
         Object data = bundle.getData(context);
+        Map<String, String> metaData = bundle.getFacet().getMetaData();
+        series.putMetaData(metaData, bundle.getArtifact(), context);
+        yAxisLabel = metaData.get("Y");
         String facetName = bundle.getFacetName();
         double [][] points;
 
@@ -65,6 +71,9 @@
 
     @Override
     public String getAxisLabel(DiagramGenerator generator) {
+        if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
+            return generator.msg(yAxisLabel, I18N_AXIS_LABEL_DEFAULT);
+        }
         return generator.msg(
                 I18N_AXIS_LABEL,
                 I18N_AXIS_LABEL_DEFAULT);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedQualityDiameterProcessor.java	Wed May 21 11:36:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedQualityDiameterProcessor.java	Wed May 21 11:40:14 2014 +0200
@@ -8,6 +8,9 @@
 
 package org.dive4elements.river.exports.process;
 
+import java.awt.Dialog.ModalExclusionType;
+import java.util.Map;
+
 import org.apache.log4j.Logger;
 import org.jfree.data.xy.XYSeries;
 
@@ -33,6 +36,7 @@
     public static final String I18N_AXIS_LABEL =
         "chart.bedquality.yaxis.label.diameter";
 
+    protected String yAxisLabel;
     @Override
     public void doOut(
             DiagramGenerator generator,
@@ -40,8 +44,11 @@
             ThemeDocument    theme,
             boolean          visible) {
         CallContext context = generator.getCallContext();
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+        Map<String, String> metaData = bundle.getFacet().getMetaData();
+        StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
                 theme);
+        series.putMetaData(metaData, bundle.getArtifact(), context);
+        yAxisLabel = metaData.get("Y");
         Object data = bundle.getData(context);
         String facetName = bundle.getFacetName();
         double [][] points;
@@ -77,6 +84,9 @@
 
     @Override
     public String getAxisLabel(DiagramGenerator generator) {
+        if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
+            return generator.msg(yAxisLabel, I18N_AXIS_LABEL_DEFAULT);
+        }
         return generator.msg(
                 I18N_AXIS_LABEL,
                 I18N_AXIS_LABEL_DEFAULT);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedQualityPorosityProcessor.java	Wed May 21 11:36:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedQualityPorosityProcessor.java	Wed May 21 11:40:14 2014 +0200
@@ -8,6 +8,8 @@
 
 package org.dive4elements.river.exports.process;
 
+import java.util.Map;
+
 import org.apache.log4j.Logger;
 import org.jfree.data.xy.XYSeries;
 
@@ -32,6 +34,8 @@
     public static final String I18N_AXIS_LABEL =
         "chart.bedquality.yaxis.label.porosity";
 
+    protected String yAxisLabel;
+
     @Override
     public void doOut(
             DiagramGenerator generator,
@@ -39,8 +43,11 @@
             ThemeDocument    theme,
             boolean          visible) {
         CallContext context = generator.getCallContext();
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+        Map<String, String> metaData = bundle.getFacet().getMetaData();
+        StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
                 theme);
+        series.putMetaData(metaData, bundle.getArtifact(), context);
+        yAxisLabel = metaData.get("Y");
         Object data = bundle.getData(context);
         String facetName = bundle.getFacetName();
         double [][] points;
@@ -69,6 +76,9 @@
 
     @Override
     public String getAxisLabel(DiagramGenerator generator) {
+        if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
+            return generator.msg(yAxisLabel, I18N_AXIS_LABEL_DEFAULT);
+        }
         return generator.msg(
                 I18N_AXIS_LABEL,
                 I18N_AXIS_LABEL_DEFAULT);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java	Wed May 21 11:36:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java	Wed May 21 11:40:14 2014 +0200
@@ -12,6 +12,7 @@
 import org.jfree.data.xy.XYSeries;
 
 import java.util.List;
+import java.util.Map;
 
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifacts.CallContext;
@@ -37,6 +38,7 @@
     public static final String I18N_AXIS_LABEL =
         "chart.beddifference.yaxis.label.morph";
 
+    protected String yAxisLabel;
     @Override
     public void doOut(
             DiagramGenerator generator,
@@ -44,8 +46,11 @@
             ThemeDocument    theme,
             boolean          visible) {
         CallContext context = generator.getCallContext();
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+        Map<String, String> metaData = bundle.getFacet().getMetaData();
+        StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
                 theme);
+        series.putMetaData(metaData, bundle.getArtifact(), context);
+        yAxisLabel = metaData.get("Y");
         Object data = bundle.getData(context);
         String facetName = bundle.getFacetName();
 
@@ -100,6 +105,9 @@
 
     @Override
     public String getAxisLabel(DiagramGenerator generator) {
+        if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
+            return generator.msg(yAxisLabel, I18N_AXIS_LABEL_DEFAULT);
+        }
         return generator.msg(
                 I18N_AXIS_LABEL,
                 I18N_AXIS_LABEL_DEFAULT);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/FlowVelocityProcessor.java	Wed May 21 11:36:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/FlowVelocityProcessor.java	Wed May 21 11:40:14 2014 +0200
@@ -8,6 +8,8 @@
 
 package org.dive4elements.river.exports.process;
 
+import java.util.Map;
+
 import org.apache.log4j.Logger;
 import org.jfree.data.xy.XYSeries;
 
@@ -32,6 +34,9 @@
     public static final String I18N_AXIS_LABEL_DEFAULT =
         "Geschwindigkeit v [m/s]";
 
+
+    protected String yAxisLabel;
+
     @Override
     public void doOut(
             DiagramGenerator generator,
@@ -39,8 +44,11 @@
             ThemeDocument    theme,
             boolean          visible) {
         CallContext context = generator.getCallContext();
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+        Map<String, String> metaData = bundle.getFacet().getMetaData();
+        StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
                 theme);
+        series.putMetaData(metaData, bundle.getArtifact(), context);
+        yAxisLabel = metaData.get("Y");
         String facetName = bundle.getFacetName();
         Object data = bundle.getData(context);
         if (data == null) {
@@ -83,6 +91,9 @@
 
     @Override
     public String getAxisLabel(DiagramGenerator generator) {
+        if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
+            return generator.msg(yAxisLabel, I18N_AXIS_LABEL_DEFAULT);
+        }
         return generator.msg(
                 I18N_AXIS_LABEL,
                 I18N_AXIS_LABEL_DEFAULT);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/MiddleBedHeightProcessor.java	Wed May 21 11:36:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/MiddleBedHeightProcessor.java	Wed May 21 11:40:14 2014 +0200
@@ -8,6 +8,8 @@
 
 package org.dive4elements.river.exports.process;
 
+import java.util.Map;
+
 import org.apache.log4j.Logger;
 
 import org.jfree.data.xy.XYSeries;
@@ -36,6 +38,8 @@
     public static final String I18N_AXIS_LABEL_DEFAULT =
         "mittlere Sohlhöhen [müNN]";
 
+    protected String yAxisLabel;
+
     @Override
     public void doOut(
             DiagramGenerator generator,
@@ -44,11 +48,14 @@
             boolean          visible) {
         CallContext context = generator.getCallContext();
         logger.debug("Processing: " + bundle.getFacetName());
+        Map<String, String> metaData = bundle.getFacet().getMetaData();
+        yAxisLabel = metaData.get("Y");
         MiddleBedHeightData data =
             (MiddleBedHeightData) bundle.getData(context);
 
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+        StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
                 theme);
+        series.putMetaData(metaData, bundle.getArtifact(), context);
 
         StyledSeriesBuilder.addPoints(series, data.getMiddleHeightsPoints(),
                 false, 0.110d);
@@ -62,6 +69,12 @@
 
         String unit = RiverUtils.getRiver(flys).getWstUnit().getName();
 
+        if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
+            return generator.msg(
+                yAxisLabel,
+                I18N_AXIS_LABEL_DEFAULT,
+                new Object[] { unit });
+        }
         return generator.msg(
                 I18N_AXIS_LABEL,
                 I18N_AXIS_LABEL_DEFAULT,

http://dive4elements.wald.intevation.org