changeset 2042:3f6b519300ec

Include selected km in cross section diagrams subtitle. flys-artifacts/trunk@3528 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 22 Dec 2011 12:54:47 +0000
parents e5f01f2325c9
children 8dec3bd9f2f6
files flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java
diffstat 1 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Thu Dec 22 12:53:29 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Thu Dec 22 12:54:47 2011 +0000
@@ -1,5 +1,7 @@
 package de.intevation.flys.exports;
 
+import java.util.List;
+
 import org.apache.log4j.Logger;
 
 import org.jfree.chart.JFreeChart;
@@ -12,8 +14,12 @@
 
 import de.intevation.flys.artifacts.WINFOArtifact;
 
+import de.intevation.flys.model.CrossSectionLine;
+
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.CrossSectionFacet;
 
+import de.intevation.artifacts.DataProvider;
 
 /**
  * An OutGenerator that generates cross section graphs.
@@ -63,11 +69,19 @@
 
     @Override
     protected String getChartSubtitle() {
-        double[] dist = getRange();
+        List<DataProvider> providers =
+            context.getDataProvider(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA);
+        double km = 0d;
+        if (providers.size() > 0) {
+            CrossSectionLine csl = (CrossSectionLine) providers.get(0).
+                provideData(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA,
+                    null, context);
+            km = csl.getKm().doubleValue();
+        }
 
         Object[] args = new Object[] {
             getRiverName(),
-            getKm()
+            km
         };
 
         return msg(I18N_CHART_SUBTITLE, "", args);
@@ -98,12 +112,10 @@
     protected Double getKm() {
         try {
             WINFOArtifact winfo = (WINFOArtifact) master;
-            // TODO get km of "master cross section."
-            //return winfo.getCrossSectionSnapKm(0);
-            return 0.0d;
+            return winfo.getCrossSectionKm();
         }
         catch (Exception e) {
-            logger.error("Cannot convert cross_section.km to double");
+            logger.warn("Cannot convert cross_section.km to double.");
             return 0.0d;
         }
     }

http://dive4elements.wald.intevation.org