Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java @ 1141:bcba246d9c03
Fix various issues like i18n in cross section diagrams.
flys-artifacts/trunk@2662 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 07 Sep 2011 10:37:14 +0000 |
parents | 65d8b3340397 |
children | 01d42a2454f6 |
comparison
equal
deleted
inserted
replaced
1140:96d7842e80ee | 1141:bcba246d9c03 |
---|---|
15 import de.intevation.artifacts.Artifact; | 15 import de.intevation.artifacts.Artifact; |
16 | 16 |
17 import de.intevation.artifactdatabase.state.Facet; | 17 import de.intevation.artifactdatabase.state.Facet; |
18 | 18 |
19 import de.intevation.flys.artifacts.FLYSArtifact; | 19 import de.intevation.flys.artifacts.FLYSArtifact; |
20 import de.intevation.flys.artifacts.WINFOArtifact; | |
20 | 21 |
21 import de.intevation.flys.artifacts.model.FacetTypes; | 22 import de.intevation.flys.artifacts.model.FacetTypes; |
22 import de.intevation.flys.artifacts.model.WQKms; | 23 import de.intevation.flys.artifacts.model.WQKms; |
23 | 24 |
24 | 25 |
59 /** | 60 /** |
60 * Get localized chart title. | 61 * Get localized chart title. |
61 */ | 62 */ |
62 protected String getChartTitle() { | 63 protected String getChartTitle() { |
63 // TODO get river etc for localized heading | 64 // TODO get river etc for localized heading |
64 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | 65 Object[] i18n_msg_args = new Object[] { |
66 getRiverName() | |
67 }; | |
68 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT, i18n_msg_args); | |
65 } | 69 } |
66 | 70 |
67 | 71 |
68 /** | 72 /** |
69 * Add localized subtitle to chart. | 73 * Add localized subtitle to chart. |
72 protected void addSubtitles(JFreeChart chart) { | 76 protected void addSubtitles(JFreeChart chart) { |
73 double[] dist = getRange(); | 77 double[] dist = getRange(); |
74 | 78 |
75 Object[] args = new Object[] { | 79 Object[] args = new Object[] { |
76 getRiverName(), | 80 getRiverName(), |
77 dist[0], | 81 getKm() |
78 dist[1] | |
79 }; | 82 }; |
80 | 83 |
81 String subtitle = msg(I18N_CHART_SUBTITLE, "", args); | 84 String subtitle = msg(I18N_CHART_SUBTITLE, "", args); |
82 chart.addSubtitle(new TextTitle(subtitle)); | 85 chart.addSubtitle(new TextTitle(subtitle)); |
83 } | 86 } |
86 /** | 89 /** |
87 * Get localized X Axis label. | 90 * Get localized X Axis label. |
88 */ | 91 */ |
89 protected String getXAxisLabel() { | 92 protected String getXAxisLabel() { |
90 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); | 93 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); |
94 } | |
95 | |
96 | |
97 /** | |
98 * Get cross_section.km data from artifact. | |
99 */ | |
100 protected Double getKm() { | |
101 try { | |
102 WINFOArtifact winfo = (WINFOArtifact) master; | |
103 return Double.parseDouble(winfo.getDataAsString("cross_section.km")); | |
104 } | |
105 catch (Exception e) { | |
106 logger.error("Cannot convert cross_section.km to double"); | |
107 return 0.0d; | |
108 } | |
91 } | 109 } |
92 | 110 |
93 | 111 |
94 /** | 112 /** |
95 * Get localized Y Axis label. | 113 * Get localized Y Axis label. |
142 if (f == null) { | 160 if (f == null) { |
143 return; | 161 return; |
144 } | 162 } |
145 | 163 |
146 if (name.equals(CROSS_SECTION)) { | 164 if (name.equals(CROSS_SECTION)) { |
147 doCrossSectionOut(f.getData(artifact, context), attr); | 165 doCrossSectionOut(f.getData(artifact, context), f.getDescription(), attr); |
148 } | 166 } |
149 else if (name.equals(CROSS_SECTION_WATER_LINE)) { | 167 else if (name.equals(CROSS_SECTION_WATER_LINE)) { |
150 doCrossSectionWaterLineOut(f.getData(artifact, context), attr); | 168 doCrossSectionWaterLineOut(f.getData(artifact, context), f.getDescription(), attr); |
151 } | 169 } |
152 else { | 170 else { |
153 logger.warn("CrossSection.doOut: Unknown facet name: " + name); | 171 logger.warn("CrossSection.doOut: Unknown facet name: " + name); |
154 return; | 172 return; |
155 } | 173 } |
157 | 175 |
158 | 176 |
159 /** | 177 /** |
160 * Do cross sections waterline out. | 178 * Do cross sections waterline out. |
161 * | 179 * |
180 * @param seriesName name of the data (line) to display in legend. | |
162 * @param theme Theme for the data series. | 181 * @param theme Theme for the data series. |
163 */ | 182 */ |
164 protected void doCrossSectionWaterLineOut(Object o, Document theme) { | 183 protected void doCrossSectionWaterLineOut(Object o, String seriesName, Document theme) { |
165 logger.debug("CrossSectionGenerator.doCrossSectionWaterLineOut"); | 184 logger.debug("CrossSectionGenerator.doCrossSectionWaterLineOut"); |
166 // TODO Series should get name like "Q=22.0" | 185 |
167 XYSeries series = new StyledXYSeries("Q= ... ", theme); | 186 XYSeries series = new StyledXYSeries(seriesName, theme); |
168 | 187 |
169 double[][] a = (double [][]) o; | 188 double[][] a = (double [][]) o; |
170 double [] pxs = a[0]; | 189 double [] pxs = a[0]; |
171 for (int i = 0; i < pxs.length; i++) { | 190 for (int i = 0; i < pxs.length; i++) { |
172 series.add (a[0][i], a[1][i]); | 191 series.add (a[0][i], a[1][i]); |
176 | 195 |
177 | 196 |
178 /** | 197 /** |
179 * Do cross sections out. | 198 * Do cross sections out. |
180 * | 199 * |
200 * @param seriesName name of the data (line) to display in legend. | |
181 * @param theme Theme for the data series. | 201 * @param theme Theme for the data series. |
182 */ | 202 */ |
183 protected void doCrossSectionOut(Object o, Document theme) { | 203 protected void doCrossSectionOut(Object o, String seriesName, Document theme) { |
184 logger.debug("CrossSectionGenerator.doCrossSectionOut"); | 204 logger.debug("CrossSectionGenerator.doCrossSectionOut"); |
185 | 205 |
186 // TODO Series should get name of selected cross-section (e.g. | 206 XYSeries series = new StyledXYSeries(seriesName, theme); |
187 // "0-93.1(1990-2002).PRF") (exposed as getCrossSectionName in | |
188 // WINFOArtifact) | |
189 XYSeries series = new StyledXYSeries("aliquide", theme); | |
190 | 207 |
191 double[][] a = (double [][]) o; | 208 double[][] a = (double [][]) o; |
192 double [] pxs = a[0]; | 209 double [] pxs = a[0]; |
193 for (int i = 0; i < pxs.length; i++) { | 210 for (int i = 0; i < pxs.length; i++) { |
194 series.add (a[0][i], a[1][i]); | 211 series.add (a[0][i], a[1][i]); |