diff flys-artifacts/src/main/java/de/intevation/flys/jfree/CollisionFreeXYTextAnnotation.java @ 3023:e19ff9086035

Avoid collisions between line labels. flys-artifacts/trunk@4590 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 05 Jun 2012 15:03:11 +0000
parents 0b8c04c7f762
children 65b6e27c6f25
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/CollisionFreeXYTextAnnotation.java	Tue Jun 05 14:56:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/CollisionFreeXYTextAnnotation.java	Tue Jun 05 15:03:11 2012 +0000
@@ -20,6 +20,8 @@
 
 import org.jfree.ui.RectangleEdge;
 
+import de.intevation.flys.jfree.JFreeUtil;
+
 
 /**
  * Custom Annotations class that is drawn only if no collisions with other
@@ -87,17 +89,9 @@
         // Deviation from superclass: prevent collision.
         Rectangle2D hotspotBox = hotspot.getBounds2D();
 
-        for (Iterator i = info.getOwner().getEntityCollection().iterator();
-                i.hasNext(); ) {
-            Object next = i.next();
-            // Collision with other stuff than XYAnnotations are okay.
-            if (next instanceof CollisionFreeXYTextAnnotationEntity) {
-                XYAnnotationEntity drawnShape = (XYAnnotationEntity) next;
-                if (drawnShape.getArea().intersects(hotspotBox)) {
-                    // Found collision, early stop.
-                    return;
-                }
-            }
+        if (JFreeUtil.collides(hotspot, info.getOwner().getEntityCollection(),
+            XYAnnotationEntity.class)) {
+            return;
         }
 
         if (this.getBackgroundPaint() != null) {

http://dive4elements.wald.intevation.org