annotate gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalProfileChartFactory.java @ 110:b465f1bbe368

Some Codeimprovments done gnv-artifacts/trunk@159 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 29 Sep 2009 15:02:27 +0000
parents 1b12021905b9
children a16f5267803e
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;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import java.awt.image.BufferedImage;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import java.io.IOException;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 import java.io.OutputStream;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 import java.util.Collection;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import java.util.Iterator;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 import org.apache.log4j.Logger;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 import org.jfree.chart.JFreeChart;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 import org.jfree.chart.axis.AxisLocation;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 import org.jfree.chart.axis.NumberAxis;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 import org.jfree.chart.axis.NumberTickUnit;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 import org.jfree.chart.encoders.KeypointPNGEncoderAdapter;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 import org.jfree.chart.plot.PlotOrientation;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 import org.jfree.chart.plot.XYPlot;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 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
35 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
36 import org.jfree.data.xy.XYDataset;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 import org.jfree.data.xy.XYSeries;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 import org.jfree.data.xy.XYSeriesCollection;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 import org.jfree.ui.RectangleInsets;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 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
42 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
43 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
44
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 *
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 83
diff changeset
47 * @author Tim Englich <tim.englich@intevation.de>
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 83
diff changeset
48 *
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 */
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 public class VerticalProfileChartFactory {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 /**
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 * Default Logging instance
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 */
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 private static Logger sLogger = Logger.getLogger(VerticalProfileChartFactory.class);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 private static boolean sDebug = sLogger.isDebugEnabled();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 83
diff changeset
59 public synchronized void createSimpleVerticalProfileChart(ChartLabels pLabels, ChartStyle pStyle, Collection<KeyValueDescibeData> parameters, Collection<KeyValueDescibeData> measurements, OutputStream outputStream, Collection<Result> resultSet) throws IOException, TechnicalChartException {
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 if (sDebug)
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 sLogger.debug("createSimpleTimeSeriesChart()");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 int lLowerLevel = Integer.MIN_VALUE;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 int lUpperLevel = Integer.MAX_VALUE;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 if (pStyle.isUseUpperDataLevel()
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 && pStyle.getUpperLevel() < Integer.MAX_VALUE) {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 lUpperLevel = pStyle.getUpperLevel();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 if (pStyle.isUseLowerDataLevel()
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69 && pStyle.getLowerLevel() > Integer.MIN_VALUE) {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 lLowerLevel = pStyle.getLowerLevel();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 if (sDebug)
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 sLogger.debug(" vor createDataset()");
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 83
diff changeset
74 XYDataset lSet = this.createDataset(resultSet, lUpperLevel,
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 lLowerLevel,parameters,measurements);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76 if (sDebug)
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 sLogger.debug(" nach createDataset()");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 final Color[] color = {Color.black, Color.red, Color.green, Color.blue};
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 83
diff changeset
79 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
80 NumberAxis axis;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81 StandardXYItemRenderer renderer = new StandardXYItemRenderer();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 XYPlot plot = new XYPlot();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 //Global settings
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85 plot.setOrientation(PlotOrientation.HORIZONTAL);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86 plot.setBackgroundPaint(Color.lightGray);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 plot.setDomainGridlinePaint(Color.white);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88 plot.setRangeGridlinePaint(Color.white);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
89 plot.setAxisOffset(new RectangleInsets(5.0,5.0,5.0,5.0));
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
90 //plot.getRangeAxis().setFixedDimension(10.0);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
91 plot.setDomainAxis(domain);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
92 plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
93 if (parameters.size() == 1) {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
94 KeyValueDescibeData parameter = parameters.iterator().next();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
95 axis = new NumberAxis(parameter.getValue());
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
96 if(parameter.getValue().contains("richtung")){
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
97 NumberAxis axis1 = new NumberAxis(
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
98 ((String) parameter.getValue()));//,new Range(0.0,360.0));
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
99 axis1.setTickUnit(new NumberTickUnit(30.0));
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100 axis1.setUpperBound(360.0);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101 axis1.setLowerBound(0.0);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
102 //axis1.setDisplayRange(0.0,360.0);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
103 plot.setRangeAxis( axis1);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
104 }else{
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
105 axis.setFixedDimension(10.0);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
106 axis.setAutoRangeIncludesZero(false);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
107 plot.setRangeAxis(axis);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
108 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
109 axis.configure();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110 plot.setRangeAxisLocation( AxisLocation.BOTTOM_OR_LEFT);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
111 plot.setRenderer(renderer);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
112 plot.setDataset(lSet);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113 } else {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 // Individual settings for different parameters
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 for (int i = 0; i < lSet.getSeriesCount(); i++) {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 plot.setDataset(i, getDataset((XYSeriesCollection) lSet, i));
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 Color mColor=color[i % color.length]; // zyklische Farbvergabe
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119 mColor = color[0];
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 // if ( pParameterId.length==1){
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
122 if(((String) lSet.getSeriesKey(i)).contains("richtung")){
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
123 NumberAxis axis1 = new NumberAxis(((String) lSet.getSeriesKey(i)));//,new Range(0.0,360.0));
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
124 axis1.setTickUnit(new NumberTickUnit(30.0));
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
125 //axis1.setDisplayRange(0.0,360.0);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
126 axis1.setLabelPaint(mColor);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
127 axis1.setTickLabelPaint(mColor);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
128 axis1.setUpperBound(360.0);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
129 axis1.setLowerBound(0.0);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
130 plot.setRangeAxis(i, axis1);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
131
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
132
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
133 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
134 else {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
135 axis = new NumberAxis((String) lSet.getSeriesKey(i));
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
136 axis.setFixedDimension(10.0);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
137 axis.setAutoRangeIncludesZero(false);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
138 axis.setLabelPaint(mColor);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
139 axis.setTickLabelPaint(mColor);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
140 plot.setRangeAxis(i, axis);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
141 axis.configure();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
142 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
143 if (i % 2 != 0)
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
144 plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
145 else
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
146 plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_LEFT);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
147 plot.mapDatasetToRangeAxis(i, i);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
148 // }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
149 renderer = new StandardXYItemRenderer();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
150 renderer.setSeriesPaint(i, mColor);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
151 // renderer.setSeriesStroke(i,stroke[j]);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
152 plot.setRenderer(i, renderer);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
153 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
154 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
155 JFreeChart chart = new JFreeChart(
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
156 pLabels.getTitle(),
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
157 new Font ("SansSerif",Font.BOLD,24),
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
158 plot,true);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
159
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
160
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
161 setStyle(chart, pStyle);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
162 configureRenderingOptions(chart);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
163 if (sDebug)
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
164 sLogger.debug(" vor encodeChart()");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
165
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
166 encodeChart(chart, pStyle, outputStream);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
167 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
168 private static XYDataset getDataset(XYSeriesCollection T, int pIndex){ //throws TechnicalChartException{
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
169 //if (T.getSeriesCount() < pIndex) throw TechnicalChartException();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170 XYSeriesCollection XYSC = new XYSeriesCollection();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
171 XYSC.addSeries(T.getSeries(pIndex));
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
172 return (XYDataset) XYSC;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
173 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
174
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
175 private void configureRenderingOptions(JFreeChart pJfreechart) {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
176 org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = ((XYPlot) pJfreechart
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
177 .getPlot()).getRenderer();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
178 if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
179 XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
180 xylineandshaperenderer.setBaseShapesVisible(true);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
181 xylineandshaperenderer.setBaseShapesFilled(true);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
182 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
183 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
184
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
185 private void setStyle(JFreeChart pJfreechart, ChartStyle pStyle) {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
186 if (sDebug)
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
187 sLogger.debug("setStyle()");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
188 pJfreechart.setBackgroundPaint(pStyle.getCanvasColor());
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
189 XYPlot xyplot = (XYPlot) pJfreechart.getPlot();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
190 xyplot.setBackgroundPaint(pStyle.getPlotBackgroundColor());
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
191 xyplot.setDomainGridlinePaint(pStyle.getDomainGridlineColor());
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
192 xyplot.setRangeGridlinePaint(pStyle.getRangeGridlineColor());
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
193
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
194 Insets lOffsets = pStyle.getAxisOffset();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
195 RectangleInsets lRectangleInsets = new RectangleInsets(lOffsets.mUpper,
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
196 lOffsets.mLeft, lOffsets.mLower, lOffsets.mRight);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
197 xyplot.setAxisOffset(lRectangleInsets);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
198 xyplot.setDomainCrosshairVisible(pStyle.isDomainCrosshairVisible());
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
199 xyplot.setRangeCrosshairVisible(pStyle.isRangeCrosshairVisible());
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
200
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
201 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
202
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
203
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
204 protected XYSeries createXYSeries(String seriesName, Collection<Result> resultSet,
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
205 int lUpperCut, int lLowerCut,int pStart,int pEnd) throws TechnicalChartException{
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
206 if (sDebug)
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
207 sLogger.debug("createXYSeries()");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
208 XYSeries series = new XYSeries(seriesName);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
209 try {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
210 double xValue=0;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
211 double yValue=0;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
212 int i = 0;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
213 Iterator<Result> resultIterator = resultSet.iterator();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
214 while (resultIterator.hasNext()){
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
215 Result lRow = resultIterator.next();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
216 if (i >= pStart && i <= pEnd ){
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
217 xValue = lRow.getDouble("XORDINATE");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
218 yValue = lRow.getDouble("YORDINATE");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
219 series.add(xValue, yValue);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
220 sLogger.debug(seriesName+" Added Value "+xValue+" / "+yValue);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
221
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
222 }else if (i > pEnd){
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
223 return series;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
224 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
225 i++;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
226 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
227 } catch (OutOfMemoryError e) {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
228 sLogger.error(e.getMessage(), e);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
229 return series;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
230
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
231 } catch (Exception e) { //TechnicalChartException
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
232 sLogger.error(e.getMessage(), e);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
233 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
234 finally {
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
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
237 return series;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
238 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
239
86
5d4f5d26bb7a Some Codecleanup done
Tim Englich <tim.englich@intevation.de>
parents: 83
diff changeset
240 private XYDataset createDataset(Collection<Result> resultSet,
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
241 int lUpperCut, int lLowerCut,Collection<KeyValueDescibeData> parameters, Collection<KeyValueDescibeData> measurements) throws TechnicalChartException {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
242
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
243 XYSeriesCollection xyDataset = new XYSeriesCollection();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
244
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
245 try{
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
246 String break1, break2, break3;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
247 int mStart = 0;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
248 int mEnd = 0;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
249
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
250
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
251 Iterator<Result> resultIterator = resultSet.iterator();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
252 if (resultIterator.hasNext()){
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
253 // Row row = new Row(sArrayStrLine);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
254 Result row = resultIterator.next();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
255
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
256 break1 = row.getString("GROUP1"); // 2
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
257 break2 = row.getString("GROUP2"); //3
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
258 break3 = row.getString("GROUP3"); // 4
83
5c8e54726a58 Added Support for Vertical Profiles Mesh
Tim Englich <tim.englich@intevation.de>
parents: 82
diff changeset
259 int i = 1;
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
260 while (resultIterator.hasNext()) {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
261 row = resultIterator.next();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
262 if (!break1.equals(row.getString("GROUP1"))
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
263 || !break2 .equals(row.getString("GROUP2"))
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
264 || !break3.equals(row.getString("GROUP3"))){
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
265 String seriesName = findValueTitle(parameters,break1)+" "+
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
266 findValueTitle(measurements,break2);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
267 sLogger.debug("Neuer Datensatz "+seriesName+ "von Datens�tzen "+mStart+" / "+mEnd);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
268 xyDataset.addSeries(createXYSeries(seriesName,
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
269 resultSet, lUpperCut, lLowerCut, mStart, mEnd));
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
270 mStart = i;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
271
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
272 break1 = row.getString("GROUP1");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
273 break2 = row.getString("GROUP2"); //3
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
274 break3 = row.getString("GROUP3"); // 4
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
275
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
276 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
277 mEnd = i;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
278 //mEnd ++;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
279 i = i + 1;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
280 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
281
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
282 String seriesName = findValueTitle(parameters,break1)+" "+
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
283 findValueTitle(measurements,break2);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
284 sLogger.debug("Neuer Datensatz "+seriesName+ "von Datens�tzen "+mStart+" / "+mEnd);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
285 xyDataset.addSeries(createXYSeries(seriesName,
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
286 resultSet, lUpperCut, lLowerCut, mStart, mEnd));
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
287 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
288 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
289 catch (Exception e){
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
290 sLogger.error(e.getMessage(), e);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
291 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
292 finally{
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
293 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
294 return xyDataset;
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
295 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
296
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
297
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
298
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
299 private void encodeChart(JFreeChart pChart, ChartStyle pStyle, OutputStream outputStream)
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
300 throws IOException {
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
301 if (sDebug)
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
302 sLogger.debug("encodeChart()");
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
303 KeypointPNGEncoderAdapter lEncoder = new KeypointPNGEncoderAdapter();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
304 lEncoder.setEncodingAlpha(true);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
305
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
306 int lWidth = (int) pStyle.getChartSize().getWidth();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
307 int lHeight = (int) pStyle.getChartSize().getHeight();
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
308
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
309 BufferedImage lImage = pChart.createBufferedImage(lWidth, lHeight,
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
310 BufferedImage.BITMASK, null);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
311
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
312 lEncoder.encode(lImage, outputStream);
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
313
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
314 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
315
110
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
316 private String findValueTitle(Collection<KeyValueDescibeData> values, String id){
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
317 if (values != null){
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
318 Iterator<KeyValueDescibeData> it = values.iterator();
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
319 while(it.hasNext()){
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
320 KeyValueDescibeData data = it.next();
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
321 if (id.equals(data.getKey())){
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
322 return data.getValue();
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
323 }
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
324 }
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
325 }
110
b465f1bbe368 Some Codeimprovments done
Tim Englich <tim.englich@intevation.de>
parents: 88
diff changeset
326 return id;
82
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
327 }
5eb62df21f9a Added Support for Vertical Profiles Marnet, STAUN, IMIS
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
328 }

http://dive4elements.wald.intevation.org