Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/StyledXYSeries.java @ 1771:c62ff9e72cea
Restore mapping of state id to facets (revert, rev 3083 and 3088).
flys-artifacts/trunk@3092 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 27 Oct 2011 09:32:05 +0000 |
parents | 8e6615ad60b8 |
children | a9b690d864a7 |
rev | line source |
---|---|
924
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.exports; |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.awt.BasicStroke; |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.awt.Color; |
1753
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
5 import java.awt.geom.Ellipse2D; |
924
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import org.apache.log4j.Logger; |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Document; |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import org.jfree.data.xy.XYSeries; |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
1753
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
14 import de.intevation.flys.utils.ThemeUtil; |
924
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 public class StyledXYSeries extends XYSeries { |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 protected Document theme; |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 private static final Logger logger = Logger.getLogger(StyledXYSeries.class); |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
1741
1bc926b5b435
Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1714
diff
changeset
|
25 public StyledXYSeries(String key, Document theme) { |
1bc926b5b435
Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1714
diff
changeset
|
26 this(key, true, theme); |
1bc926b5b435
Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1714
diff
changeset
|
27 } |
924
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
1741
1bc926b5b435
Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1714
diff
changeset
|
29 public StyledXYSeries(String key, boolean sorted, Document theme) { |
1bc926b5b435
Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1714
diff
changeset
|
30 super(key, sorted); |
924
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 this.theme = theme; |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 } |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 public XYLineAndShapeRenderer applyTheme(XYLineAndShapeRenderer r, int idx){ |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 applyLineColor(r, idx); |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 applyLineSize(r, idx); |
1714
004b1b0838d6
Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
924
diff
changeset
|
38 applyLineType(r, idx); |
1753
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
39 applyShowLine(r, idx); |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
40 applyShowPoints(r, idx); |
924
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 return r; |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 } |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 protected void applyLineColor(XYLineAndShapeRenderer r, int idx) { |
1753
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
47 Color c = ThemeUtil.parseLineColorField(theme); |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
48 r.setSeriesPaint(idx, c); |
924
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 } |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 protected void applyLineSize(XYLineAndShapeRenderer r, int idx) { |
1753
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
53 int size = ThemeUtil.parseLineWidth(theme); |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
54 r.setSeriesStroke( |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
55 idx, |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
56 new BasicStroke(Integer.valueOf(size))); |
924
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 } |
1714
004b1b0838d6
Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
924
diff
changeset
|
58 |
004b1b0838d6
Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
924
diff
changeset
|
59 |
004b1b0838d6
Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
924
diff
changeset
|
60 protected void applyLineType(XYLineAndShapeRenderer r, int idx) { |
1753
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
61 int size = ThemeUtil.parseLineWidth(theme); |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
62 float[] dashes = ThemeUtil.parseLineStyle(theme); |
1714
004b1b0838d6
Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
924
diff
changeset
|
63 |
1753
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
64 // Do not apply the dashed style. |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
65 if (dashes.length <= 1) { |
1714
004b1b0838d6
Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
924
diff
changeset
|
66 return; |
004b1b0838d6
Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
924
diff
changeset
|
67 } |
004b1b0838d6
Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
924
diff
changeset
|
68 |
1753
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
69 r.setSeriesStroke( |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
70 idx, |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
71 new BasicStroke(Integer.valueOf(size), |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
72 BasicStroke.CAP_BUTT, |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
73 BasicStroke.JOIN_ROUND, |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
74 1.0f, |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
75 dashes, |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
76 0.0f)); |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
77 } |
1714
004b1b0838d6
Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
924
diff
changeset
|
78 |
1753
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
79 |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
80 protected void applyShowPoints(XYLineAndShapeRenderer r, int idx) { |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
81 boolean show = ThemeUtil.parseShowPoints(theme); |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
82 r.setSeriesShape(idx, new Ellipse2D.Double(-2.0, -2.0, 4.0, 4.0)); |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
83 r.setSeriesShapesVisible(idx, show); |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
84 r.setDrawOutlines(true); |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
85 } |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
86 |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
87 |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
88 protected void applyShowLine(XYLineAndShapeRenderer r, int idx) { |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
89 boolean show = ThemeUtil.parseShowLine(theme); |
741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1741
diff
changeset
|
90 r.setSeriesLinesVisible(idx, show); |
1714
004b1b0838d6
Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
924
diff
changeset
|
91 } |
924
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 } |
f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |