comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java @ 1082:f16b66839e59

Prepare StickyAxisAnnotation implementation to handle annotations at 'y' (vertical) axis. flys-artifacts/trunk@2579 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 25 Aug 2011 10:50:30 +0000
parents 8873c43119ca
children 07878836ee0d
comparison
equal deleted inserted replaced
1081:d10efbe2e5c0 1082:f16b66839e59
18 import org.jfree.chart.plot.PlotRenderingInfo; 18 import org.jfree.chart.plot.PlotRenderingInfo;
19 import org.jfree.chart.ChartRenderingInfo; 19 import org.jfree.chart.ChartRenderingInfo;
20 import org.jfree.chart.plot.Plot; 20 import org.jfree.chart.plot.Plot;
21 21
22 import org.jfree.ui.RectangleEdge; 22 import org.jfree.ui.RectangleEdge;
23 import org.jfree.ui.TextAnchor;
23 24
24 25
25 /** 26 /**
26 * Custom Annotations class that is drawn only if no collisions with other 27 * Custom Annotations class that is drawn only if no collisions with other
27 * already drawn CustomAnnotations in current plot are found. 28 * already drawn CustomAnnotations in current plot are found.
50 * @param x X-position in dataspace (typical horizontal, in km). 51 * @param x X-position in dataspace (typical horizontal, in km).
51 * @param y Y-position in dataspace (typical vertical, in m). 52 * @param y Y-position in dataspace (typical vertical, in m).
52 */ 53 */
53 public StickyAxisAnnotation(String text, float x, float y) { 54 public StickyAxisAnnotation(String text, float x, float y) {
54 super(text, x, y); 55 super(text, x, y);
55 } 56 setStickyAxis(SimpleAxis.X_AXIS);
57 }
58
59 public StickyAxisAnnotation(String text, float x, float y,
60 SimpleAxis stickAxis) {
61 super(text, x, y);
62 setStickyAxis(stickAxis);
63 }
64
56 65
57 66
58 /** 67 /**
59 * Sets the "sticky axis" (whether to draw annotations at the 68 * Sets the "sticky axis" (whether to draw annotations at the
60 * X- or the Y-Axis. 69 * X- or the Y-Axis.
61 * 70 *
62 * @param stickyAxis axis to stick to. 71 * @param stickyAxis axis to stick to.
63 */ 72 */
64 public void setStickyAxis(SimpleAxis stickyAxis) { 73 public void setStickyAxis(SimpleAxis stickyAxis) {
65 this.stickyAxis = stickyAxis; 74 this.stickyAxis = stickyAxis;
75 if (stickyAxis == SimpleAxis.X_AXIS) {
76 this.setRotationAngle(270f * (Math.PI / 180f));
77 this.setRotationAnchor(TextAnchor.CENTER_LEFT);
78 this.setTextAnchor(TextAnchor.CENTER_LEFT);
79 }
66 } 80 }
67 81
68 82
69 /** 83 /**
70 * Draws a small line at axis where this annotation resides. 84 * Draws a small line at axis where this annotation resides.

http://dive4elements.wald.intevation.org