Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/XYStyle.java @ 3464:0b9b2a0c4e64
Point labels can have a background color now.
flys-artifacts/trunk@5132 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Thu, 26 Jul 2012 10:02:07 +0000 |
parents | b0ba96bbf01d |
children |
comparison
equal
deleted
inserted
replaced
3463:7198f04e4221 | 3464:0b9b2a0c4e64 |
---|---|
1 package de.intevation.flys.jfree; | 1 package de.intevation.flys.jfree; |
2 | |
3 import de.intevation.flys.utils.ThemeUtil; | |
2 | 4 |
3 import java.awt.BasicStroke; | 5 import java.awt.BasicStroke; |
4 import java.awt.Color; | 6 import java.awt.Color; |
5 import java.awt.geom.Ellipse2D; | 7 import java.awt.geom.Ellipse2D; |
6 | 8 |
7 import org.apache.log4j.Logger; | 9 import org.apache.log4j.Logger; |
8 | 10 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; |
9 import org.w3c.dom.Document; | 11 import org.w3c.dom.Document; |
10 | |
11 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; | |
12 | |
13 import de.intevation.flys.utils.ThemeUtil; | |
14 | 12 |
15 | 13 |
16 /** | 14 /** |
17 * Utility to apply theme-settings to a renderer. | 15 * Utility to apply theme-settings to a renderer. |
18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
34 | 32 |
35 /** | 33 /** |
36 * Applies line color, size and type attributes to renderer, also | 34 * Applies line color, size and type attributes to renderer, also |
37 * whether to draw lines and/or points. | 35 * whether to draw lines and/or points. |
38 */ | 36 */ |
37 @Override | |
39 public XYLineAndShapeRenderer applyTheme(XYLineAndShapeRenderer r, int idx){ | 38 public XYLineAndShapeRenderer applyTheme(XYLineAndShapeRenderer r, int idx){ |
40 this.renderer = r; | 39 this.renderer = r; |
41 applyLineColor(r, idx); | 40 applyLineColor(r, idx); |
42 applyLineSize(r, idx); | 41 applyLineSize(r, idx); |
43 applyLineType(r, idx); | 42 applyLineType(r, idx); |
45 applyShowPoints(r, idx); | 44 applyShowPoints(r, idx); |
46 applyPointSize(r, idx); | 45 applyPointSize(r, idx); |
47 applyPointColor(r, idx); | 46 applyPointColor(r, idx); |
48 applyShowMinimum(r, idx); | 47 applyShowMinimum(r, idx); |
49 applyShowMaximum(r, idx); | 48 applyShowMaximum(r, idx); |
49 | |
50 // Line label styles | |
50 applyShowLineLabel(r, idx); | 51 applyShowLineLabel(r, idx); |
52 applyShowLineLabelBG(r, idx); | |
51 applyLineLabelFont(r, idx); | 53 applyLineLabelFont(r, idx); |
52 applyLineLabelColor(r, idx); | 54 applyLineLabelColor(r, idx); |
53 applyShowLineLabelBG(r, idx); | |
54 applyLineLabelBGColor(r, idx); | 55 applyLineLabelBGColor(r, idx); |
56 | |
57 // Point label styles | |
58 // TODO: Currently point label are annotations and are not drawn this way | |
59 /* | |
60 applyShowPointLabelBG(r, idx); | |
61 applyLinePointFont(r, idx); | |
62 applyLinePointColor(r, idx); | |
63 applyLinePointBGColor(r, idx);*/ | |
55 | 64 |
56 return r; | 65 return r; |
57 } | 66 } |
58 | 67 |
59 | 68 |
86 /** Tells the renderer whether or not to fill the bg of a lines label. */ | 95 /** Tells the renderer whether or not to fill the bg of a lines label. */ |
87 protected void applyShowLineLabelBG(XYLineAndShapeRenderer r, int idx) { | 96 protected void applyShowLineLabelBG(XYLineAndShapeRenderer r, int idx) { |
88 if (!(r instanceof EnhancedLineAndShapeRenderer)) { | 97 if (!(r instanceof EnhancedLineAndShapeRenderer)) { |
89 return; | 98 return; |
90 } | 99 } |
91 boolean showLabelLine = ThemeUtil.parseShowLineLabelBG(theme); | 100 boolean showLabelLine = ThemeUtil.parseLabelShowBackground(theme); |
92 ((EnhancedLineAndShapeRenderer)r).setShowLineLabelBG(idx, showLabelLine); | 101 ((EnhancedLineAndShapeRenderer)r).setShowLineLabelBG(idx, showLabelLine); |
93 } | 102 } |
94 | 103 |
95 /** Tell the renderer which font (and -size and -style) to use for | 104 /** Tell the renderer which font (and -size and -style) to use for |
96 * linelabels. */ | 105 * linelabels. */ |
97 protected void applyLineLabelFont(XYLineAndShapeRenderer r, int idx) { | 106 protected void applyLineLabelFont(XYLineAndShapeRenderer r, int idx) { |
98 if (!(r instanceof EnhancedLineAndShapeRenderer)) { | 107 if (!(r instanceof EnhancedLineAndShapeRenderer)) { |
99 return; | 108 return; |
100 } | 109 } |
101 ((EnhancedLineAndShapeRenderer)r).setLineLabelFont(ThemeUtil.parseLineLabelFont(theme), idx); | 110 ((EnhancedLineAndShapeRenderer)r).setLineLabelFont( |
111 ThemeUtil.parseTextFont(theme), idx); | |
102 } | 112 } |
103 | 113 |
104 /** Tell the renderer which color to use for | 114 /** Tell the renderer which color to use for |
105 * linelabels. */ | 115 * linelabels. */ |
106 protected void applyLineLabelColor(XYLineAndShapeRenderer r, int idx) { | 116 protected void applyLineLabelColor(XYLineAndShapeRenderer r, int idx) { |
107 if (!(r instanceof EnhancedLineAndShapeRenderer)) { | 117 if (!(r instanceof EnhancedLineAndShapeRenderer)) { |
108 return; | 118 return; |
109 } | 119 } |
110 ((EnhancedLineAndShapeRenderer)r).setLineLabelTextColor(idx, ThemeUtil.parseLineLabelTextColor(theme)); | 120 ((EnhancedLineAndShapeRenderer)r).setLineLabelTextColor( |
121 idx, ThemeUtil.parseTextColor(theme)); | |
111 } | 122 } |
112 | 123 |
113 /** Tell the renderer which color to use for bg of | 124 /** Tell the renderer which color to use for bg of |
114 * linelabels. */ | 125 * linelabels. */ |
115 protected void applyLineLabelBGColor(XYLineAndShapeRenderer r, int idx) { | 126 protected void applyLineLabelBGColor(XYLineAndShapeRenderer r, int idx) { |
116 if (!(r instanceof EnhancedLineAndShapeRenderer)) { | 127 if (!(r instanceof EnhancedLineAndShapeRenderer)) { |
117 return; | 128 return; |
118 } | 129 } |
119 ((EnhancedLineAndShapeRenderer)r).setLineLabelBGColor(idx, | 130 ((EnhancedLineAndShapeRenderer)r).setLineLabelBGColor(idx, |
120 ThemeUtil.parseLineLabelBGColor(theme)); | 131 ThemeUtil.parseTextBackground(theme)); |
121 } | 132 } |
122 | 133 |
123 /** Set stroke of series. */ | 134 /** Set stroke of series. */ |
124 protected void applyLineSize(XYLineAndShapeRenderer r, int idx) { | 135 protected void applyLineSize(XYLineAndShapeRenderer r, int idx) { |
125 int size = ThemeUtil.parseLineWidth(theme); | 136 int size = ThemeUtil.parseLineWidth(theme); |
208 EnhancedLineAndShapeRenderer er = (EnhancedLineAndShapeRenderer) r; | 219 EnhancedLineAndShapeRenderer er = (EnhancedLineAndShapeRenderer) r; |
209 er.setIsMaximumShapeVisible(idx, visible); | 220 er.setIsMaximumShapeVisible(idx, visible); |
210 } | 221 } |
211 | 222 |
212 | 223 |
224 @Override | |
213 public XYLineAndShapeRenderer getRenderer() { | 225 public XYLineAndShapeRenderer getRenderer() { |
214 return this.renderer; | 226 return this.renderer; |
215 } | 227 } |
216 } | 228 } |
217 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 229 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |