Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java @ 358:2f7a28f211c7
Fetch ChartTheme from CallContext instead of creating it each time before creating a chart.
gnv-artifacts/trunk@431 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 15 Dec 2009 15:30:25 +0000 |
parents | bb1afbbd93e4 |
children | 6491000407dd |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java Tue Dec 15 15:14:21 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java Tue Dec 15 15:30:25 2009 +0000 @@ -35,7 +35,10 @@ import de.intevation.artifactdatabase.Config; import de.intevation.artifactdatabase.XMLUtils; import de.intevation.artifacts.CallMeta; +import de.intevation.artifacts.CallContext; import de.intevation.artifacts.PreferredLocale; +import de.intevation.gnv.artifacts.context.GNVArtifactContext; +import de.intevation.gnv.artifacts.context.GNVArtifactContextFactory; import de.intevation.gnv.artifacts.ressource.RessourceFactory; import de.intevation.gnv.chart.Chart; import de.intevation.gnv.chart.ChartLabels; @@ -176,7 +179,7 @@ Collection<InputData> inputData, OutputStream outputStream, String uuid, - CallMeta callMeta + CallContext callContext ) throws StateException { log.debug("TimeSeriesOutputTransition.out"); @@ -190,6 +193,8 @@ "action/out/mime-type/@value" ); + CallMeta callMeta = callContext.getMeta(); + try { if (outputMode.equalsIgnoreCase("chart")) { log.debug("Chart will be generated."); @@ -249,6 +254,7 @@ measurements, dates, chartLables, + callContext, uuid, exportFormat, locale, @@ -292,9 +298,10 @@ uuid, "A4", true, + linesVisible, + shapesVisible, locale, - linesVisible, - shapesVisible + callContext ); } else if (outputMode.equalsIgnoreCase("svg")) { @@ -335,7 +342,8 @@ width, height, linesVisible, - shapesVisible + shapesVisible, + callContext ); } else if (outputMode.equalsIgnoreCase("csv")) { @@ -529,6 +537,7 @@ Collection measurements, Collection dates, ChartLabels chartLables, + CallContext context, String uuid, String exportFormat, Locale locale, @@ -542,6 +551,7 @@ log.debug("Create chart."); Chart chart = getChart( chartLables, + createStyle(context), parameters, measurements, dates, @@ -581,12 +591,14 @@ String uuid, String exportFormat, boolean landscape, + boolean linesVisible, + boolean shapesVisible, Locale locale, - boolean linesVisible, - boolean shapesVisible + CallContext context ) { Chart chart = getChart( chartLables, + createStyle(context), parameters, measurements, dates, @@ -636,10 +648,12 @@ int width, int height, boolean linesVisible, - boolean shapesVisible + boolean shapesVisible, + CallContext callContext ) { Chart chart = getChart( chartLables, + createStyle(callContext), parameters, measurements, dates, @@ -668,6 +682,7 @@ protected Chart getChart( ChartLabels chartLables, + ChartTheme theme, Collection parameters, Collection measurements, Collection dates, @@ -690,7 +705,7 @@ log.info("Chart not in cache yet."); chart = new TimeSeriesChart( chartLables, - createStyle(), + theme, parameters, measurements, dates, @@ -710,18 +725,16 @@ return chart; } - protected ChartTheme createStyle() { - XMLChartTheme theme = null; + protected ChartTheme createStyle(CallContext callContext) { + log.debug("Fetch chart theme from global context"); - Document template = Config.getChartTemplate(); - String name = Config.getStringXPath( - template, - "theme/name/@value" + GNVArtifactContext context = + (GNVArtifactContext) callContext.globalContext(); + + XMLChartTheme theme = (XMLChartTheme) context.get( + GNVArtifactContextFactory.CHARTTEMPLATE ); - theme = new XMLChartTheme(name); - theme.applyXMLConfiguration(template); - return theme; }