comparison flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java @ 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 76cedac30d35
children 5d6e82abe859
comparison
equal deleted inserted replaced
2041:e5f01f2325c9 2042:3f6b519300ec
1 package de.intevation.flys.exports; 1 package de.intevation.flys.exports;
2
3 import java.util.List;
2 4
3 import org.apache.log4j.Logger; 5 import org.apache.log4j.Logger;
4 6
5 import org.jfree.chart.JFreeChart; 7 import org.jfree.chart.JFreeChart;
6 import org.jfree.chart.title.TextTitle; 8 import org.jfree.chart.title.TextTitle;
10 12
11 import de.intevation.artifactdatabase.state.ArtifactAndFacet; 13 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
12 14
13 import de.intevation.flys.artifacts.WINFOArtifact; 15 import de.intevation.flys.artifacts.WINFOArtifact;
14 16
17 import de.intevation.flys.model.CrossSectionLine;
18
15 import de.intevation.flys.artifacts.model.FacetTypes; 19 import de.intevation.flys.artifacts.model.FacetTypes;
16 20 import de.intevation.flys.artifacts.model.CrossSectionFacet;
21
22 import de.intevation.artifacts.DataProvider;
17 23
18 /** 24 /**
19 * An OutGenerator that generates cross section graphs. 25 * An OutGenerator that generates cross section graphs.
20 */ 26 */
21 public class CrossSectionGenerator 27 public class CrossSectionGenerator
61 } 67 }
62 68
63 69
64 @Override 70 @Override
65 protected String getChartSubtitle() { 71 protected String getChartSubtitle() {
66 double[] dist = getRange(); 72 List<DataProvider> providers =
73 context.getDataProvider(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA);
74 double km = 0d;
75 if (providers.size() > 0) {
76 CrossSectionLine csl = (CrossSectionLine) providers.get(0).
77 provideData(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA,
78 null, context);
79 km = csl.getKm().doubleValue();
80 }
67 81
68 Object[] args = new Object[] { 82 Object[] args = new Object[] {
69 getRiverName(), 83 getRiverName(),
70 getKm() 84 km
71 }; 85 };
72 86
73 return msg(I18N_CHART_SUBTITLE, "", args); 87 return msg(I18N_CHART_SUBTITLE, "", args);
74 } 88 }
75 89
96 * Get cross_section.km data from artifact. 110 * Get cross_section.km data from artifact.
97 */ 111 */
98 protected Double getKm() { 112 protected Double getKm() {
99 try { 113 try {
100 WINFOArtifact winfo = (WINFOArtifact) master; 114 WINFOArtifact winfo = (WINFOArtifact) master;
101 // TODO get km of "master cross section." 115 return winfo.getCrossSectionKm();
102 //return winfo.getCrossSectionSnapKm(0);
103 return 0.0d;
104 } 116 }
105 catch (Exception e) { 117 catch (Exception e) {
106 logger.error("Cannot convert cross_section.km to double"); 118 logger.warn("Cannot convert cross_section.km to double.");
107 return 0.0d; 119 return 0.0d;
108 } 120 }
109 } 121 }
110 122
111 123

http://dive4elements.wald.intevation.org