Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java @ 2734:89731cb8c385
More debugging of discharge curve issue.
flys-artifacts/trunk@4467 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 22 May 2012 19:54:22 +0000 |
parents | f0cc556eda29 |
children | 5642a83420f2 |
rev | line source |
---|---|
2614
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.services; |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifactdatabase.DefaultService; |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.artifacts.CallMeta; |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.artifacts.GlobalContext; |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.Service; |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
9 import de.intevation.flys.artifacts.model.FixingsColumn; |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
10 import de.intevation.flys.artifacts.model.FixingsColumnFactory; |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
11 import de.intevation.flys.artifacts.model.FixingsFilterBuilder; |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
12 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
13 import de.intevation.flys.artifacts.model.FixingsOverview.Fixing; |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
14 |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
15 import de.intevation.flys.artifacts.model.FixingsOverview; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
16 import de.intevation.flys.artifacts.model.FixingsOverviewFactory; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
17 |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
18 import de.intevation.flys.backend.SessionHolder; |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
19 |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
20 import de.intevation.flys.utils.Pair; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
21 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
22 import gnu.trove.TDoubleArrayList; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
23 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
24 import java.awt.Dimension; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
25 import java.awt.Transparency; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
26 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
27 import java.awt.image.BufferedImage; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
28 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
29 import java.io.ByteArrayOutputStream; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
30 import java.io.IOException; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
31 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
32 import java.util.ArrayList; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
33 import java.util.List; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
34 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
35 import javax.imageio.ImageIO; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
36 |
2614
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 import org.apache.log4j.Logger; |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
39 import org.jfree.chart.ChartFactory; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
40 import org.jfree.chart.ChartUtilities; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
41 import org.jfree.chart.JFreeChart; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
42 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
43 import org.jfree.chart.plot.PlotOrientation; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
44 import org.jfree.chart.plot.XYPlot; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
45 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
46 import org.jfree.data.xy.DefaultXYDataset; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
47 |
2614
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 import org.w3c.dom.Document; |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
49 import org.w3c.dom.Element; |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
50 import org.w3c.dom.NodeList; |
2614
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 public class FixingsKMChartService |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 extends DefaultService |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 { |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 private static final Logger log = |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 Logger.getLogger(FixingsKMChartService.class); |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
58 public static final int DEFAULT_WIDTH = 240; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
59 public static final int DEFAULT_HEIGHT = 180; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
60 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
61 public static final String DEFAULT_FORMAT = "png"; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
62 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
63 // TODO: Load fancy image from resources. |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
64 public static final byte [] EMPTY = { |
2614
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 (byte)0x89, (byte)0x50, (byte)0x4e, (byte)0x47, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 (byte)0x0d, (byte)0x0a, (byte)0x1a, (byte)0x0a, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0d, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 (byte)0x49, (byte)0x48, (byte)0x44, (byte)0x52, |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
69 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
70 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
71 (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
72 (byte)0x00, (byte)0x3a, (byte)0x7e, (byte)0x9b, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
73 (byte)0x55, (byte)0x00, (byte)0x00, (byte)0x00, |
2614
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 (byte)0x01, (byte)0x73, (byte)0x52, (byte)0x47, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 (byte)0x42, (byte)0x00, (byte)0xae, (byte)0xce, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 (byte)0x1c, (byte)0xe9, (byte)0x00, (byte)0x00, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 (byte)0x00, (byte)0x09, (byte)0x70, (byte)0x48, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 (byte)0x59, (byte)0x73, (byte)0x00, (byte)0x00, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 (byte)0x0b, (byte)0x13, (byte)0x00, (byte)0x00, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 (byte)0x0b, (byte)0x13, (byte)0x01, (byte)0x00, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 (byte)0x9a, (byte)0x9c, (byte)0x18, (byte)0x00, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 (byte)0x00, (byte)0x00, (byte)0x07, (byte)0x74, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 (byte)0x49, (byte)0x4d, (byte)0x45, (byte)0x07, |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
84 (byte)0xdc, (byte)0x04, (byte)0x04, (byte)0x10, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
85 (byte)0x30, (byte)0x15, (byte)0x7d, (byte)0x77, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
86 (byte)0x36, (byte)0x0b, (byte)0x00, (byte)0x00, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
87 (byte)0x00, (byte)0x08, (byte)0x74, (byte)0x45, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
88 (byte)0x58, (byte)0x74, (byte)0x43, (byte)0x6f, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
89 (byte)0x6d, (byte)0x6d, (byte)0x65, (byte)0x6e, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
90 (byte)0x74, (byte)0x00, (byte)0xf6, (byte)0xcc, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
91 (byte)0x96, (byte)0xbf, (byte)0x00, (byte)0x00, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
92 (byte)0x00, (byte)0x0a, (byte)0x49, (byte)0x44, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
93 (byte)0x41, (byte)0x54, (byte)0x08, (byte)0xd7, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
94 (byte)0x63, (byte)0xf8, (byte)0x0f, (byte)0x00, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
95 (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x00, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
96 (byte)0x1b, (byte)0xb6, (byte)0xee, (byte)0x56, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
97 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
98 (byte)0x49, (byte)0x45, (byte)0x4e, (byte)0x44, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
99 (byte)0xae, (byte)0x42, (byte)0x60, (byte)0x82 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
100 }; |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
101 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
102 private static final Output empty() { |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
103 return new Output(EMPTY, "image/png"); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
104 } |
2614
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 @Override |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 public Service.Output process( |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 Document data, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 GlobalContext globalContext, |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 CallMeta callMeta |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 ) { |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 log.debug("FixingsKMChartService.process"); |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
113 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
114 SessionHolder.acquire(); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
115 try { |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
116 return doProcess(data, globalContext, callMeta); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
117 } |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
118 finally { |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
119 SessionHolder.HOLDER.get().close(); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
120 SessionHolder.release(); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
121 } |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
122 } |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
123 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
124 protected Service.Output doProcess( |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
125 Document input, |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
126 GlobalContext globalContext, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
127 CallMeta callMeta |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
128 ) { |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
129 String river = getRiverName(input); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
130 Double km = getKM(input); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
131 Dimension extent = getExtent(input); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
132 String format = getFormat(input); |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
133 |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
134 if (river == null || km == null) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
135 log.warn("River and/or km invalid."); |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
136 return empty(); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
137 } |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
138 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
139 FixingsOverview overview = FixingsOverviewFactory.getOverview(river); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
140 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
141 if (overview == null) { |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
142 log.warn("No overview found for river '" + river + "'"); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
143 return empty(); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
144 } |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
145 |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
146 FixingsFilterBuilder ffb = new FixingsFilterBuilder(input); |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
147 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
148 List<Fixing.Column> columns = overview.filter( |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
149 ffb.getRange(), |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
150 ffb.getFilter()); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
151 |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
152 List<Pair<Fixing.Column, FixingsColumn>> cols = |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
153 new ArrayList<Pair<Fixing.Column, FixingsColumn>>(); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
154 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
155 for (Fixing.Column col: columns) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
156 FixingsColumn data = |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
157 FixingsColumnFactory.INSTANCE.getColumnData(col); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
158 if (data != null) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
159 cols.add(new Pair<Fixing.Column, FixingsColumn>(col, data)); |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
160 } |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
161 } |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
162 |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
163 JFreeChart chart = createChart(cols, river, km); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
164 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
165 return encode(chart, extent, format); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
166 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
167 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
168 protected static Output encode( |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
169 JFreeChart chart, |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
170 Dimension extent, |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
171 String format |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
172 ) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
173 BufferedImage image = chart.createBufferedImage( |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
174 extent.width, extent.height, |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
175 Transparency.BITMASK, |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
176 null); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
177 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
178 ByteArrayOutputStream out = new ByteArrayOutputStream(); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
179 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
180 try { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
181 ImageIO.write(image, format, out); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
182 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
183 catch (IOException ioe) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
184 log.warn("writing image failed", ioe); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
185 return empty(); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
186 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
187 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
188 return new Output(out.toByteArray(), "image/" + format); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
189 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
190 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
191 protected static JFreeChart createChart( |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
192 List<Pair<Fixing.Column, FixingsColumn>> cols, |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
193 String river, |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
194 double km |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
195 ) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
196 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
197 TDoubleArrayList ws = new TDoubleArrayList(cols.size()); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
198 TDoubleArrayList qs = new TDoubleArrayList(cols.size()); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
199 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
200 double [] w = new double[1]; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
201 for (Pair<Fixing.Column, FixingsColumn> col: cols) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
202 boolean interpolated = col.getB().getW(km, w); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
203 // TODO: Do something special with the interpolated values. |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
204 double q = col.getB().getQ(km); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
205 if (!Double.isNaN(w[0]) && !Double.isNaN(q)) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
206 ws.add(w[0]); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
207 qs.add(q); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
208 // TODO: Generate labels depending on sectors. |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
209 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
210 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
211 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
212 DefaultXYDataset dataset = new DefaultXYDataset(); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
213 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
214 dataset.addSeries( |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
215 "Fixierungen", // TODO: i18n |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
216 new double [][] { qs.toNativeArray(), ws.toNativeArray() }); |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
217 |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
218 JFreeChart chart = ChartFactory.createScatterPlot( |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
219 "Fixierungen " + river + ": km " + km, // TODO: i18n |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
220 "Q", // TODO: i18n |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
221 "W", // TODO: i18n |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
222 dataset, |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
223 PlotOrientation.VERTICAL, |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
224 true, |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
225 false, |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
226 false); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
227 |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
228 //XYPlot plot = chart.getXYPlot(); |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
229 |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
230 //plot.setDataset(dataset); |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
231 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
232 ChartUtilities.applyCurrentTheme(chart); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
233 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
234 return chart; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
235 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
236 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
237 protected static String getRiverName(Document input) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
238 NodeList rivers = input.getElementsByTagName("river"); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
239 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
240 if (rivers.getLength() == 0) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
241 return null; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
242 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
243 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
244 String river = ((Element)rivers.item(0)).getAttribute("name"); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
245 |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
246 return river.length() > 0 ? river : null; |
2620
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
247 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
248 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
249 protected static Double getKM(Document input) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
250 NodeList kms = input.getElementsByTagName("km"); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
251 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
252 if (kms.getLength() == 0) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
253 return null; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
254 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
255 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
256 String km = ((Element)kms.item(0)).getAttribute("value"); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
257 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
258 try { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
259 return Double.valueOf(km); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
260 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
261 catch (NumberFormatException nfe) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
262 log.warn("Km '" + km + " is not a valid number."); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
263 return null; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
264 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
265 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
266 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
267 protected static Dimension getExtent(Document input) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
268 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
269 int width = DEFAULT_WIDTH; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
270 int height = DEFAULT_HEIGHT; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
271 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
272 NodeList extents = input.getElementsByTagName("extent"); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
273 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
274 if (extents.getLength() > 0) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
275 Element element = (Element)extents.item(0); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
276 String w = element.getAttribute("width"); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
277 String h = element.getAttribute("height"); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
278 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
279 try { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
280 width = Math.max(1, Integer.parseInt(w)); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
281 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
282 catch (NumberFormatException nfe) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
283 log.warn("width '" + w + "' is not a valid."); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
284 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
285 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
286 try { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
287 height = Math.max(1, Integer.parseInt(h)); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
288 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
289 catch (NumberFormatException nfe) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
290 log.warn("height '" + h + "' is not a valid"); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
291 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
292 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
293 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
294 return new Dimension(width, height); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
295 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
296 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
297 protected static String getFormat(Document input) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
298 String format = DEFAULT_FORMAT; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
299 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
300 NodeList formats = input.getElementsByTagName("format"); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
301 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
302 if (formats.getLength() > 0) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
303 String type = ((Element)formats.item(0)).getAttribute("type"); |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
304 if (type.length() > 0) { |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
305 format = type; |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
306 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
307 } |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
308 |
cc0fa1798a3c
FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2615
diff
changeset
|
309 return format; |
2614
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
310 } |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
311 } |
036e234c2385
Added service to generate a chart of fixings for given river and km applied
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
312 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |