Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/StyledAreaSeriesCollection.java @ 2066:2b6a0de47379
Improved the WaterlevelExporter: added range check for W/Q at gauge.
flys-artifacts/trunk@3561 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 02 Jan 2012 10:59:42 +0000 |
parents | ca8997aa683e |
children | fd95bfbb2ec2 |
rev | line source |
---|---|
2020
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.exports; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
2032
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
3 import java.awt.Color; |
2020
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 import org.w3c.dom.Document; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 import org.jfree.data.xy.XYSeriesCollection; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.flys.utils.ThemeUtil; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.jfree.StableXYDifferenceRenderer; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 /** |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 * One or more dataseries to draw a polygon (either "open up/downwards", or |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 * the area between two curves), a theme-document and further display options. |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 * The theme-document will later "style" the graphical representation. |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 * The display options can be used to control the z-order and the axis of the |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 * dataset. |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 public class StyledAreaSeriesCollection extends XYSeriesCollection { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 /** Mode, how to draw/which areas to fill. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 public enum FILL_MODE {UNDER, ABOVE, BETWEEN}; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 /** MODE in use. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 protected FILL_MODE mode; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 /** The theme-document with attributes about actual visual representation. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 protected Document theme; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 /** Own logger. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 private static final Logger logger = |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 Logger.getLogger(StyledAreaSeriesCollection.class); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 /** |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 * @param theme the theme-document. |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 public StyledAreaSeriesCollection(Document theme) { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 this.theme = theme; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 this.mode = FILL_MODE.BETWEEN; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 } |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 /** Gets the Fill mode. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 public FILL_MODE getMode() { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 return this.mode; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 } |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 /** Sets the Fill mode. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 public void setMode(FILL_MODE fMode) { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 this.mode = fMode; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 } |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 /** |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 * Applies line color, size and type attributes to renderer, also |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 * whether to draw lines and/or points. |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 public StableXYDifferenceRenderer applyTheme( |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 StableXYDifferenceRenderer renderer |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 ) { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 applyFillColor(renderer); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 applyShowShape(renderer); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 return renderer; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 } |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
70 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 /** |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 * Blindly (for now) apply the postiviepaint of renderer. |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 protected void applyFillColor(StableXYDifferenceRenderer renderer) { |
2032
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
76 // Get color. |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
77 Color paint = ThemeUtil.parseFillColorField(theme); |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
78 // Get half-transparency flag. |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
79 if (ThemeUtil.parseTransparency(theme)) { |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
80 paint = new Color(paint.getRed(), paint.getGreen(), paint.getBlue(), |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
81 128); |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
82 } |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
83 if (paint != null && this.getMode() == FILL_MODE.ABOVE) { |
2020
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 renderer.setPositivePaint(paint); |
2032
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
85 renderer.setNegativePaint(new Color(0,0,0,0)); |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
86 } |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
87 else if (paint != null && this.getMode() == FILL_MODE.UNDER) { |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
88 renderer.setNegativePaint(paint); |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
89 renderer.setPositivePaint(new Color(0,0,0,0)); |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
90 } |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
91 else { |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
92 renderer.setPositivePaint(paint); |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
93 renderer.setNegativePaint(paint); |
5746c74c69cf
Added a transparency setting to area theme style.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
94 } |
2020
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 } |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
97 /** |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 * Blindly (for now) apply the postiviepaint of renderer. |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
100 protected void applyShowShape(StableXYDifferenceRenderer renderer) { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
101 boolean show = ThemeUtil.parseShowBorder(theme); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 renderer.setShapesVisible(show); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
103 } |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 } |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |