annotate flys-artifacts/src/main/java/de/intevation/flys/exports/StyledXYSeries.java @ 1881:0e9c0b49b4ef

CrossSectionApp: draw ground with StableXYDifferenceRenderer flys-artifacts/trunk@3240 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 12 Nov 2011 12:05:37 +0000
parents a9b690d864a7
children 6c24ffe946a5
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
1814
a9b690d864a7 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
16 /**
a9b690d864a7 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
17 * Dataset in two dimensions with additional theme-document.
a9b690d864a7 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
18 * The theme-document will later "style" the graphical representation.
a9b690d864a7 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
19 */
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
20 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
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 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
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 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
25
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
26
1741
1bc926b5b435 Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1714
diff changeset
27 public StyledXYSeries(String key, Document theme) {
1bc926b5b435 Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1714
diff changeset
28 this(key, true, theme);
1bc926b5b435 Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1714
diff changeset
29 }
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
30
1814
a9b690d864a7 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
31
a9b690d864a7 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
32 /**
a9b690d864a7 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
33 * @param sorted whether or not to sort the points. Sorting will move NANs
a9b690d864a7 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
34 * to one extrema which can cause problems in certain
a9b690d864a7 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
35 * algorithms.
a9b690d864a7 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
36 */
1741
1bc926b5b435 Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1714
diff changeset
37 public StyledXYSeries(String key, boolean sorted, Document theme) {
1bc926b5b435 Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1714
diff changeset
38 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
39 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
40 }
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
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 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
44 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
45 applyLineSize(r, idx);
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
46 applyLineType(r, idx);
1753
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
47 applyShowLine(r, idx);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
48 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
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 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
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
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
53
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
54 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
55 Color c = ThemeUtil.parseLineColorField(theme);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
56 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
57 }
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
58
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
59
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
60 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
61 int size = ThemeUtil.parseLineWidth(theme);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
62 r.setSeriesStroke(
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
63 idx,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
64 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
65 }
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
66
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 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
69 int size = ThemeUtil.parseLineWidth(theme);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
70 float[] dashes = ThemeUtil.parseLineStyle(theme);
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
71
1753
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
72 // Do not apply the dashed style.
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
73 if (dashes.length <= 1) {
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
74 return;
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
75 }
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
76
1753
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
77 r.setSeriesStroke(
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
78 idx,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
79 new BasicStroke(Integer.valueOf(size),
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
80 BasicStroke.CAP_BUTT,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
81 BasicStroke.JOIN_ROUND,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
82 1.0f,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
83 dashes,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
84 0.0f));
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
85 }
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
86
1753
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 applyShowPoints(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.parseShowPoints(theme);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
90 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
91 r.setSeriesShapesVisible(idx, show);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
92 r.setDrawOutlines(true);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
93 }
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
94
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
95
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
96 protected void applyShowLine(XYLineAndShapeRenderer r, int idx) {
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
97 boolean show = ThemeUtil.parseShowLine(theme);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
98 r.setSeriesLinesVisible(idx, show);
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
99 }
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
100 }
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
101 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org