changeset 8357:24d044866c2a

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 01 Oct 2014 13:42:19 +0200
parents e15d2fc7aab4 (diff) 0d3d018fc632 (current diff)
children 011e2290e801
files artifacts/doc/conf/generators/discharge-diagrams.xml
diffstat 12 files changed, 150 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/generators/discharge-diagram-defaults.xml	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/doc/conf/generators/discharge-diagram-defaults.xml	Wed Oct 01 13:42:19 2014 +0200
@@ -2,7 +2,7 @@
 <discharge-defaults>
     <axis name="W"/>
     <axis name="Transport" logarithmic="true"/>
-    <domain-axis key="chart.discharge.xaxis.label" default="Q [kuhbikmeter]"
+    <domain-axis key="chart.discharge.curve.xaxis.label" default="Q [kuhbikmeter]"
                  include-zero="true"/>
     <processor class="org.dive4elements.river.exports.process.DischargeProcessor" axis="W"/>
     <processor class="org.dive4elements.river.exports.process.MiscDischargeProcessor" axis="W"/>
--- a/artifacts/doc/conf/generators/discharge-diagrams.xml	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/doc/conf/generators/discharge-diagrams.xml	Wed Oct 01 13:42:19 2014 +0200
@@ -40,7 +40,7 @@
       <title key="chart.fixings.discharge.curve.title" default="Fixierungsanalyse W/Q"/>
     <subtitle key="chart.computed.discharge.curve.subtitle" default="-">
         <arg expr="artifact.river"/>
-        <arg expr="artifact.ld_locations" type="double"/>
+        <arg expr="context.currentkm" type="double"/>
     </subtitle>
     &discharge-defaults;
   </output-generator>
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java	Wed Oct 01 13:42:19 2014 +0200
@@ -10,6 +10,7 @@
 import java.awt.Font;
 
 import org.apache.log4j.Logger;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.exports.injector.InjectorConstants;
 import org.dive4elements.river.jfree.AxisDataset;
 import org.dive4elements.river.jfree.DoubleBounds;
@@ -23,6 +24,8 @@
 {
     private static Logger log = Logger.getLogger(DischargeGenerator.class);
 
+    private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.cm.label";
+
     public DischargeGenerator() {
     }
 
@@ -85,10 +88,11 @@
             getYAxisFontSize(wAxisIndex));
 
         String axisName = "W.in.cm";
+        String axisLabel = Resources.getMsg(context.getMeta(),
+            I18N_AXIS_LABEL, "W [cm]");
 
-        // TODO: I18N
         IdentifiableNumberAxis axis = new IdentifiableNumberAxis(
-            axisName, "W.in.cm");
+            axisName, axisLabel);
 
         axis.setAutoRangeIncludesZero(false);
         axis.setLabelFont(labelFont);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/ComputedDischargeProcessor.java	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/ComputedDischargeProcessor.java	Wed Oct 01 13:42:19 2014 +0200
@@ -1,15 +1,20 @@
 package org.dive4elements.river.exports.process;
 
+import java.util.Map;
+
 import org.apache.log4j.Logger;
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.WQKms;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.exports.StyledSeriesBuilder;
 import org.dive4elements.river.jfree.StyledXYSeries;
 import org.dive4elements.river.themes.ThemeDocument;
-import org.jfree.data.xy.XYSeries;
 
 
 public class ComputedDischargeProcessor
@@ -19,6 +24,9 @@
     private static Logger log =
         Logger.getLogger(ComputedDischargeProcessor.class);
 
+    private String yAxisLabel = "";
+
+    private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label";
 
     @Override
     public void doOut(
@@ -36,7 +44,19 @@
 
     @Override
     public String getAxisLabel(DiagramGenerator generator) {
-        return null;
+        CallMeta meta = generator.getCallContext().getMeta();
+        RiverAccess access = new RiverAccess((D4EArtifact)generator.getMaster());
+        String unit = access.getRiver().getWstUnit().getName();
+        if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
+            return Resources.getMsg(
+                meta,
+                yAxisLabel,
+                new Object[] { unit });
+        }
+        return Resources.getMsg(
+                meta,
+                I18N_AXIS_LABEL,
+                new Object[] { unit });
     }
 
     /**
@@ -57,8 +77,15 @@
         boolean visible
     ) {
         CallContext context = generator.getCallContext();
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+        Map<String, String> metaData = bundle.getFacet().getMetaData(
+            bundle.getArtifact(), context);
+        StyledXYSeries series =
+            new StyledXYSeries(bundle.getFacetDescription(), theme);
         Object data = bundle.getData(context);
+
+        series.putMetaData(metaData, bundle.getArtifact(), context);
+        yAxisLabel = metaData.get("Y");
+
         WQKms wqkms = (WQKms) data;
         double[][] wqData = new double[2][wqkms.size()];
         for (int i = 0; i < wqkms.size(); i++) {
@@ -67,6 +94,5 @@
         }
         StyledSeriesBuilder.addPoints(series, wqData, false);
         generator.addAxisSeries(series, axisName, visible);
-        
     }
 }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java	Wed Oct 01 13:42:19 2014 +0200
@@ -8,15 +8,19 @@
 
 package org.dive4elements.river.exports.process;
 
+import java.util.Map;
+
 import org.apache.log4j.Logger;
 import org.jfree.data.xy.XYSeries;
 
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.CallMeta;
 import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.access.RiverAccess;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.WQKms;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.exports.StyledSeriesBuilder;
 import org.dive4elements.river.jfree.StyledXYSeries;
@@ -38,6 +42,10 @@
     /** Tolerance for comparison of kilometers. */
     public static final double KM_EPSILON = 0.001d;
 
+    private String yAxisLabel = "";
+
+    private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label";
+
 
     /** This processor needs to be constructed with a given km. */
     public DischargeProcessor() {
@@ -100,8 +108,10 @@
     {
         log.debug("DischargeCurveGenerator.doDischargeOut");
         CallContext context = generator.getCallContext();
+        Map<String, String> metaData = bundle.getFacet().getMetaData(
+            bundle.getArtifact(), context);
         WQKms data = (WQKms)bundle.getData(context);
-        XYSeries series = new StyledXYSeries(name, theme);
+        StyledXYSeries series = new StyledXYSeries(name, theme);
         double[][] wqData = new double[2][data.size()];
         for (int i = 0; i < data.size(); i++) {
             wqData[0][i] = data.getQ(i);
@@ -109,6 +119,9 @@
         }
         StyledSeriesBuilder.addPoints(series, wqData, false);
 
+        series.putMetaData(metaData, bundle.getArtifact(), context);
+        yAxisLabel = metaData.get("Y");
+
         String gaugeName = data.getName();
         RiverAccess access = new RiverAccess((D4EArtifact)bundle.getArtifact());
         River river = access.getRiver();
@@ -127,5 +140,23 @@
 
         generator.addAxisSeries(series, axisName, visible);
     }
+
+    @Override
+    public String getAxisLabel(DiagramGenerator generator) {
+        CallMeta meta = generator.getCallContext().getMeta();
+        RiverAccess access = new RiverAccess((D4EArtifact)generator.getMaster());
+        String unit = access.getRiver().getWstUnit().getName();
+
+        if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
+            return Resources.getMsg(
+                meta,
+                yAxisLabel,
+                new Object[] { unit });
+        }
+        return Resources.getMsg(
+                meta,
+                I18N_AXIS_LABEL,
+                new Object[] { unit });
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/FixDerivedProcessor.java	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/FixDerivedProcessor.java	Wed Oct 01 13:42:19 2014 +0200
@@ -1,10 +1,17 @@
 package org.dive4elements.river.exports.process;
 
+import java.util.Map;
+
 import org.apache.log4j.Logger;
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.fixings.FixDerivateFacet;
 import org.dive4elements.river.artifacts.model.fixings.FixFunction;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.jfree.JFreeUtil;
 import org.dive4elements.river.jfree.StyledXYSeries;
@@ -18,6 +25,11 @@
 
     private static Logger log = Logger.getLogger(FixDerivedProcessor.class);
 
+    private String yAxisLabel = "";
+
+    private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label";
+
+
     public FixDerivedProcessor() {
     }
 
@@ -28,10 +40,16 @@
         ThemeDocument theme,
         boolean visible
     ) {
+        CallContext context = generator.getCallContext();
+        Map<String, String> metaData = bundle.getFacet().getMetaData(
+            bundle.getArtifact(), context);
         FixDerivateFacet facet = (FixDerivateFacet)bundle.getFacet();
         FixFunction func = (FixFunction)facet.getData(
                 bundle.getArtifact(), generator.getCallContext());
 
+        yAxisLabel = metaData.get("Y");
+
+
         if (func == null) {
             log.warn("doOut: Facet does not contain FixFunction");
             return;
@@ -48,6 +66,7 @@
                     0.0 ,  // start
                     maxQ); // end
             generator.addAxisSeries(series, axisName, visible);
+            series.putMetaData(metaData, bundle.getArtifact(), context);
         }
     }
 
@@ -55,4 +74,22 @@
     public boolean canHandle(String facettype) {
         return FIX_DERIVATE_CURVE.equals(facettype);
     }
+
+    @Override
+    public String getAxisLabel(DiagramGenerator generator) {
+        CallMeta meta = generator.getCallContext().getMeta();
+        RiverAccess access = new RiverAccess((D4EArtifact)generator.getMaster());
+        String unit = access.getRiver().getWstUnit().getName();
+
+        if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
+            return Resources.getMsg(
+                meta,
+                yAxisLabel,
+                new Object[] { unit });
+        }
+        return Resources.getMsg(
+                meta,
+                I18N_AXIS_LABEL,
+                new Object[] { unit });
+    }
 }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java	Wed Oct 01 13:42:19 2014 +0200
@@ -8,6 +8,9 @@
 
 import org.apache.log4j.Logger;
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.NamedDouble;
 import org.dive4elements.river.artifacts.model.QWDDateRange;
@@ -16,6 +19,7 @@
 import org.dive4elements.river.artifacts.model.fixings.FixWQCurveFacet;
 import org.dive4elements.river.artifacts.model.fixings.QWD;
 import org.dive4elements.river.artifacts.model.fixings.QWI;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.exports.StyledSeriesBuilder;
 import org.dive4elements.river.exports.fixings.FixChartGenerator;
@@ -43,6 +47,8 @@
 
     private static Logger logger = Logger.getLogger(FixWQProcessor.class);
 
+    private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label";
+
     public FixWQProcessor() {
     }
 
@@ -528,4 +534,16 @@
             || STATIC_WKMS_INTERPOL.equals(facettype)
             || FIX_WQ_LS.equals(facettype);
     }
+
+    @Override
+    public String getAxisLabel(DiagramGenerator generator) {
+        CallMeta meta = generator.getCallContext().getMeta();
+
+        RiverAccess access = new RiverAccess((D4EArtifact)generator.getMaster());
+        String unit = access.getRiver().getWstUnit().getName();
+        return Resources.getMsg(
+                meta,
+                I18N_AXIS_LABEL,
+                new Object[] { unit });
+    }
 }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java	Wed Oct 01 13:42:19 2014 +0200
@@ -16,8 +16,12 @@
 
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.WQKms;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.exports.DischargeCurveGenerator;
 import org.dive4elements.river.exports.StyledSeriesBuilder;
@@ -45,6 +49,7 @@
     /** Tolerance for comparison of kilometers. */
     public static final double KM_EPSILON = 0.001d;
 
+    private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label";
 
     /** This processor needs to be constructed with a given km. */
     public MiscDischargeProcessor() {
@@ -356,5 +361,17 @@
             generator.addAnnotations(annotations);
         }
     }
+
+    @Override
+    public String getAxisLabel(DiagramGenerator generator) {
+        CallMeta meta = generator.getCallContext().getMeta();
+        RiverAccess access = new RiverAccess((D4EArtifact)generator.getMaster());
+        String unit = access.getRiver().getWstUnit().getName();
+
+        return Resources.getMsg(
+                meta,
+                I18N_AXIS_LABEL,
+                new Object[] { unit });
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/resources/messages.properties	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/src/main/resources/messages.properties	Wed Oct 01 13:42:19 2014 +0200
@@ -169,7 +169,8 @@
 
 chart.discharge.curve.title = Discharge Curve
 chart.discharge.curve.xaxis.label = Q [m\u00b3/s]
-chart.discharge.curve.yaxis.label = W [cm]
+chart.discharge.curve.yaxis.label = W [{0}]
+chart.discharge.curve.yaxis.cm.label = W [cm]
 chart.discharge.curve.curve.valid.from = {0} (valid from {1,date,short})
 chart.discharge.curve.curve.valid.range = {0} (valid from {1,date,short} - {2,date,short})
 chart.computed.discharge.curve.title = Discharge Curve
--- a/artifacts/src/main/resources/messages_de.properties	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Wed Oct 01 13:42:19 2014 +0200
@@ -169,7 +169,8 @@
 chart.longitudinal.annotations.label = {0}.km
 chart.discharge.curve.title = Abflusskurve
 chart.discharge.curve.xaxis.label = Q [m\u00b3/s]
-chart.discharge.curve.yaxis.label = W [cm]
+chart.discharge.curve.yaxis.label = W [{0}]
+chart.discharge.curve.yaxis.cm.label = W [cm]
 chart.discharge.curve.curve.valid.from = {0} (g\u00fcltig ab {1,date,medium})
 chart.discharge.curve.curve.valid.range = {0} (g\u00fcltig ab {1,date,medium} - {2,date,medium})
 chart.computed.discharge.curve.title = Abflusskurve
--- a/artifacts/src/main/resources/messages_de_DE.properties	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/src/main/resources/messages_de_DE.properties	Wed Oct 01 13:42:19 2014 +0200
@@ -168,7 +168,8 @@
 chart.longitudinal.annotations.label = {0}.km
 chart.discharge.curve.title = Abflusskurve
 chart.discharge.curve.xaxis.label = Q [m\u00b3/s]
-chart.discharge.curve.yaxis.label = W [cm]
+chart.discharge.curve.yaxis.label = W [{0}]
+chart.discharge.curve.yaxis.cm.label = W [cm]
 chart.discharge.curve.curve.valid.from = {0} (g\u00fcltig ab {1,date,medium})
 chart.discharge.curve.curve.valid.range = {0} (g\u00fcltig ab {1,date,medium} - {2,date,medium})
 chart.computed.discharge.curve.title = Abflusskurve
--- a/artifacts/src/main/resources/messages_en.properties	Wed Oct 01 13:40:30 2014 +0200
+++ b/artifacts/src/main/resources/messages_en.properties	Wed Oct 01 13:42:19 2014 +0200
@@ -168,7 +168,8 @@
 chart.longitudinal.annotations.label = {0}.km
 chart.discharge.curve.title = Discharge Curve
 chart.discharge.curve.xaxis.label = Q [m\u00b3/s]
-chart.discharge.curve.yaxis.label = W [cm]
+chart.discharge.curve.yaxis.label = W [{0}]
+chart.discharge.curve.yaxis.cm.label = W [cm]
 chart.discharge.curve.curve.valid.from = {0} (valid from {1,date,short})
 chart.discharge.curve.curve.valid.range = {0} (valid from {1,date,short} - {2,date,short})
 chart.computed.discharge.curve.title = Discharge Curve

http://dive4elements.wald.intevation.org