Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java @ 6876:a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Tue, 20 Aug 2013 19:50:37 +0200 |
parents | af13ceeba52a |
children | 1b35b2ddfc28 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3317
diff
changeset
|
9 package org.dive4elements.river.jfree; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
3155
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
11 import java.util.List; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import org.apache.log4j.Logger; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import org.w3c.dom.Document; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
3155
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
17 import org.jfree.data.xy.XYDataItem; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import org.jfree.data.xy.XYSeries; |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 /** |
2321
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
21 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 */ |
2652
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
23 public class StyledXYSeries extends XYSeries implements StyledSeries, HasLabel { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 private static final Logger logger = Logger.getLogger(StyledXYSeries.class); |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
2321
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
27 protected Style style; |
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
28 |
2652
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
29 /** If this Series is to be labelled, use this String as label. */ |
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
30 protected String label; |
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
31 |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 public StyledXYSeries(String key, Document theme) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 this(key, true, theme); |
2652
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
35 this.label = key.toString(); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 } |
3160
8c78c707aa2d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3155
diff
changeset
|
37 |
8c78c707aa2d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3155
diff
changeset
|
38 |
3155
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
39 public StyledXYSeries(String key, Document theme, XYSeries unstyledSeries) { |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
40 this(key, theme); |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
41 add(unstyledSeries); |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
42 } |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 /** |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 * @param sorted whether or not to sort the points. Sorting will move NANs |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 * to one extrema which can cause problems in certain |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 * algorithms. |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 */ |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 public StyledXYSeries(String key, boolean sorted, Document theme) { |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 super(key, sorted); |
2321
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
52 setStyle(new XYStyle(theme)); |
2652
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
53 this.label = key.toString(); |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 |
6876
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
56 public StyledXYSeries( |
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
57 String key, |
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
58 boolean sorted, |
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
59 boolean allowDuplicateXValues, |
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
60 Document theme |
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
61 ) { |
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
62 super(key, sorted, allowDuplicateXValues); |
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
63 setStyle(new XYStyle(theme)); |
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
64 this.label = key.toString(); |
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
65 } |
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
66 |
a071f0a80883
FixA W/Q Diagram: Allow duplicate points. It should work but it doesn't. :-/
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
67 |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
2321
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
69 @Override |
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
70 public void setStyle(Style style) { |
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
71 this.style = style; |
2076
41037d51c8b6
Added support for pointsize in chart themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2074
diff
changeset
|
72 } |
41037d51c8b6
Added support for pointsize in chart themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2074
diff
changeset
|
73 |
41037d51c8b6
Added support for pointsize in chart themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2074
diff
changeset
|
74 |
2321
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
75 @Override |
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
76 public Style getStyle() { |
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
77 return style; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 } |
2652
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
79 |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2652
diff
changeset
|
80 |
2652
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
81 @Override |
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
82 public String getLabel() { |
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
83 return label; |
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
84 } |
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
85 |
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
86 @Override |
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
87 public void setLabel(String label) { |
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
88 this.label = label; |
9d2a06c3a134
Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2321
diff
changeset
|
89 } |
3160
8c78c707aa2d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3155
diff
changeset
|
90 |
3155
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
91 protected void add(XYSeries series) { |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
92 List<XYDataItem> items = series.getItems(); |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
93 add(items); |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
94 } |
3160
8c78c707aa2d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3155
diff
changeset
|
95 |
3155
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
96 protected void add(List<XYDataItem> items) { |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
97 for(XYDataItem item : items) { |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
98 add(item.getXValue(), item.getYValue()); |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
99 } |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
100 } |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |