Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/StyledAreaSeriesCollection.java @ 2021:1ae17b100973
Let StableDifferenceRenderer create a rectangular legenditem.
flys-artifacts/trunk@3476 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 20 Dec 2011 06:50:06 +0000 |
parents | 4f7f781e4481 |
children | 3c3693e9c538 |
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 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import java.awt.BasicStroke; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 import java.awt.Color; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 import java.awt.Paint; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 import java.awt.geom.Ellipse2D; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 import org.apache.log4j.Logger; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 import org.w3c.dom.Document; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import org.jfree.data.xy.XYSeriesCollection; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 import org.jfree.data.Range; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 import org.jfree.data.xy.XYSeries; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.flys.utils.ThemeUtil; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.flys.jfree.StableXYDifferenceRenderer; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 |
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 * 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
|
23 * 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
|
24 * The theme-document will later "style" the graphical representation. |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 * 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
|
26 * dataset. |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 public class StyledAreaSeriesCollection extends XYSeriesCollection { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 /** Mode, how to draw/which areas to fill. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 public enum FILL_MODE {UNDER, ABOVE, BETWEEN}; |
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 /** MODE in use. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 protected FILL_MODE mode; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 /** The theme-document with attributes about actual visual representation. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 protected Document theme; |
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 /** Own logger. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 private static final Logger logger = |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 Logger.getLogger(StyledAreaSeriesCollection.class); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 |
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 * @param theme the theme-document. |
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 public StyledAreaSeriesCollection(Document theme) { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 this.theme = theme; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 this.mode = FILL_MODE.BETWEEN; |
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 /** Gets the Fill mode. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 public FILL_MODE getMode() { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 return this.mode; |
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 /** Sets the Fill mode. */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 public void setMode(FILL_MODE fMode) { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 this.mode = fMode; |
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 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 |
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 * Applies line color, size and type attributes to renderer, also |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 * whether to draw lines and/or points. |
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 public StableXYDifferenceRenderer applyTheme( |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 StableXYDifferenceRenderer renderer |
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 applyFillColor(renderer); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 applyShowShape(renderer); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 return renderer; |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 } |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 /** |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
79 * Blindly (for now) apply the postiviepaint of renderer. |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 protected void applyFillColor(StableXYDifferenceRenderer renderer) { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 Paint paint = ThemeUtil.parseFillColorField(theme); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
83 if (paint != null) |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 renderer.setPositivePaint(paint); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 // TODO set negativepaint? Dependend on the over/under/between settings |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 } |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
87 |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
88 /** |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
89 * Blindly (for now) apply the postiviepaint of renderer. |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
90 */ |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
91 protected void applyShowShape(StableXYDifferenceRenderer renderer) { |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 boolean show = ThemeUtil.parseShowBorder(theme); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
93 renderer.setShapesVisible(show); |
4f7f781e4481
Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 } |
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |