annotate gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalProfileChartFactory.java @ 196:60c61f323f16

Bugfix for TIMESERIESPOINT the first and the last value weren't used in the Query which was integrated from the Prototyp to the Project ussue54 gnv-artifacts/trunk@249 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 20 Oct 2009 10:07:22 +0000
parents 34f233123a6f
children 3d6d89bcbf42
rev   line source
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
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 $
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
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 $
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 * created by: Stefan Blume (blume)
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5 * erstellt am: 06.12.2007
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 * Copyright: con terra GmbH, 2005
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 *
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 * modified by: $Author: blume $
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 * modified on: $Date: 2007/12/21 12:31:15 $
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 * Version: $Revision: 1.8 $
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 * TAG: $Name: $
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 * locked from: $Locker: $
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 * CVS State: $State: Exp $
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 * Project: $ProjectName$
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 */
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 package de.intevation.gnv.chart;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import java.awt.Color;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
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: 113
diff changeset
20 import java.awt.Transparency;
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import java.awt.image.BufferedImage;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 import java.io.IOException;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 import java.io.OutputStream;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import java.util.Collection;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 import java.util.Iterator;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 import org.apache.log4j.Logger;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 import org.jfree.chart.JFreeChart;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 import org.jfree.chart.axis.AxisLocation;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 import org.jfree.chart.axis.NumberAxis;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 import org.jfree.chart.axis.NumberTickUnit;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 import org.jfree.chart.encoders.KeypointPNGEncoderAdapter;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 import org.jfree.chart.plot.PlotOrientation;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 import org.jfree.chart.plot.XYPlot;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 import org.jfree.data.xy.XYDataset;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 import org.jfree.data.xy.XYSeries;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 import org.jfree.data.xy.XYSeriesCollection;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 import org.jfree.ui.RectangleInsets;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 import de.intevation.gnv.chart.exception.TechnicalChartException;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 import de.intevation.gnv.geobackend.base.Result;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 import de.intevation.gnv.transition.describedata.KeyValueDescibeData;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 /**
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 *
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 83
diff changeset
48 * @author Tim Englich <tim.englich@intevation.de>
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
49 *
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 */
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 public class VerticalProfileChartFactory {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
53 /**
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
54 * Default Logging instance
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
55 */
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
56 private static Logger sLogger = Logger
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
57 .getLogger(VerticalProfileChartFactory.class);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
58 private static boolean sDebug = sLogger.isDebugEnabled();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
59 protected PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL;
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
61 public synchronized void createProfileChart(
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
62 ChartLabels pLabels,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
63 ChartStyle pStyle,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
64 Collection<KeyValueDescibeData> parameters,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
65 Collection<KeyValueDescibeData> measurements,
179
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
66 Collection<KeyValueDescibeData> dates,
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
67 OutputStream outputStream,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
68 Collection<Result> resultSet)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
69 throws IOException,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
70 TechnicalChartException {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
71 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
72 sLogger.debug("createSimpleTimeSeriesChart()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
73 int lLowerLevel = Integer.MIN_VALUE;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
74 int lUpperLevel = Integer.MAX_VALUE;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
75 if (pStyle.isUseUpperDataLevel()
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
76 && pStyle.getUpperLevel() < Integer.MAX_VALUE) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
77 lUpperLevel = pStyle.getUpperLevel();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
78 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
79 if (pStyle.isUseLowerDataLevel()
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
80 && pStyle.getLowerLevel() > Integer.MIN_VALUE) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
81 lLowerLevel = pStyle.getLowerLevel();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
82 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
83 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
84 sLogger.debug(" vor createDataset()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
85 XYDataset lSet = this.createDataset(resultSet, lUpperLevel,
179
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
86 lLowerLevel, parameters, measurements, dates);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
87 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
88 sLogger.debug(" nach createDataset()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
89 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: 113
diff changeset
90 NumberAxis domain = new NumberAxis(pLabels.getDomainAxisLabel());
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
91 NumberAxis axis;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
92 StandardXYItemRenderer renderer = new StandardXYItemRenderer();
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
93 XYPlot plot = new XYPlot();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
94 // Global settings
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
95
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
96 plot.setOrientation(plotOrientation);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
97 plot.setBackgroundPaint(Color.lightGray);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
98 plot.setDomainGridlinePaint(Color.white);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
99 plot.setRangeGridlinePaint(Color.white);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
100 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: 113
diff changeset
101 // plot.getRangeAxis().setFixedDimension(10.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
102 plot.setDomainAxis(domain);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
103 plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
104 if (parameters.size() == 1) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
105 KeyValueDescibeData parameter = parameters.iterator().next();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
106 axis = new NumberAxis(parameter.getValue());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
107 if (parameter.getValue().contains("richtung")) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
108 NumberAxis axis1 = new NumberAxis((parameter
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
109 .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: 113
diff changeset
110 axis1.setTickUnit(new NumberTickUnit(30.0));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
111 axis1.setUpperBound(360.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
112 axis1.setLowerBound(0.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
113 // axis1.setDisplayRange(0.0,360.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
114 plot.setRangeAxis(axis1);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
115 } else {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
116 axis.setFixedDimension(10.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
117 axis.setAutoRangeIncludesZero(false);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
118 plot.setRangeAxis(axis);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
119 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
120 axis.configure();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
121 plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
122 plot.setRenderer(renderer);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
123 plot.setDataset(lSet);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
124 } else {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
125 // Individual settings for different parameters
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
126 for (int i = 0; i < lSet.getSeriesCount(); i++) {
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
127
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
128 plot.setDataset(i, getDataset((XYSeriesCollection) lSet, i));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
129 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: 113
diff changeset
130 mColor = color[0];
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
131 // if ( pParameterId.length==1){
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
132
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
133 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: 113
diff changeset
134 NumberAxis axis1 = new NumberAxis(((String) lSet
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
135 .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: 113
diff changeset
136 axis1.setTickUnit(new NumberTickUnit(30.0));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
137 // axis1.setDisplayRange(0.0,360.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
138 axis1.setLabelPaint(mColor);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
139 axis1.setTickLabelPaint(mColor);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
140 axis1.setUpperBound(360.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
141 axis1.setLowerBound(0.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
142 plot.setRangeAxis(i, axis1);
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
143
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
144 } else {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
145 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: 113
diff changeset
146 axis.setFixedDimension(10.0);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
147 axis.setAutoRangeIncludesZero(false);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
148 axis.setLabelPaint(mColor);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
149 axis.setTickLabelPaint(mColor);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
150 plot.setRangeAxis(i, axis);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
151 axis.configure();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
152 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
153 if (i % 2 != 0)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
154 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: 113
diff changeset
155 else
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
156 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: 113
diff changeset
157 plot.mapDatasetToRangeAxis(i, i);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
158 // }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
159 renderer = new StandardXYItemRenderer();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
160 renderer.setSeriesPaint(i, mColor);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
161 // renderer.setSeriesStroke(i,stroke[j]);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
162 plot.setRenderer(i, renderer);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
163 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
164 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
165 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: 113
diff changeset
166 "SansSerif", Font.BOLD, 24), plot, true);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
167
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
168 setStyle(chart, pStyle);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
169 configureRenderingOptions(chart);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
170 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
171 sLogger.debug(" vor encodeChart()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
172
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
173 encodeChart(chart, pStyle, outputStream);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
174 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
175
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
176 private static XYDataset getDataset(XYSeriesCollection T, int pIndex) { // throws
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
177 // TechnicalChartException{
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
178 // if (T.getSeriesCount() < pIndex) throw TechnicalChartException();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
179 XYSeriesCollection XYSC = new XYSeriesCollection();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
180 XYSC.addSeries(T.getSeries(pIndex));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
181 return XYSC;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
182 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
183
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
184 private void configureRenderingOptions(JFreeChart pJfreechart) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
185 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: 113
diff changeset
186 .getPlot()).getRenderer();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
187 if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
188 XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
189 xylineandshaperenderer.setBaseShapesVisible(true);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
190 xylineandshaperenderer.setBaseShapesFilled(true);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
191 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
192 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
193
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
194 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: 113
diff changeset
195 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
196 sLogger.debug("setStyle()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
197 pJfreechart.setBackgroundPaint(pStyle.getCanvasColor());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
198 XYPlot xyplot = (XYPlot) pJfreechart.getPlot();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
199 xyplot.setBackgroundPaint(pStyle.getPlotBackgroundColor());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
200 xyplot.setDomainGridlinePaint(pStyle.getDomainGridlineColor());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
201 xyplot.setRangeGridlinePaint(pStyle.getRangeGridlineColor());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
202
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
203 Insets lOffsets = pStyle.getAxisOffset();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
204 RectangleInsets lRectangleInsets = new RectangleInsets(lOffsets.mUpper,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
205 lOffsets.mLeft, lOffsets.mLower, lOffsets.mRight);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
206 xyplot.setAxisOffset(lRectangleInsets);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
207 xyplot.setDomainCrosshairVisible(pStyle.isDomainCrosshairVisible());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
208 xyplot.setRangeCrosshairVisible(pStyle.isRangeCrosshairVisible());
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
209
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
210 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
211
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
212 protected XYSeries createXYSeries(String seriesName,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
213 Collection<Result> resultSet,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
214 int lUpperCut, int lLowerCut, int pStart,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
215 int pEnd) throws TechnicalChartException {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
216 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
217 sLogger.debug("createXYSeries()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
218 XYSeries series = new XYSeries(seriesName);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
219 try {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
220 double xValue = 0;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
221 double yValue = 0;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
222 int i = 0;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
223 Iterator<Result> resultIterator = resultSet.iterator();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
224 while (resultIterator.hasNext()) {
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
225 Result lRow = resultIterator.next();
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
226 if (i >= pStart && i <= pEnd) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
227 xValue = lRow.getDouble("XORDINATE");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
228 yValue = lRow.getDouble("YORDINATE");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
229 series.add(xValue, yValue);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
230 sLogger.debug(seriesName + " Added Value " + xValue + " / "
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
231 + yValue);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
232
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
233 } else if (i > pEnd) {
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
234 return series;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
235 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
236 i++;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
237 }
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
238 } catch (OutOfMemoryError e) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
239 sLogger.error(e.getMessage(), e);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
240 return series;
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
241
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
242 } catch (Exception e) { // TechnicalChartException
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
243 sLogger.error(e.getMessage(), e);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
244 } finally {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
245 }
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
246
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
247 return series;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
248 }
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
249
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
250 private XYDataset createDataset(Collection<Result> resultSet,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
251 int lUpperCut, int lLowerCut,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
252 Collection<KeyValueDescibeData> parameters,
179
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
253 Collection<KeyValueDescibeData> measurements,
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
254 Collection<KeyValueDescibeData> dates)
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
255 throws TechnicalChartException {
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
256
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
257 XYSeriesCollection xyDataset = new XYSeriesCollection();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
258
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
259 try {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
260 String break1, break2, break3;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
261 int mStart = 0;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
262 int mEnd = 0;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
263
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
264 Iterator<Result> resultIterator = resultSet.iterator();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
265 if (resultIterator.hasNext()) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
266 // Row row = new Row(sArrayStrLine);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
267 Result row = resultIterator.next();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
268
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
269 break1 = row.getString("GROUP1"); // 2
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
270 break2 = row.getString("GROUP2"); // 3
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
271 break3 = row.getString("GROUP3"); // 4
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
272 int i = 1;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
273 while (resultIterator.hasNext()) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
274 row = resultIterator.next();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
275 if (!break1.equals(row.getString("GROUP1"))
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
276 || !break2.equals(row.getString("GROUP2"))
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
277 || !break3.equals(row.getString("GROUP3"))) {
179
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
278 String seriesName = this.createSeriesName(parameters, measurements, dates, break1, break2, break3);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
279 sLogger.debug("Neuer Datensatz " + seriesName
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
280 + "von Datens�tzen " + mStart + " / "
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
281 + mEnd);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
282 xyDataset.addSeries(createXYSeries(seriesName,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
283 resultSet, lUpperCut, lLowerCut, mStart, mEnd));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
284 mStart = i;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
285
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
286 break1 = row.getString("GROUP1");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
287 break2 = row.getString("GROUP2"); // 3
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
288 break3 = row.getString("GROUP3"); // 4
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
289
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
290 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
291 mEnd = i;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
292 // mEnd ++;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
293 i = i + 1;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
294 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
295
179
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
296 String seriesName = this.createSeriesName(parameters, measurements, dates, break1, break2, break3);
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
297 sLogger.debug("Neuer Datensatz " + seriesName
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
298 + "von Datens�tzen " + mStart + " / " + mEnd);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
299 xyDataset.addSeries(createXYSeries(seriesName, resultSet,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
300 lUpperCut, lLowerCut, mStart, mEnd));
193
34f233123a6f Adding empty Series into Chart to prevent NPE issue 19
Tim Englich <tim.englich@intevation.de>
parents: 179
diff changeset
301 }else{
34f233123a6f Adding empty Series into Chart to prevent NPE issue 19
Tim Englich <tim.englich@intevation.de>
parents: 179
diff changeset
302 xyDataset.addSeries(createXYSeries("",
34f233123a6f Adding empty Series into Chart to prevent NPE issue 19
Tim Englich <tim.englich@intevation.de>
parents: 179
diff changeset
303 resultSet, lUpperCut, lLowerCut, mStart, mEnd));
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
304 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
305 } catch (Exception e) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
306 sLogger.error(e.getMessage(), e);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
307 } finally {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
308 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
309 return xyDataset;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
310 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
311
179
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
312 /**
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
313 * @param parameters
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
314 * @param measurements
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
315 * @param break1
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
316 * @param break2
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
317 * @return
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
318 */
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
319 protected String createSeriesName(
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
320 Collection<KeyValueDescibeData> break1Candidates,
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
321 Collection<KeyValueDescibeData> break2Candidates,
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
322 Collection<KeyValueDescibeData> break3Candidates,
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
323 String break1, String break2, String break3) {
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
324 String seriesName = findValueTitle(break1Candidates, break1)
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
325 + " "
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
326 + findValueTitle(break2Candidates,
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
327 break2);
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
328 return seriesName.trim();
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
329 }
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
330
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
331 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: 113
diff changeset
332 OutputStream outputStream) throws IOException {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
333 if (sDebug)
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
334 sLogger.debug("encodeChart()");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
335 KeypointPNGEncoderAdapter lEncoder = new KeypointPNGEncoderAdapter();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
336 lEncoder.setEncodingAlpha(true);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
337
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
338 int lWidth = (int) pStyle.getChartSize().getWidth();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
339 int lHeight = (int) pStyle.getChartSize().getHeight();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
340
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
341 BufferedImage lImage = pChart.createBufferedImage(lWidth, lHeight,
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
342 Transparency.BITMASK, null);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
343
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
344 lEncoder.encode(lImage, outputStream);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
345
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
346 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
347
179
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
348 protected String findValueTitle(Collection<KeyValueDescibeData> values,
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
349 String id) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
350 if (values != null) {
110
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
351 Iterator<KeyValueDescibeData> it = values.iterator();
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
352 while (it.hasNext()) {
110
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
353 KeyValueDescibeData data = it.next();
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
354 if (id.equals(data.getKey())) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
355 return data.getValue();
110
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
356 }
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
357 }
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
358 }
179
f2c76f35da5a Added missing Class Description Values to the Horizontal Profile Charts
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
359 return "";
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
360 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
361 }

http://dive4elements.wald.intevation.org