annotate artifacts/src/main/java/org/dive4elements/river/artifacts/services/FixingsKMChartService.java @ 5863:4897a58c8746

River artifacts: Added new copyright headers.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 14:40:59 +0200
parents 5aa05a7a34b7
children af13ceeba52a
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
9 package org.dive4elements.river.artifacts.services;
2615
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
11 import org.dive4elements.artifactdatabase.DefaultService;
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
12
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
13 import org.dive4elements.artifacts.CallMeta;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
14 import org.dive4elements.artifacts.GlobalContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
15 import org.dive4elements.artifacts.Service;
2615
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
16
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
17 import org.dive4elements.river.artifacts.model.FixingsColumn;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
18 import org.dive4elements.river.artifacts.model.FixingsColumnFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
19 import org.dive4elements.river.artifacts.model.FixingsFilterBuilder;
3173
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
20
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
21 import org.dive4elements.river.artifacts.model.FixingsOverview.Fixing;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
22
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
23 import org.dive4elements.river.artifacts.model.FixingsOverview;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
24 import org.dive4elements.river.artifacts.model.FixingsOverviewFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
25 import org.dive4elements.river.artifacts.model.GaugeFinder;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
26 import org.dive4elements.river.artifacts.model.GaugeFinderFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
27 import org.dive4elements.river.artifacts.model.GaugeRange;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
28
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
29 import org.dive4elements.river.artifacts.model.fixings.QWI;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
30
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
31 import org.dive4elements.river.artifacts.resources.Resources;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
32
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
33 import org.dive4elements.river.backend.SessionHolder;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
34
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
35 import org.dive4elements.river.jfree.ShapeRenderer;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
36
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
37 import org.dive4elements.river.utils.Formatter;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5373
diff changeset
38 import org.dive4elements.river.utils.Pair;
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
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
40 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
41 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
42 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
43 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
44
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
45 import java.awt.geom.Rectangle2D;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
46
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
47 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
48
cc0fa1798a3c 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 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
50 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
51
cc0fa1798a3c 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 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
53 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
54
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
55 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
56
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
57 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
58
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
59 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
60 import org.jfree.chart.JFreeChart;
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
61 import org.jfree.chart.LegendItemCollection;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
62
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
63 import org.jfree.chart.axis.NumberAxis;
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
64
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
65 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
66 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
67 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
68 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
69
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
70 import org.jfree.data.Range;
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
71
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
72 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
73 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
74
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
75 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
76 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
77 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
78
3571
64a59cca1887 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3174
diff changeset
79
64a59cca1887 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3174
diff changeset
80 /** Serve chart of Fixings at certain km. */
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
81 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
82 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
83 {
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
84 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
85 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
86
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
87 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
88 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
89
3170
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
90 public static final String [] I18N_Q_SECTOR_BOARDERS = {
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
91 "fix.km.chart.q.sector.border0",
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
92 "fix.km.chart.q.sector.border1",
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
93 "fix.km.chart.q.sector.border2"
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
94 };
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
95
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
96 public static final String [] DEFAULT_Q_SECTOR_BORDERS = {
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
97 "(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
98 "(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
99 "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
100 };
1edc17b0d79d FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
101
3170
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
102 public static final String I18N_CHART_LABEL_DATE =
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
103 "fix.km.chart.label.date";
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
104
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
105 public static final String DEFAULT_CHART_LABEL_DATE =
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
106 "yyyy/MM/dd";
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
107
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
108 public static final String I18N_CHART_TITLE =
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
109 "fix.km.chart.title";
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
110
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
111 public static final String DEFAULT_CHART_TITLE =
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
112 "Fixings {0} km {1,number,#.###}";
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
113
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
114 public static final String I18N_Q_AXIS =
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
115 "fix.km.chart.q.axis";
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
116
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
117 public static final String DEFAULT_Q_AXIS =
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
118 "Q [m\u00b3/s]";
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
119
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
120 public static final String I18N_W_AXIS =
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
121 "fix.km.chart.w.axis";
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
122
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
123 public static final String DEFAULT_W_AXIS =
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
124 "W [NN + m]";
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
125
3173
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
126 public static final String I18N_MEASURED =
3174
6bde7c90dc93 FixA: Fixed typo in I18N key
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3173
diff changeset
127 "fix.km.chart.measured";
3173
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
128
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
129 public static final String DEFAULT_MEASURED =
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
130 "measured";
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
131
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
132 public static final String I18N_INTERPOLATED =
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
133 "fix.km.chart.interpolated";
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
134
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
135 public static final String DEFAULT_INTERPOLATED =
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
136 "interpolated";
3170
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
137
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
138 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
139
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
140 // 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
141 public static final byte [] EMPTY = {
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2621
diff changeset
142 (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
143 (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
144 (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
145 (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
146 (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
147 (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
148 (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
149 (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
150 (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
151 (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
152 (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
153 (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
154 (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
155 (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
156 (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
157 (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
158 (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
159 (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
160 (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
161 (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
162 (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
163 (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
164 (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
165 (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
166 (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
167 (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
168 (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
169 (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
170 (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
171 (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
172 (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
173 (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
174 (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
175 (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
176 (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
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 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
180 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
181 }
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
182
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
183 @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
184 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
185 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
186 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
187 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
188 ) {
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
189 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
190
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
191 SessionHolder.acquire();
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
192 try {
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
193 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
194 }
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
195 finally {
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
196 SessionHolder.HOLDER.get().close();
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
197 SessionHolder.release();
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
198 }
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
199 }
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
200
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
201 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
202 Document input,
2615
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
203 GlobalContext globalContext,
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
204 CallMeta callMeta
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
205 ) {
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
206 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
207 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
208 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
209 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
210
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
211 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
212 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
213 return empty();
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
214 }
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
215
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
216 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
217
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
218 if (overview == null) {
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
219 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
220 return empty();
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
221 }
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
222
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 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
224
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
225 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
226 ffb.getRange(),
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
227 ffb.getFilter());
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
228
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 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
230 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
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 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
233 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
234 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
235 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
236 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
237 }
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
238 }
b0597a63fe70 More code for the fixings km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2614
diff changeset
239
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
240 JFreeChart chart = createChart(cols, river, km, callMeta);
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
241
cc0fa1798a3c 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 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
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
cc0fa1798a3c 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 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
246 JFreeChart chart,
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2621
diff changeset
247 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
248 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
249 ) {
cc0fa1798a3c 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 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
251 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
252 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
253 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 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
256
cc0fa1798a3c 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 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
258 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
259 }
cc0fa1798a3c 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 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
261 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
262 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
263 }
cc0fa1798a3c 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 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
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
cc0fa1798a3c 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 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
269 List<Pair<Fixing.Column, FixingsColumn>> cols,
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
270 String river,
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
271 double km,
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
272 CallMeta callMeta
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
273 ) {
3170
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
274 String labelFormat = Resources.getMsg(
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
275 callMeta, I18N_CHART_LABEL_DATE, DEFAULT_CHART_LABEL_DATE);
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
276
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
277 QWSeriesCollection.LabelGenerator lg =
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
278 new QWSeriesCollection.DateFormatLabelGenerator(labelFormat);
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
279
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
280 QWSeriesCollection dataset = new QWSeriesCollection(lg);
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
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 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
283 for (Pair<Fixing.Column, FixingsColumn> col: cols) {
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
284 boolean interpolated = !col.getB().getW(km, w);
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
285 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
286 if (!Double.isNaN(w[0]) && !Double.isNaN(q)) {
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3604
diff changeset
287 QWI qw = new QWI(
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
288 q, w[0],
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
289 col.getA().getDescription(),
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
290 col.getA().getStartTime(),
3604
2382b26079ac FixA: Store unique coulun index into QW models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3577
diff changeset
291 interpolated, 0);
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
292 dataset.add(qw);
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
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 }
cc0fa1798a3c 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
3170
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
296 String title = Resources.format(
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
297 callMeta, I18N_CHART_TITLE, DEFAULT_CHART_TITLE, river, km);
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
298
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
299 String qAxis = Resources.getMsg(
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
300 callMeta, I18N_Q_AXIS, DEFAULT_Q_AXIS);
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
301
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
302 String wAxis = Resources.getMsg(
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
303 callMeta, I18N_W_AXIS, DEFAULT_W_AXIS);
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
304
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
305 JFreeChart chart = ChartFactory.createXYLineChart(
3170
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
306 title,
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
307 qAxis,
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
308 wAxis,
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
309 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
310 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
311 true,
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
312 true,
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
313 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
314
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
315 XYPlot plot = (XYPlot)chart.getPlot();
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
316
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
317 NumberAxis qA = (NumberAxis)plot.getDomainAxis();
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
318 qA.setNumberFormatOverride(Formatter.getWaterlevelQ(callMeta));
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
319
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
320 NumberAxis wA = (NumberAxis)plot.getRangeAxis();
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
321 wA.setNumberFormatOverride(Formatter.getWaterlevelW(callMeta));
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
322
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
323 plot.setRenderer(0, dataset.createRenderer());
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
324 plot.setDataset(0, dataset);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
325
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
326 Rectangle2D area = dataset.getArea();
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
327
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
328 if (area != null) {
3166
591be3486087 FixA: Prevent that the plot becomes to small if only one point is drawn.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3164
diff changeset
329 double height = area.getHeight();
591be3486087 FixA: Prevent that the plot becomes to small if only one point is drawn.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3164
diff changeset
330 double wInset = Math.max(height, 0.01) * 0.25d;
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
331
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
332 wA.setAutoRangeIncludesZero(false);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
333 wA.setRange(new Range(
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
334 area.getMinY() - wInset,
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
335 area.getMaxY() + wInset));
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
336 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
337
3173
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
338 final String measuredS = Resources.getMsg(
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
339 callMeta, I18N_MEASURED, DEFAULT_MEASURED);
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
340
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
341 final String interpolatedS = Resources.getMsg(
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
342 callMeta, I18N_INTERPOLATED, DEFAULT_INTERPOLATED);
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
343
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
344 LegendItemCollection lic = plot.getLegendItems();
3173
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
345 dataset.addLegendItems(lic, new ShapeRenderer.LabelGenerator() {
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
346 @Override
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
347 public String createLabel(ShapeRenderer.Entry entry) {
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
348 return entry.getFilled() ? measuredS : interpolatedS;
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
349 }
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
350 });
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
351 plot.setFixedLegendItems(lic);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3152
diff changeset
352
3170
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
353 applyQSectorMarkers(plot, river, km, callMeta);
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
354
3164
6d0567a8387d Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3162
diff changeset
355 chart.setBackgroundPaint(Color.white);
6d0567a8387d Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3162
diff changeset
356 plot.setBackgroundPaint(Color.white);
6d0567a8387d Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3162
diff changeset
357 plot.setDomainGridlinePaint(Color.gray);
6d0567a8387d Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3162
diff changeset
358 plot.setRangeGridlinePaint(Color.gray);
6d0567a8387d Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3162
diff changeset
359 plot.setDomainGridlinesVisible(true);
6d0567a8387d Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3162
diff changeset
360 plot.setRangeGridlinesVisible(true);
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
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 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
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
3577
25cce741d03c Rudimentary Themeing for qsector lines.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3571
diff changeset
365 /** Add domain markers to plot that indicate Q-sectors. */
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
366 protected static void applyQSectorMarkers(
3170
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
367 XYPlot plot,
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
368 String river,
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
369 double km,
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
370 CallMeta meta
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
371 ) {
1edc17b0d79d FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
372 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
373 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
374
1edc17b0d79d FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
375 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
376 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
377 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
378 }
1edc17b0d79d FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
379
3152
368d1837ce5d Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3151
diff changeset
380 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
381 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
382 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
383 + 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
384 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
385 }
1edc17b0d79d FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
386
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
387 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
388 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
389 }
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
390
3170
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
391 for (int i = 0; i < I18N_Q_SECTOR_BOARDERS.length; ++i) {
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
392 String key = I18N_Q_SECTOR_BOARDERS[i];
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
393 String def = DEFAULT_Q_SECTOR_BORDERS[i];
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
394 String label = Resources.getMsg(meta, key, def);
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
395
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
396 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
397 gr.getSectorBorder(i),
3170
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
398 label);
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3166
diff changeset
399
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
400 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
401 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
402 }
1edc17b0d79d FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
403 }
1edc17b0d79d FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
404 }
1edc17b0d79d FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
405
5373
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3729
diff changeset
406 /** Create Marker at value with label. */
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3729
diff changeset
407 protected static Marker createQSectorMarker(
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3729
diff changeset
408 double value, String label
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3729
diff changeset
409 ) {
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
410 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
411 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
412 }
1edc17b0d79d FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
413 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
414 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
415 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
416 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
417 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
418 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
419 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
420 }
1edc17b0d79d FixA: Draw domain markers for borders of Q sectors in helper diagram.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
421
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
422 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
423 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
424
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
425 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
426 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
427 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
428
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
429 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
430
2621
f0cc556eda29 FixingsKMChartService.java: Small fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2620
diff changeset
431 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
432 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
433
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
434 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
435 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
436
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
437 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
438 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
439 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
440
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
441 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
442
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
443 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
444 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
445 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
446 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
447 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
448 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
449 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
450 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
451
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
452 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
453
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
454 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
455 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
456
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
457 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
458
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
459 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
460 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
461 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
462 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
463
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
464 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
465 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
466 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
467 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
468 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
469 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
470
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
471 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
472 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
473 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
474 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
475 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
476 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
477 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
478
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
479 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
480 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
481
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
482 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
483 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
484
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
485 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
486
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
487 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
488 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
489 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
490 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
491 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
492 }
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
493
cc0fa1798a3c FixingsKMChartService: Generate chart and deliver the image as the response of the service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2615
diff changeset
494 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
495 }
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
496 }
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
497 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org