Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/BedloadKMChartService.java @ 4031:e4e345d81a65
issue889/2
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 04 Oct 2012 14:54:44 +0200 |
parents | 854666f70a80 |
children | 58bdf95df5e4 |
rev | line source |
---|---|
3751
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.services; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import java.awt.Color; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 import java.awt.Dimension; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 import java.awt.Transparency; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import java.awt.image.BufferedImage; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 import java.io.ByteArrayOutputStream; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import java.io.IOException; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import java.util.Date; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import java.util.List; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 import javax.imageio.ImageIO; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 import org.apache.log4j.Logger; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import org.jfree.chart.ChartFactory; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 import org.jfree.chart.JFreeChart; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 import org.jfree.chart.axis.DateAxis; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 import org.jfree.chart.plot.PlotOrientation; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 import org.jfree.chart.plot.XYPlot; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 import org.jfree.data.xy.XYSeries; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 import org.jfree.data.xy.XYSeriesCollection; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 import org.w3c.dom.Document; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 import org.w3c.dom.Element; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 import org.w3c.dom.NodeList; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 import de.intevation.artifactdatabase.DefaultService; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 import de.intevation.artifacts.CallMeta; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 import de.intevation.artifacts.GlobalContext; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 import de.intevation.artifacts.Service; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 import de.intevation.flys.artifacts.model.minfo.BedloadOverview; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 import de.intevation.flys.artifacts.model.minfo.BedloadOverviewFactory; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 import de.intevation.flys.artifacts.resources.Resources; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 import de.intevation.flys.backend.SedDBSessionHolder; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 import de.intevation.flys.utils.KMIndex; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 public class BedloadKMChartService extends DefaultService { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 /** |
3752
854666f70a80
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3751
diff
changeset
|
40 * |
3751
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 */ |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 private static final long serialVersionUID = 4156704841305086495L; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 private static final Logger log = |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 Logger.getLogger(BedloadKMChartService.class); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 public static final int DEFAULT_WIDTH = 240; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 public static final int DEFAULT_HEIGHT = 180; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 public static final String I18N_CHART_LABEL = |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 "bedload.km.chart.label"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 public static final String DEFAULT_CHART_LABEL = |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 "Measuring Points"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 public static final String I18N_CHART_TITLE = |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 "bedload.km.chart.title"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 public static final String DEFAULT_CHART_TITLE = |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 "Measuring points"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 public static final String I18N_KM_AXIS = |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 "bedload.km.chart.km.axis"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 public static final String DEFAULT_KM_AXIS = |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 "km"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 public static final String I18N_DATE_AXIS = |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 "bedload.km.chart.date.axis"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 public static final String DEFAULT_DATE_AXIS = |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 "Date"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 public static final String DEFAULT_FORMAT = "png"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 // TODO: Load fancy image from resources. |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 public static final byte [] EMPTY = { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 (byte)0x89, (byte)0x50, (byte)0x4e, (byte)0x47, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 (byte)0x0d, (byte)0x0a, (byte)0x1a, (byte)0x0a, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0d, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 (byte)0x49, (byte)0x48, (byte)0x44, (byte)0x52, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 (byte)0x00, (byte)0x3a, (byte)0x7e, (byte)0x9b, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 (byte)0x55, (byte)0x00, (byte)0x00, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 (byte)0x01, (byte)0x73, (byte)0x52, (byte)0x47, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 (byte)0x42, (byte)0x00, (byte)0xae, (byte)0xce, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 (byte)0x1c, (byte)0xe9, (byte)0x00, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 (byte)0x00, (byte)0x09, (byte)0x70, (byte)0x48, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 (byte)0x59, (byte)0x73, (byte)0x00, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 (byte)0x0b, (byte)0x13, (byte)0x00, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 (byte)0x0b, (byte)0x13, (byte)0x01, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 (byte)0x9a, (byte)0x9c, (byte)0x18, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 (byte)0x00, (byte)0x00, (byte)0x07, (byte)0x74, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 (byte)0x49, (byte)0x4d, (byte)0x45, (byte)0x07, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 (byte)0xdc, (byte)0x04, (byte)0x04, (byte)0x10, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 (byte)0x30, (byte)0x15, (byte)0x7d, (byte)0x77, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 (byte)0x36, (byte)0x0b, (byte)0x00, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 (byte)0x00, (byte)0x08, (byte)0x74, (byte)0x45, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 (byte)0x58, (byte)0x74, (byte)0x43, (byte)0x6f, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 (byte)0x6d, (byte)0x6d, (byte)0x65, (byte)0x6e, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 (byte)0x74, (byte)0x00, (byte)0xf6, (byte)0xcc, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 (byte)0x96, (byte)0xbf, (byte)0x00, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 (byte)0x00, (byte)0x0a, (byte)0x49, (byte)0x44, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 (byte)0x41, (byte)0x54, (byte)0x08, (byte)0xd7, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 (byte)0x63, (byte)0xf8, (byte)0x0f, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 (byte)0x1b, (byte)0xb6, (byte)0xee, (byte)0x56, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 (byte)0x49, (byte)0x45, (byte)0x4e, (byte)0x44, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 (byte)0xae, (byte)0x42, (byte)0x60, (byte)0x82 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 }; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 private static final Output empty() { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 return new Output(EMPTY, "image/png"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 @Override |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 public Service.Output process( |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 Document data, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 GlobalContext globalContext, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
123 CallMeta callMeta |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 ) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 log.debug("SQKMChartService.process"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 SedDBSessionHolder.acquire(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 try { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 return doProcess(data, globalContext, callMeta); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 finally { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 SedDBSessionHolder.HOLDER.get().close(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 SedDBSessionHolder.release(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 protected Service.Output doProcess( |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 Document input, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 GlobalContext globalContext, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 CallMeta callMeta |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 ) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 String river = getRiverName(input); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 Dimension extent = getExtent(input); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
144 String format = getFormat(input); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
145 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
146 if (river == null) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 log.warn("River invalid."); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 return empty(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 BedloadOverview overview = BedloadOverviewFactory.getOverview(river); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 if (overview == null) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 log.warn("No overview found for river '" + river + "'"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 return empty(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 KMIndex<List<Date>> entries = overview.filter(BedloadOverview.ACCEPT); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 JFreeChart chart = createChart(entries, river, callMeta); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 return encode(chart, extent, format); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
163 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
164 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 protected static Output encode( |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 JFreeChart chart, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 Dimension extent, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 String format |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 ) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 BufferedImage image = chart.createBufferedImage( |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 extent.width, extent.height, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 Transparency.BITMASK, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
173 null); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 ByteArrayOutputStream out = new ByteArrayOutputStream(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 try { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 ImageIO.write(image, format, out); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
179 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
180 catch (IOException ioe) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
181 log.warn("writing image failed", ioe); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 return empty(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
183 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
184 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
185 return new Output(out.toByteArray(), "image/" + format); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
186 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
187 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
188 protected static JFreeChart createChart( |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
189 KMIndex<List<Date>> entries, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 String river, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
191 CallMeta callMeta |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
192 ) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 XYSeriesCollection dataset = new XYSeriesCollection(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 String key = Resources.format( |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
196 callMeta, I18N_CHART_LABEL, DEFAULT_CHART_LABEL, river); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
197 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 XYSeries series = new XYSeries(key); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
199 for (KMIndex.Entry<List<Date>> e: entries) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 double km = e.getKm(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 List<Date> ds = e.getValue(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
202 for (Date d: ds) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
203 series.add(km, d.getTime()); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
204 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
205 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
206 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
207 dataset.addSeries(series); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
208 String title = Resources.format( |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
209 callMeta, I18N_CHART_TITLE, DEFAULT_CHART_TITLE, river); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
210 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
211 String kmAxis = Resources.getMsg( |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
212 callMeta, I18N_KM_AXIS, DEFAULT_KM_AXIS); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
213 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
214 String dateAxis = Resources.getMsg( |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
215 callMeta, I18N_DATE_AXIS, DEFAULT_DATE_AXIS); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
216 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
217 JFreeChart chart = ChartFactory.createXYLineChart( |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
218 title, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
219 kmAxis, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
220 dateAxis, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
221 null, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
222 PlotOrientation.VERTICAL, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
223 true, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
224 true, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
225 false); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
226 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
227 XYPlot plot = (XYPlot)chart.getPlot(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
228 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
229 DateAxis dA = new DateAxis(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
230 plot.setRangeAxis(dA); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
231 plot.setDataset(0, dataset); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
232 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
233 chart.setBackgroundPaint(Color.white); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
234 plot.setBackgroundPaint(Color.white); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
235 plot.setDomainGridlinePaint(Color.gray); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
236 plot.setRangeGridlinePaint(Color.gray); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
237 plot.setDomainGridlinesVisible(true); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
238 plot.setRangeGridlinesVisible(true); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
239 XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
240 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
241 renderer.setSeriesPaint(0, Color.gray); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
242 renderer.setSeriesLinesVisible(0, false); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
243 renderer.setSeriesShapesVisible(0, true); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
244 renderer.setDrawOutlines(true); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
245 return chart; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
246 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
247 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
248 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
249 protected static String getRiverName(Document input) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
250 NodeList rivers = input.getElementsByTagName("river"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
251 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
252 if (rivers.getLength() == 0) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
253 return null; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
254 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
255 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
256 String river = ((Element)rivers.item(0)).getAttribute("name"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
257 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
258 return river.length() > 0 ? river : null; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
259 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
260 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
261 protected static Dimension getExtent(Document input) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
262 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
263 int width = DEFAULT_WIDTH; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
264 int height = DEFAULT_HEIGHT; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
265 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
266 NodeList extents = input.getElementsByTagName("extent"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
267 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
268 if (extents.getLength() > 0) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
269 Element element = (Element)extents.item(0); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
270 String w = element.getAttribute("width"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
271 String h = element.getAttribute("height"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
272 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
273 try { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
274 width = Math.max(1, Integer.parseInt(w)); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
275 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
276 catch (NumberFormatException nfe) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
277 log.warn("width '" + w + "' is not a valid."); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
278 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
279 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
280 try { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
281 height = Math.max(1, Integer.parseInt(h)); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
282 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
283 catch (NumberFormatException nfe) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
284 log.warn("height '" + h + "' is not a valid"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
285 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
286 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
287 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
288 return new Dimension(width, height); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
289 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
290 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
291 protected static String getFormat(Document input) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
292 String format = DEFAULT_FORMAT; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
293 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
294 NodeList formats = input.getElementsByTagName("format"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
295 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
296 if (formats.getLength() > 0) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
297 String type = ((Element)formats.item(0)).getAttribute("type"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
298 if (type.length() > 0) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
299 format = type; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
300 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
301 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
302 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
303 return format; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
304 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
305 } |