comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/CollisionFreeXYTextAnnotation.java @ 2161:c68f4f227c09

Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation. flys-artifacts/trunk@3747 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 23 Jan 2012 10:44:34 +0000
parents c4ceade9d50e
children 0b8c04c7f762
comparison
equal deleted inserted replaced
2160:8428de5846e8 2161:c68f4f227c09
4 4
5 import java.util.Iterator; 5 import java.util.Iterator;
6 6
7 import java.awt.Shape; 7 import java.awt.Shape;
8 import java.awt.geom.Rectangle2D; 8 import java.awt.geom.Rectangle2D;
9 import java.awt.Color;
10 import java.awt.Font;
11 import java.awt.BasicStroke;
12 9
13 import org.jfree.chart.annotations.XYTextAnnotation; 10 import org.jfree.chart.annotations.XYTextAnnotation;
14 import org.jfree.chart.axis.ValueAxis; 11 import org.jfree.chart.axis.ValueAxis;
15 import org.jfree.chart.plot.PlotOrientation; 12 import org.jfree.chart.plot.PlotOrientation;
16 import org.jfree.chart.plot.XYPlot; 13 import org.jfree.chart.plot.XYPlot;
20 17
21 import org.jfree.text.TextUtilities; 18 import org.jfree.text.TextUtilities;
22 19
23 import org.jfree.ui.RectangleEdge; 20 import org.jfree.ui.RectangleEdge;
24 21
25 import de.intevation.flys.utils.ThemeAccess;
26 22
27 /** 23 /**
28 * Custom Annotations class that is drawn only if no collisions with other 24 * Custom Annotations class that is drawn only if no collisions with other
29 * already drawn CustomAnnotations in current plot are found. 25 * already drawn CustomAnnotations in current plot are found.
30 */ 26 */
32 28
33 /** Logger for this class. */ 29 /** Logger for this class. */
34 private static Logger logger = 30 private static Logger logger =
35 Logger.getLogger(CollisionFreeXYTextAnnotation.class); 31 Logger.getLogger(CollisionFreeXYTextAnnotation.class);
36 32
37 public CollisionFreeXYTextAnnotation(String text, float x, double y) { 33
34 public CollisionFreeXYTextAnnotation(String text, double x, double y) {
38 super(text, x, y); 35 super(text, x, y);
39 } 36 }
40 37
41 38
42 /** 39 /**
86 getText(), g2, anchorX, anchorY, getTextAnchor(), 83 getText(), g2, anchorX, anchorY, getTextAnchor(),
87 getRotationAngle(), getRotationAnchor()); 84 getRotationAngle(), getRotationAnchor());
88 85
89 // Deviation from superclass: prevent collision. 86 // Deviation from superclass: prevent collision.
90 Rectangle2D hotspotBox = hotspot.getBounds2D(); 87 Rectangle2D hotspotBox = hotspot.getBounds2D();
88
91 for (Iterator i = info.getOwner().getEntityCollection().iterator(); 89 for (Iterator i = info.getOwner().getEntityCollection().iterator();
92 i.hasNext(); ) { 90 i.hasNext(); ) {
93 Object next = i.next(); 91 Object next = i.next();
94 // Collision with other stuff than XYAnnotations are okay. 92 // Collision with other stuff than XYAnnotations are okay.
95 if (next instanceof XYAnnotationEntity) { 93 if (next instanceof XYAnnotationEntity) {
123 addEntity(info, hotspot, rendererIndex, 121 addEntity(info, hotspot, rendererIndex,
124 "CollisionFreeXYTextAnnotation", 122 "CollisionFreeXYTextAnnotation",
125 "CollisionFreeXYTextAnnotation"); 123 "CollisionFreeXYTextAnnotation");
126 } 124 }
127 } 125 }
128
129
130 /*
131 public void applyTheme(ThemeAccess ta) {
132 lineWidth = ta.parseLineWidth();
133 lineColor = ta.parseLineColorField();
134 textColor = ta.parseTextColor();
135 font = ta.parseTextFont();
136 textOrientation = ta.parseTextOrientation();
137 textBackground = ta.parseTextBackground();
138 showBackground = ta.parseShowTextBackground();
139 }
140 */
141 } 126 }
142 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 127 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org