Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.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 | fb07f936b5ad |
children | 5642a83420f2 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java Tue Jun 05 14:56:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java Tue Jun 05 15:03:11 2012 +0000 @@ -19,10 +19,13 @@ * True if \param hotspot collides with a Entity in \param entities. * @param hotspot Shape to compare against other shapes (bounds only). * @param entities entities against which to compare shape. - * @param true if a collision (non-zero intersection) exists between + * @param exclusiveEntityClass If not null, consider only entities of + * given class. + * @return true if a collision (non-zero intersection) exists between * shapes. */ - public static boolean collides(Shape hotspot, EntityCollection entities) { + public static boolean collides(Shape hotspot, EntityCollection entities, + Class exclusiveEntityClass) { if (entities == null) return false; Rectangle2D hotspotBox = hotspot.getBounds2D(); @@ -30,9 +33,13 @@ for (Iterator i = entities.iterator(); i.hasNext(); ) { Object next = i.next(); ChartEntity entity = (ChartEntity) next; - if (entity.getArea().intersects(hotspotBox)) { - // Found collision, early stop. - return true; + if (exclusiveEntityClass == null + || exclusiveEntityClass.isInstance(entity)) + { + if (entity.getArea().intersects(hotspotBox)) { + // Found collision, early stop. + return true; + } } }