changeset 3762:0c978a80726a

Splitted up facets for porosity and density into two facets: a toplayer and a sublayer facet for each. BedQualityState will now create facets based on the calculation result. flys-artifacts/trunk@5464 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 14 Sep 2012 07:12:08 +0000
parents 066e2b4d69ca
children 55fe9c1dc6f3
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/minfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java
diffstat 5 files changed, 100 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Sep 13 20:58:24 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Sep 14 07:12:08 2012 +0000
@@ -1,3 +1,17 @@
+2012-09-14  Ingo Weinzierl <ingo@intevation.de>
+
+	* doc/conf/artifacts/minfo.xml: Splitted porosity and density facets into
+	  two facets: a toplayer and a sublayer facet for each.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added
+	  the new facets for toplayer and sublayer for porosity and density.
+
+	* src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java:
+	  Create Facets based on the calculation results.
+
+	* src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java:
+	  Use concrete result types in doXXXOut().
+
 2012-09-13	Christian Lins	<christian.lins@intevation.de>
 
 	* doc/conf/artifacts/fixanalysis.xml,
--- a/flys-artifacts/doc/conf/artifacts/minfo.xml	Thu Sep 13 20:58:24 2012 +0000
+++ b/flys-artifacts/doc/conf/artifacts/minfo.xml	Fri Sep 14 07:12:08 2012 +0000
@@ -282,10 +282,12 @@
             <outputmodes>
                 <outputmode name="bed_longitudinal_section" description="output.bed_longitudinal_section" mime-type="image/png" type="chart">
                     <facets>
-                    	<facet name="bed_longitudinal_section.porosity"/>
+                    	<facet name="bed_longitudinal_section.porosity_toplayer"/>
+                    	<facet name="bed_longitudinal_section.porosity_sublayer"/>
+                    	<facet name="bed_longitudinal_section.sediment_density_toplayer"/>
+                    	<facet name="bed_longitudinal_section.sediment_density_sublayer"/>
                     	<facet name="bed_longitudinal_section.bedload_diameter"/>
                     	<facet name="bed_longitudinal_section.bed_diameter"/>
-                    	<facet name="bed_longitudinal_section.sediment_density"/>
                     </facets>
                 </outputmode>
             </outputmodes>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu Sep 13 20:58:24 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Fri Sep 14 07:12:08 2012 +0000
@@ -215,10 +215,12 @@
     String MIDDLE_BED_HEIGHT_EPOCH      = "bedheight_middle.epoch";
     String MIDDLE_BED_HEIGHT_ANNOTATION = "bedheight_middle.annotation";
 
-    String BED_QUALITY_POROSITY         = "bed_longitudinal_section.porosity";
-    String BED_QUALITY_BED_DIAMETER     = "bed_longitudinal_section.bed_diameter";
-    String BED_QUALITY_BEDLOAD_DIAMETER = "bed_longitudinal_section.bedload_diameter";
-    String BED_QUALITY_SEDIMENT_DENSITY = "bed_longitudinal_section.sediment_density";
+    String BED_QUALITY_POROSITY_TOPLAYER = "bed_longitudinal_section.porosity_toplayer";
+    String BED_QUALITY_POROSITY_SUBLAYER = "bed_longitudinal_section.porosity_sublayer";
+    String BED_QUALITY_BED_DIAMETER      = "bed_longitudinal_section.bed_diameter";
+    String BED_QUALITY_BEDLOAD_DIAMETER  = "bed_longitudinal_section.bedload_diameter";
+    String BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER = "bed_longitudinal_section.sediment_density_toplayer";
+    String BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER = "bed_longitudinal_section.sediment_density_sublayer";
 
     String SQ_OVERVIEW       = "sq_overview";
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java	Thu Sep 13 20:58:24 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java	Fri Sep 14 07:12:08 2012 +0000
@@ -11,10 +11,13 @@
 import de.intevation.flys.artifacts.access.BedQualityAccess;
 import de.intevation.flys.artifacts.model.CalculationResult;
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.minfo.BedBedQualityResult;
 import de.intevation.flys.artifacts.model.minfo.BedDensityFacet;
 import de.intevation.flys.artifacts.model.minfo.BedDiameterFacet;
+import de.intevation.flys.artifacts.model.minfo.BedLoadBedQualityResult;
 import de.intevation.flys.artifacts.model.minfo.BedPorosityFacet;
 import de.intevation.flys.artifacts.model.minfo.BedQualityCalculation;
+import de.intevation.flys.artifacts.model.minfo.BedQualityResult;
 import de.intevation.flys.artifacts.model.minfo.BedloadDiameterFacet;
 import de.intevation.flys.artifacts.states.DefaultState;
 
@@ -42,25 +45,63 @@
             return res;
         }
 
-        String stateId = getID();
-
-        // TODO CREATE FACETS DEPENDING ON THE CALCULATION RESULT
-        newFacets.add(new BedDiameterFacet(0, BED_QUALITY_BED_DIAMETER,
-            "bed diameter", ComputeType.ADVANCE, stateId, hash));
+        BedQualityResult[] results = (BedQualityResult[]) res.getData();
 
-        newFacets.add(new BedloadDiameterFacet(0, BED_QUALITY_BEDLOAD_DIAMETER,
-            "bedload diameter", ComputeType.ADVANCE, stateId, hash));
+        if (results == null || results.length == 0) {
+            logger.warn("Calculation computed no results!");
+            return res;
+        }
 
-        newFacets.add(new BedPorosityFacet(0, BED_QUALITY_POROSITY, "porosity",
-            ComputeType.ADVANCE, stateId, hash));
+        generateFacets(newFacets, results, getID(), hash);
+        logger.debug("Created " + newFacets.size() + " new Facets.");
 
-        newFacets.add(new BedDensityFacet(0, BED_QUALITY_SEDIMENT_DENSITY,
-            "density", ComputeType.ADVANCE, stateId, hash));
-
-        logger.debug("Created " + newFacets.size() + " new Facets.");
         facets.addAll(newFacets);
 
         return res;
     }
+
+    protected void generateFacets(List<Facet> newFacets,
+        BedQualityResult[] results, String stateId, String hash) {
+        logger.debug("BedQualityState.generateFacets");
+
+        for (int idx = 0; idx < results.length; idx++) {
+            BedQualityResult result = results[idx];
+
+            if (result instanceof BedBedQualityResult) {
+                // TODO I18N for Facet description
+                newFacets.add(new BedPorosityFacet(idx,
+                    BED_QUALITY_POROSITY_TOPLAYER, "porosity_toplayer",
+                    ComputeType.ADVANCE, stateId, hash));
+
+                // TODO I18N for Facet description
+                newFacets.add(new BedPorosityFacet(idx,
+                    BED_QUALITY_POROSITY_SUBLAYER, "porosity_sublayer",
+                    ComputeType.ADVANCE, stateId, hash));
+
+                // TODO I18N for Facet description
+                newFacets.add(new BedDensityFacet(idx,
+                    BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER, "density_toplayer",
+                    ComputeType.ADVANCE, stateId, hash));
+
+                // TODO I18N for Facet description
+                newFacets.add(new BedDensityFacet(idx,
+                    BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER, "density_sublayer",
+                    ComputeType.ADVANCE, stateId, hash));
+
+                // TODO I18N for Facet description
+                newFacets.add(new BedloadDiameterFacet(idx,
+                    BED_QUALITY_BEDLOAD_DIAMETER, "bed diameter",
+                    ComputeType.ADVANCE, stateId, hash));
+            }
+            else if (result instanceof BedLoadBedQualityResult) {
+                // TODO CREATE FACETS DEPENDING ON THE CALCULATION RESULT
+                newFacets.add(new BedDiameterFacet(idx, BED_QUALITY_BED_DIAMETER,
+                    "bedload diameter", ComputeType.ADVANCE, stateId, hash));
+            }
+            else {
+                logger.warn("unknown result object: " + result.getClass());
+            }
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java	Thu Sep 13 20:58:24 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java	Fri Sep 14 07:12:08 2012 +0000
@@ -6,15 +6,11 @@
 
 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
 import de.intevation.artifactdatabase.state.Facet;
-import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.MiddleBedHeightData;
-import de.intevation.flys.exports.ChartGenerator.YAxisWalker;
-import de.intevation.flys.exports.StyledSeriesBuilder;
+import de.intevation.flys.artifacts.model.minfo.BedBedQualityResult;
+import de.intevation.flys.artifacts.model.minfo.BedLoadBedQualityResult;
 import de.intevation.flys.exports.XYChartGenerator;
-import de.intevation.flys.jfree.FLYSAnnotation;
 import de.intevation.flys.jfree.StyledXYSeries;
-import de.intevation.flys.utils.FLYSUtils;
 
 
 /**
@@ -148,26 +144,25 @@
         }
 
         if (name.equals(BED_QUALITY_BED_DIAMETER)) {
-            doBedDiameterOut(artifactAndFacet.getData(context), // TODO CAST TO
-                                                                // SPECIFIC
-                                                                // CLASS
+            doBedDiameterOut(
+                (BedBedQualityResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
         else if (name.equals(BED_QUALITY_BEDLOAD_DIAMETER)) {
-            doBedloadDiameterOut(artifactAndFacet.getData(context), // TODO CAST
-                                                                    // TO
-                                                                    // SPECIFIC
-                                                                    // CLASS
+            doBedloadDiameterOut(
+                (BedLoadBedQualityResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
-        else if (name.equals(BED_QUALITY_POROSITY)) {
-            doPorosityOut(artifactAndFacet.getData(context), // TODO CAST TO
-                                                             // SPECIFIC CLASS
+        else if (name.equals(BED_QUALITY_POROSITY_TOPLAYER)
+            || name.equals(BED_QUALITY_POROSITY_SUBLAYER)) {
+            doPorosityOut(
+                (BedBedQualityResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
-        else if (name.equals(BED_QUALITY_SEDIMENT_DENSITY)) {
-            doDensityOut(artifactAndFacet.getData(context), // TODO CAST TO
-                                                            // SPECIFIC CLASS
+        else if (name.equals(BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER)
+            || name.equals(BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER)) {
+            doDensityOut(
+                (BedBedQualityResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
         else if (FacetTypes.IS.MANUALPOINTS(name)) {
@@ -180,8 +175,8 @@
         }
     }
 
-    protected void doBedDiameterOut(Object data, ArtifactAndFacet aandf,
-        Document theme, boolean visible) {
+    protected void doBedDiameterOut(BedBedQualityResult data,
+        ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doBedDiameterOut");
 
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
@@ -192,8 +187,8 @@
         addAxisSeries(series, YAXIS.W.idx, visible);
     }
 
-    protected void doBedloadDiameterOut(Object data, ArtifactAndFacet aandf,
-        Document theme, boolean visible) {
+    protected void doBedloadDiameterOut(BedLoadBedQualityResult data,
+        ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doBedloadDiameterOut");
 
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
@@ -204,8 +199,8 @@
         addAxisSeries(series, YAXIS.W.idx, visible);
     }
 
-    protected void doPorosityOut(Object data, ArtifactAndFacet aandf,
-        Document theme, boolean visible) {
+    protected void doPorosityOut(BedBedQualityResult data,
+        ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doPorosityOut");
 
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
@@ -216,8 +211,8 @@
         addAxisSeries(series, YAXIS.P.idx, visible);
     }
 
-    protected void doDensityOut(Object data, ArtifactAndFacet aandf,
-        Document theme, boolean visible) {
+    protected void doDensityOut(BedBedQualityResult data,
+        ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doDensityOut");
 
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);

http://dive4elements.wald.intevation.org