annotate flys-artifacts/src/main/java/de/intevation/flys/exports/StyledAreaSeriesCollection.java @ 2022:3c3693e9c538

Removed obsolete imports. flys-artifacts/trunk@3479 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 20 Dec 2011 07:01:08 +0000
parents 4f7f781e4481
children 5746c74c69cf
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.Paint;
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) {
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 Paint paint = ThemeUtil.parseFillColorField(theme);
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 if (paint != null)
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 renderer.setPositivePaint(paint);
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 // TODO set negativepaint? Dependend on the over/under/between settings
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
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 /**
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 * Blindly (for now) apply the postiviepaint of renderer.
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84 */
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 protected void applyShowShape(StableXYDifferenceRenderer renderer) {
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 boolean show = ThemeUtil.parseShowBorder(theme);
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 renderer.setShapesVisible(show);
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 }
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
90 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org