annotate gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java @ 94:6a825a184883

Remove Compile-Errors from the StatisticsPart gnv-artifacts/trunk@139 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 28 Sep 2009 07:32:03 +0000
parents bd284d8306db
children 13402ac8d8fe
rev   line source
64
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.transition.timeseries;
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
6 import java.awt.Color;
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
7 import java.awt.Dimension;
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
8 import java.io.IOException;
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
9 import java.io.OutputStream;
90
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
10 import java.io.OutputStreamWriter;
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
11 import java.util.Collection;
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
12 import java.util.Iterator;
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
13
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
14 import org.apache.log4j.Logger;
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
15
90
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
16 import au.com.bytecode.opencsv.CSVWriter;
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
17
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
18 import de.intevation.gnv.chart.ChartFactory;
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
19 import de.intevation.gnv.chart.ChartLabels;
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
20 import de.intevation.gnv.chart.ChartStyle;
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
21 import de.intevation.gnv.chart.exception.TechnicalChartException;
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
22 import de.intevation.gnv.geobackend.base.Result;
91
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
23 import de.intevation.gnv.transition.InputData;
64
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import de.intevation.gnv.transition.OutputTransitionBase;
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
25 import de.intevation.gnv.transition.describedata.KeyValueDescibeData;
81
9b41f3688610 Added Support for TimeSeriesMesh
Tim Englich <tim.englich@intevation.de>
parents: 73
diff changeset
26 import de.intevation.gnv.transition.describedata.NamedCollection;
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
27 import de.intevation.gnv.transition.exception.TransitionException;
64
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 /**
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 * @author Tim Englich <tim.englich@intevation.de>
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 *
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 */
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 public class TimeSeriesOutputTransition extends OutputTransitionBase{
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
34
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
35 /**
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
36 * The UID of this Class
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
37 */
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
38 private static final long serialVersionUID = 4178407570503098858L;
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
39
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
40 /**
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
41 * the logger, used to log exceptions and additonaly information
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
42 */
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
43 private static Logger log = Logger.getLogger(TimeSeriesOutputTransition.class);
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
44
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
45 protected String domainLable = "Zeit [UTC]";
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
46
64
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 /**
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 * Constructor
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 */
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 public TimeSeriesOutputTransition() {
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 super();
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 }
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 /**
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 * @see de.intevation.gnv.transition.Transition#validate()
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 */
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 public boolean validate() {
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 return true;
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 }
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
61 /**
91
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
62 * @see de.intevation.gnv.transition.OutputTransition#out(java.lang.String, java.util.Collection, java.io.OutputStream)
73
504570de21fd Refactoring Work depending on Infrastructurchanges in the Artifact-Module
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
63 */
91
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
64 public void out(String outputMode, Collection<InputData> inputData, OutputStream outputStream) throws TransitionException {
90
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
65 log.debug("TimeSeriesOutputTransition.out");
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
66 try {
90
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
67 this.advance();
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
68 if (outputMode.equalsIgnoreCase("chart")){
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
69 log.debug("Chart will be generated.");
91
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
70 int chartWidth = 600;
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
71 int chartHeight = 400;
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
72 try {
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
73 if (inputData != null){
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
74 Iterator<InputData> it = inputData.iterator();
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
75 while (it.hasNext()){
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
76 InputData ip = it.next();
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
77 if (ip.getName().equalsIgnoreCase("width")){
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
78 chartWidth = Integer.parseInt(ip.getValue());
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
79 }else if (ip.getName().equalsIgnoreCase("height")){
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
80 chartHeight = Integer.parseInt(ip.getValue());
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
81 }
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
82 }
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
83 }
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
84 } catch (NumberFormatException e) {
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
85 log.error(e,e);
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
86 throw new TransitionException(e);
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
87 }
90
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
88 Collection<KeyValueDescibeData> parameters = this.getParameters();
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
89 Collection<KeyValueDescibeData> measurements = this.getMeasurements();
91
bd284d8306db Added Support for Patameters in OutputModes
Tim Englich <tim.englich@intevation.de>
parents: 90
diff changeset
90 ChartStyle chartStyle = this.creatStyle(chartWidth,chartHeight);
90
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
91 ChartLabels chartLables = new ChartLabels(this.getSelectedFeatureName(),this.domainLable);
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
92 this.createChart(outputStream, parameters, measurements,
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
93 chartStyle, chartLables);
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
94 }else if (outputMode.equalsIgnoreCase("csv")){
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
95 log.debug("CSV-File will be generated.");
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
96 if(this.chartResult != null){
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
97 CSVWriter writer = new CSVWriter(new OutputStreamWriter(outputStream,"ISO-8859-1"), ','); // USE THIS ENCODING BECAUSE OF PROBLEMS WITH EXCEL AND UTF-8
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
98 Iterator<Result>it = this.chartResult.iterator();
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
99 while (it.hasNext()){
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
100 Result result = it.next();
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
101 int i = 0;
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
102 String[] entries = new String[5];
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
103 entries[i++] = result.getString("XORDINATE");
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
104 entries[i++] = result.getString("YORDINATE");
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
105 entries[i++] = result.getString("GROUP1");
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
106 entries[i++] = result.getString("GROUP2");
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
107 entries[i++] = result.getString("GROUP3");
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
108 writer.writeNext(entries);
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
109 }
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
110 writer.close();
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
111 }else{
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
112 log.error("No Data given for generation an CSV-File.");
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
113 throw new TransitionException("No Data given for generation an CSV-File.");
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
114 }
6bdef6e590d6 Added CSV-Support and do some performanceimprovments
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
115 }
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
116 } catch (IOException e) {
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
117 log.error(e,e);
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
118 throw new TransitionException(e);
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
119 } catch (TechnicalChartException e) {
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
120 log.error(e,e);
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
121 throw new TransitionException(e);
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
122 }
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
123 }
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
124
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
125
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
126 protected String getSelectedFeatureName(){
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
127 String collectionName = "featureid"; // TODO: Konfigurierbar machen
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
128 Collection<KeyValueDescibeData> values = this.getCollection(collectionName);
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
129 if (values != null){
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
130 Iterator<KeyValueDescibeData> it = values.iterator();
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
131 while(it.hasNext()){
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
132 KeyValueDescibeData data = it.next();
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
133 if (data.isSelected()){
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
134 return data.getValue();
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
135 }
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
136 }
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
137 }
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
138 return null;
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
139 }
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
140 /**
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
141 * @param outputStream
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
142 * @param parameters
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
143 * @param measurements
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
144 * @param timeSeriesName
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
145 * @param chartStyle
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
146 * @param chartLables
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
147 * @throws IOException
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
148 * @throws TechnicalChartException
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
149 */
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
150 protected void createChart(OutputStream outputStream,
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
151 Collection<KeyValueDescibeData> parameters,
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
152 Collection<KeyValueDescibeData> measurements,
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
153 ChartStyle chartStyle, ChartLabels chartLables) throws IOException,
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
154 TechnicalChartException {
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
155 ChartFactory chartFactory = new ChartFactory();
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
156 chartFactory.createSimpleTimeSeriesChart(chartLables, chartStyle,
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
157 parameters, measurements,
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
158 outputStream, this.chartResult);
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
159 }
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
160
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
161 /**
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
162 * @see de.intevation.gnv.transition.TransitionBase#purifyResult(java.util.Collection)
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
163 */
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
164 @Override
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
165 protected void purifyResult(Collection<Result> result) {
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
166 this.chartResult = result;
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
167 }
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
168
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
169 protected ChartStyle creatStyle(int witdh, int height){
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
170 // TODO Konfigurierbar machen
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
171 de.intevation.gnv.chart.Insets lInsets = new de.intevation.gnv.chart.Insets(5d, 5d, 5d, 5d);
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
172 Dimension lChartSize = new Dimension(witdh, height);
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
173 return new ChartStyle(Color.white, new Color(230, 230, 230), Color.white, Color.white, true, true, lInsets, lChartSize);
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
174 }
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
175
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
176 protected Collection<KeyValueDescibeData> getParameters(){
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
177 String collectionName = "parameterid"; // TODO: Konfigurierbar machen
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
178 return this.getCollection(collectionName);
64
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
179 }
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
180
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
181 protected Collection<KeyValueDescibeData> getMeasurements(){
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
182 String collectionName = "measurementid"; // TODO: Konfigurierbar machen
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
183 return this.getCollection(collectionName);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
184 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
185
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
186 /**
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
187 * @param collectionName
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
188 * @return
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
189 */
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
190 protected Collection<KeyValueDescibeData> getCollection(
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
191 String collectionName) {
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
192 Iterator<Object> it = this.descibeData.iterator();
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
193 while (it.hasNext()){
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
194
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
195 Object o = it.next();
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 81
diff changeset
196
81
9b41f3688610 Added Support for TimeSeriesMesh
Tim Englich <tim.englich@intevation.de>
parents: 73
diff changeset
197 if (o instanceof NamedCollection<?>){
9b41f3688610 Added Support for TimeSeriesMesh
Tim Englich <tim.englich@intevation.de>
parents: 73
diff changeset
198 NamedCollection<KeyValueDescibeData> nc = (NamedCollection<KeyValueDescibeData>)o;
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
199 if (nc.getName().equals(collectionName)){
81
9b41f3688610 Added Support for TimeSeriesMesh
Tim Englich <tim.englich@intevation.de>
parents: 73
diff changeset
200 return nc;
9b41f3688610 Added Support for TimeSeriesMesh
Tim Englich <tim.englich@intevation.de>
parents: 73
diff changeset
201 }
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
202 }
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
203 }
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
204 return null;
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 64
diff changeset
205 }
64
5db77e0a8594 Integrated Output Methods and Interfacsstructure
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
206 }

http://dive4elements.wald.intevation.org