Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java @ 6955:94cb1845c667
(issue1452) Coalesce to zero to avoid NaN arithmetic.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 30 Aug 2013 15:45:14 +0200 |
parents | 1b35b2ddfc28 |
children | d20a26e96ef1 |
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; |
6905
1b35b2ddfc28
Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6876
diff
changeset
|
14 import org.dive4elements.river.themes.ThemeDocument; |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
3155
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
16 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
|
17 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
|
18 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 /** |
2321
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
20 * @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
|
21 */ |
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
|
22 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
|
23 |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 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
|
25 |
2321
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
26 protected Style style; |
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
27 |
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
|
28 /** 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
|
29 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
|
30 |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
6905
1b35b2ddfc28
Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6876
diff
changeset
|
32 public StyledXYSeries(String key, ThemeDocument theme) { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 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
|
34 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
|
35 } |
3160
8c78c707aa2d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3155
diff
changeset
|
36 |
8c78c707aa2d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3155
diff
changeset
|
37 |
6905
1b35b2ddfc28
Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6876
diff
changeset
|
38 public StyledXYSeries(String key, ThemeDocument theme, XYSeries unstyledSeries) { |
3155
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
39 this(key, theme); |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
40 add(unstyledSeries); |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
41 } |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
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 * @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
|
46 * 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
|
47 * algorithms. |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 */ |
6905
1b35b2ddfc28
Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6876
diff
changeset
|
49 public StyledXYSeries(String key, boolean sorted, ThemeDocument theme) { |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 super(key, sorted); |
2321
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
51 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
|
52 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
|
53 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
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
|
55 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
|
56 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
|
57 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
|
58 boolean allowDuplicateXValues, |
6905
1b35b2ddfc28
Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6876
diff
changeset
|
59 ThemeDocument theme |
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
|
60 ) { |
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 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
|
62 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
|
63 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
|
64 } |
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 |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 |
2321
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
68 @Override |
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
69 public void setStyle(Style style) { |
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
70 this.style = style; |
2076
41037d51c8b6
Added support for pointsize in chart themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2074
diff
changeset
|
71 } |
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 |
2321
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
74 @Override |
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
75 public Style getStyle() { |
991e4a5df323
Enabled styling in timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2076
diff
changeset
|
76 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
|
77 } |
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
|
78 |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2652
diff
changeset
|
79 |
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
|
80 @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
|
81 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
|
82 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
|
83 } |
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 @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
|
86 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
|
87 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
|
88 } |
3160
8c78c707aa2d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3155
diff
changeset
|
89 |
3155
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
90 protected void add(XYSeries series) { |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
91 List<XYDataItem> items = series.getItems(); |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
92 add(items); |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
93 } |
3160
8c78c707aa2d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3155
diff
changeset
|
94 |
3155
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
95 protected void add(List<XYDataItem> items) { |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
96 for(XYDataItem item : items) { |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
97 add(item.getXValue(), item.getYValue()); |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
98 } |
74c974b10c75
Output code to trackdown the linecolor problem
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
99 } |
2074
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 } |
a026d005accd
Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |