annotate artifacts/src/main/java/org/dive4elements/river/jfree/RiverAnnotation.java @ 6955:94cb1845c667

(issue1452) Coalesce to zero to avoid NaN arithmetic.
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 30 Aug 2013 15:45:14 +0200
parents 1b35b2ddfc28
children 5e38e2924c07
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5864
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5864
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4277
diff changeset
9 package org.dive4elements.river.jfree;
1677
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4277
diff changeset
11 import org.dive4elements.river.artifacts.model.HYKFactory;
6905
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
12 import org.dive4elements.river.themes.ThemeDocument;
4044
7eebd9e58641 Add chart legend entries for interpolated series (#838).
Christian Lins <christian.lins@intevation.de>
parents: 3317
diff changeset
13
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
14 import java.util.Collections;
1677
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import java.util.List;
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
4044
7eebd9e58641 Add chart legend entries for interpolated series (#838).
Christian Lins <christian.lins@intevation.de>
parents: 3317
diff changeset
17 import org.jfree.chart.annotations.XYTextAnnotation;
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1677
diff changeset
18
1721
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1712
diff changeset
19 /**
4277
18c66e586e44 Doc and whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4044
diff changeset
20 * List of Text- Annotations (Sticky to one axis or in space)
18c66e586e44 Doc and whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4044
diff changeset
21 * and 'HYK'-Annotations (rectangles/areas) with name and theme.
1721
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1712
diff changeset
22 */
5864
f2e46a668fe6 River artifacts: Renamed FLYSAnnotation to RiverAnnotation.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
23 public class RiverAnnotation {
1677
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
4044
7eebd9e58641 Add chart legend entries for interpolated series (#838).
Christian Lins <christian.lins@intevation.de>
parents: 3317
diff changeset
25 /** 'Other' Text Annotations. */
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
26 protected List<XYTextAnnotation> textAnnotations;
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
27
2183
a79d5cd26083 Render labels of manual points in a very primitive manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
28 /** Annotations at axis. */
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
29 protected List<StickyAxisAnnotation> axisTextAnnotations;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
30
2183
a79d5cd26083 Render labels of manual points in a very primitive manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
31 /** Areas at axis. */
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
32 protected List<HYKFactory.Zone> boxes;
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1677
diff changeset
33
2183
a79d5cd26083 Render labels of manual points in a very primitive manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
34 /** Styling information. */
6905
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
35 protected ThemeDocument theme;
1677
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
2183
a79d5cd26083 Render labels of manual points in a very primitive manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
37 /** Chart-legend information. */
1677
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 protected String label;
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
5864
f2e46a668fe6 River artifacts: Renamed FLYSAnnotation to RiverAnnotation.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
41 public RiverAnnotation(String label, List<StickyAxisAnnotation> annotations) {
2152
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
42 this(label, annotations, null, null);
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
43 }
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
44
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
45
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
46 /** Create annotations, parameter might be null. */
5864
f2e46a668fe6 River artifacts: Renamed FLYSAnnotation to RiverAnnotation.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
47 public RiverAnnotation(String label, List<StickyAxisAnnotation> annotations,
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
48 List<HYKFactory.Zone> bAnnotations
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
49 ) {
2152
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
50 this(label, annotations, bAnnotations, null);
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
51 }
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
52
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
53
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
54 /** Create annotations, parameter might be null. */
5864
f2e46a668fe6 River artifacts: Renamed FLYSAnnotation to RiverAnnotation.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
55 public RiverAnnotation(String label, List<StickyAxisAnnotation> annotations,
6905
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
56 List<HYKFactory.Zone> bAnnotations, ThemeDocument theme
2152
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
57 ) {
4277
18c66e586e44 Doc and whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4044
diff changeset
58 this.label = label;
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
59 this.axisTextAnnotations = (annotations != null)
4277
18c66e586e44 Doc and whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4044
diff changeset
60 ? annotations
18c66e586e44 Doc and whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4044
diff changeset
61 : Collections.<StickyAxisAnnotation>emptyList();
18c66e586e44 Doc and whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4044
diff changeset
62 this.boxes = (bAnnotations != null)
18c66e586e44 Doc and whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4044
diff changeset
63 ? bAnnotations
18c66e586e44 Doc and whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4044
diff changeset
64 : Collections.<HYKFactory.Zone>emptyList();
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
65 this.textAnnotations = Collections.<XYTextAnnotation>emptyList();
2152
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
66 this.setTheme(theme);
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
67 }
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
68
1677
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
1712
7e19449d7826 #253 Modified the title creation of chart curves - titles will now equal the Facet's description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
70 public void setLabel(String label) {
7e19449d7826 #253 Modified the title creation of chart curves - titles will now equal the Facet's description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
71 this.label = label;
7e19449d7826 #253 Modified the title creation of chart curves - titles will now equal the Facet's description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
72 }
7e19449d7826 #253 Modified the title creation of chart curves - titles will now equal the Facet's description.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
73
1677
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 public String getLabel() {
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 return label;
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 }
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
78 public List<StickyAxisAnnotation> getAxisTextAnnotations() {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
79 return axisTextAnnotations;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
80 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
81
2183
a79d5cd26083 Render labels of manual points in a very primitive manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
82 public void setTextAnnotations(List<XYTextAnnotation> annotations) {
a79d5cd26083 Render labels of manual points in a very primitive manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
83 this.textAnnotations = annotations;
a79d5cd26083 Render labels of manual points in a very primitive manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
84 }
a79d5cd26083 Render labels of manual points in a very primitive manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
85
a79d5cd26083 Render labels of manual points in a very primitive manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
86 /** Set the "other" Text Annotations. */
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
87 public List<XYTextAnnotation> getTextAnnotations() {
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
88 return textAnnotations;
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
89 }
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
90
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
91 public List<HYKFactory.Zone> getBoxes() {
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
92 return boxes;
1677
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 }
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1677
diff changeset
94
6905
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
95 public void setTheme(ThemeDocument theme) {
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1677
diff changeset
96 this.theme = theme;
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1677
diff changeset
97 }
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1677
diff changeset
98
6905
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
99 public ThemeDocument getTheme() {
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1677
diff changeset
100 return theme;
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1677
diff changeset
101 }
2768
1ddfb54e5db6 Added accidentally omitted file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
102
1ddfb54e5db6 Added accidentally omitted file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
103 /**
1ddfb54e5db6 Added accidentally omitted file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
104 * Set sticky axis of all axisTextAnnotations
1ddfb54e5db6 Added accidentally omitted file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
105 * to the X axis if it is currently Y, and vice versa.
1ddfb54e5db6 Added accidentally omitted file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
106 * @return this
1ddfb54e5db6 Added accidentally omitted file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
107 */
5864
f2e46a668fe6 River artifacts: Renamed FLYSAnnotation to RiverAnnotation.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
108 public RiverAnnotation flipStickyAxis() {
2768
1ddfb54e5db6 Added accidentally omitted file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
109 for (StickyAxisAnnotation saa: axisTextAnnotations) {
1ddfb54e5db6 Added accidentally omitted file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
110 saa.flipStickyAxis();
1ddfb54e5db6 Added accidentally omitted file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
111 }
1ddfb54e5db6 Added accidentally omitted file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
112 return this;
1ddfb54e5db6 Added accidentally omitted file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
113 }
1677
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 }
dd9dfe1e48fa Bugfixes for various issues: Improved rendering process of annotations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org