Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/BedloadKMChartService.java @ 5421:420c553bc86d
Cosmetics, fix typo in i18n.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 26 Mar 2013 11:25:44 +0100 |
parents | 58bdf95df5e4 |
children |
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 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
|
40 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 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
|
42 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
|
43 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 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
|
45 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
|
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 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
|
48 "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
|
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 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
|
51 "Measuring Points"; |
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 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
|
54 "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
|
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 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
|
57 "Measuring points"; |
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 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
|
60 "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
|
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 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
|
63 "km"; |
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 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
|
66 "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
|
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 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
|
69 "Date"; |
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_FORMAT = "png"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 // 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
|
74 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
|
75 (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
|
76 (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
|
77 (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
|
78 (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
|
79 (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
|
80 (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
|
81 (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
|
82 (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
|
83 (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
|
84 (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
|
85 (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
|
86 (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
|
87 (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
|
88 (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
|
89 (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
|
90 (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
|
91 (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
|
92 (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
|
93 (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
|
94 (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
|
95 (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
|
96 (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
|
97 (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
|
98 (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
|
99 (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
|
100 (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
|
101 (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
|
102 (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
|
103 (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
|
104 (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
|
105 (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
|
106 (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
|
107 (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
|
108 (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
|
109 (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
|
110 }; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 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
|
113 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
|
114 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 @Override |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 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
|
118 Document data, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 GlobalContext globalContext, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 CallMeta callMeta |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 ) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 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
|
123 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 SedDBSessionHolder.acquire(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 try { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 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
|
127 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 finally { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 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
|
130 SedDBSessionHolder.release(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 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
|
135 Document input, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 GlobalContext globalContext, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 CallMeta callMeta |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 ) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 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
|
140 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
|
141 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
|
142 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 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
|
144 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
|
145 return empty(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
146 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 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
|
149 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 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
|
151 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
|
152 return empty(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 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
|
156 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 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
|
158 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 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
|
160 } |
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 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
|
163 JFreeChart chart, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
164 Dimension extent, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 String format |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 ) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 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
|
168 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
|
169 Transparency.BITMASK, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 null); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 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
|
173 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 try { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 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
|
176 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 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
|
178 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
|
179 return empty(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
180 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
181 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 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
|
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 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
|
186 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
|
187 String river, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
188 CallMeta callMeta |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
189 ) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
191 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
|
192 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
|
193 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
|
194 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 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
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
202 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
203 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
204 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
|
205 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
|
206 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
|
207 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
208 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
|
209 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
|
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 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
|
212 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
|
213 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
214 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
|
215 title, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
216 kmAxis, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
217 dateAxis, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
218 null, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
219 PlotOrientation.VERTICAL, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
220 true, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
221 true, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
222 false); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
223 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
224 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
|
225 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
226 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
|
227 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
|
228 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
|
229 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
238 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
|
239 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
|
240 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
|
241 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
|
242 return chart; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
243 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
244 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
245 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
246 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
|
247 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
|
248 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
249 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
|
250 return null; |
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 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
253 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
|
254 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
255 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
|
256 } |
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 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
|
259 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
260 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
|
261 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
|
262 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
263 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
|
264 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
265 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
|
266 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
|
267 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
|
268 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
|
269 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
270 try { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
271 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
|
272 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
273 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
|
274 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
|
275 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
276 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
277 try { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
278 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
|
279 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
280 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
|
281 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
|
282 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
283 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
284 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
285 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
|
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 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
|
289 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
|
290 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
291 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
|
292 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
293 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
|
294 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
|
295 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
|
296 format = type; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
297 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
298 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
299 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
300 return format; |
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 } |