annotate gnv-artifacts/src/main/java/de/intevation/gnv/chart/ChartFactory.java @ 112:b8dbf39ca935

Fixed some text/xml MIME types in configuration. gnv-artifacts/trunk@161 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 30 Sep 2009 06:00:21 +0000
parents f07637f96312
children 7fb9441dd8af
rev   line source
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 * Title: ChartFactory, $Header: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/output/chart/ChartFactory.java,v 1.8 2007/12/21 12:31:15 blume Exp $
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 * Source: $Source: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/output/chart/ChartFactory.java,v $
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 * created by: Stefan Blume (blume)
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5 * erstellt am: 06.12.2007
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 * Copyright: con terra GmbH, 2005
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 *
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 * modified by: $Author: blume $
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 * modified on: $Date: 2007/12/21 12:31:15 $
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 * Version: $Revision: 1.8 $
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 * TAG: $Name: $
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 * locked from: $Locker: $
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 * CVS State: $State: Exp $
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 * Project: $ProjectName$
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 */
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 package de.intevation.gnv.chart;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import java.awt.Color;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import java.awt.Font;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import java.awt.image.BufferedImage;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import java.io.IOException;
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
22 import java.io.OutputStream;
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
23 import java.util.Collection;
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import java.util.Date;
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
25 import java.util.Iterator;
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 import org.apache.log4j.Logger;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 import org.jfree.chart.JFreeChart;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 import org.jfree.chart.axis.AxisLocation;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 import org.jfree.chart.axis.DateAxis;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 import org.jfree.chart.axis.NumberAxis;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 import org.jfree.chart.axis.NumberTickUnit;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 import org.jfree.chart.encoders.KeypointPNGEncoderAdapter;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 import org.jfree.chart.plot.PlotOrientation;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 import org.jfree.chart.plot.XYPlot;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 import org.jfree.data.time.Minute;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 import org.jfree.data.time.TimeSeries;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 import org.jfree.data.time.TimeSeriesCollection;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 import org.jfree.data.xy.XYDataset;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 import org.jfree.ui.RectangleInsets;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
44 import de.intevation.gnv.chart.exception.TechnicalChartException;
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
45 import de.intevation.gnv.geobackend.base.Result;
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
46 import de.intevation.gnv.transition.describedata.KeyValueDescibeData;
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 /**
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 * The class <code>ChartFactory</code> fulfills the following purposes:
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 * <ol>
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 * <li></li>
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 * </ol>
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 *
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 * @author blume
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 * @version 1.0
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 * @serial 1.0
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 * @see
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 * @since 06.12.2007 17:25:59
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 */
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 public class ChartFactory {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 /**
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 * Default Logging instance
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 */
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 private static Logger sLogger = Logger.getLogger(ChartFactory.class);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 private static boolean sDebug = sLogger.isDebugEnabled();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
69 public synchronized void createSimpleTimeSeriesChart(ChartLabels pLabels, ChartStyle pStyle, Collection<KeyValueDescibeData> parameters, Collection<KeyValueDescibeData> measurements, OutputStream outputStream, Collection<Result> resultSet) throws IOException, TechnicalChartException {
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 if (sDebug)
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 sLogger.debug("createSimpleTimeSeriesChart()");
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 int lLowerLevel = Integer.MIN_VALUE;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 int lUpperLevel = Integer.MAX_VALUE;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 if (pStyle.isUseUpperDataLevel()
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 && pStyle.getUpperLevel() < Integer.MAX_VALUE) {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76 lUpperLevel = pStyle.getUpperLevel();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 if (pStyle.isUseLowerDataLevel()
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 && pStyle.getLowerLevel() > Integer.MIN_VALUE) {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 lLowerLevel = pStyle.getLowerLevel();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 if (sDebug)
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 sLogger.debug(" vor createDataset()");
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
84 XYDataset lSet = this.createDataset(resultSet, lUpperLevel,
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
85 lLowerLevel,parameters,measurements);
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86 if (sDebug)
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 sLogger.debug(" nach createDataset()");
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88 final Color[] color = {Color.black, Color.red, Color.green, Color.blue};
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
89 DateAxis domain = new DateAxis(pLabels.getDomainAxisLabel());
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
90 NumberAxis axis;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
91 StandardXYItemRenderer renderer = new StandardXYItemRenderer();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
92 XYPlot plot = new XYPlot();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
93 //Global settings
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
94
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
95 plot.setOrientation(PlotOrientation.VERTICAL);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
96 plot.setBackgroundPaint(Color.lightGray);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
97 plot.setDomainGridlinePaint(Color.white);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
98 plot.setRangeGridlinePaint(Color.white);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
99 plot.setAxisOffset(new RectangleInsets(5.0,5.0,5.0,5.0));
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100 //plot.getRangeAxis().setFixedDimension(10.0);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101 plot.setDomainAxis(domain);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
102 plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
103 if (parameters.size() == 1) {
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
104 KeyValueDescibeData parameter = parameters.iterator().next();
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
105 axis = new NumberAxis(parameter.getValue());
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
106 if(parameter.getValue().contains("richtung")){
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
107 NumberAxis axis1 = new NumberAxis(
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
108 ((String) parameter.getValue()));//,new Range(0.0,360.0));
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
109 axis1.setTickUnit(new NumberTickUnit(30.0));
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110 axis1.setUpperBound(360.0);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
111 axis1.setLowerBound(0.0);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
112 //axis1.setDisplayRange(0.0,360.0);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113 plot.setRangeAxis( axis1);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 }else{
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 axis.setFixedDimension(10.0);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116 axis.setAutoRangeIncludesZero(false);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 plot.setRangeAxis(axis);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119 axis.configure();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 plot.setRangeAxisLocation( AxisLocation.BOTTOM_OR_LEFT);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121 plot.setRenderer(renderer);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
122 plot.setDataset(lSet);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
123 } else {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
124 // Individual settings for different parameters
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
125 for (int i = 0; i < lSet.getSeriesCount(); i++) {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
126
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
127 plot.setDataset(i, getDataset((TimeSeriesCollection) lSet, i));
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
128 Color mColor=color[i % color.length]; // zyklische Farbvergabe
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
129 mColor = color[0];
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
130 // if ( pParameterId.length==1){
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
131
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
132 if(((String) lSet.getSeriesKey(i)).contains("richtung")){
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
133 NumberAxis axis1 = new NumberAxis(((String) lSet.getSeriesKey(i)));//,new Range(0.0,360.0));
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
134 axis1.setTickUnit(new NumberTickUnit(30.0));
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
135 //axis1.setDisplayRange(0.0,360.0);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
136 axis1.setLabelPaint(mColor);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
137 axis1.setTickLabelPaint(mColor);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
138 axis1.setUpperBound(360.0);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
139 axis1.setLowerBound(0.0);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
140 plot.setRangeAxis(i, axis1);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
141
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
142
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
143 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
144 else {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
145 axis = new NumberAxis((String) lSet.getSeriesKey(i));
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
146 axis.setFixedDimension(10.0);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
147 axis.setAutoRangeIncludesZero(false);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
148 axis.setLabelPaint(mColor);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
149 axis.setTickLabelPaint(mColor);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
150 plot.setRangeAxis(i, axis);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
151 axis.configure();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
152 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
153 if (i % 2 != 0)
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
154 plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
155 else
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
156 plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_LEFT);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
157 plot.mapDatasetToRangeAxis(i, i);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
158 // }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
159 renderer = new StandardXYItemRenderer();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
160 renderer.setSeriesPaint(i, mColor);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
161 // renderer.setSeriesStroke(i,stroke[j]);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
162 plot.setRenderer(i, renderer);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
163 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
164 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
165 JFreeChart chart = new JFreeChart(
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
166 pLabels.getTitle(),
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
167 new Font ("SansSerif",Font.BOLD,24),
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
168 plot,true);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
169
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
171 setStyle(chart, pStyle);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
172 configureRenderingOptions(chart);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
173 if (sDebug)
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
174 sLogger.debug(" vor encodeChart()");
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
175
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
176 encodeChart(chart, pStyle, outputStream);
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
177 }
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
178 private static XYDataset getDataset(TimeSeriesCollection T, int pIndex){ //throws TechnicalChartException{
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
179 //if (T.getSeriesCount() < pIndex) throw TechnicalChartException();
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
180 TimeSeriesCollection TSC = new TimeSeriesCollection();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
181 TSC.addSeries(T.getSeries(pIndex));
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
182 return (XYDataset) TSC;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
183 }
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
184
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
185 private void configureRenderingOptions(JFreeChart pJfreechart) {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
186 org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = ((XYPlot) pJfreechart
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
187 .getPlot()).getRenderer();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
188 if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
189 XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
190 xylineandshaperenderer.setBaseShapesVisible(true);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
191 xylineandshaperenderer.setBaseShapesFilled(true);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
192 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
193 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
194
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
195 private void setStyle(JFreeChart pJfreechart, ChartStyle pStyle) {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
196 if (sDebug)
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
197 sLogger.debug("setStyle()");
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
198 pJfreechart.setBackgroundPaint(pStyle.getCanvasColor());
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
199 XYPlot xyplot = (XYPlot) pJfreechart.getPlot();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
200 xyplot.setBackgroundPaint(pStyle.getPlotBackgroundColor());
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
201 xyplot.setDomainGridlinePaint(pStyle.getDomainGridlineColor());
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
202 xyplot.setRangeGridlinePaint(pStyle.getRangeGridlineColor());
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
203
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
204 Insets lOffsets = pStyle.getAxisOffset();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
205 RectangleInsets lRectangleInsets = new RectangleInsets(lOffsets.mUpper,
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
206 lOffsets.mLeft, lOffsets.mLower, lOffsets.mRight);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
207 xyplot.setAxisOffset(lRectangleInsets);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
208 xyplot.setDomainCrosshairVisible(pStyle.isDomainCrosshairVisible());
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
209 xyplot.setRangeCrosshairVisible(pStyle.isRangeCrosshairVisible());
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
210
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
211 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
212
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
213
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
214 private TimeSeries createTimeSeries(String pTimeSeriesName, Collection<Result> resultSet,
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
215 int lUpperCut, int lLowerCut,int pStart,int pEnd, Date dStart, Date dEnd) throws TechnicalChartException{
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
216 if (sDebug)
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
217 sLogger.debug("createTimeSeries()");
100
f07637f96312 Some Performanceimprovement done
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
218 Result lRow0, lRow1;
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
219
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
220 Date lDate=null, lDate0=null;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
221
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
222 TimeSeries lTimeseries = new TimeSeries(pTimeSeriesName,
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
223 org.jfree.data.time.Minute.class);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
224 try {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
225 long maxGap=0, lDateDiff=0;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
226 double lValue=0;
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
227
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
228
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
229 int i = 0;
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
230 Iterator<Result> resultIterator = resultSet.iterator();
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
231 while (resultIterator.hasNext()){
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
232 Result lRow = resultIterator.next();
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
233 if (i >= pStart+1 && i <= pEnd){
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
234 if (i == pStart+1){
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
235 lRow0 = lRow;//
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
236
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
237 // Handle Gaps > 0.5% timeserieslength, i.e do not draw here
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
238 // +TODO mache maxGap variabel �ber diagram options
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
239 maxGap = (dEnd.getTime() - dStart.getTime()) / 200; // 0,5 prozent der L�nge
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
240 if (maxGap < 3600000) maxGap=3600010;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
241 if (maxGap <(dEnd.getTime() - dStart.getTime())/(pEnd-pStart))
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
242 maxGap = (dEnd.getTime() - dStart.getTime())/(pEnd-pStart) + 1000;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
243
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
244 if (sDebug)
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
245 sLogger.debug("MaxGap : "+maxGap/1000+" L�nge : "+(dEnd.getTime() - dStart.getTime())/1000+
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
246 "Intervall "+(dEnd.getTime() - dStart.getTime())/(pEnd-pStart)/1000);
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
247 lDate = lRow0.getDate("XORDINATE");
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
248 lDate0 = lDate;
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
249 lValue = lRow0.getDouble("YORDINATE");
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
250 if (lValue > lLowerCut && lValue < lUpperCut){
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
251 //lTimeseries.addOrUpdate(new Minute(lDate), lValue);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
252 lTimeseries.add(new Minute(lDate), lValue);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
253 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
254 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
255 //for (int i = pStart+1; i <= pEnd; i++) {
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
256 lRow1 =lRow;
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
257 lDate = lRow1.getDate("XORDINATE");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
258 lValue = lRow1.getDouble("YORDINATE");
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
259 lDateDiff = lDate.getTime() - lDate0.getTime();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
260 if (lDateDiff > maxGap) {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
261 // add 1 minute in millisecs to left hand side Date
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
262 // and insert Dummy to break line
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
263 lDate0.setTime((lDate0.getTime() + 60000));
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
264 lTimeseries.addOrUpdate(new Minute(lDate0), null);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
265 lTimeseries.addOrUpdate(new Minute(lDate), lValue);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
266 //lTimeseries.add(new Minute(lDate0), null);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
267 } else if (lDateDiff == 0) {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
268 if (sDebug)
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
269 sLogger.debug("Datediff: "+lDateDiff+" bei index : "+i+" Datum : "+lDate+" "+lDate0);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
270 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
271 else if (lValue > lLowerCut && lValue < lUpperCut) {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
272 lTimeseries.addOrUpdate(new Minute(lDate), lValue);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
273 //lTimeseries.add(new Minute(lDate), lValue);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
274 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
275 lRow0 = lRow1;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
276 lDate0 = lDate;
100
f07637f96312 Some Performanceimprovement done
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
277 }else if (i > pEnd){
f07637f96312 Some Performanceimprovement done
Tim Englich <tim.englich@intevation.de>
parents: 86
diff changeset
278 return lTimeseries;
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
279 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
280 i++;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
281 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
282
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
283
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
284 } catch (OutOfMemoryError e) {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
285 sLogger.error(e.getMessage(), e);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
286 return lTimeseries;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
287
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
288 } catch (Exception e) { //TechnicalChartException
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
289 sLogger.error(e.getMessage(), e);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
290 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
291 finally {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
292 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
293
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
294 return lTimeseries;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
295 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
296
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
297 private XYDataset createDataset(Collection<Result> resultSet,
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
298 int lUpperCut, int lLowerCut,Collection<KeyValueDescibeData> parameters, Collection<KeyValueDescibeData> measurements) throws TechnicalChartException {
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
299
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
300 TimeSeriesCollection lTimeSeriesCollection = new TimeSeriesCollection();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
301 try{
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
302 Date dStart = null, dEnd= null;
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
303 String break1, break2, break3;
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
304 int mStart = 0;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
305 int mEnd = 0;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
306
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
307
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
308 Iterator<Result> resultIterator = resultSet.iterator();
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
309 if (resultIterator.hasNext()){
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
310 Result row = resultIterator.next();
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
311
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
312 break1 = row.getString("GROUP1"); // 2
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
313 break2 = row.getString("GROUP2"); //3
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
314 break3 = row.getString("GROUP3"); // 4
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
315 dStart = row.getDate("XORDINATE");
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
316 int i = 1;
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
317 while (resultIterator.hasNext()) {
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
318 row = resultIterator.next();
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
319 if (!break1.equals(row.getString("GROUP1"))
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
320 || !break2 .equals(row.getString("GROUP2"))
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
321 || !break3.equals(row.getString("GROUP3"))){
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
322 String mTimeSeriesName = findValueTitle(parameters,break1)+" "+
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
323 findValueTitle(measurements,break2)+"m";
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
324
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
325 lTimeSeriesCollection.addSeries(createTimeSeries(mTimeSeriesName,
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
326 resultSet, lUpperCut, lLowerCut, mStart, mEnd, dStart, dEnd));
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
327 mStart = i;
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
328 dStart = row.getDate("XORDINATE");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
329 break1 = row.getString("GROUP1");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
330 break2 = row.getString("GROUP2"); //3
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
331 break3 = row.getString("GROUP3"); // 4
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
332
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
333 }
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
334 mEnd = i;
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
335 dEnd = row.getDate("XORDINATE");
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
336 i = i + 1;
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
337 }
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
338
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
339 String mTimeSeriesName = findValueTitle(parameters,break1)+" "+
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
340 findValueTitle(measurements,break2)+"m";
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
341 lTimeSeriesCollection.addSeries(createTimeSeries(mTimeSeriesName,
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
342 resultSet, lUpperCut, lLowerCut, mStart, mEnd, dStart, dEnd));
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
343 }
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
344 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
345 catch (Exception e){
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
346 sLogger.error(e.getMessage(), e);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
347 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
348 finally{
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
349 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
350 return lTimeSeriesCollection;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
351 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
352
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
353
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
354
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
355 private void encodeChart(JFreeChart pChart, ChartStyle pStyle, OutputStream outputStream)
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
356 throws IOException {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
357 if (sDebug)
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
358 sLogger.debug("encodeChart()");
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
359 KeypointPNGEncoderAdapter lEncoder = new KeypointPNGEncoderAdapter();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
360 lEncoder.setEncodingAlpha(true);
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
361
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
362 int lWidth = (int) pStyle.getChartSize().getWidth();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
363 int lHeight = (int) pStyle.getChartSize().getHeight();
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
364
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
365 BufferedImage lImage = pChart.createBufferedImage(lWidth, lHeight,
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
366 BufferedImage.BITMASK, null);
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
367
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
368 lEncoder.encode(lImage, outputStream);
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
369
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
370 }
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
371
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
372 private String findValueTitle(Collection<KeyValueDescibeData> values, String pMmtId){
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
373 int id = 0;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
374 try {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
375 id = Integer.parseInt(pMmtId);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
376 } catch (NumberFormatException e) {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
377 sLogger.warn(e,e);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
378 return pMmtId;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
379 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
380
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
381 Iterator<KeyValueDescibeData> it = values.iterator();
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
382 while(it.hasNext()){
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
383 KeyValueDescibeData data = it.next();
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
384 if (id ==Integer.parseInt(data.getKey())){
68
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
385 return data.getValue();
d117fd4b82e5 Chartrendering integrated in Timeseries Transition
Tim Englich <tim.englich@intevation.de>
parents: 67
diff changeset
386 }
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
387 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
388 return "";
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
389 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
390 }

http://dive4elements.wald.intevation.org