annotate flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java @ 2096:bf598599782a

Made old calculation results available for floodmaps. flys-artifacts/trunk@3644 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 11 Jan 2012 10:17:16 +0000
parents 59622ba800c8
children c68f4f227c09
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 import java.util.Iterator;
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 import java.awt.Shape;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8 import java.awt.geom.Rectangle2D;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
9 import java.awt.geom.Line2D;
1738
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
10 import java.awt.Color;
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
11 import java.awt.Font;
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
12 import java.awt.BasicStroke;
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 import org.jfree.chart.annotations.XYTextAnnotation;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import org.jfree.chart.axis.ValueAxis;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 import org.jfree.chart.util.LineUtilities;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import org.jfree.chart.plot.PlotOrientation;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 import org.jfree.chart.plot.XYPlot;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import org.jfree.chart.entity.XYAnnotationEntity;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 import org.jfree.chart.plot.PlotRenderingInfo;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 import org.jfree.chart.ChartRenderingInfo;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22 import org.jfree.chart.plot.Plot;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
24 import org.jfree.data.Range;
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
25
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
26 import org.jfree.text.TextUtilities;
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
27
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 import org.jfree.ui.RectangleEdge;
1082
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
29 import org.jfree.ui.TextAnchor;
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30
1754
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1753
diff changeset
31 import de.intevation.flys.utils.ThemeAccess;
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 /**
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 * 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
35 * 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
36 * 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
37 * 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
38 */
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 public class StickyAxisAnnotation extends XYTextAnnotation {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 /** Logger for this class. */
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 private static Logger logger =
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 Logger.getLogger(StickyAxisAnnotation.class);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 /** Simplified view on axes. */
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 public static enum SimpleAxis {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 X_AXIS, /** Usually "horizontal". */
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 Y_AXIS /** Usually "vertical". */
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 }
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 /** Which axis to stick to. */
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 protected SimpleAxis stickyAxis = SimpleAxis.X_AXIS;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
54 /** 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
55 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
56
1738
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
57 /** Theme attributes. */
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
58 protected Color textColor;
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
59 protected Color lineColor;
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
60 protected Font font;
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
61 protected int lineWidth;
1751
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
62 protected String textOrientation = "vertical";
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
63 protected Color textBackground;
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
64 protected boolean showBackground;
1738
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
65
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 /**
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 * Trivial constructor.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 *
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 * @param text Text to display.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 * @param x X-position in dataspace (typical horizontal, in km).
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 * @param y Y-position in dataspace (typical vertical, in m).
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
73 * @deprecated
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 */
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 public StickyAxisAnnotation(String text, float x, float y) {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 super(text, x, y);
1082
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
77 setStickyAxis(SimpleAxis.X_AXIS);
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 }
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
80
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
81 /**
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
82 * Constructor with implicit sticky x-axis.
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
83 * @param text the text to display.
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
84 * @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
85 */
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
86 public StickyAxisAnnotation(String text, float pos) {
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
87 this(text, pos, pos, SimpleAxis.X_AXIS);
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
88 }
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
89
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
90
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
91 /**
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
92 * 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
93 * @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
94 * @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
95 * @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
96 * relative).
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
97 */
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
98 public StickyAxisAnnotation(String text, float pos, SimpleAxis stickAxis) {
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
99 super(text, pos, pos);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
100 setStickyAxis(stickAxis);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
101 this.pos = pos;
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
102 }
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
103
1962
59622ba800c8 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1759
diff changeset
104
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
105 /**
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
106 * Legacy-Constructor.
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
107 * @deprecated
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
108 */
1082
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
109 public StickyAxisAnnotation(String text, float x, float y,
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
110 SimpleAxis stickAxis) {
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
111 super(text, x, y);
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
112 setStickyAxis(stickAxis);
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
113 this.pos = x;
1082
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
114 }
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
115
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
116
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
117 /**
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
118 * 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
119 * X- or the Y-Axis.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
120 *
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
121 * @param stickyAxis axis to stick to.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
122 */
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
123 public void setStickyAxis(SimpleAxis stickyAxis) {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
124 this.stickyAxis = stickyAxis;
1751
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
125 if (stickyAxis == SimpleAxis.X_AXIS){
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
126 float o = 270f;
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
127 if(textOrientation.equals("horizontal")) {
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
128 o = 0f;
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
129 }
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
130 this.setRotationAngle(o * (Math.PI / 180f));
1082
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
131 this.setRotationAnchor(TextAnchor.CENTER_LEFT);
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
132 this.setTextAnchor(TextAnchor.CENTER_LEFT);
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
133 } else {
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
134 this.setRotationAngle(0f * (Math.PI / 180f));
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
135 this.setRotationAnchor(TextAnchor.CENTER_LEFT);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
136 this.setTextAnchor(TextAnchor.CENTER_LEFT);
1082
f16b66839e59 Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1042
diff changeset
137 }
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
138 }
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
139
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
140
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
141 /**
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
142 * Draws a small line at axis where this annotation resides.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
143 *
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
144 * @param g2 the graphics device.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
145 * @param dataArea the data area.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
146 * @param domainAxis the domain axis.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
147 * @param rangeAxis the range axis.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
148 * @param domainEdge the domain edge.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
149 * @param rangeEdge the range edge.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
150 * @param orientation the plot orientation.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
151 */
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
152 protected void drawAxisMark(
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
153 java.awt.Graphics2D g2,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
154 java.awt.geom.Rectangle2D dataArea,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
155 ValueAxis domainAxis,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
156 ValueAxis rangeAxis,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
157 RectangleEdge domainEdge,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
158 RectangleEdge rangeEdge,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
159 PlotOrientation orientation) {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
160 float j2DX1 = 0.0f;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
161 float j2DX2 = 0.0f;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
162 float j2DY1 = 0.0f;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
163 float j2DY2 = 0.0f;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
164 float x = (float) getX();
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
165 float y = (float) getY();
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
166 /* When dependent on X/Y-Axis and orientation, following
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
167 can be used as a base:
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
168 if (orientation == PlotOrientation.VERTICAL) {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
169 j2DX1 = (float) domainAxis.valueToJava2D(x, dataArea,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
170 domainEdge);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
171 j2DY1 = (float) rangeAxis.valueToJava2D(y, dataArea,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
172 rangeEdge);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
173 j2DX2 = (float) domainAxis.valueToJava2D(x, dataArea,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
174 domainEdge);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
175 j2DY2 = (float) rangeAxis.valueToJava2D(y, dataArea,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
176 rangeEdge);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
177 }
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
178 else if (orientation == PlotOrientation.HORIZONTAL) {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
179 j2DY1 = (float) domainAxis.valueToJava2D(x, dataArea,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
180 domainEdge);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
181 j2DX1 = (float) rangeAxis.valueToJava2D(y, dataArea,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
182 rangeEdge);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
183 j2DY2 = (float) domainAxis.valueToJava2D(x, dataArea,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
184 domainEdge);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
185 j2DX2 = (float) rangeAxis.valueToJava2D(y, dataArea,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
186 rangeEdge);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
187 }
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
188
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
189 g2.setPaint(this.paint);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
190 g2.setStroke(this.stroke);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
191 */
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
192 if (this.stickyAxis == SimpleAxis.X_AXIS) {
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
193 j2DY1 = (float) RectangleEdge.coordinate(dataArea, domainEdge);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
194 double rangeLow = rangeAxis.getRange().getLowerBound();
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
195 // Line ends at 1.5% of full distance.
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
196 j2DY2 = (float) rangeAxis.valueToJava2D(
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
197 (1f - 0.015f) * rangeLow + 0.015f *
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
198 rangeAxis.getRange().getUpperBound(),
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
199 dataArea, rangeEdge);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
200 j2DX1 = (float) domainAxis.valueToJava2D(x, dataArea, domainEdge);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
201 j2DX2 = j2DX1;
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
202 } else {
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
203 j2DX1 = (float) RectangleEdge.coordinate(dataArea, rangeEdge);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
204 Range domainRange = domainAxis.getRange();
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
205 double rangeLow = domainRange.getLowerBound();
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
206 // Line ends at 1.5% of full distance.
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
207 j2DX2 = (float) domainAxis.valueToJava2D(
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
208 (1f - 0.015f) * rangeLow + 0.015f *
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
209 domainRange.getUpperBound(),
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
210 dataArea, domainEdge);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
211 j2DY1 = (float) rangeAxis.valueToJava2D(pos, dataArea, rangeEdge);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
212 j2DY2 = j2DY1;
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
213 }
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
214
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
215 Line2D line = new Line2D.Float(j2DX1, j2DY1, j2DX2, j2DY2);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
216
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
217 // line is clipped to avoid JRE bug 6574155, for more info
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
218 // see JFreeChart bug 2221495
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
219 boolean visible = LineUtilities.clipLine(line, dataArea);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
220 if (visible) {
1759
c51089a84d13 Restored correct drawing behavior for Annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
221 setOutlineStroke(new BasicStroke((float) lineWidth));
c51089a84d13 Restored correct drawing behavior for Annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
222 g2.setStroke(getOutlineStroke());
c51089a84d13 Restored correct drawing behavior for Annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
223 g2.setPaint(lineColor);
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
224 g2.draw(line);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
225 }
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
226 }
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
227
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
228
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
229 /**
1962
59622ba800c8 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1759
diff changeset
230 * Draw the Annotation; the text only if it does not collide with other
59622ba800c8 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1759
diff changeset
231 * already drawn Annotations- texts.
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
232 *
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
233 * @param g2 the graphics device.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
234 * @param plot the plot.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
235 * @param dataArea the data area.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
236 * @param domainAxis the domain axis.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
237 * @param rangeAxis the range axis.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
238 * @param rendererIndex the render index.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
239 * @param info state information, escpecially collects info about
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
240 * already drawn shapes (and thus annotations), used
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
241 * for collision detection.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
242 */
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
243 @Override
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
244 public void draw(
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
245 java.awt.Graphics2D g2,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
246 XYPlot plot,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
247 java.awt.geom.Rectangle2D dataArea,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
248 ValueAxis domainAxis,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
249 ValueAxis rangeAxis,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
250 int rendererIndex,
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
251 PlotRenderingInfo info) {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
252
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
253 if (info == null)
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
254 return;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
255
1167
f1c9bfb07ba7 Fix crash when StickyAxisAnnotation should be drawn without proper axis
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1156
diff changeset
256 if (domainAxis == null || rangeAxis == null
f1c9bfb07ba7 Fix crash when StickyAxisAnnotation should be drawn without proper axis
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1156
diff changeset
257 || domainAxis.getRange() == null
f1c9bfb07ba7 Fix crash when StickyAxisAnnotation should be drawn without proper axis
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1156
diff changeset
258 || rangeAxis.getRange() == null
f1c9bfb07ba7 Fix crash when StickyAxisAnnotation should be drawn without proper axis
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1156
diff changeset
259 ) {
f1c9bfb07ba7 Fix crash when StickyAxisAnnotation should be drawn without proper axis
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1156
diff changeset
260 logger.error("Annotation cannot be drawn (missing axis).");
f1c9bfb07ba7 Fix crash when StickyAxisAnnotation should be drawn without proper axis
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1156
diff changeset
261 return;
f1c9bfb07ba7 Fix crash when StickyAxisAnnotation should be drawn without proper axis
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1156
diff changeset
262 }
f1c9bfb07ba7 Fix crash when StickyAxisAnnotation should be drawn without proper axis
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1156
diff changeset
263
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
264 // Calculate the bounding box.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
265 ChartRenderingInfo chartInfo = info.getOwner();
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
266
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
267 PlotOrientation orientation = plot.getOrientation();
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
268 RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
269 plot.getDomainAxisLocation(), orientation);
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
270 RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
271 plot.getRangeAxisLocation(), orientation);
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
272 float anchorX = 0f;
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
273 float anchorY = 0.0f;
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
274 if (this.stickyAxis == SimpleAxis.X_AXIS) {
1962
59622ba800c8 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1759
diff changeset
275 // Text starts at 2% of full distance.
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
276 float rangeLow = (float) rangeAxis.getRange().getLowerBound();
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
277 float y = rangeLow + 0.02f * ((float)
1962
59622ba800c8 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1759
diff changeset
278 rangeAxis.getRange().getUpperBound() - rangeLow);
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
279 setY(y);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
280
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
281 anchorX = (float) domainAxis.valueToJava2D(
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
282 getX(), dataArea, domainEdge);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
283 anchorY = (float) rangeAxis.valueToJava2D(
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
284 getY(), dataArea, rangeEdge);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
285 } else {
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
286 float rangeLow = (float) domainAxis.getRange().getLowerBound();
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
287 float x = rangeLow + 0.02f * ((float)
1962
59622ba800c8 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1759
diff changeset
288 domainAxis.getRange().getUpperBound() - rangeLow);
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
289 setX(x);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
290 anchorX = (float) domainAxis.valueToJava2D(
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
291 getX(), dataArea, domainEdge);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
292 anchorY = (float) rangeAxis.valueToJava2D(
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
293 getY(), dataArea, rangeEdge);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1082
diff changeset
294 }
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
295 if (orientation == PlotOrientation.HORIZONTAL) {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
296 float tempAnchor = anchorX;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
297 anchorX = anchorY;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
298 anchorY = tempAnchor;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
299 }
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
300
1751
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
301 //Call to apply orientation.
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
302 setStickyAxis(stickyAxis);
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
303
1759
c51089a84d13 Restored correct drawing behavior for Annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
304 // Always draw the small line at axis.
c51089a84d13 Restored correct drawing behavior for Annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
305 drawAxisMark(g2, dataArea, domainAxis, rangeAxis, domainEdge,
1962
59622ba800c8 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1759
diff changeset
306 rangeEdge, orientation);
1759
c51089a84d13 Restored correct drawing behavior for Annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1754
diff changeset
307
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
308 Shape hotspot = TextUtilities.calculateRotatedStringBounds(
1962
59622ba800c8 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1759
diff changeset
309 getText(), g2, anchorX, anchorY, getTextAnchor(),
59622ba800c8 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1759
diff changeset
310 getRotationAngle(), getRotationAnchor());
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
311 Rectangle2D hotspotBox = hotspot.getBounds2D();
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
312 // Check for collisions with other XYAnnotations.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
313 for (Iterator i = chartInfo.getEntityCollection().iterator();
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
314 i.hasNext(); ) {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
315 Object next = i.next();
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
316 // Collision with other stuff than XYAnnotations are okay.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
317 if (next instanceof XYAnnotationEntity) {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
318 XYAnnotationEntity drawnShape = (XYAnnotationEntity) next;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
319 if (drawnShape.getArea().intersects(hotspotBox)) {
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
320 // Found collision, early stop.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
321 return;
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
322 }
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
323 }
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
324 }
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
325
1751
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
326 // Draw the background.
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
327 if (showBackground) {
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
328 g2.setStroke(new BasicStroke ((float) 1));
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
329 g2.setBackground(textBackground);
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
330 g2.setPaint(textBackground);
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
331 hotspot = TextUtilities.calculateRotatedStringBounds(
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
332 getText(), g2, anchorX, anchorY, getTextAnchor(),
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
333 getRotationAngle(), getRotationAnchor());
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
334 g2.fill(hotspot);
1751
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
335 g2.draw(hotspot);
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
336 }
1751
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
337
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
338 // Draw the text.
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
339 g2.setPaint(textColor);
27b8836abec9 Draw the text background and use orientation attribute.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1738
diff changeset
340 g2.setFont(font);
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
341 TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY,
1962
59622ba800c8 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1759
diff changeset
342 getTextAnchor(), getRotationAngle(), getRotationAnchor());
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
343
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
344 // Add info that we have drawn this Annotation.
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
345 addEntity(info, hotspot, rendererIndex, getToolTipText(), getURL());
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
346 }
1738
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
347
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
348
1754
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1753
diff changeset
349 public void applyTheme(ThemeAccess ta) {
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1753
diff changeset
350 lineWidth = ta.parseLineWidth();
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1753
diff changeset
351 lineColor = ta.parseLineColorField();
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1753
diff changeset
352 textColor = ta.parseTextColor();
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1753
diff changeset
353 font = ta.parseTextFont();
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1753
diff changeset
354 textOrientation = ta.parseTextOrientation();
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1753
diff changeset
355 textBackground = ta.parseTextBackground();
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1753
diff changeset
356 showBackground = ta.parseShowTextBackground();
1738
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1711
diff changeset
357 }
1039
cf39205df113 Part of refactoring (see next commit).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
358 }
1711
f708120cb7bc Fix flys/issue363 (W-INFO/ Abflusskurve, Extremwert-Rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1167
diff changeset
359 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org