comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java @ 492:79e80c289018

Added labels and titles to 'Profilschnitt' charts. gnv-artifacts/trunk@569 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 19 Jan 2010 10:06:03 +0000
parents ab29e4ff2fda
children 1bf058f1a2d1
comparison
equal deleted inserted replaced
491:cbb6b592bc6f 492:79e80c289018
33 import de.intevation.artifacts.CallContext; 33 import de.intevation.artifacts.CallContext;
34 34
35 import de.intevation.gnv.artifacts.context.GNVArtifactContext; 35 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
36 36
37 import de.intevation.gnv.artifacts.cache.CacheFactory; 37 import de.intevation.gnv.artifacts.cache.CacheFactory;
38 import de.intevation.gnv.artifacts.ressource.RessourceFactory;
38 39
39 import de.intevation.gnv.chart.Chart; 40 import de.intevation.gnv.chart.Chart;
40 import de.intevation.gnv.chart.ChartLabels; 41 import de.intevation.gnv.chart.ChartLabels;
41 import de.intevation.gnv.chart.ChartStyle; 42 import de.intevation.gnv.chart.ChartStyle;
42 import de.intevation.gnv.chart.VerticalCrossSectionChart; 43 import de.intevation.gnv.chart.VerticalCrossSectionChart;
85 86
86 import de.intevation.gnv.geobackend.sde.datasources.RasterObject; 87 import de.intevation.gnv.geobackend.sde.datasources.RasterObject;
87 88
88 /** 89 /**
89 * @author Tim Englich (tim.englich@intevation.de) 90 * @author Tim Englich (tim.englich@intevation.de)
90 * @author Ingo Weinzierl (iweinzierl@intevation.de) 91 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
91 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) 92 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
92 */ 93 */
93 public class VerticalCrossSectionOutputState extends TimeSeriesOutputState { 94 public class VerticalCrossSectionOutputState extends TimeSeriesOutputState {
95
96 public static final String CHART_TYPE = "verticalcrosssection";
94 97
95 public static final String[] ATTRIBUTE_LIST = { 98 public static final String[] ATTRIBUTE_LIST = {
96 "SHAPE", 99 "SHAPE",
97 "Z", 100 "Z",
98 "YORDINATE", 101 "YORDINATE",
104 private static Logger log = Logger.getLogger( 107 private static Logger log = Logger.getLogger(
105 VerticalCrossSectionOutputState.class); 108 VerticalCrossSectionOutputState.class);
106 109
107 private String ijkQueryID = "horizontalprofile_meshpoint_cross_ij"; 110 private String ijkQueryID = "horizontalprofile_meshpoint_cross_ij";
108 111
112 private String rangeLabel;
113
109 /** 114 /**
110 * The UID of this Class 115 * The UID of this Class
111 */ 116 */
112 private static final long serialVersionUID = 3233620652465061860L; 117 private static final long serialVersionUID = 3233620652465061860L;
113 118
115 * Constructor 120 * Constructor
116 */ 121 */
117 public VerticalCrossSectionOutputState() { 122 public VerticalCrossSectionOutputState() {
118 super(); 123 super();
119 super.domainLable = "chart.verticalcrosssection.title.xaxis"; 124 super.domainLable = "chart.verticalcrosssection.title.xaxis";
125 this.rangeLabel = "chart.verticalcrosssection.title.yaxis";
126 }
127
128
129 @Override
130 protected ChartLabels createChartLabels(Locale locale, String uuid) {
131 RessourceFactory factory = RessourceFactory.getInstance();
132 String parameterName = getSelectedInputDataName(
133 uuid, parameterValuesName);
134
135 if (parameterName == null)
136 parameterName = "parameterid";
137
138 return new ChartLabels(
139 createChartTitle(locale, uuid),
140 createChartSubtitle(locale, uuid),
141 factory.getRessource(locale, domainLable, domainLable),
142 factory.getRessource(locale, rangeLabel, rangeLabel),
143 parameterName
144 );
145 }
146
147
148 @Override
149 protected String createChartSubtitle(Locale locale, String uuid) {
150 String date = getSelectedInputDataName(uuid, dateValueName);
151
152 if (date == null)
153 date = "dateid";
154
155 RessourceFactory factory = RessourceFactory.getInstance();
156 String chartType = factory.getRessource(
157 locale, CHART_TYPE, CHART_TYPE);
158
159 return chartType + ": " + date;
120 } 160 }
121 161
122 162
123 @Override 163 @Override
124 protected Object getChartResult(String uuid, CallContext callContext) { 164 protected Object getChartResult(String uuid, CallContext callContext) {
179 callContext); 219 callContext);
180 220
181 CacheFactory.getInstance().getCache().put(new Element(key, obj)); 221 CacheFactory.getInstance().getCache().put(new Element(key, obj));
182 222
183 return obj; 223 return obj;
224 }
225
226
227 protected String getSelectedInputDataName(String uuid, String id) {
228 Collection values = getCollection(id, uuid);
229
230 if (values != null) {
231 Iterator it = values.iterator();
232
233 while (it.hasNext()) {
234 KeyValueDescibeData data = (KeyValueDescibeData) it.next();
235
236 if (data.isSelected()) {
237 return data.getValue();
238 }
239 }
240 }
241 return null;
184 } 242 }
185 243
186 private static int getGroundInterpolation(CallContext callContext) { 244 private static int getGroundInterpolation(CallContext callContext) {
187 GNVArtifactContext context = 245 GNVArtifactContext context =
188 (GNVArtifactContext)callContext.globalContext(); 246 (GNVArtifactContext)callContext.globalContext();
488 } 546 }
489 547
490 chart = new VerticalCrossSectionChart( 548 chart = new VerticalCrossSectionChart(
491 columns, 549 columns,
492 paletteManager.getBase(), 550 paletteManager.getBase(),
493 locale); 551 locale,
552 chartLables);
494 553
495 chart.generateChart(); 554 chart.generateChart();
496 555
497 if (CACHE_CHART) { 556 if (CACHE_CHART) {
498 log.info("Put chart into cache."); 557 log.info("Put chart into cache.");
499 purifyChart(chart, uuid); 558 purifyChart(chart, uuid);
500 } 559 }
501 560
502 return chart; 561 return chart;
503 } 562 }
563
504 564
505 /** 565 /**
506 * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#createChart(java.io.OutputStream, 566 * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#createChart(java.io.OutputStream,
507 * java.util.Collection, java.util.Collection, java.lang.String, 567 * java.util.Collection, java.util.Collection, java.lang.String,
508 * de.intevation.gnv.chart.ChartStyle, 568 * de.intevation.gnv.chart.ChartStyle,

http://dive4elements.wald.intevation.org