Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java @ 321:a4376fd23f99
Implemented svg export of charts.
gnv-artifacts/trunk@383 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 30 Nov 2009 14:18:37 +0000 |
parents | 18302372703f |
children | 3eff9241ea1e |
comparison
equal
deleted
inserted
replaced
320:18302372703f | 321:a4376fd23f99 |
---|---|
4 package de.intevation.gnv.transition.timeseries; | 4 package de.intevation.gnv.transition.timeseries; |
5 | 5 |
6 import java.io.IOException; | 6 import java.io.IOException; |
7 import java.io.File; | 7 import java.io.File; |
8 import java.io.OutputStream; | 8 import java.io.OutputStream; |
9 import java.io.FileOutputStream; | |
9 import java.io.UnsupportedEncodingException; | 10 import java.io.UnsupportedEncodingException; |
10 import java.util.ArrayList; | 11 import java.util.ArrayList; |
11 import java.util.Collection; | 12 import java.util.Collection; |
12 import java.util.Iterator; | 13 import java.util.Iterator; |
13 import java.util.List; | 14 import java.util.List; |
268 this.domainLable), | 269 this.domainLable), |
269 uuid, | 270 uuid, |
270 "A4", | 271 "A4", |
271 true, | 272 true, |
272 locale | 273 locale |
274 ); | |
275 } | |
276 else if (outputMode.equalsIgnoreCase("svg")) { | |
277 log.debug("Output mode == svg"); | |
278 int width = 600; | |
279 int height = 400; | |
280 | |
281 Locale[] serverLocales = | |
282 RessourceFactory.getInstance().getLocales(); | |
283 Locale locale = | |
284 callMeta.getPreferredLocale(serverLocales); | |
285 | |
286 log.debug( | |
287 "Best locale - regarding intersection of server and " + | |
288 "browser locales - is " + locale.toString() | |
289 ); | |
290 | |
291 createSVG( | |
292 outputStream, | |
293 getParameters(uuid), | |
294 getMeasurements(uuid), | |
295 getDates(uuid), | |
296 new ChartLabels( | |
297 this.getFisName(callMeta.getLanguages()) + | |
298 " "+ getSelectedFeatureName(uuid), | |
299 this.domainLable), | |
300 uuid, | |
301 locale, | |
302 width, | |
303 height | |
273 ); | 304 ); |
274 } | 305 } |
275 else if (outputMode.equalsIgnoreCase("csv")) { | 306 else if (outputMode.equalsIgnoreCase("csv")) { |
276 log.debug("CSV-File will be generated."); | 307 log.debug("CSV-File will be generated."); |
277 Collection<Result> chartResult = this.getChartResult(uuid); | 308 Collection<Result> chartResult = this.getChartResult(uuid); |
511 chart.generateChart(), | 542 chart.generateChart(), |
512 "A4", | 543 "A4", |
513 PDF_FORMAT_LANDSCAPE, | 544 PDF_FORMAT_LANDSCAPE, |
514 50F, 50F, 50F, 50F | 545 50F, 50F, 50F, 50F |
515 ); | 546 ); |
547 | |
548 try { | |
549 OutputStream toFile = new FileOutputStream("/vol1/home/iweinzierl/tmp/test.svg"); | |
550 ChartExportHelper.exportSVG( | |
551 toFile, | |
552 chart.generateChart(), | |
553 null, | |
554 600, 400 | |
555 ); | |
556 toFile.flush(); | |
557 toFile.close(); | |
558 } | |
559 catch(Exception e) { log.debug("ERROR WHLILE TEST."); } | |
560 } | |
561 | |
562 | |
563 protected void createSVG( | |
564 OutputStream outputStream, | |
565 Collection parameters, | |
566 Collection measurements, | |
567 Collection dates, | |
568 ChartLabels chartLables, | |
569 String uuid, | |
570 Locale locale, | |
571 int width, | |
572 int height | |
573 ) { | |
574 Chart chart = getChart( | |
575 chartLables, | |
576 parameters, | |
577 measurements, | |
578 dates, | |
579 getChartResult(uuid), | |
580 locale, | |
581 uuid | |
582 ); | |
583 | |
584 if (chart == null) { | |
585 log.error("Could not initialize chart."); | |
586 return; | |
587 } | |
588 | |
589 ChartExportHelper.exportSVG( | |
590 outputStream, | |
591 chart.generateChart(), | |
592 null, | |
593 600, 400 | |
594 ); | |
595 | |
596 log.debug("svg export finished."); | |
516 } | 597 } |
517 | 598 |
518 | 599 |
519 protected Chart getChart( | 600 protected Chart getChart( |
520 ChartLabels chartLables, | 601 ChartLabels chartLables, |