annotate gnv-artifacts/src/main/java/de/intevation/gnv/chart/ChartFactory.java @ 223:05663e307495

Added the RegionFilters into the configuration of the Products for Meshes. gnv-artifacts/trunk@287 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Thu, 05 Nov 2009 15:16:51 +0000
parents 21152e1bf325
children 219e9666f590
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;
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
20 import java.awt.Transparency;
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import java.awt.image.BufferedImage;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 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
23 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
24 import java.util.Collection;
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 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
26 import java.util.Iterator;
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 import org.apache.log4j.Logger;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 import org.jfree.chart.JFreeChart;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 import org.jfree.chart.axis.AxisLocation;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 import org.jfree.chart.axis.DateAxis;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 import org.jfree.chart.axis.NumberAxis;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 import org.jfree.chart.axis.NumberTickUnit;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 import org.jfree.chart.encoders.KeypointPNGEncoderAdapter;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 import org.jfree.chart.plot.PlotOrientation;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 import org.jfree.chart.plot.XYPlot;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 import org.jfree.data.time.Minute;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 import org.jfree.data.time.TimeSeries;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 import org.jfree.data.time.TimeSeriesCollection;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 import org.jfree.data.xy.XYDataset;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 import org.jfree.ui.RectangleInsets;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44
67
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.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
46 import de.intevation.gnv.geobackend.base.Result;
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
47 import de.intevation.gnv.timeseries.gap.TimeGap;
67
0e9762ebd18d Refactor ChartFactory so that it is able to be compiled without errors.
Tim Englich <tim.englich@intevation.de>
parents: 65
diff changeset
48 import de.intevation.gnv.transition.describedata.KeyValueDescibeData;
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 /**
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 * 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
52 * <ol>
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 * <li></li>
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 * </ol>
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 *
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 * @author blume
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 * @version 1.0
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 * @serial 1.0
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 * @see
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 * @since 06.12.2007 17:25:59
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 public class ChartFactory {
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
64 /**
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
65 * Default Logging instance
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
66 */
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
67 private static Logger sLogger = Logger.getLogger(ChartFactory.class);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
68 private static boolean sDebug = sLogger.isDebugEnabled();
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
70 public synchronized void createSimpleTimeSeriesChart(
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
71 ChartLabels pLabels,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
72 ChartStyle pStyle,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
73 Collection<KeyValueDescibeData> parameters,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
74 Collection<KeyValueDescibeData> measurements,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
75 OutputStream outputStream,
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
76 Collection<Result> resultSet,
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
77 Collection<TimeGap> timeGaps)
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
78 throws IOException,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
79 TechnicalChartException {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
80 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
81 sLogger.debug("createSimpleTimeSeriesChart()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
82 int lLowerLevel = Integer.MIN_VALUE;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
83 int lUpperLevel = Integer.MAX_VALUE;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
84 if (pStyle.isUseUpperDataLevel()
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
85 && pStyle.getUpperLevel() < Integer.MAX_VALUE) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
86 lUpperLevel = pStyle.getUpperLevel();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
87 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
88 if (pStyle.isUseLowerDataLevel()
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
89 && pStyle.getLowerLevel() > Integer.MIN_VALUE) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
90 lLowerLevel = pStyle.getLowerLevel();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
91 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
92 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
93 sLogger.debug(" vor createDataset()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
94 XYDataset lSet = this.createDataset(resultSet, lUpperLevel,
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
95 lLowerLevel, parameters, measurements,timeGaps);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
96 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
97 sLogger.debug(" nach createDataset()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
98 final Color[] color = { Color.black, Color.red, Color.green, Color.blue };
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
99 DateAxis domain = new DateAxis(pLabels.getDomainAxisLabel());
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100 NumberAxis axis;
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101 StandardXYItemRenderer renderer = new StandardXYItemRenderer();
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
102 XYPlot plot = new XYPlot();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
103 // Global settings
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
104
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
105 plot.setOrientation(PlotOrientation.VERTICAL);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
106 plot.setBackgroundPaint(Color.lightGray);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
107 plot.setDomainGridlinePaint(Color.white);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
108 plot.setRangeGridlinePaint(Color.white);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
109 plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
110 // plot.getRangeAxis().setFixedDimension(10.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
111 plot.setDomainAxis(domain);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
112 plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
113 if (parameters.size() == 1) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
114 KeyValueDescibeData parameter = parameters.iterator().next();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
115 axis = new NumberAxis(parameter.getValue());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
116 if (parameter.getValue().contains("richtung")) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
117 NumberAxis axis1 = new NumberAxis((parameter
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
118 .getValue()));// ,new Range(0.0,360.0));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
119 axis1.setTickUnit(new NumberTickUnit(30.0));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
120 axis1.setUpperBound(360.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
121 axis1.setLowerBound(0.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
122 // axis1.setDisplayRange(0.0,360.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
123 plot.setRangeAxis(axis1);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
124 } else {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
125 axis.setFixedDimension(10.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
126 axis.setAutoRangeIncludesZero(false);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
127 plot.setRangeAxis(axis);
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
128 }
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
129 axis.configure();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
130 plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
131 plot.setRenderer(renderer);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
132 plot.setDataset(lSet);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
133 } else {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
134 // Individual settings for different parameters
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
135 for (int i = 0; i < lSet.getSeriesCount(); i++) {
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
136
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
137 plot.setDataset(i, getDataset((TimeSeriesCollection) lSet, i));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
138 Color mColor = color[i % color.length]; // zyklische Farbvergabe
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
139 mColor = color[0];
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
140 // if ( pParameterId.length==1){
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
141
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
142 if (((String) lSet.getSeriesKey(i)).contains("richtung")) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
143 NumberAxis axis1 = new NumberAxis(((String) lSet
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
144 .getSeriesKey(i)));// ,new Range(0.0,360.0));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
145 axis1.setTickUnit(new NumberTickUnit(30.0));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
146 // axis1.setDisplayRange(0.0,360.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
147 axis1.setLabelPaint(mColor);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
148 axis1.setTickLabelPaint(mColor);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
149 axis1.setUpperBound(360.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
150 axis1.setLowerBound(0.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
151 plot.setRangeAxis(i, axis1);
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
152
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
153 } else {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
154 axis = new NumberAxis((String) lSet.getSeriesKey(i));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
155 axis.setFixedDimension(10.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
156 axis.setAutoRangeIncludesZero(false);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
157 axis.setLabelPaint(mColor);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
158 axis.setTickLabelPaint(mColor);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
159 plot.setRangeAxis(i, axis);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
160 axis.configure();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
161 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
162 if (i % 2 != 0)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
163 plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
164 else
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
165 plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_LEFT);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
166 plot.mapDatasetToRangeAxis(i, i);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
167 // }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
168 renderer = new StandardXYItemRenderer();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
169 renderer.setSeriesPaint(i, mColor);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
170 // renderer.setSeriesStroke(i,stroke[j]);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
171 plot.setRenderer(i, renderer);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
172 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
173 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
174 JFreeChart chart = new JFreeChart(pLabels.getTitle(), new Font(
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
175 "SansSerif", Font.BOLD, 24), plot, true);
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
176
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
177 setStyle(chart, pStyle);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
178 configureRenderingOptions(chart);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
179 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
180 sLogger.debug(" vor encodeChart()");
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
181
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
182 encodeChart(chart, pStyle, outputStream);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
183 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
184
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
185 private static XYDataset getDataset(TimeSeriesCollection T, int pIndex) { // throws
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
186 // TechnicalChartException{
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
187 // if (T.getSeriesCount() < pIndex) throw TechnicalChartException();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
188 TimeSeriesCollection TSC = new TimeSeriesCollection();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
189 TSC.addSeries(T.getSeries(pIndex));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
190 return TSC;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
191 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
192
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
193 private void configureRenderingOptions(JFreeChart pJfreechart) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
194 org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = ((XYPlot) pJfreechart
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
195 .getPlot()).getRenderer();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
196 if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
197 XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
198 xylineandshaperenderer.setBaseShapesVisible(true);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
199 xylineandshaperenderer.setBaseShapesFilled(true);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
200 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
201 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
202
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
203 private void setStyle(JFreeChart pJfreechart, ChartStyle pStyle) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
204 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
205 sLogger.debug("setStyle()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
206 pJfreechart.setBackgroundPaint(pStyle.getCanvasColor());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
207 XYPlot xyplot = (XYPlot) pJfreechart.getPlot();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
208 xyplot.setBackgroundPaint(pStyle.getPlotBackgroundColor());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
209 xyplot.setDomainGridlinePaint(pStyle.getDomainGridlineColor());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
210 xyplot.setRangeGridlinePaint(pStyle.getRangeGridlineColor());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
211
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
212 Insets lOffsets = pStyle.getAxisOffset();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
213 RectangleInsets lRectangleInsets = new RectangleInsets(lOffsets.mUpper,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
214 lOffsets.mLeft, lOffsets.mLower, lOffsets.mRight);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
215 xyplot.setAxisOffset(lRectangleInsets);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
216 xyplot.setDomainCrosshairVisible(pStyle.isDomainCrosshairVisible());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
217 xyplot.setRangeCrosshairVisible(pStyle.isRangeCrosshairVisible());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
218
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
219 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
220
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
221 private TimeSeries createTimeSeries(String pTimeSeriesName,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
222 Collection<Result> resultSet,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
223 int lUpperCut, int lLowerCut,
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
224 int pStart, int pEnd, long maxGap)
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
225 throws TechnicalChartException {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
226 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
227 sLogger.debug("createTimeSeries()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
228 Result lRow0, lRow1;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
229
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
230 Date lDate = null, lDate0 = null;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
231
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
232 TimeSeries lTimeseries = new TimeSeries(pTimeSeriesName,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
233 org.jfree.data.time.Minute.class);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
234 try {
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
235 long lDateDiff = 0;
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
236 double lValue = 0;
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
237
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
238 int i = 0;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
239 Iterator<Result> resultIterator = resultSet.iterator();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
240 while (resultIterator.hasNext()) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
241 Result lRow = resultIterator.next();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
242 if (i >= pStart + 1 && i <= pEnd) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
243 if (i == pStart + 1) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
244 lRow0 = lRow;//
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
245 lDate = lRow0.getDate("XORDINATE");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
246 lDate0 = lDate;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
247 lValue = lRow0.getDouble("YORDINATE");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
248 if (lValue > lLowerCut && lValue < lUpperCut) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
249 // lTimeseries.addOrUpdate(new Minute(lDate),
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
250 // lValue);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
251 lTimeseries.add(new Minute(lDate), lValue);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
252 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
253 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
254 // for (int i = pStart+1; i <= pEnd; i++) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
255 lRow1 = lRow;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
256 lDate = lRow1.getDate("XORDINATE");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
257 lValue = lRow1.getDouble("YORDINATE");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
258 lDateDiff = lDate.getTime() - lDate0.getTime();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
259 if (lDateDiff > maxGap) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
260 // add 1 minute in millisecs to left hand side Date
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
261 // and insert Dummy to break line
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
262 lDate0.setTime((lDate0.getTime() + 60000));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
263 lTimeseries.addOrUpdate(new Minute(lDate0), null);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
264 lTimeseries.addOrUpdate(new Minute(lDate), lValue);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
265 // lTimeseries.add(new Minute(lDate0), null);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
266 } else if (lDateDiff == 0) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
267 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
268 sLogger.debug("Datediff: " + lDateDiff
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
269 + " bei index : " + i + " Datum : "
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
270 + lDate + " " + lDate0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
271 } else if (lValue > lLowerCut && lValue < lUpperCut) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
272 lTimeseries.addOrUpdate(new Minute(lDate), lValue);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
273 // lTimeseries.add(new Minute(lDate), lValue);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
274 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
275 lRow0 = lRow1;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
276 lDate0 = lDate;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
277 } else if (i > pEnd) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
278 return lTimeseries;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
279 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
280 i++;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
281 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
282
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
283 } catch (OutOfMemoryError e) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
284 sLogger.error(e.getMessage(), e);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
285 return lTimeseries;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
286
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
287 } catch (Exception e) { // TechnicalChartException
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
288 sLogger.error(e.getMessage(), e);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
289 } finally {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
290 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
291
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
292 return lTimeseries;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
293 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
294
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
295 private XYDataset createDataset(Collection<Result> resultSet,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
296 int lUpperCut, int lLowerCut,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
297 Collection<KeyValueDescibeData> parameters,
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
298 Collection<KeyValueDescibeData> measurements,
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
299 Collection<TimeGap> timeGaps)
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
300 throws TechnicalChartException {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
301
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
302 TimeSeriesCollection lTimeSeriesCollection = new TimeSeriesCollection();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
303 try {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
304 Date dStart = null, dEnd = null;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
305 String break1, break2, break3;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
306 int mStart = 0;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
307 int mEnd = 0;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
308
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
309 Iterator<Result> resultIterator = resultSet.iterator();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
310 if (resultIterator.hasNext()) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
311 Result row = resultIterator.next();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
312
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
313 break1 = row.getString("GROUP1"); // 2
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
314 break2 = row.getString("GROUP2"); // 3
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
315 break3 = row.getString("GROUP3"); // 4
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
316 dStart = row.getDate("XORDINATE");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
317 int i = 1;
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
318 Integer gapID = -1;
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
319 while (resultIterator.hasNext()) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
320 row = resultIterator.next();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
321 if (!break1.equals(row.getString("GROUP1"))
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
322 || !break2.equals(row.getString("GROUP2"))
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
323 || !break3.equals(row.getString("GROUP3"))) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
324 String mTimeSeriesName = findValueTitle(parameters,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
325 break1)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
326 + " "
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
327 + findValueTitle(measurements,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
328 break2) + "m";
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
329 long maxGap = this.calculateMaxGap(dStart, dEnd,mStart,
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
330 mEnd, gapID.intValue(),
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
331 timeGaps);
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
332
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
333
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
334 lTimeSeriesCollection.addSeries(createTimeSeries(
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
335 mTimeSeriesName, resultSet, lUpperCut,
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
336 lLowerCut, mStart, mEnd,maxGap));
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
337 mStart = i;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
338 dStart = row.getDate("XORDINATE");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
339 break1 = row.getString("GROUP1");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
340 break2 = row.getString("GROUP2"); // 3
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
341 break3 = row.getString("GROUP3"); // 4
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
342
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
343 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
344 mEnd = i;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
345 dEnd = row.getDate("XORDINATE");
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
346 gapID = row.getInteger("GAPID");
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
347 i = i + 1;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
348 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
349
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
350 String mTimeSeriesName = findValueTitle(parameters, break1)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
351 + " "
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
352 + findValueTitle(measurements, break2)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
353 + "m";
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
354 long maxGap = this.calculateMaxGap(dStart, dEnd,mStart,
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
355 mEnd,gapID.intValue(),
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
356 timeGaps);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
357 lTimeSeriesCollection.addSeries(createTimeSeries(
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
358 mTimeSeriesName, resultSet, lUpperCut, lLowerCut,
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
359 mStart, mEnd, maxGap));
193
34f233123a6f Adding empty Series into Chart to prevent NPE issue 19
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
360 }else{
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
361 // Es sind keine Daten vorhanden: Es wird eine Zeitserie eingef�gt.
193
34f233123a6f Adding empty Series into Chart to prevent NPE issue 19
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
362 lTimeSeriesCollection.addSeries(createTimeSeries(
34f233123a6f Adding empty Series into Chart to prevent NPE issue 19
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
363 "", resultSet, lUpperCut, lLowerCut,
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
364 mStart, mEnd, 999999));
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
365 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
366 } catch (Exception e) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
367 sLogger.error(e.getMessage(), e);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
368 } finally {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
369 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
370 return lTimeSeriesCollection;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
371 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
372
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
373 /**
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
374 * @param dStart
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
375 * @param dEnd
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
376 */
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
377 private long calculateMaxGap(Date dStart, Date dEnd, int pStart ,
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
378 int pEnd, int gapID,
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
379 Collection<TimeGap> timeGaps) {
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
380
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
381 // umgesetzt nach issue 45
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
382 // Handle Gaps > 0.5% timeserieslength,
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
383 // i.e do not draw here
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
384 long maxGap = (dEnd.getTime() - dStart.getTime()) / 200;
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
385 // 0,5 prozent der L�nge
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
386 long timeInterval = this.getTimeGapValue(dStart, dEnd, pStart,
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
387 pEnd, gapID, timeGaps);
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
388
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
389 if (maxGap < timeInterval){
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
390 maxGap = timeInterval + 10;
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
391 }
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
392 // if (maxGap < (dEnd.getTime() - dStart.getTime())
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
393 // / (pEnd - pStart))
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
394 // maxGap = (dEnd.getTime() - dStart.getTime())
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
395 // / (pEnd - pStart) + 1000;
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
396
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
397 return maxGap;
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
398 }
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
399
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
400 private long getTimeGapValue(Date dStart, Date dEnd,
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
401 int pStart ,int pEnd,
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
402 int gapID, Collection<TimeGap> timeGaps){
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
403 long gap = 0;
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
404
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
405 if (gapID < 0 || gapID >= 99){
221
21152e1bf325 Implemented the special case for TimeGaps in Meshes issue45
Tim Englich <tim.englich@intevation.de>
parents: 217
diff changeset
406
21152e1bf325 Implemented the special case for TimeGaps in Meshes issue45
Tim Englich <tim.englich@intevation.de>
parents: 217
diff changeset
407 if (gapID == -1){ // Mesh
21152e1bf325 Implemented the special case for TimeGaps in Meshes issue45
Tim Englich <tim.englich@intevation.de>
parents: 217
diff changeset
408 gap = Long.MAX_VALUE; // Es gibt keine L�cken in Netzen.
21152e1bf325 Implemented the special case for TimeGaps in Meshes issue45
Tim Englich <tim.englich@intevation.de>
parents: 217
diff changeset
409 }else if (pEnd-pStart < 60){
21152e1bf325 Implemented the special case for TimeGaps in Meshes issue45
Tim Englich <tim.englich@intevation.de>
parents: 217
diff changeset
410 gap = (3/(pEnd-pStart)) * (dEnd.getTime() - dStart.getTime());
21152e1bf325 Implemented the special case for TimeGaps in Meshes issue45
Tim Englich <tim.englich@intevation.de>
parents: 217
diff changeset
411 }
217
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
412 }else{
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
413
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
414 Iterator<TimeGap> it = timeGaps.iterator();
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
415
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
416 while (it.hasNext()){
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
417 TimeGap tempTimeGap = it.next();
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
418 if (tempTimeGap.getKey() == gapID){
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
419 int gapValue = tempTimeGap.getValue();
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
420 String unit = tempTimeGap.getUnit();
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
421
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
422 if (unit.equals(TimeGap.TIME_UNIT_MINUTE)){
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
423 gap = gapValue * TimeGap.MINUTE_IN_MILLIS;
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
424 }else if (unit.equals(TimeGap.TIME_UNIT_HOUR)){
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
425 gap = gapValue * TimeGap.HOUR_IN_MILLIS;
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
426 }else if (unit.equals(TimeGap.TIME_UNIT_DAY)){
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
427 gap = gapValue * TimeGap.DAY_IN_MILLIS;
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
428 }else if (unit.equals(TimeGap.TIME_UNIT_WEEK)){
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
429 gap = gapValue * TimeGap.WEEK_IN_MILLIS;
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
430 }else if (unit.equals(TimeGap.TIME_UNIT_MONTH)){
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
431 // TODO wie soll das laufen
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
432 gap = gapValue * (TimeGap.DAY_IN_MILLIS *30);
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
433 }else if (unit.equals(TimeGap.TIME_UNIT_YEAR)){
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
434 // TODO wie soll das laufen f�r schaltjahre
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
435 gap = gapValue * (TimeGap.DAY_IN_MILLIS *365);
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
436 }
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
437 break;
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
438 }
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
439 }
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
440 }
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
441
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
442 return gap;
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
443 }
3dcd2b0b456e Added configurable TimeGap Support to the TimeSeries-Chart-Generation. issu45
Tim Englich <tim.englich@intevation.de>
parents: 193
diff changeset
444
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
445 private void encodeChart(JFreeChart pChart, ChartStyle pStyle,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
446 OutputStream outputStream) throws IOException {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
447 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
448 sLogger.debug("encodeChart()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
449 KeypointPNGEncoderAdapter lEncoder = new KeypointPNGEncoderAdapter();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
450 lEncoder.setEncodingAlpha(true);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
451
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
452 int lWidth = (int) pStyle.getChartSize().getWidth();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
453 int lHeight = (int) pStyle.getChartSize().getHeight();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
454
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
455 BufferedImage lImage = pChart.createBufferedImage(lWidth, lHeight,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
456 Transparency.BITMASK, null);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
457
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
458 lEncoder.encode(lImage, outputStream);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
459
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
460 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
461
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
462 private String findValueTitle(Collection<KeyValueDescibeData> values,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
463 String pMmtId) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
464 int id = 0;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
465 try {
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
466 id = Integer.parseInt(pMmtId);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
467 } catch (NumberFormatException e) {
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
468 sLogger.warn(e, e);
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
469 return pMmtId;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
470 }
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
471
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents: 68
diff changeset
472 Iterator<KeyValueDescibeData> it = values.iterator();
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
473 while (it.hasNext()) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
474 KeyValueDescibeData data = it.next();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
475 if (id == Integer.parseInt(data.getKey())) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
476 return data.getValue();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
477 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
478 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 100
diff changeset
479 return "";
65
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
480 }
8b75d01fa5b5 Insert Chart-Classes from old Repository
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
481 }

http://dive4elements.wald.intevation.org