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