annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/SQKMChartService.java @ 5282:14db045d6368

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

http://dive4elements.wald.intevation.org