Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java @ 3889:940cd2ef149f
Area transparency fix
flys-artifacts/trunk@5542 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Thu, 20 Sep 2012 20:35:44 +0000 |
parents | cd5eb8f5f6f1 |
children | e8a4d2fd25cc |
comparison
equal
deleted
inserted
replaced
3888:44a071455709 | 3889:940cd2ef149f |
---|---|
2 | 2 |
3 import java.awt.BasicStroke; | 3 import java.awt.BasicStroke; |
4 import java.awt.Color; | 4 import java.awt.Color; |
5 import java.awt.Stroke; | 5 import java.awt.Stroke; |
6 | 6 |
7 import org.apache.log4j.Logger; | |
8 import org.jfree.data.xy.XYSeriesCollection; | 7 import org.jfree.data.xy.XYSeriesCollection; |
9 import org.w3c.dom.Document; | 8 import org.w3c.dom.Document; |
10 | 9 |
11 import de.intevation.flys.themes.ThemeAccess; | 10 import de.intevation.flys.themes.ThemeAccess; |
12 import de.intevation.flys.utils.ThemeUtil; | 11 import de.intevation.flys.utils.ThemeUtil; |
18 * The theme-document will later "style" the graphical representation. | 17 * The theme-document will later "style" the graphical representation. |
19 * The display options can be used to control the z-order and the axis of the | 18 * The display options can be used to control the z-order and the axis of the |
20 * dataset. | 19 * dataset. |
21 */ | 20 */ |
22 public class StyledAreaSeriesCollection extends XYSeriesCollection { | 21 public class StyledAreaSeriesCollection extends XYSeriesCollection { |
22 private static final long serialVersionUID = 5274940965666948237L; | |
23 | |
23 /** Mode, how to draw/which areas to fill. */ | 24 /** Mode, how to draw/which areas to fill. */ |
24 public enum FILL_MODE {UNDER, ABOVE, BETWEEN}; | 25 public enum FILL_MODE {UNDER, ABOVE, BETWEEN}; |
25 | 26 |
26 /** MODE in use. */ | 27 /** MODE in use. */ |
27 protected FILL_MODE mode; | 28 protected FILL_MODE mode; |
28 | 29 |
29 /** The theme-document with attributes about actual visual representation. */ | 30 /** The theme-document with attributes about actual visual representation. */ |
30 protected Document theme; | 31 protected Document theme; |
31 | |
32 /** Own logger. */ | |
33 private static final Logger logger = | |
34 Logger.getLogger(StyledAreaSeriesCollection.class); | |
35 | 32 |
36 | 33 |
37 /** | 34 /** |
38 * @param theme the theme-document. | 35 * @param theme the theme-document. |
39 */ | 36 */ |
83 new ThemeAccess(theme).parseTextStyle().apply(renderer); | 80 new ThemeAccess(theme).parseTextStyle().apply(renderer); |
84 return renderer; | 81 return renderer; |
85 } | 82 } |
86 | 83 |
87 | 84 |
88 /** | |
89 * Blindly (for now) apply the positivepaint of renderer. | |
90 */ | |
91 protected void applyFillColor(StableXYDifferenceRenderer renderer) { | 85 protected void applyFillColor(StableXYDifferenceRenderer renderer) { |
92 // Get color. | 86 Color paint = ThemeUtil.parseColor( |
93 Color paint = ThemeUtil.parseFillColorField(theme); | 87 ThemeUtil.getBackgroundColorString(theme)); |
94 // Get half-transparency flag. | 88 |
95 if (ThemeUtil.parseTransparency(theme)) { | 89 int transparency = ThemeUtil.parseTransparency(theme); |
96 paint = new Color(paint.getRed(), paint.getGreen(), paint.getBlue(), | 90 if (transparency > 0) { |
97 128); | 91 paint = new Color( |
92 paint.getRed(), | |
93 paint.getGreen(), | |
94 paint.getBlue(), | |
95 (int)((100 - transparency) * 2.55f)); | |
98 } | 96 } |
97 | |
99 if (paint != null && this.getMode() == FILL_MODE.ABOVE) { | 98 if (paint != null && this.getMode() == FILL_MODE.ABOVE) { |
100 renderer.setPositivePaint(paint); | 99 renderer.setPositivePaint(paint); |
101 renderer.setNegativePaint(new Color(0,0,0,0)); | 100 renderer.setNegativePaint(new Color(0,0,0,0)); |
102 } | 101 } |
103 else if (paint != null && this.getMode() == FILL_MODE.UNDER) { | 102 else if (paint != null && this.getMode() == FILL_MODE.UNDER) { |
104 renderer.setNegativePaint(paint); | 103 renderer.setNegativePaint(paint); |
105 renderer.setPositivePaint(new Color(0,0,0,0)); | 104 renderer.setPositivePaint(new Color(0,0,0,0)); |
106 } | 105 } |
107 else { | 106 else { |
108 if (paint == null) paint = new Color(177, 117, 102); | 107 if (paint == null) |
108 paint = new Color(177, 117, 102); | |
109 renderer.setPositivePaint(paint); | 109 renderer.setPositivePaint(paint); |
110 renderer.setNegativePaint(paint); | 110 renderer.setNegativePaint(paint); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 /** | 114 |
115 * Blindly (for now) apply the postiviepaint of renderer. | |
116 */ | |
117 protected void applyShowShape(StableXYDifferenceRenderer renderer) { | 115 protected void applyShowShape(StableXYDifferenceRenderer renderer) { |
118 boolean show = ThemeUtil.parseShowBorder(theme); | 116 boolean show = ThemeUtil.parseShowBorder(theme); |
119 renderer.setDrawOutline(show); | 117 renderer.setDrawOutline(show); |
120 } | 118 } |
121 | 119 |