annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/QWSeriesCollection.java @ 4917:c499201a30a3 dc-km-filter

[branch dc-km-filter] meta-data.xml: Use global vars and art. data for wst-km-filter.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 30 Jan 2013 15:54:07 +0100
parents e727e3ebdf85
children
rev   line source
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.services;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3403
diff changeset
3 import de.intevation.flys.artifacts.model.fixings.QWI;
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import de.intevation.flys.java2d.ShapeUtils;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import de.intevation.flys.jfree.ShapeRenderer;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 import java.awt.BasicStroke;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 import java.awt.Color;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import java.awt.Paint;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import java.awt.Shape;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 import java.awt.geom.Rectangle2D;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 import java.text.DateFormat;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 import java.text.SimpleDateFormat;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 import java.util.ArrayList;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 import java.util.Date;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 import java.util.HashMap;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 import java.util.List;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 import java.util.Map;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 import org.jfree.chart.LegendItem;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 import org.jfree.chart.LegendItemCollection;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 import org.jfree.chart.labels.XYItemLabelGenerator;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 import org.jfree.data.xy.XYDataset;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 import org.jfree.data.xy.XYSeries;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 import org.jfree.data.xy.XYSeriesCollection;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 public class QWSeriesCollection
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 extends XYSeriesCollection
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 implements XYItemLabelGenerator
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 public interface LabelGenerator {
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3403
diff changeset
41 String createLabel(QWI qw);
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 } // interface LabelGenerator
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 public static class DateFormatLabelGenerator
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 implements LabelGenerator
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 protected DateFormat format;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 public DateFormatLabelGenerator() {
3170
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3164
diff changeset
50 this("dd.MM.yyyy");
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3164
diff changeset
51 }
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3164
diff changeset
52
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3164
diff changeset
53 public DateFormatLabelGenerator(String format) {
79e7bba0f593 FixA: I18N for chart km service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3164
diff changeset
54 this(new SimpleDateFormat(format));
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 public DateFormatLabelGenerator(DateFormat format) {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 this.format = format;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 @Override
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3403
diff changeset
62 public String createLabel(QWI qw) {
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 Date date = qw.getDate();
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 return date != null ? format.format(date) : "";
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 } // class DateFormatLabelGenerator
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 public static final LabelGenerator SIMPLE_GENERATOR =
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 new DateFormatLabelGenerator();
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 protected Date minDate;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 protected Date maxDate;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3403
diff changeset
74 protected List<List<QWI>> labels;
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 protected Rectangle2D area;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 protected LabelGenerator labelGenerator;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 protected Map<ShapeRenderer.Entry, Integer> knownShapes =
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 new HashMap<ShapeRenderer.Entry, Integer>();
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 public QWSeriesCollection() {
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3403
diff changeset
84 labels = new ArrayList<List<QWI>>();
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 labelGenerator = SIMPLE_GENERATOR;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 public QWSeriesCollection(LabelGenerator labelGenerator) {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 this();
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 this.labelGenerator = labelGenerator;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3403
diff changeset
93 protected static ShapeRenderer.Entry classify(QWI qw) {
3164
6d0567a8387d Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3162
diff changeset
94 boolean interpolated = qw.getInterpolated();
6d0567a8387d Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3162
diff changeset
95
6d0567a8387d Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3162
diff changeset
96 Shape shape = interpolated
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 ? ShapeUtils.INTERPOLATED_SHAPE
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 : ShapeUtils.MEASURED_SHAPE;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99
3164
6d0567a8387d Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3162
diff changeset
100 boolean filled = !interpolated;
3403
04d090d06d3f FixA: KM chart service: Use only blue as point color.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3173
diff changeset
101 Color color = Color.blue;
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102
3164
6d0567a8387d Label more points in FixingsKMChartService
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3162
diff changeset
103 return new ShapeRenderer.Entry(shape, color, filled);
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3403
diff changeset
106 public void add(QWI qw) {
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 ShapeRenderer.Entry key = classify(qw);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 Integer seriesNo = knownShapes.get(key);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 XYSeries series;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114 if (seriesNo == null) {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115 seriesNo = Integer.valueOf(getSeriesCount());
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 knownShapes.put(key, seriesNo);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117 series = new XYSeries(seriesNo, false);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 addSeries(series);
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3403
diff changeset
119 labels.add(new ArrayList<QWI>());
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121 else {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 series = getSeries(seriesNo);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 series.add(qw.getQ(), qw.getW());
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 labels.get(seriesNo).add(qw);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 extendDateRange(qw);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 extendArea(qw);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3403
diff changeset
133 protected void extendDateRange(QWI qw) {
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134 Date date = qw.getDate();
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 if (date != null) {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 if (minDate == null) {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137 minDate = maxDate = date;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139 else {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 if (date.compareTo(minDate) < 0) {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141 minDate = date;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 if (date.compareTo(maxDate) > 0) {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 maxDate = date;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
146 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
147 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3403
diff changeset
150 protected void extendArea(QWI qw) {
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
151 if (area == null) {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
152 area = new Rectangle2D.Double(
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153 qw.getQ(), qw.getW(), 0d, 0d);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
154 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155 else {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156 area.add(qw.getQ(), qw.getW());
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
157 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
159
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160 public Rectangle2D getArea() {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
161 return area;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
162 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
163
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
164 public Date getMinDate() {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
165 return minDate;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
166 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
167
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
168 public Date getMaxDate() {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
169 return maxDate;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
170 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
171
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
172 public LabelGenerator getLabelGenerator() {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
173 return labelGenerator;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
174 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
175
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
176 @Override
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
177 public String generateLabel(XYDataset dataset, int series, int item) {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
178 return labelGenerator.createLabel(labels.get(series).get(item));
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
179 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
180
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
181 public StandardXYItemRenderer createRenderer() {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
182 StandardXYItemRenderer renderer = new ShapeRenderer(knownShapes);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
183 renderer.setBaseItemLabelGenerator(this);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
184 renderer.setBaseSeriesVisibleInLegend(false);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
185 renderer.setBaseItemLabelsVisible(true);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
186 return renderer;
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
187 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
188
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
189 public static final LegendItem legendItem(
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
190 String label,
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
191 Paint paint,
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
192 Shape shape,
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
193 boolean filled
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
194 ) {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
195 BasicStroke stroke = new BasicStroke();
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
196 return new LegendItem(
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
197 label, // label
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
198 null, // description
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
199 null, // tooltip
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
200 null, // url
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
201 true, // shape visible
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
202 shape, // shape
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
203 filled, // shape filled
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
204 filled ? paint : Color.white, // fill paint
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
205 true, // shape outline
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
206 paint, // outline paint
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
207 stroke, // outline stroke
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
208 false, // line visible
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
209 shape, // line
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
210 stroke, // line stroke
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
211 Color.white);
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
213
3173
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
214 public void addLegendItems(
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
215 LegendItemCollection lic,
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
216 ShapeRenderer.LabelGenerator lg
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
217 ) {
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
218 for (ShapeRenderer.Entry entry: knownShapes.keySet()) {
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
219 lic.add(legendItem(
3173
0cf647fe2a96 FixA: Finished I18N for km chart service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3170
diff changeset
220 lg.createLabel(entry),
3162
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
221 entry.getPaint(),
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
222 entry.getShape(),
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
223 entry.getFilled()));
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
224 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
225 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
226 }
0d8146989012 Added labeling for Q/W points FixingsKMChartService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
227 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org