Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java @ 304:a16d337c5678
The style of charts can be configured with ChartThemes using XML configuration files.
gnv-artifacts/trunk@362 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 23 Nov 2009 17:01:28 +0000 |
parents | 9ba2cf8cad8d |
children | 45625b5cd6d4 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java Fri Nov 20 15:45:25 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java Mon Nov 23 17:01:28 2009 +0000 @@ -3,9 +3,8 @@ */ package de.intevation.gnv.transition.timeseries; -import java.awt.Color; -import java.awt.Dimension; import java.io.IOException; +import java.io.File; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.util.ArrayList; @@ -39,8 +38,8 @@ import de.intevation.gnv.artifacts.ressource.RessourceFactory; import de.intevation.gnv.chart.Chart; import de.intevation.gnv.chart.ChartLabels; -import de.intevation.gnv.chart.ChartStyle; import de.intevation.gnv.chart.TimeSeriesChart; +import de.intevation.gnv.chart.XMLChartTheme; import de.intevation.gnv.chart.exception.TechnicalChartException; import de.intevation.gnv.exports.DefaultExport; import de.intevation.gnv.exports.DefaultDataCollector; @@ -213,8 +212,6 @@ Collection<KeyValueDescibeData> parameters = this.getParameters(uuid); Collection<KeyValueDescibeData> measurements = this.getMeasurements(uuid); Collection<KeyValueDescibeData> dates = this.getDates(uuid); - ChartStyle chartStyle = this - .creatStyle(chartWidth, chartHeight); ChartLabels chartLables = new ChartLabels(this.getFisName(callMeta.getLanguages())+" "+this .getSelectedFeatureName(uuid), this.domainLable); @@ -225,10 +222,11 @@ parameters, measurements, dates, - chartStyle, chartLables, uuid, - exportFormat + exportFormat, + chartWidth, + chartHeight ); } else if (outputMode.equalsIgnoreCase("csv")) { log.debug("CSV-File will be generated."); @@ -398,17 +396,17 @@ Collection parameters, Collection measurements, Collection dates, - ChartStyle chartStyle, ChartLabels chartLables, String uuid, - String exportFormat + String exportFormat, + int width, + int height ) throws IOException, TechnicalChartException { log.debug("Create chart."); Chart chart = getChart( chartLables, - null, // ChartTheme parameters, measurements, getChartResult(uuid), @@ -422,10 +420,6 @@ return; } - Dimension dim = chartStyle.getChartSize(); - int width = new Double(dim.getWidth()).intValue(); - int height = new Double(dim.getHeight()).intValue(); - log.debug( "export chart as " + exportFormat + " in " + width + "x" + height @@ -440,7 +434,6 @@ protected Chart getChart( ChartLabels chartLables, - ChartTheme chartTheme, Collection parameters, Collection measurements, Collection result, @@ -461,7 +454,7 @@ log.info("Chart not in cache yet."); chart = new TimeSeriesChart( chartLables, - null, + createStyle(), parameters, measurements, result, @@ -478,15 +471,21 @@ return chart; } - protected ChartStyle creatStyle(int witdh, int height) { - // TODO Konfigurierbar machen - de.intevation.gnv.chart.Insets lInsets = new de.intevation.gnv.chart.Insets( - 5d, 5d, 5d, 5d); - Dimension lChartSize = new Dimension(witdh, height); - return new ChartStyle(Color.white, new Color(230, 230, 230), - Color.white, Color.white, true, true, lInsets, lChartSize); + protected ChartTheme createStyle() { + XMLChartTheme theme = null; + + Document template = Config.getChartTemplate(); + String name = Config.getStringXPath( + template, + "theme/name/@value" + ); + + theme = new XMLChartTheme(name); + theme.applyXMLConfiguration(template); + + return theme; } - + protected String getFisName(PreferredLocale[] preferredLocales){ String returnValue = ""; InputData inputData = this.inputData.get("fisname");