Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java @ 3161:cd8d81b2824d
FixA: Re-added accidentially removed code.
flys-artifacts/trunk@4773 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 25 Jun 2012 07:59:22 +0000 |
parents | 368d1837ce5d |
children | 0d8146989012 |
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; |
3146
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
17 import de.intevation.flys.artifacts.model.GaugeFinder; |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
18 import de.intevation.flys.artifacts.model.GaugeFinderFactory; |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
19 import de.intevation.flys.artifacts.model.GaugeRange; |
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 |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
21 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
|
22 |
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
|
23 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
|
24 |
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 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
|
26 |
3146
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
27 import java.awt.BasicStroke; |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
28 import java.awt.Color; |
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
|
29 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
|
30 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
|
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.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
|
33 |
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 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
|
35 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
|
36 |
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
|
37 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
|
38 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
|
39 |
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 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
|
41 |
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
|
42 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
|
43 |
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
|
44 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
|
45 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
|
46 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
|
47 |
3146
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
48 import org.jfree.chart.plot.Marker; |
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
|
49 import org.jfree.chart.plot.PlotOrientation; |
3146
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
50 import org.jfree.chart.plot.ValueMarker; |
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
|
51 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
|
52 |
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
|
53 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
|
54 |
3146
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
55 import org.jfree.ui.RectangleAnchor; |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
56 import org.jfree.ui.TextAnchor; |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
57 |
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
|
58 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
|
59 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
|
60 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
|
61 |
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
|
62 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
|
63 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
|
64 { |
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 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
|
66 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
|
67 |
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
|
68 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
|
69 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
|
70 |
3146
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
71 // TODO: i18n |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
72 public static final String [] Q_SECTOR_LABELS = { |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
73 "(MNQ + MQ)/2", |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
74 "(MQ + MHQ)/2", |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
75 "HQ5" |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
76 }; |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
77 |
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
|
78 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
|
79 |
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
|
80 // 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
|
81 public static final byte [] EMPTY = { |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
82 (byte)0x89, (byte)0x50, (byte)0x4e, (byte)0x47, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
83 (byte)0x0d, (byte)0x0a, (byte)0x1a, (byte)0x0a, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
84 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0d, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
85 (byte)0x49, (byte)0x48, (byte)0x44, (byte)0x52, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
86 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
87 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
88 (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
89 (byte)0x00, (byte)0x3a, (byte)0x7e, (byte)0x9b, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
90 (byte)0x55, (byte)0x00, (byte)0x00, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
91 (byte)0x01, (byte)0x73, (byte)0x52, (byte)0x47, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
92 (byte)0x42, (byte)0x00, (byte)0xae, (byte)0xce, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
93 (byte)0x1c, (byte)0xe9, (byte)0x00, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
94 (byte)0x00, (byte)0x09, (byte)0x70, (byte)0x48, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
95 (byte)0x59, (byte)0x73, (byte)0x00, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
96 (byte)0x0b, (byte)0x13, (byte)0x00, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
97 (byte)0x0b, (byte)0x13, (byte)0x01, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
98 (byte)0x9a, (byte)0x9c, (byte)0x18, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
99 (byte)0x00, (byte)0x00, (byte)0x07, (byte)0x74, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
100 (byte)0x49, (byte)0x4d, (byte)0x45, (byte)0x07, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
101 (byte)0xdc, (byte)0x04, (byte)0x04, (byte)0x10, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
102 (byte)0x30, (byte)0x15, (byte)0x7d, (byte)0x77, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
103 (byte)0x36, (byte)0x0b, (byte)0x00, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
104 (byte)0x00, (byte)0x08, (byte)0x74, (byte)0x45, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
105 (byte)0x58, (byte)0x74, (byte)0x43, (byte)0x6f, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
106 (byte)0x6d, (byte)0x6d, (byte)0x65, (byte)0x6e, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
107 (byte)0x74, (byte)0x00, (byte)0xf6, (byte)0xcc, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
108 (byte)0x96, (byte)0xbf, (byte)0x00, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
109 (byte)0x00, (byte)0x0a, (byte)0x49, (byte)0x44, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
110 (byte)0x41, (byte)0x54, (byte)0x08, (byte)0xd7, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
111 (byte)0x63, (byte)0xf8, (byte)0x0f, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
112 (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
113 (byte)0x1b, (byte)0xb6, (byte)0xee, (byte)0x56, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
114 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
115 (byte)0x49, (byte)0x45, (byte)0x4e, (byte)0x44, |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
116 (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
|
117 }; |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
118 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
119 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
|
120 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
|
121 } |
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
|
122 |
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
|
123 @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
|
124 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
|
125 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
|
126 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
|
127 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
|
128 ) { |
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
|
129 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
|
130 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
131 SessionHolder.acquire(); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
132 try { |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
133 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
|
134 } |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
135 finally { |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
136 SessionHolder.HOLDER.get().close(); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
137 SessionHolder.release(); |
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 } |
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 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
|
142 Document input, |
2615
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
143 GlobalContext globalContext, |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
144 CallMeta callMeta |
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 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
|
147 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
|
148 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
|
149 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
|
150 |
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
|
151 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
|
152 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
|
153 return empty(); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
154 } |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
155 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
156 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
|
157 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
158 if (overview == null) { |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
159 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
|
160 return empty(); |
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 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
|
164 |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
165 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
|
166 ffb.getRange(), |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
167 ffb.getFilter()); |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
168 |
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
|
169 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
|
170 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
|
171 |
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 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
|
173 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
|
174 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
|
175 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
|
176 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
|
177 } |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
178 } |
b0597a63fe70
More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2614
diff
changeset
|
179 |
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
|
180 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
|
181 |
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 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
|
183 } |
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 |
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 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
|
186 JFreeChart chart, |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2621
diff
changeset
|
187 Dimension extent, |
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
|
188 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
|
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 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
|
191 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
|
192 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
|
193 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
|
194 |
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 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
|
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 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
|
198 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
|
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 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
|
201 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
|
202 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
|
203 } |
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 |
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 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
|
206 } |
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 |
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 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
|
209 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
|
210 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
|
211 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
|
212 ) { |
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 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
|
215 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
|
216 |
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 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
|
218 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
|
219 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
|
220 // 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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 // 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
|
226 } |
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 } |
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
|
228 |
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 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
|
230 |
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 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
|
232 "Fixierungen", // TODO: i18n |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
233 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
|
234 |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
235 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
|
236 "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
|
237 "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
|
238 "W", // TODO: i18n |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
239 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
|
240 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
|
241 true, |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
242 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
|
243 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
|
244 |
3146
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
245 applyQSectorMarkers(chart.getXYPlot(), river, km); |
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
|
246 |
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 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
|
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 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
|
250 } |
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 |
3146
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
252 protected static void applyQSectorMarkers( |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
253 XYPlot plot, |
3152
368d1837ce5d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3151
diff
changeset
|
254 String river, |
3146
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
255 double km |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
256 ) { |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
257 GaugeFinderFactory ggf = GaugeFinderFactory.getInstance(); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
258 GaugeFinder gf = ggf.getGaugeFinder(river); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
259 |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
260 if (gf == null) { |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
261 log.warn("No gauge finder found for river '" + river + "'"); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
262 return; |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
263 } |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
264 |
3152
368d1837ce5d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3151
diff
changeset
|
265 GaugeRange gr = gf.find(km); |
3146
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
266 if (gr == null) { |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
267 log.debug("No gauge range found for km " |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
268 + km + " on river " + river + "."); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
269 return; |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
270 } |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
271 |
3151
08230c76cd92
FixA: KM chart helper service: Added debug output when creating Q sector markers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3146
diff
changeset
|
272 if (log.isDebugEnabled()) { |
08230c76cd92
FixA: KM chart helper service: Added debug output when creating Q sector markers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3146
diff
changeset
|
273 log.debug(gr); |
08230c76cd92
FixA: KM chart helper service: Added debug output when creating Q sector markers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3146
diff
changeset
|
274 } |
08230c76cd92
FixA: KM chart helper service: Added debug output when creating Q sector markers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3146
diff
changeset
|
275 |
3146
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
276 for (int i = 0; i < Q_SECTOR_LABELS.length; ++i) { |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
277 Marker m = createQSectorMarker( |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
278 gr.getSectorBorder(i), |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
279 Q_SECTOR_LABELS[i]); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
280 if (m != null) { |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
281 plot.addDomainMarker(m); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
282 } |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
283 } |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
284 } |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
285 |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
286 protected static Marker createQSectorMarker(double value, String label) { |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
287 if (Double.isNaN(value)) { |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
288 return null; |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
289 } |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
290 Marker m = new ValueMarker(value); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
291 m.setPaint(Color.black); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
292 m.setStroke(new BasicStroke()); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
293 m.setLabel(label); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
294 m.setLabelAnchor(RectangleAnchor.TOP_LEFT); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
295 m.setLabelTextAnchor(TextAnchor.TOP_LEFT); |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
296 return m; |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
297 } |
1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
298 |
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
|
299 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
|
300 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
|
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 (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
|
303 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
|
304 } |
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 |
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 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
|
307 |
2621
f0cc556eda29
FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2620
diff
changeset
|
308 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
|
309 } |
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
|
310 |
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
|
311 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
|
312 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
|
313 |
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
|
314 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
|
315 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
|
316 } |
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
|
317 |
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
|
318 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
|
319 |
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
|
320 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
|
321 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
|
322 } |
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
|
323 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
|
324 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
|
325 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
|
326 } |
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
|
327 } |
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
|
328 |
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
|
329 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
|
330 |
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
|
331 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
|
332 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
|
333 |
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
|
334 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
|
335 |
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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 |
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
|
341 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
|
342 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
|
343 } |
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
|
344 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
|
345 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
|
346 } |
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
|
347 |
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
|
348 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
|
349 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
|
350 } |
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
|
351 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
|
352 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
|
353 } |
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
|
354 } |
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
|
355 |
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
|
356 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
|
357 } |
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
|
358 |
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
|
359 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
|
360 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
|
361 |
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
|
362 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
|
363 |
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
|
364 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
|
365 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
|
366 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
|
367 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
|
368 } |
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
|
369 } |
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
|
370 |
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
|
371 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
|
372 } |
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
|
373 } |
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
|
374 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |