Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledXYSeries.java @ 3468:f37e7e8907cb
merged flys-artifacts/2.8.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:39 +0200 |
parents | 0f7abd95c6e2 |
children |
comparison
equal
deleted
inserted
replaced
3387:5ffad8bde8ad | 3468:f37e7e8907cb |
---|---|
1 package de.intevation.flys.jfree; | |
2 | |
3 import java.util.List; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import org.w3c.dom.Document; | |
8 | |
9 import org.jfree.data.xy.XYDataItem; | |
10 import org.jfree.data.xy.XYSeries; | |
11 | |
12 /** | |
13 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
14 */ | |
15 public class StyledXYSeries extends XYSeries implements StyledSeries, HasLabel { | |
16 | |
17 private static final Logger logger = Logger.getLogger(StyledXYSeries.class); | |
18 | |
19 protected Style style; | |
20 | |
21 /** If this Series is to be labelled, use this String as label. */ | |
22 protected String label; | |
23 | |
24 | |
25 public StyledXYSeries(String key, Document theme) { | |
26 this(key, true, theme); | |
27 this.label = key.toString(); | |
28 } | |
29 | |
30 | |
31 public StyledXYSeries(String key, Document theme, XYSeries unstyledSeries) { | |
32 this(key, theme); | |
33 add(unstyledSeries); | |
34 } | |
35 | |
36 | |
37 /** | |
38 * @param sorted whether or not to sort the points. Sorting will move NANs | |
39 * to one extrema which can cause problems in certain | |
40 * algorithms. | |
41 */ | |
42 public StyledXYSeries(String key, boolean sorted, Document theme) { | |
43 super(key, sorted); | |
44 setStyle(new XYStyle(theme)); | |
45 this.label = key.toString(); | |
46 } | |
47 | |
48 | |
49 @Override | |
50 public void setStyle(Style style) { | |
51 this.style = style; | |
52 } | |
53 | |
54 | |
55 @Override | |
56 public Style getStyle() { | |
57 return style; | |
58 } | |
59 | |
60 | |
61 @Override | |
62 public String getLabel() { | |
63 return label; | |
64 } | |
65 | |
66 @Override | |
67 public void setLabel(String label) { | |
68 this.label = label; | |
69 } | |
70 | |
71 protected void add(XYSeries series) { | |
72 List<XYDataItem> items = series.getItems(); | |
73 add(items); | |
74 } | |
75 | |
76 protected void add(List<XYDataItem> items) { | |
77 for(XYDataItem item : items) { | |
78 add(item.getXValue(), item.getYValue()); | |
79 } | |
80 } | |
81 } | |
82 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |