comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java @ 502:fec85cd01497

Fixed issue105. Added option to enable/disable data points in charts. Parse this option while creating charts. gnv-artifacts/trunk@585 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 20 Jan 2010 15:17:35 +0000
parents 4080b57dcb52
children a162793b6053
comparison
equal deleted inserted replaced
501:70adafe2b9d5 502:fec85cd01497
205 String mimeType = XMLUtils.xpathString( 205 String mimeType = XMLUtils.xpathString(
206 format, XPATH_MIME_TYPE, ArtifactNamespaceContext.INSTANCE); 206 format, XPATH_MIME_TYPE, ArtifactNamespaceContext.INSTANCE);
207 207
208 CallMeta callMeta = callContext.getMeta(); 208 CallMeta callMeta = callContext.getMeta();
209 209
210 int chartWidth = 600;
211 int chartHeight = 400;
212 boolean sVisible = false;
213
214 // lines are always visible. if lines should be configurable we need a
215 // parameter in the user interface
216 boolean lVisible = true;
217
218 try {
219 if (inputData != null) {
220 Iterator<InputData> it = inputData.iterator();
221 while (it.hasNext()) {
222 InputData ip = it.next();
223 String optionName = ip.getName().trim();
224
225 if (optionName.equals("width")) {
226 chartWidth = Integer.parseInt(ip.getValue());
227 }
228 else if (optionName.equals("height")) {
229 chartHeight = Integer.parseInt(ip.getValue());
230 }
231 else if (optionName.equals("points")) {
232 sVisible = Boolean.parseBoolean(ip.getValue());
233 }
234 }
235 }
236 } catch (NumberFormatException e) {
237 log.error(e, e);
238 throw new StateException(e);
239 }
240
210 try { 241 try {
211 if (outputMode.equalsIgnoreCase("chart")) { 242 if (outputMode.equalsIgnoreCase("chart")) {
212 log.debug("Chart will be generated."); 243 log.debug("Chart will be generated.");
213 int chartWidth = 600;
214 int chartHeight = 400;
215 try {
216 if (inputData != null) {
217 Iterator<InputData> it = inputData.iterator();
218 while (it.hasNext()) {
219 InputData ip = it.next();
220 if (ip.getName().equalsIgnoreCase("width")) {
221 chartWidth = Integer.parseInt(ip.getValue());
222 } else if (ip.getName().equalsIgnoreCase("height")) {
223 chartHeight = Integer.parseInt(ip.getValue());
224 }
225 }
226 }
227 } catch (NumberFormatException e) {
228 log.error(e, e);
229 throw new StateException(e);
230 }
231 244
232 PreferredLocale[] locales = callMeta.getLanguages(); 245 PreferredLocale[] locales = callMeta.getLanguages();
233 Locale[] serverLocales = 246 Locale[] serverLocales =
234 RessourceFactory.getInstance().getLocales(); 247 RessourceFactory.getInstance().getLocales();
235 Locale locale = 248 Locale locale =
245 Collection dates = this.getDates(uuid); 258 Collection dates = this.getDates(uuid);
246 259
247 ChartLabels chartLables = createChartLabels(locale, uuid); 260 ChartLabels chartLables = createChartLabels(locale, uuid);
248 261
249 String exportFormat = getExportFormat(mimeType); 262 String exportFormat = getExportFormat(mimeType);
250
251 // TODO Remove this and parse input data
252 boolean linesVisible = true;
253 boolean shapesVisible = true;
254 263
255 this.createChart( 264 this.createChart(
256 outputStream, 265 outputStream,
257 parameters, 266 parameters,
258 measurements, 267 measurements,
262 uuid, 271 uuid,
263 exportFormat, 272 exportFormat,
264 locale, 273 locale,
265 chartWidth, 274 chartWidth,
266 chartHeight, 275 chartHeight,
267 linesVisible, 276 lVisible,
268 shapesVisible, 277 sVisible,
269 callContext 278 callContext
270 ); 279 );
271 } 280 }
272 else if (outputMode.equalsIgnoreCase("pdf")) { 281 else if (outputMode.equalsIgnoreCase("pdf")) {
273 log.debug("Output mode == pdf"); 282 log.debug("Output mode == pdf");
274 283
275 Locale[] serverLocales = 284 Locale[] serverLocales =
276 RessourceFactory.getInstance().getLocales(); 285 RessourceFactory.getInstance().getLocales();
277 Locale locale = 286 Locale locale =
278 callMeta.getPreferredLocale(serverLocales); 287 callMeta.getPreferredLocale(serverLocales);
279
280 // TODO Remove this and parse input data
281 boolean linesVisible = true;
282 boolean shapesVisible = true;
283 288
284 log.debug( 289 log.debug(
285 "Best locale - regarding intersection of server and " + 290 "Best locale - regarding intersection of server and " +
286 "browser locales - is " + locale.toString() 291 "browser locales - is " + locale.toString()
287 ); 292 );
301 ) 306 )
302 ), 307 ),
303 uuid, 308 uuid,
304 "A4", 309 "A4",
305 true, 310 true,
306 linesVisible, 311 lVisible,
307 shapesVisible, 312 sVisible,
308 locale, 313 locale,
309 callContext 314 callContext
310 ); 315 );
311 } 316 }
312 else if (outputMode.equalsIgnoreCase("svg")) { 317 else if (outputMode.equalsIgnoreCase("svg")) {
313 log.debug("Output mode == svg"); 318 log.debug("Output mode == svg");
314 int width = 600;
315 int height = 400;
316
317 // TODO Remove this and parse input data
318 boolean linesVisible = true;
319 boolean shapesVisible = true;
320 319
321 Locale[] serverLocales = 320 Locale[] serverLocales =
322 RessourceFactory.getInstance().getLocales(); 321 RessourceFactory.getInstance().getLocales();
323 Locale locale = 322 Locale locale =
324 callMeta.getPreferredLocale(serverLocales); 323 callMeta.getPreferredLocale(serverLocales);
342 domainLable 341 domainLable
343 ) 342 )
344 ), 343 ),
345 uuid, 344 uuid,
346 locale, 345 locale,
347 width, 346 chartWidth,
348 height, 347 chartHeight,
349 linesVisible, 348 lVisible,
350 shapesVisible, 349 sVisible,
351 callContext 350 callContext
352 ); 351 );
353 } 352 }
354 else if (outputMode.equalsIgnoreCase("csv")) { 353 else if (outputMode.equalsIgnoreCase("csv")) {
355 log.debug("CSV-File will be generated."); 354 log.debug("CSV-File will be generated.");
390 Document doc = writeStatistics2XML(statistics); 389 Document doc = writeStatistics2XML(statistics);
391 390
392 XMLUtils.toStream(doc, outputStream); 391 XMLUtils.toStream(doc, outputStream);
393 392
394 } else if (outputMode.equalsIgnoreCase("odv")) { 393 } else if (outputMode.equalsIgnoreCase("odv")) {
395
396 Collection<Result> odvResult = this.getODVResult(uuid); 394 Collection<Result> odvResult = this.getODVResult(uuid);
397 this.createODV(outputStream, odvResult); 395 this.createODV(outputStream, odvResult);
398 } 396 }
399 } catch (IOException e) { 397 } catch (IOException e) {
400 log.error(e, e); 398 log.error(e, e);

http://dive4elements.wald.intevation.org