Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java @ 320:18302372703f
Implemented pdf export of charts.
gnv-artifacts/trunk@381 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 30 Nov 2009 09:51:59 +0000 |
parents | 5f2820e821e0 |
children | a4376fd23f99 |
comparison
equal
deleted
inserted
replaced
319:251f16a083f8 | 320:18302372703f |
---|---|
66 * @author Tim Englich <tim.englich@intevation.de> | 66 * @author Tim Englich <tim.englich@intevation.de> |
67 * | 67 * |
68 */ | 68 */ |
69 public class TimeSeriesOutputTransition extends OutputTransitionBase { | 69 public class TimeSeriesOutputTransition extends OutputTransitionBase { |
70 | 70 |
71 protected static final boolean CACHE_CHART = | 71 protected static final boolean CACHE_CHART = |
72 Boolean.parseBoolean(System.getProperty("cache.chart", "false")); | 72 Boolean.parseBoolean(System.getProperty("cache.chart", "false")); |
73 | |
74 protected static final boolean PDF_FORMAT_LANDSCAPE = | |
75 Boolean.parseBoolean(System.getProperty("export.pdf.landscape","true")); | |
73 | 76 |
74 protected static final String[] IMG_EXPORT_FORMAT = { | 77 protected static final String[] IMG_EXPORT_FORMAT = { |
75 "PNG", "JPEG", "GIF" | 78 "PNG", "JPEG", "GIF" |
76 }; | 79 }; |
77 | 80 |
237 uuid, | 240 uuid, |
238 exportFormat, | 241 exportFormat, |
239 locale, | 242 locale, |
240 chartWidth, | 243 chartWidth, |
241 chartHeight | 244 chartHeight |
245 ); | |
246 } | |
247 else if (outputMode.equalsIgnoreCase("pdf")) { | |
248 log.debug("Output mode == pdf"); | |
249 | |
250 Locale[] serverLocales = | |
251 RessourceFactory.getInstance().getLocales(); | |
252 Locale locale = | |
253 callMeta.getPreferredLocale(serverLocales); | |
254 | |
255 log.debug( | |
256 "Best locale - regarding intersection of server and " + | |
257 "browser locales - is " + locale.toString() | |
258 ); | |
259 | |
260 createPDF( | |
261 outputStream, | |
262 getParameters(uuid), | |
263 getMeasurements(uuid), | |
264 getDates(uuid), | |
265 new ChartLabels( | |
266 this.getFisName(callMeta.getLanguages()) + | |
267 " "+ getSelectedFeatureName(uuid), | |
268 this.domainLable), | |
269 uuid, | |
270 "A4", | |
271 true, | |
272 locale | |
242 ); | 273 ); |
243 } | 274 } |
244 else if (outputMode.equalsIgnoreCase("csv")) { | 275 else if (outputMode.equalsIgnoreCase("csv")) { |
245 log.debug("CSV-File will be generated."); | 276 log.debug("CSV-File will be generated."); |
246 Collection<Result> chartResult = this.getChartResult(uuid); | 277 Collection<Result> chartResult = this.getChartResult(uuid); |
447 height | 478 height |
448 ); | 479 ); |
449 } | 480 } |
450 | 481 |
451 | 482 |
483 protected void createPDF( | |
484 OutputStream outputStream, | |
485 Collection parameters, | |
486 Collection measurements, | |
487 Collection dates, | |
488 ChartLabels chartLables, | |
489 String uuid, | |
490 String exportFormat, | |
491 boolean landscape, | |
492 Locale locale | |
493 ) { | |
494 Chart chart = getChart( | |
495 chartLables, | |
496 parameters, | |
497 measurements, | |
498 dates, | |
499 getChartResult(uuid), | |
500 locale, | |
501 uuid | |
502 ); | |
503 | |
504 if (chart == null) { | |
505 log.error("Could not initialize chart."); | |
506 return; | |
507 } | |
508 | |
509 ChartExportHelper.exportPDF( | |
510 outputStream, | |
511 chart.generateChart(), | |
512 "A4", | |
513 PDF_FORMAT_LANDSCAPE, | |
514 50F, 50F, 50F, 50F | |
515 ); | |
516 } | |
517 | |
518 | |
452 protected Chart getChart( | 519 protected Chart getChart( |
453 ChartLabels chartLables, | 520 ChartLabels chartLables, |
454 Collection parameters, | 521 Collection parameters, |
455 Collection measurements, | 522 Collection measurements, |
456 Collection dates, | 523 Collection dates, |
605 } | 672 } |
606 } | 673 } |
607 return null; | 674 return null; |
608 } | 675 } |
609 } | 676 } |
610 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 677 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |