annotate flys-artifacts/src/main/java/de/intevation/flys/exports/StyledXYSeries.java @ 1753:741ba9e34c7d

Apply the attributes 'showpoints' and 'showline'. flys-artifacts/trunk@3056 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 21 Oct 2011 14:02:07 +0000
parents 1bc926b5b435
children 8e6615ad60b8
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
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
14 import de.intevation.artifacts.common.utils.XMLUtils;
1753
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
15 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
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
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 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
19
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 static final String XPATH_LINE_COLOR =
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 "/theme/field[@name='linecolor']/@default";
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
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 public static final String XPATH_LINE_SIZE =
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 "/theme/field[@name='linesize']/@default";
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
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
26 public static final String XPATH_LINE_TYPE =
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
27 "/theme/field[@name='linetype']/@default";
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
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
29 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
30
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
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 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
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
1741
1bc926b5b435 Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1714
diff changeset
35 public StyledXYSeries(String key, Document theme) {
1bc926b5b435 Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1714
diff changeset
36 this(key, true, theme);
1bc926b5b435 Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1714
diff changeset
37 }
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
38
1741
1bc926b5b435 Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1714
diff changeset
39 public StyledXYSeries(String key, boolean sorted, Document theme) {
1bc926b5b435 Fix for flys/issue316
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1714
diff changeset
40 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
41 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
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
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 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
46 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
47 applyLineSize(r, idx);
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
48 applyLineType(r, idx);
1753
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
49 applyShowLine(r, idx);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
50 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
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 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
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
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
55
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
56 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
57 Color c = ThemeUtil.parseLineColorField(theme);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
58 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
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
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
61
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
62 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
63 int size = ThemeUtil.parseLineWidth(theme);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
64 r.setSeriesStroke(
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
65 idx,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
66 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
67 }
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
68
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
69
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
70 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
71 int size = ThemeUtil.parseLineWidth(theme);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
72 float[] dashes = ThemeUtil.parseLineStyle(theme);
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
73
1753
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
74 // Do not apply the dashed style.
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
75 if (dashes.length <= 1) {
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
76 return;
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
77 }
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 r.setSeriesStroke(
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
80 idx,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
81 new BasicStroke(Integer.valueOf(size),
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
82 BasicStroke.CAP_BUTT,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
83 BasicStroke.JOIN_ROUND,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
84 1.0f,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
85 dashes,
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
86 0.0f));
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
87 }
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
88
1753
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
89
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
90 protected void applyShowPoints(XYLineAndShapeRenderer r, int idx) {
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
91 boolean show = ThemeUtil.parseShowPoints(theme);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
92 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
93 r.setSeriesShapesVisible(idx, show);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
94 r.setDrawOutlines(true);
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
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
97
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
98 protected void applyShowLine(XYLineAndShapeRenderer r, int idx) {
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
99 boolean show = ThemeUtil.parseShowLine(theme);
741ba9e34c7d Apply the attributes 'showpoints' and 'showline'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1741
diff changeset
100 r.setSeriesLinesVisible(idx, show);
1714
004b1b0838d6 Apply line type to styled themes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 924
diff changeset
101 }
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
102 }
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
103 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org