Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java @ 2197:5781847433d8
"Bezugslinienverfahren": Implemented the on-the-flys shift to (0, 0).
flys-artifacts/trunk@3813 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 27 Jan 2012 17:59:24 +0000 |
parents | 105097966111 |
children | 7dc4681a2bed |
rev | line source |
---|---|
1039
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.jfree; |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 /** |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 * Custom Annotations class that is drawn only if no collisions with other |
1759
c51089a84d13
Restored correct drawing behavior for Annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1754
diff
changeset
|
8 * already drawn CustomAnnotations in current plot are found. A mark on |
c51089a84d13
Restored correct drawing behavior for Annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1754
diff
changeset
|
9 * the axis is shown in all cases, though. |
1039
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 * Draws a given text and a line to it from either axis. |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 */ |
2161
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
12 public class StickyAxisAnnotation { |
1039
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 /** Logger for this class. */ |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 private static Logger logger = |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 Logger.getLogger(StickyAxisAnnotation.class); |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 /** Simplified view on axes. */ |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 public static enum SimpleAxis { |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 X_AXIS, /** Usually "horizontal". */ |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 Y_AXIS /** Usually "vertical". */ |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 } |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 |
2163
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
24 /** The "symbolic" integer representing which axis to stick to. */ |
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
25 protected int axisSymbol; |
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
26 |
1039
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 /** Which axis to stick to. */ |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 protected SimpleAxis stickyAxis = SimpleAxis.X_AXIS; |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
30 /** The 1-dimensional position of this annotation. */ |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
31 protected float pos; |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
32 |
2161
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
33 String text; |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
34 |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
35 /** |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
36 * Constructor with implicit sticky x-axis. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
37 * @param text the text to display. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
38 * @param pos the position at which to draw the text and mark. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
39 */ |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
40 public StickyAxisAnnotation(String text, float pos) { |
2161
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
41 this(text, pos, SimpleAxis.X_AXIS); |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
42 } |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
43 |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
44 |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
45 /** |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
46 * Constructor with given explicit axis. |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
47 * @param text the text to display. |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
48 * @param pos the position at which to draw the text and mark. |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
49 * @param stickyAxis the axis at which to stick (and to which 'pos' is |
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
50 * relative). |
2161
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
51 * @param lineTo upto where to draw a line (NaN for none). |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
52 */ |
2161
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
53 public StickyAxisAnnotation(String text, float pos, SimpleAxis stickAxis |
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
54 ) { |
2163
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
55 this(text, pos, stickAxis, 0); |
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
56 } |
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
57 |
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
58 public StickyAxisAnnotation(String text, float pos, SimpleAxis stickAxis, |
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
59 int axisSymbol |
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
60 ) { |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1082
diff
changeset
|
61 setStickyAxis(stickAxis); |
2161
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
62 this.text = text; |
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
63 this.pos = pos; |
2163
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
64 this.axisSymbol = axisSymbol; |
1082
f16b66839e59
Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1042
diff
changeset
|
65 } |
f16b66839e59
Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1042
diff
changeset
|
66 |
f16b66839e59
Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1042
diff
changeset
|
67 |
1039
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 /** |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 * Sets the "sticky axis" (whether to draw annotations at the |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
70 * X- or the Y-Axis. |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 * |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 * @param stickyAxis axis to stick to. |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 */ |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 public void setStickyAxis(SimpleAxis stickyAxis) { |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 this.stickyAxis = stickyAxis; |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 } |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 |
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 |
2161
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
79 public float getPos() { |
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
80 return this.pos; |
1039
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 } |
1738
6cdc7a77d3d4
Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1711
diff
changeset
|
82 |
2161
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
83 public SimpleAxis getStickyAxis() { |
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
84 return this.stickyAxis; |
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
85 } |
1738
6cdc7a77d3d4
Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1711
diff
changeset
|
86 |
2161
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
87 public boolean atX() { |
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
88 return this.getStickyAxis() == SimpleAxis.X_AXIS; |
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
89 } |
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
90 |
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
91 public String getText() { |
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1962
diff
changeset
|
92 return this.text; |
1738
6cdc7a77d3d4
Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1711
diff
changeset
|
93 } |
2163
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
94 |
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
95 public int getAxisSymbol() { |
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
96 return this.axisSymbol; |
105097966111
Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2161
diff
changeset
|
97 } |
1039
cf39205df113
Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 } |
1711
f708120cb7bc
Fix flys/issue363 (W-INFO/ Abflusskurve, Extremwert-Rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1167
diff
changeset
|
99 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |