Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java @ 855:e26935963871
Adjusted chart titles of different horizontalprofile charts.
gnv-artifacts/trunk@973 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 23 Apr 2010 12:11:18 +0000 |
parents | 05bf8534a35a |
children | f953c9a559d8 |
comparison
equal
deleted
inserted
replaced
854:bb2175726c8a | 855:e26935963871 |
---|---|
12 | 12 |
13 import org.apache.log4j.Logger; | 13 import org.apache.log4j.Logger; |
14 import org.jfree.chart.ChartTheme; | 14 import org.jfree.chart.ChartTheme; |
15 | 15 |
16 import de.intevation.artifacts.CallContext; | 16 import de.intevation.artifacts.CallContext; |
17 import de.intevation.gnv.artifacts.ressource.RessourceFactory; | |
17 import de.intevation.gnv.chart.Chart; | 18 import de.intevation.gnv.chart.Chart; |
18 import de.intevation.gnv.chart.ChartLabels; | 19 import de.intevation.gnv.chart.ChartLabels; |
19 import de.intevation.gnv.chart.HorizontalProfileChart; | 20 import de.intevation.gnv.chart.HorizontalProfileChart; |
20 import de.intevation.gnv.exports.DefaultExport; | 21 import de.intevation.gnv.exports.DefaultExport; |
21 import de.intevation.gnv.exports.DefaultProfile; | 22 import de.intevation.gnv.exports.DefaultProfile; |
22 import de.intevation.gnv.exports.ShapeDataCollector; | 23 import de.intevation.gnv.exports.ShapeDataCollector; |
23 import de.intevation.gnv.exports.Export.Profile; | 24 import de.intevation.gnv.exports.Export.Profile; |
24 import de.intevation.gnv.geobackend.base.Result; | 25 import de.intevation.gnv.geobackend.base.Result; |
25 import de.intevation.gnv.state.InputData; | 26 import de.intevation.gnv.state.InputData; |
27 import de.intevation.gnv.state.State; | |
26 import de.intevation.gnv.state.describedata.KeyValueDescibeData; | 28 import de.intevation.gnv.state.describedata.KeyValueDescibeData; |
27 import de.intevation.gnv.state.exception.StateException; | 29 import de.intevation.gnv.state.exception.StateException; |
28 import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; | 30 import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; |
29 import de.intevation.gnv.statistics.HorizontalProfileStatistics; | 31 import de.intevation.gnv.statistics.HorizontalProfileStatistics; |
30 import de.intevation.gnv.statistics.Statistics; | 32 import de.intevation.gnv.statistics.Statistics; |
31 import de.intevation.gnv.utils.InputValidator; | |
32 import de.intevation.gnv.utils.WKTUtils; | |
33 | 33 |
34 /** | 34 /** |
35 * This <code>OutputState</code> is used for 'Horizontalprofile' products. | 35 * This <code>OutputState</code> is used for 'Horizontalprofile' products. |
36 * | 36 * |
37 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> | 37 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> |
252 | 252 |
253 return fisName; | 253 return fisName; |
254 } | 254 } |
255 | 255 |
256 | 256 |
257 /** | |
258 * Creates and returns the subtitle of a chart. | |
259 * | |
260 * @param locale The Locale used to adjust the language of the subtitle. | |
261 * @param uuid The UUID of the current artifact. | |
262 * @return the timeperiod of this chart and the start coordinate. | |
263 */ | |
264 @Override | 257 @Override |
265 protected String createChartSubtitle(Locale locale, String uuid) { | 258 protected String createChartSubtitle(Locale locale, String uuid) { |
266 log.debug("create chart subtitle."); | 259 log.debug("Create subtitle for horizontalprofile chart on meshes."); |
267 String subtitle = createTimePeriod(locale, uuid); | 260 |
268 | 261 StringBuilder sb = new StringBuilder(); |
269 // ODV results contain meta information about cruise, station and so on | 262 String ship = getData(locale, "vehicleid"); |
270 Collection results = getODVResult(uuid); | 263 if (ship != null) { |
271 if (results != null) { | 264 sb.append(ship); |
272 Iterator iter = results.iterator(); | 265 } |
273 Result result = iter.hasNext() ? (Result) iter.next() : null; | 266 |
274 | 267 String cruise = getData(locale, "cruiseid"); |
275 subtitle += subtitle.length() != 0 ? "\n" : ""; | 268 if (cruise != null) { |
276 subtitle += createMetaChartSubtitle(locale, result); | 269 if (ship != null) |
277 } | 270 sb.append("\n"); |
278 | 271 |
279 return subtitle; | 272 sb.append(cruise); |
280 } | 273 } |
281 | 274 |
282 | 275 String track = getData(locale, "trackid"); |
283 /** | 276 if (track != null) { |
284 * Create meta information used in subtitles. | 277 if (cruise != null) |
285 * | 278 sb.append("\n"); |
286 * @param locale The Locale used to adjust the language of the subtitle. | 279 |
287 * @param result A data object. | 280 sb.append(track); |
288 * @return the start coordinate as human readable string. | 281 } |
289 */ | 282 |
290 protected String createMetaChartSubtitle(Locale locale, Result result) { | 283 return sb.toString(); |
291 log.debug("Fetch meta information and put it into subtitle."); | 284 } |
292 if (result == null) | 285 |
293 return ""; | 286 |
294 | 287 protected String getData(Locale locale, String data) { |
295 StringBuilder meta = new StringBuilder(); | 288 InputData input = null; |
296 | 289 |
297 for (int i = 0; i < CHART_TITLE_META.length; i++) { | 290 State parent = this; |
298 String qry = CHART_TITLE_META[i]; | 291 do { |
299 | 292 input = inputData.get(data); |
300 if (qry.equals("SHAPE")) { | 293 |
301 try { | 294 if (input != null) |
302 InputData data = getInputDataByName("mesh_coordinate"); | 295 break; |
303 if (data == null) { | 296 } |
304 continue; | 297 while ((parent = parent.getParent()) != null); |
305 } | 298 |
306 String wktPoint = data.getValue(); | 299 if (input == null) { |
307 meta.append(getMessage(locale,"coordinate","coordinate")); | 300 log.warn("No data found for: " + data); |
308 meta.append(": "); | 301 return null; |
309 meta.append(WKTUtils.toText( | 302 } |
310 locale, | 303 |
311 InputValidator.getPointValue(wktPoint))); | 304 String value = input.getDescription(input.getValue()); |
312 } | 305 String title = RessourceFactory.getInstance().getRessource( |
313 catch (Exception e) { | 306 locale, data, data); |
314 log.error(e, e); | 307 |
315 } | 308 return (title + ": " + value); |
316 } | |
317 else { | |
318 log.debug( | |
319 "Add " + qry + " to meta information of subtitle: " | |
320 + result.getString(qry) | |
321 ); | |
322 meta.append(getMessage( | |
323 locale, | |
324 CHART_TITLE_META_RESSOURCES[i], | |
325 CHART_TITLE_META_RESSOURCES[i] | |
326 )); | |
327 meta.append(": "); | |
328 meta.append(result.getString(qry)); | |
329 } | |
330 | |
331 if (i != CHART_TITLE_META.length-1) | |
332 meta.append("\n"); | |
333 } | |
334 | |
335 log.debug("Meta title for chart: " + meta.toString()); | |
336 return meta.toString(); | |
337 } | 309 } |
338 | 310 |
339 | 311 |
340 /** | 312 /** |
341 * Creates a timeperiod taking account for all data items used in charts. | 313 * Creates a timeperiod taking account for all data items used in charts. |