changeset 3785:a5f65e8983be

Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from file:///home/clients/bsh/bsh-generischer-viewer/Material/SVN/flys-artifacts/trunk ........ r5501 | felix | 2012-09-18 11:49:45 +0200 (Di, 18 Sep 2012) | 1 line fix issue865 - missing showarea theme prop. ........ r5502 | clins | 2012-09-18 12:18:30 +0200 (Di, 18 Sep 2012) | 1 line Add robustness checks to prevent NPEs ........ r5504 | felix | 2012-09-18 14:03:15 +0200 (Di, 18 Sep 2012) | 1 line i18n for area label (fix issue487). ........ r5505 | clins | 2012-09-18 16:19:59 +0200 (Di, 18 Sep 2012) | 1 line Update themes to show point descriptions ........ r5506 | rrenkert | 2012-09-18 17:00:30 +0200 (Di, 18 Sep 2012) | 3 lines Removed incorrect characteristic diameter. ........ r5507 | rrenkert | 2012-09-18 17:03:20 +0200 (Di, 18 Sep 2012) | 3 lines Fixed some stupid bugs in bed quality data factory and calculation. ........ r5508 | teichmann | 2012-09-18 17:45:49 +0200 (Di, 18 Sep 2012) | 1 line The usual whitespace and import cleanups. ........ r5511 | teichmann | 2012-09-18 18:24:51 +0200 (Di, 18 Sep 2012) | 1 line Use generics aware Collections.emptyList(). ........ r5512 | teichmann | 2012-09-18 20:36:52 +0200 (Di, 18 Sep 2012) | 1 line Some more little steps towards "Auslagerung extremer Wasserspiegellagen". ........ r5513 | clins | 2012-09-18 23:38:19 +0200 (Di, 18 Sep 2012) | 1 line A and B facets of fix analyis are now deactivated by default ........ r5516 | bricks | 2012-09-19 10:45:51 +0200 (Mi, 19 Sep 2012) | 2 lines Add the gauge station to the GaugeOverviewInfoService xml response ........ r5517 | rrenkert | 2012-09-19 10:50:23 +0200 (Mi, 19 Sep 2012) | 3 lines Added CSV export to bed quality calculation. ........ r5518 | bricks | 2012-09-19 11:04:04 +0200 (Mi, 19 Sep 2012) | 2 lines Fix date in changelog entry ........ r5519 | teichmann | 2012-09-19 11:17:14 +0200 (Mi, 19 Sep 2012) | 1 line Removed trailing whitespace. ........ flys-artifacts/tags/2.9.1@5531 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 19 Sep 2012 14:58:31 +0000
parents 9f9d5ada96ca
children 4adc35aa655c
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/minfo.xml flys-artifacts/doc/conf/conf.xml flys-artifacts/doc/conf/default-themes.xml flys-artifacts/doc/conf/second-themes.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationsFactory.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiameterResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedParametersResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedloadDiameterResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/GaugeOverviewInfoService.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SoundingsSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixAnalysisCompute.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FunctionSelect.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/CharDiameter.java flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionDescriptionHelper.java flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/OutputHelper.java flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedQualityExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeFactory.java flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeMapping.java flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties
diffstat 34 files changed, 679 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Sep 19 14:58:31 2012 +0000
@@ -1,3 +1,114 @@
+2012-09-19	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/minfo/BedQualityExporter.java:
+	  Removed superfluous imports.
+
+2012-09-19  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/minfo/BedQualityExporter.java:
+	  New. CSV exporter for bed quality calculation result.
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedloadDiameterResult.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiameterResult.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedParametersResult.java:
+	  Added getter with km as parameter.
+
+	* src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java:
+	  Added facet for csv export.
+
+	* doc/conf/artifacts/minfo.xml:
+	  Added output mode.
+
+	* doc/conf/conf.xml:
+	  Added export generator.
+
+2012-09-19	Björn Ricks	<bjoern.ricks@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/services/GaugeOverviewInfoService.java:
+	  Return also the station in a service response.
+
+2012-09-18	Christian Lins	<christian.lins@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/states/fixation/FunctionSelect.java:
+	  Cosmetics.
+
+	* src/main/java/de/intevation/flys/artifacts/states/fixation/FixAnalysisCompute.java:
+	  A and B facets of fix analysis are now deactivated by default (#717).
+
+2012-09-18	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCalculation.java:
+	  Extract parameters needed for calculation from access.
+
+	* src/main/java/de/intevation/flys/utils/DoubleUtil.java(isValid):
+	  Added method to check if 2d double array is valid.
+
+2012-09-18	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java,
+	  src/main/java/de/intevation/flys/artifacts/model/AnnotationsFactory.java,
+	  src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java:
+	  Use generics aware Collections.emptyList().
+
+2012-09-18	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityResult.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java,
+	  src/main/java/de/intevation/flys/artifacts/states/SoundingsSelect.java,
+	  src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java,
+	  src/main/java/de/intevation/flys/exports/OutputHelper.java,
+	  src/main/java/de/intevation/flys/exports/ChartGenerator.java,
+	  src/main/java/de/intevation/flys/themes/ThemeFactory.java,
+	  src/main/java/de/intevation/flys/themes/ThemeMapping.java,
+	  src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java:
+	  The usual whitespace and import cleanups.
+
+2012-09-18  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java:
+	  Avoid loading empty data sets.
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java:
+	  Load bedload data sets...
+
+2012-09-18  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/states/minfo/CharDiameter.java:
+	  Removed incorrect characteristic diameter.
+
+2012-09-18	Christian Lins	<christian.lins@intevation.de>
+
+	* doc/conf/default-themes.xml:
+	  Update point themes of fixing W/Q chart to show point descriptions
+	  per default (#685).
+
+2012-09-18	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	i18n for area label (fix issue487).
+
+	* src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java,
+	  src/main/java/de/intevation/flys/exports/ChartGenerator.java:
+	  Get internationalized label and numberformat, pass it to renderer,
+	  where its used.
+
+	* src/main/resources/messages.properties,
+	  src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_en.properties,
+	  src/main/resources/messages_de.properties: Area label translations.
+
+2012-09-18	Christian Lins	<christian.lins@intevation.de>
+
+	* src/main/java/de/intevation/flys/collections/CollectionDescriptionHelper.java,
+	  src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
+	  Add robustness checks to prevent NPEs (#859).
+
+2012-09-18	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Brought showarea-theme setting back (fix issue865).
+
+	* doc/conf/default-themes.xml, doc/conf/second-themes.xml:
+	  Define showarea theme prop where its needed.
+
 2012-09-17  Raimund Renkert <raimund.renkert@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityResult.java:
--- a/flys-artifacts/doc/conf/artifacts/minfo.xml	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/doc/conf/artifacts/minfo.xml	Wed Sep 19 14:58:31 2012 +0000
@@ -291,6 +291,11 @@
                     	<facet name="bed_longitudinal_section.bedload_diameter"/>
                     </facets>
                 </outputmode>
+                <outputmode name="bed_quality_export" description="output.bed_quality_export" type="export">
+                    <facets>
+                        <facet name="csv" description="facet.bed_quality_export.csv" />
+                    </facets>
+                </outputmode>
             </outputmodes>
         </state>
     </states>
--- a/flys-artifacts/doc/conf/conf.xml	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Wed Sep 19 14:58:31 2012 +0000
@@ -288,6 +288,7 @@
         <output-generator name="bedheight_middle_export">de.intevation.flys.exports.MiddleBedHeightExporter</output-generator>
         <output-generator name="bed_longitudinal_section">de.intevation.flys.exports.minfo.BedQualityGenerator</output-generator>
         <output-generator name="bed_longitudinal_section_chartinfo">de.intevation.flys.exports.minfo.BedQualityInfoGenerator</output-generator>
+        <output-generator name="bed_quality_export">de.intevation.flys.exports.minfo.BedQualityExporter</output-generator>
         <output-generator name="sq_relation_a">de.intevation.flys.exports.sq.SQRelationGeneratorA</output-generator>
         <output-generator name="sq_relation_b">de.intevation.flys.exports.sq.SQRelationGeneratorB</output-generator>
         <output-generator name="sq_relation_c">de.intevation.flys.exports.sq.SQRelationGeneratorC</output-generator>
--- a/flys-artifacts/doc/conf/default-themes.xml	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/doc/conf/default-themes.xml	Wed Sep 19 14:58:31 2012 +0000
@@ -949,7 +949,11 @@
     <theme name="Area">
         <inherits>
             <inherit from="Areas" />
-        </inherits>
+         </inherits>
+         <fields>
+            <field name="showarea" type="boolean" display="Show Area"
+                default="true"/>
+         </fields>
     </theme>
 
     <!-- Map -->
@@ -1242,7 +1246,7 @@
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="0, 128, 0" />
             <field name="showpointlabel" type="boolean"
-                display="Punktbeschriftung anzeigen" default="false"/>
+                display="Punktbeschriftung anzeigen" default="true"/>
         </fields>
     </theme>
     <theme name="FixingSectorAverageWQ1">
@@ -1258,7 +1262,7 @@
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="0, 0, 255" />
             <field name="showpointlabel" type="boolean"
-                display="Punktbeschriftung anzeigen" default="false"/>
+                display="Punktbeschriftung anzeigen" default="true"/>
         </fields>
     </theme>
     <theme name="FixingSectorAverageWQ2">
@@ -1274,7 +1278,7 @@
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="255, 0, 255" />
             <field name="showpointlabel" type="boolean"
-                display="Punktbeschriftung anzeigen" default="false"/>
+                display="Punktbeschriftung anzeigen" default="true"/>
         </fields>
     </theme>
     <theme name="FixingSectorAverageWQ3">
@@ -1290,7 +1294,7 @@
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="255, 0, 0" />
             <field name="showpointlabel" type="boolean"
-                display="Punktbeschriftung anzeigen" default="false"/>
+                display="Punktbeschriftung anzeigen" default="true"/>
         </fields>
     </theme>
 
@@ -1305,7 +1309,7 @@
             <field name="pointcolor" type="Color" display="Punktfarbe"
                 default="0, 255, 0" />
             <field name="showpointlabel" type="boolean"
-                display="Punktbeschriftung anzeigen" default="false"/>
+                display="Punktbeschriftung anzeigen" default="true"/>
         </fields>
     </theme>
 
--- a/flys-artifacts/doc/conf/second-themes.xml	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/doc/conf/second-themes.xml	Wed Sep 19 14:58:31 2012 +0000
@@ -950,6 +950,10 @@
         <inherits>
             <inherit from="Areas" />
         </inherits>
+        <fields>
+            <field name="showarea" type="boolean" display="Show Area"
+                default="true"/>
+        </fields>
     </theme>
 
     <!-- Map -->
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Wed Sep 19 14:58:31 2012 +0000
@@ -560,12 +560,12 @@
         StateData wqValues = getData("wq_values");
         if (wqValues == null) {
             logger.warn("no wq_values given");
-            return Collections.emptyList();
+            return Collections.<Segment>emptyList();
         }
         String input = (String) wqValues.getValue();
         if (input == null || (input = input.trim()).length() == 0) {
             logger.warn("wq_values are empty");
-            return Collections.emptyList();
+            return Collections.<Segment>emptyList();
         }
         return Segment.parseSegments(input);
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationsFactory.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationsFactory.java	Wed Sep 19 14:58:31 2012 +0000
@@ -100,8 +100,7 @@
         riverQuery.setParameter("name", riverName);
         List<River> rivers = riverQuery.list();
         if (rivers.isEmpty()) {
-            List<Annotation> list = Collections.emptyList();
-            return list.iterator();
+            return Collections.<Annotation>emptyList().iterator();
         }
 
         Query query = session.createQuery(
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCalculation.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCalculation.java	Wed Sep 19 14:58:31 2012 +0000
@@ -2,26 +2,160 @@
 
 import de.intevation.flys.artifacts.access.ExtremeAccess;
 
+import de.intevation.flys.artifacts.math.fitting.Function;
+import de.intevation.flys.artifacts.math.fitting.FunctionFactory;
+
 import de.intevation.flys.artifacts.model.Calculation;
 import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.RangeWithValues;
+import de.intevation.flys.artifacts.model.RiverFactory;
+import de.intevation.flys.artifacts.model.WstValueTable;
+import de.intevation.flys.artifacts.model.WstValueTableFactory;
+
+import de.intevation.flys.model.River;
+
+import de.intevation.flys.utils.DoubleUtil;
+
+import java.util.List;
 
 public class ExtremeCalculation
 extends      Calculation
 {
+    protected String                river;
+    protected String                function;
+    protected double                from;
+    protected double                to;
+    protected double                step;
+    protected double                percent;
+    protected List<RangeWithValues> ranges;
+
     public ExtremeCalculation() {
     }
 
     public ExtremeCalculation(ExtremeAccess access) {
-        // TODO: Implement me!
+        String                river    = access.getRiver();
+        String                function = access.getFunction();
+        Double                from     = access.getFrom();
+        Double                to       = access.getTo();
+        Double                step     = access.getStep();
+        Double                percent  = access.getPercent();
+        List<RangeWithValues> ranges   = access.getRanges();
+
+        if (river == null) {
+            // TODO: i18n
+            addProblem("extreme.no.river");
+        }
+
+        if (function == null) {
+            // TODO: i18n
+            addProblem("extreme.no.function");
+        }
+
+        if (from == null) {
+            // TODO: i18n
+            addProblem("extreme.no.from");
+        }
+
+        if (to == null) {
+            // TODO: i18n
+            addProblem("extreme.no.to");
+        }
+
+        if (step == null) {
+            // TODO: i18n
+            addProblem("extreme.no.step");
+        }
+
+        if (percent == null) {
+            // TODO: i18n
+            addProblem("extreme.no.percent");
+        }
+
+        if (ranges == null) {
+            // TODO: i18n
+            addProblem("extreme.no.ranges");
+        }
+
+        if (!hasProblems()) {
+            this.river    = river;
+            this.function = function;
+            this.from     = Math.min(from, to);
+            this.to       = Math.max(from, to);
+            this.step     = Math.max(0.001d, Math.abs(step)/1000d);
+            this.percent  = Math.max(0d, Math.min(100d, percent));
+            this.ranges   = ranges;
+        }
     }
 
     public CalculationResult calculate() {
-        if (hasProblems()) {
-            return new CalculationResult(this);
+
+        WstValueTable wst = null;
+
+        River river = RiverFactory.getRiver(this.river);
+        if (river == null) {
+            // TODO: i18n
+            addProblem("extreme.no.such.river", this.river);
         }
-        // TODO: Implement me!
+        else {
+            wst = WstValueTableFactory.getTable(river);
+            if (wst == null) {
+                // TODO: i18n
+                addProblem("extreme.no.wst.table");
+            }
+        }
+
+        Function function =
+            FunctionFactory.getInstance().getFunction(this.function);
+        if (function == null) {
+            // TODO: i18n
+            addProblem("extreme.no.such.function", this.function);
+        }
+
+        return hasProblems()
+            ? new CalculationResult(this)
+            : innerCalculate(wst, function);
+    }
+
+    protected CalculationResult innerCalculate(
+        WstValueTable wst,
+        Function      function
+    ) {
+        RangeWithValues range = null;
+
+        KMs: for (double km = from; km <= to; km += step) {
+            double currentKm = DoubleUtil.round(km);
+
+            if (range == null || !range.inside(currentKm)) {
+                for (RangeWithValues r: ranges) {
+                    if (r.inside(currentKm)) {
+                        range = r;
+                        break;
+                    }
+                }
+                // TODO: i18n
+                addProblem(currentKm, "extreme.no.range");
+                continue KMs;
+            }
+
+            double [][] wqs = wst.interpolateTabulated(currentKm);
+            if (wqs == null) {
+                // TODO: i18n
+                addProblem(currentKm, "extreme.no.raw.data");
+                continue;
+            }
+
+            // XXX: This should not be necessary for model data.
+            if (!DoubleUtil.isValid(wqs)) {
+                // TODO: i18n
+                addProblem(currentKm, "extreme.invalid.data");
+                continue;
+            }
+            // TODO: Implement extraction of points for curve fitting.
+            // TODO: Implement curve fitting.
+            // TODO: Implement generating Curve object per km.
+        }
+
         ExtremeResult result = new ExtremeResult();
-
         return new CalculationResult(result, this);
     }
 }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiameterResult.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiameterResult.java	Wed Sep 19 14:58:31 2012 +0000
@@ -34,6 +34,20 @@
         return Double.NaN;
     }
 
+    public double getDiameterCap(double km) {
+        if (kms.indexOf(km) >= 0) {
+            return diameterCap.get(kms.indexOf(km));
+        }
+        return Double.NaN;
+    }
+
+    public double getDiameterSub(double km) {
+        if (kms.indexOf(km) >= 0) {
+            return diameterSub.get(kms.indexOf(km));
+        }
+        return Double.NaN;
+    }
+
     public double[][] getDiameterCapData() {
         return new double[][] {
             kms.toNativeArray(),
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedParametersResult.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedParametersResult.java	Wed Sep 19 14:58:31 2012 +0000
@@ -48,6 +48,34 @@
         return loadDensitySub.get(ndx);
     }
 
+    public double getPorosityCap(double km) {
+        if (kms.indexOf(km) >= 0) {
+            return porosityCap.get(kms.indexOf(km));
+        }
+        return Double.NaN;
+    }
+
+    public double getPorositySub(double km) {
+        if (kms.indexOf(km) >= 0) {
+            return porositySub.get(kms.indexOf(km));
+        }
+        return Double.NaN;
+    }
+
+    public double getLoadDensityCap(double km) {
+        if (kms.indexOf(km) >= 0) {
+            return loadDensityCap.get(kms.indexOf(km));
+        }
+        return Double.NaN;
+    }
+
+    public double getLoadDensitySub(double km) {
+        if (kms.indexOf(km) >= 0) {
+            return loadDensitySub.get(kms.indexOf(km));
+        }
+        return Double.NaN;
+    }
+
     public double[][] getPorosityCapData() {
         return new double[][] {
             kms.toNativeArray(),
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java	Wed Sep 19 14:58:31 2012 +0000
@@ -86,7 +86,7 @@
         // Calculate for all time periods.
         for (DateRange dr : ranges) {
             QualityMeasurements loadMeasurements =
-                QualityMeasurementFactory.getBedMeasurements(
+                QualityMeasurementFactory.getBedloadMeasurements(
                     river,
                     from,
                     to,
@@ -139,7 +139,7 @@
         TDoubleArrayList porositySub = new TDoubleArrayList();
         TDoubleArrayList densityCap = new TDoubleArrayList();
         TDoubleArrayList densitySub = new TDoubleArrayList();
- 
+
         for(double km : kms) {
             double[] pCap = calculatePorosity(capFiltered, km);
             double[] pSub = calculatePorosity(subFiltered, km);
@@ -163,7 +163,7 @@
             porositySub.add((pSubRes / pSub.length) * 100);
             densityCap.add((dCapRes / dCap.length) / 1000);
             densitySub.add((dSubRes / dSub.length) / 1000);
- 
+
         }
 
         return new BedParametersResult(
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityResult.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityResult.java	Wed Sep 19 14:58:31 2012 +0000
@@ -6,8 +6,6 @@
 
 import de.intevation.flys.artifacts.model.DateRange;
 
-import gnu.trove.TDoubleArrayList;
-
 public class BedQualityResult
 implements Serializable
 {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedloadDiameterResult.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedloadDiameterResult.java	Wed Sep 19 14:58:31 2012 +0000
@@ -26,6 +26,13 @@
         return Double.NaN;
     }
 
+    public double getDiameter(double km) {
+        if (kms.indexOf(km) >= 0) {
+            return diameter.get(kms.indexOf(km));
+        }
+        return Double.NaN;
+    }
+
     public double[][] getDiameterData() {
         return new double[][] {
             kms.toNativeArray(),
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java	Wed Sep 19 14:58:31 2012 +0000
@@ -45,7 +45,7 @@
         "WHERE gw.name = :name AND " +
         "      st.km IS NOT NULL AND " +
         "      sp.tiefevon IS NOT NULL AND " +
-        "      sp.tiefebis IS NOT NULL AND " +
+        "      sp.tiefebis IS NOT NULL AND " + // TODO: Test if char diameter ist null.
         "      st.km BETWEEN :from - 0.001 AND :to + 0.001 AND " +
         "      st.datum BETWEEN :start AND :end";
 
@@ -72,6 +72,7 @@
         "    JOIN gewaesser gw ON gw.gewaesserid = sn.gewaesserid " +
         "WHERE gw.name = :name AND " +
         "      m.km IS NOT NULL AND " +
+        "      m.d10 IS NOT NULL AND" + //TODO: Add all other char. diameter.
         "      m.km BETWEEN :from - 0.001 AND :to + 0.001 AND" +
         "      m.datum BETWEEN :start AND :end";
 
@@ -196,7 +197,7 @@
                 SQL_BEDLOAD_MEASUREMENT);
         }
         finally {
-            session.close();
+            //session.close();
         }
     }
 }
\ No newline at end of file
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/GaugeOverviewInfoService.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/GaugeOverviewInfoService.java	Wed Sep 19 14:58:31 2012 +0000
@@ -127,6 +127,11 @@
                 ec.addAttr(eg, "maxq", maxq, true);
             }
 
+            String station = getGaugeValue(gauge.getStation());
+            if (station != null) {
+                ec.addAttr(eg, "station", station, true);
+            }
+
             egs.appendChild(eg);
         }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SoundingsSelect.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SoundingsSelect.java	Wed Sep 19 14:58:31 2012 +0000
@@ -75,12 +75,12 @@
     ) {
         List<BedHeightSingle> singles =
             BedHeightSingle.getBedHeightSingles(river, kmLo, kmHi);
-        
+
         if (singles != null) {
             int size = singles.size();
-            
+
             logger.debug("Found " + size + " singles.");
-            
+
             for (int i = 0; i < size; i++) {
                 BedHeightSingle s = singles.get(i);
 
@@ -104,9 +104,9 @@
 
         if (epochs != null) {
             int size = epochs.size();
-            
+
             logger.debug("Found " + size + " epochs.");
-            
+
             for (int i = 0; i < size; i++) {
                 BedHeightEpoch e = epochs.get(i);
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixAnalysisCompute.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixAnalysisCompute.java	Wed Sep 19 14:58:31 2012 +0000
@@ -7,6 +7,8 @@
 import org.apache.log4j.Logger;
 
 import de.intevation.artifactdatabase.state.Facet;
+import de.intevation.artifactdatabase.state.FacetActivity;
+import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.access.FixAnalysisAccess;
@@ -64,6 +66,34 @@
         "[HQ5 - \u221e)"
     };
 
+    static {
+        // Active/deactivate facets.
+        FacetActivity.Registry.getInstance().register(
+            "fixanalysis",
+            new FacetActivity() {
+                @Override
+                public Boolean isInitialActive(
+                    Artifact artifact,
+                    Facet    facet,
+                    String   output
+                ) {
+                    String name = facet.getName();
+
+                    if (name.contains(FacetTypes.FIX_ANALYSIS_EVENTS_DWT)
+                     || name.contains(FacetTypes.FIX_ANALYSIS_EVENTS_LS)
+                     || name.contains(FacetTypes.FIX_ANALYSIS_EVENTS_WQ)
+                     || name.contains(FacetTypes.FIX_REFERENCE_EVENTS_DWT)
+                     || name.contains(FacetTypes.FIX_REFERENCE_EVENTS_LS)
+                     || name.contains(FacetTypes.FIX_REFERENCE_EVENTS_WQ)
+                    ) {
+                        return Boolean.FALSE;
+                    }
+
+                    return Boolean.TRUE;
+                }
+            });
+    }
+
     /**
      * The default constructor that initializes an empty State object.
      */
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FunctionSelect.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FunctionSelect.java	Wed Sep 19 14:58:31 2012 +0000
@@ -4,17 +4,14 @@
 import java.util.Iterator;
 
 import org.apache.log4j.Logger;
-
 import org.w3c.dom.Element;
 
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
-
 import de.intevation.artifacts.common.utils.XMLUtils;
-
-import de.intevation.flys.artifacts.states.DefaultState;
 import de.intevation.flys.artifacts.math.fitting.Function;
 import de.intevation.flys.artifacts.math.fitting.FunctionFactory;
+import de.intevation.flys.artifacts.states.DefaultState;
 
 /**
  * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
@@ -31,6 +28,7 @@
     public FunctionSelect() {
     }
 
+    @Override
     public String getUIProvider() {
         return "fix.functionselect";
     }
@@ -43,13 +41,13 @@
         CallContext             context)
     {
         FunctionFactory ff = FunctionFactory.getInstance();
-        Collection fc = ff.getFunctions();
+        Collection<Function> fc = ff.getFunctions();
         Element[] functions = new Element[fc.size()];
-        Iterator i = fc.iterator();
+        Iterator<Function> i = fc.iterator();
 
         int j = 0;
         while(i.hasNext()) {
-            Function f = (Function)i.next();
+            Function f = i.next();
             String n = f.getName();
             String d = f.getDescription();
             functions[j] = createItem(ec, new String[] {d, n});
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java	Wed Sep 19 14:58:31 2012 +0000
@@ -12,6 +12,7 @@
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.access.BedQualityAccess;
 import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.DataFacet;
 import de.intevation.flys.artifacts.model.DateRange;
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.minfo.BedDensityFacet;
@@ -83,6 +84,7 @@
 
         CallMeta meta = context.getMeta();
 
+        newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
         for (int idx = 0; idx < results.length; idx++) {
             BedQualityResult result = results[idx];
             DateRange range = result.getDateRange();
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/CharDiameter.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/CharDiameter.java	Wed Sep 19 14:58:31 2012 +0000
@@ -20,7 +20,6 @@
 
     private static final String CHAR_DIAMETER_MIN  = "calc.bed.dmin";
     private static final String CHAR_DIAMETER_MAX  = "calc.bed.dmax";
-    private static final String CHAR_DIAMETER_MID  = "calc.bed.dmid";
     private static final String CHAR_DIAMETER_90  = "calc.bed.d90";
     private static final String CHAR_DIAMETER_84  = "calc.bed.d84";
     private static final String CHAR_DIAMETER_80  = "calc.bed.d80";
@@ -50,7 +49,6 @@
         CHAR_DIAMETER_84,
         CHAR_DIAMETER_90,
         CHAR_DIAMETER_MAX,
-        CHAR_DIAMETER_MID,
         CHAR_DIAMETER_MIN
     };
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionDescriptionHelper.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/CollectionDescriptionHelper.java	Wed Sep 19 14:58:31 2012 +0000
@@ -6,18 +6,16 @@
 
 import javax.xml.xpath.XPathConstants;
 
+import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import org.apache.log4j.Logger;
-
 import de.intevation.artifacts.ArtifactDatabase;
 import de.intevation.artifacts.ArtifactDatabaseException;
 import de.intevation.artifacts.ArtifactNamespaceContext;
 import de.intevation.artifacts.CallContext;
-
 import de.intevation.artifacts.common.utils.XMLUtils;
 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
 
@@ -63,20 +61,17 @@
         long        ttl,
         CallContext callContext
     ) {
-        this.name     = name;
-        this.uuid     = uuid;
-        this.creation = creation;
-        this.ttl      = ttl;
-        this.context  = callContext;
-        this.database = callContext.getDatabase();
+        this.name      = name;
+        this.uuid      = uuid;
+        this.creation  = creation;
+        this.ttl       = ttl;
+        this.context   = callContext;
+        this.database  = callContext.getDatabase();
+        this.artifacts = new ArrayList<String>();
     }
 
 
     public void addArtifact(String uuid) {
-        if (artifacts == null) {
-            artifacts = new ArrayList<String>();
-        }
-
         if (uuid != null && uuid.length() > 0) {
             artifacts.add(uuid);
         }
@@ -197,10 +192,12 @@
 
 
     protected void appendAttribute(Element root) {
-        Document owner = root.getOwnerDocument();
-        Document attr  = attribute.toXML();
+        if (attribute != null) {
+            Document owner = root.getOwnerDocument();
+            Document attr  = attribute.toXML();
 
-        root.appendChild(owner.importNode(attr.getFirstChild(), true));
+            root.appendChild(owner.importNode(attr.getFirstChild(), true));
+        }
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Wed Sep 19 14:58:31 2012 +0000
@@ -1,5 +1,21 @@
 package de.intevation.flys.collections;
 
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.xpath.XPathConstants;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
 import de.intevation.artifactdatabase.Backend;
 import de.intevation.artifactdatabase.Backend.PersistentArtifact;
 import de.intevation.artifactdatabase.DefaultArtifactCollection;
@@ -19,22 +35,6 @@
 import de.intevation.flys.exports.OutputHelper;
 import de.intevation.flys.utils.FLYSUtils;
 
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.xpath.XPathConstants;
-
-import org.apache.log4j.Logger;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
@@ -126,6 +126,11 @@
         CollectionAttribute cAttribute =
             buildOutAttributes(db, context, oldParser, uuids);
 
+        if (cAttribute == null) {
+            log.warn("mergeAttributes: cAttribute == null");
+            return null;
+        }
+
         cAttribute.setLoadedRecommendations(
             getLoadedRecommendations(oldParser.getAttributeDocument()));
 
@@ -450,8 +455,6 @@
         AttributeParser  aParser,
         String[]         uuids)
     {
-        Document doc = XMLUtils.newDocument();
-
         FLYSContext flysContext = FLYSUtils.getFlysContext(context);
         StateEngine engine = (StateEngine) flysContext.get(
             FLYSContext.STATE_ENGINE_KEY);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Wed Sep 19 14:58:31 2012 +0000
@@ -65,6 +65,7 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import de.intevation.flys.utils.Formatter;
 
 /**
  * The base class for chart creation. It should provide some basic things that
@@ -1669,6 +1670,12 @@
 
         area.applyTheme(dRenderer);
 
+        // i18n
+        dRenderer.setAreaLabelNumberFormat(Formatter.getFormatter(context.getMeta(), 2, 4));
+
+        dRenderer.setAreaLabelTemplate(Resources.getMsg(
+            context.getMeta(), "area.label.template", "Area=%sm2"));
+
         LegendItem legendItem = dRenderer.getLegendItem(idx, 0);
         if (legendItem != null) {
             legendItem.setLabelFont(legendFont);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/OutputHelper.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/OutputHelper.java	Wed Sep 19 14:58:31 2012 +0000
@@ -457,7 +457,6 @@
                       pattern,
                       outName,
                       "default");
-        
 
         if (t != null) {
             log.debug("found theme for facet '" + facet + "'");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedQualityExporter.java	Wed Sep 19 14:58:31 2012 +0000
@@ -0,0 +1,216 @@
+package de.intevation.flys.exports.minfo;
+
+import gnu.trove.TDoubleArrayList;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+
+import au.com.bytecode.opencsv.CSVWriter;
+import de.intevation.artifacts.CallContext;
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.minfo.BedDiameterResult;
+import de.intevation.flys.artifacts.model.minfo.BedParametersResult;
+import de.intevation.flys.artifacts.model.minfo.BedQualityResult;
+import de.intevation.flys.artifacts.model.minfo.BedloadDiameterResult;
+import de.intevation.flys.exports.AbstractExporter;
+import de.intevation.flys.utils.Formatter;
+
+
+public class BedQualityExporter
+extends AbstractExporter
+{
+    /** Private logger. */
+    private static Logger logger = Logger.getLogger(BedQualityExporter.class);
+
+    private static final String CSV_HEADER_KM = "export.minfo.bedquality.km";
+    private static final String CSV_HEADER_DENSITY_CAP =
+        "export.minfo.bedquality.density_cap";
+    private static final String CSV_HEADER_DENSITY_SUB =
+        "export.minfo.bedquality.density_sub";
+    private static final String CSV_HEADER_POROSITY_CAP =
+        "export.minfo.bedquality.porosity_cap";
+    private static final String CSV_HEADER_POROSITY_SUB =
+        "export.minfo.bedquality.porosity_sub";
+    private static final String CSV_HEADER_BEDLOAD =
+        "export.minfo.bedquality.bedload";
+    private static final String CSV_HEADER_BED_CAP =
+        "export.minfo.bedquality.bed_cap";
+    private static final String CSV_HEADER_BED_SUB =
+        "export.minfo.bedquality.bed_sub";
+
+    private BedQualityResult[] results;
+
+    @Override
+    public void init(Document request, OutputStream out, CallContext context) {
+        logger.debug("BedQualityExporter.init");
+        super.init(request, out, context);
+        results = new BedQualityResult[0];
+    }
+
+    @Override
+    protected void writeCSVData(CSVWriter writer) throws IOException {
+        // TODO Auto-generated method stub
+        writeCSVHeader(writer);
+
+        NumberFormat kmf = Formatter.getCalculationKm(context.getMeta());
+
+        TDoubleArrayList kms = new TDoubleArrayList();
+        int cols = 1;
+        for (int i = 0; i < results.length; i++) {
+            BedDiameterResult[] beds = results[i].getBedResults();
+            for (int j = 0; j < beds.length; j++) {
+                TDoubleArrayList bkms = beds[j].getKms();
+                for (int k = 0; k < bkms.size(); k++) {
+                    if (!kms.contains(bkms.get(k))) {
+                        kms.add(bkms.get(k));
+                    }
+                }
+            }
+            BedloadDiameterResult[] loads = results[i].getBedloadResults();
+            for (int j = 0; j < loads.length; j++) {
+                TDoubleArrayList lkms = loads[i].getKms();
+                for (int k = 0; k < lkms.size(); k++) {
+                    if (!kms.contains(lkms.get(k))) {
+                        kms.add(lkms.get(k));
+                    }
+                }
+            }
+            cols += beds.length * 2;
+            cols += loads.length;
+            if (beds.length > 0) {
+                cols += 4;
+            }
+        }
+
+        kms.sort();
+        List<double[]> rows = new LinkedList<double[]>();
+        for (int i = 0; i < kms.size(); i++) {
+            double[] row = new double[cols];
+            double km = kms.get(i);
+            row[0] = km;
+            for (int j = 0; j < results.length; j++) {
+                BedloadDiameterResult[] loads = results[j].getBedloadResults();
+
+                for(int k = 0; k < loads.length; k++) {
+                    // k + 1: shift km column.
+                    // j* loads.length: shift periods.
+                    row[(k + 1) + (j * loads.length)] =
+                        loads[k].getDiameter(km);
+                }
+                BedDiameterResult[] beds = results[j].getBedResults();
+                for (int k = 0; k < beds.length; k++) {
+                    // k + 1: shift km column.
+                    // j * beds.length: shift periods.
+                    // loads.length * results.length: shift bed load columns.
+                    int ndx = (k + 1) + (j * beds.length) + (loads.length * results.length);
+                    row[ndx] = beds[k].getDiameterCap(km);
+                    row[ndx + 1] = beds[k].getDiameterSub(km);
+                }
+                BedParametersResult[] params = results[j].getParameters();
+                for(int k = 0; k < params.length; k++) {
+                    // loads.length + (beds.lenght * 2) * (j + 1): shift bed and bedload columns.
+                    int ndx = 1 + (loads.length + (beds.length * 2) * (j + 1));
+                    row[ndx] = params[k].getLoadDensityCap(km);
+                    row[ndx + 1] = params[k].getLoadDensitySub(km);
+                    row[ndx + 2] = params[k].getPorosityCap(km);
+                    row[ndx + 3] = params[k].getPorositySub(km);
+                }
+            }
+            rows.add(row);
+        }
+        for (double[] d : rows) {
+            logger.debug(Arrays.toString(d));
+            List<String> cells = new LinkedList<String>();
+            for (int i = 0; i < d.length; i++) {
+                if (!Double.isNaN(d[i])) {
+                    NumberFormat nf = Formatter.getFormatter(context, 1, 3);
+                    cells.add(nf.format(d[i]));
+                }
+                else {
+                    cells.add("");
+                }
+            }
+            writer.writeNext(cells.toArray(new String[cells.size()]));
+        }
+    }
+
+    @Override
+    protected void writePDF(OutputStream out) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    protected void addData(Object data) {
+        // TODO Auto-generated method stub
+        logger.debug("addData()");
+        if (!(data instanceof CalculationResult)) {
+            logger.warn("Invalid data type.");
+            return;
+        }
+        Object[] d = (Object[])((CalculationResult)data).getData();
+
+        if (!(d instanceof BedQualityResult[])) {
+            logger.warn("Invalid result object.");
+            return;
+        }
+        results = (BedQualityResult[])d;
+    }
+
+    protected void writeCSVHeader(CSVWriter writer) {
+        logger.debug("writeCSVHeader()");
+
+        List<String> header = new LinkedList<String>();
+        if (results != null)  {
+            header.add(msg(CSV_HEADER_KM, "km"));
+            for (int i = 0; i < results.length; i++) {
+                DateFormat df = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy");
+                String d1 = df.format(results[i].getDateRange().getFrom());
+                String d2 = df.format(results[i].getDateRange().getTo());
+                BedloadDiameterResult[] loads = results[i].getBedloadResults();
+                BedDiameterResult[] beds = results[i].getBedResults();
+                BedParametersResult[] params = results[i].getParameters();
+                for (int j = 0; j < loads.length; j++) {
+                    header.add(msg(CSV_HEADER_BEDLOAD, CSV_HEADER_BEDLOAD) +
+                        " - " +
+                        msg(loads[j].getType().toString(),
+                            loads[j].getType().toString()) + " - " +
+                        d1 + "-" + d2);
+                }
+                for (int j = 0; j < beds.length; j++) {
+                    header.add(msg(CSV_HEADER_BED_CAP, CSV_HEADER_BED_CAP) + " - " +
+                        msg(beds[j].getType().toString(),
+                            beds[j].getType().toString()) + " - " +
+                        d1 + "-" + d2);
+                    header.add(msg(CSV_HEADER_BED_SUB, CSV_HEADER_BED_SUB) + " - " +
+                        msg(beds[j].getType().toString(),
+                            beds[j].getType().toString()) + " - " +
+                        d1 + "-" + d2);
+                }
+                if (params.length > 0) {
+                    header.add(
+                        msg(CSV_HEADER_DENSITY_CAP, CSV_HEADER_DENSITY_CAP));// +
+                        //" - " + d1 + "-" + d2);
+                    header.add(
+                        msg(CSV_HEADER_DENSITY_SUB, CSV_HEADER_DENSITY_SUB)); //+
+                        //" - " + d1 + "-" + d2);
+                    header.add(
+                        msg(CSV_HEADER_POROSITY_CAP, CSV_HEADER_POROSITY_CAP)); //+
+                        //" - " + d1 + "-" + d2);
+                    header.add(
+                        msg(CSV_HEADER_POROSITY_SUB, CSV_HEADER_POROSITY_SUB));// +
+                        //" - " + d1 + "-" + d2);
+                }
+            }
+        }
+        writer.writeNext(header.toArray(new String[header.size()]));
+    }
+}
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java	Wed Sep 19 14:58:31 2012 +0000
@@ -9,7 +9,6 @@
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.minfo.BedDiameterResult;
 import de.intevation.flys.artifacts.model.minfo.BedParametersResult;
-import de.intevation.flys.artifacts.model.minfo.BedQualityResult;
 import de.intevation.flys.artifacts.model.minfo.BedloadDiameterResult;
 import de.intevation.flys.exports.StyledSeriesBuilder;
 import de.intevation.flys.exports.XYChartGenerator;
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StableXYDifferenceRenderer.java	Wed Sep 19 14:58:31 2012 +0000
@@ -123,6 +123,8 @@
 
 import de.intevation.flys.artifacts.math.Linear;
 
+import java.text.NumberFormat;
+
 import org.apache.log4j.Logger;
 
 /**
@@ -179,6 +181,12 @@
     /** Font to draw label of calculated area with. */
     protected Font labelFont;
 
+    /** Template to create i18ned label for area. */
+    protected String areaLabelTamplate;
+
+    /** NumberFormat to use for area. */
+    protected NumberFormat areaLabelNumberFormat;
+
     protected int areaCalculationMode;
 
     protected double positiveArea;
@@ -260,6 +268,18 @@
         this.areaCalculationMode = areaCalculationMode;
     }
 
+
+    /** Set template to use to create area label (e.g. 'Area=%dm2'). */
+    public void setAreaLabelTemplate(String areaTemplate) {
+        this.areaLabelTamplate = areaTemplate;
+    }
+
+
+    public void setAreaLabelNumberFormat(NumberFormat nf) {
+        this.areaLabelNumberFormat = nf;
+    }
+
+
     public boolean isLabelArea() {
         return this.labelArea;
     }
@@ -826,7 +846,7 @@
 
         switch (dataset.getSeriesCount()) {
             case 0:
-                return Collections.emptyList();
+                return Collections.<XYDataset>emptyList();
             case 1:
                 return splitByNaNsOneSeries(dataset);
             default: // two or more
@@ -880,8 +900,7 @@
         }
 
         // Find geometric middle, calculate area and paint a string with it here.
-        // TODO also i18n
-        if (pass == 1 && this.labelArea) {
+        if (pass == 1 && this.labelArea && areaLabelNumberFormat != null && areaLabelTamplate != null) {
             double center_x = centroid.getX();
             double center_y = centroid.getY();
             center_x = domainAxis.valueToJava2D(center_x, dataArea,
@@ -904,7 +923,8 @@
                 Color oldColor = g2.getColor();
                 Font oldFont = g2.getFont();
                 g2.setFont(labelFont);
-                String labelText = "Area= " + area + "m2";
+                String labelText = String.format(this.areaLabelTamplate,
+                    areaLabelNumberFormat.format(area));
                 if (labelBGColor != null) {
                     EnhancedLineAndShapeRenderer.drawTextBox(g2, labelText,
                         (float)center_x, (float)center_y, labelBGColor);
--- a/flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeFactory.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeFactory.java	Wed Sep 19 14:58:31 2012 +0000
@@ -130,7 +130,7 @@
                 && tm.outputMatches(output))
             {
                 String target = tm.getTo();
-                
+
                 logger.debug("Found theme '" + target + "'");
                 return t.get(target);
             }
--- a/flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeMapping.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeMapping.java	Wed Sep 19 14:58:31 2012 +0000
@@ -88,7 +88,7 @@
             return true;
         }
         Matcher m = pattern.matcher(text);
-        
+
        if (m.matches()) {
            logger.debug("Pattern matches: " + text);
            return true;
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java	Wed Sep 19 14:58:31 2012 +0000
@@ -177,5 +177,16 @@
             }
         }
     }
+
+    public static final boolean isValid(double [][] data) {
+        for (double [] ds: data) {
+            for (double d: ds) {
+                if (Double.isNaN(d)) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/resources/messages.properties	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Wed Sep 19 14:58:31 2012 +0000
@@ -462,3 +462,6 @@
 
 load_diameter = Bedload Diameter
 bed_diameter = Bed Diameter
+
+area.label.template = Area = %s m\u00b3
+
--- a/flys-artifacts/src/main/resources/messages_de.properties	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Wed Sep 19 14:58:31 2012 +0000
@@ -465,3 +465,6 @@
 
 load_diameter = Geschiebedurchmesser
 bed_diameter = Sohldurchmesser
+
+area.label.template = Fl\u00e4che = %s m\u00b3
+
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Wed Sep 19 14:58:31 2012 +0000
@@ -465,3 +465,5 @@
 load_diameter = Geschiebedurchmesser
 bed_diameter = Sohldurchmesser
 
+area.label.template = Fl\u00e4che = %s m\u00b3
+
--- a/flys-artifacts/src/main/resources/messages_en.properties	Wed Sep 19 14:56:13 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Wed Sep 19 14:58:31 2012 +0000
@@ -463,3 +463,5 @@
 
 load_diameter = Bedload Diameter
 bed_diameter = Bed Diameter
+
+area.label.template = Area = %s m\u00b3

http://dive4elements.wald.intevation.org