annotate flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java @ 3077:5c87d4ca1bd3

Added chart and export generator stubs for SQ relation. flys-artifacts/trunk@4672 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 15 Jun 2012 10:17:22 +0000
parents 5642a83420f2
children 4bd3d8bbb60c
rev   line source
3018
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.jfree;
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import java.awt.Shape;
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4 import java.awt.geom.Rectangle2D;
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6 import java.util.Iterator;
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8 import org.jfree.chart.entity.ChartEntity;
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
9 import org.jfree.chart.entity.EntityCollection;
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 public class JFreeUtil {
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3023
diff changeset
12
3018
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 /** Do not instantiate. */
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 private JFreeUtil() {
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 }
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 /**
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 * True if \param hotspot collides with a Entity in \param entities.
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 * @param hotspot Shape to compare against other shapes (bounds only).
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 * @param entities entities against which to compare shape.
3023
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
22 * @param exclusiveEntityClass If not null, consider only entities of
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
23 * given class.
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
24 * @return true if a collision (non-zero intersection) exists between
3018
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 * shapes.
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 */
3023
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
27 public static boolean collides(Shape hotspot, EntityCollection entities,
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
28 Class exclusiveEntityClass) {
3018
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 if (entities == null) return false;
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 Rectangle2D hotspotBox = hotspot.getBounds2D();
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3023
diff changeset
32
3018
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 for (Iterator i = entities.iterator(); i.hasNext(); ) {
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 Object next = i.next();
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 ChartEntity entity = (ChartEntity) next;
3023
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
36 if (exclusiveEntityClass == null
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
37 || exclusiveEntityClass.isInstance(entity))
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
38 {
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
39 if (entity.getArea().intersects(hotspotBox)) {
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
40 // Found collision, early stop.
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
41 return true;
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3018
diff changeset
42 }
3018
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 }
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 }
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 return false;
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 }
fb07f936b5ad New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 }

http://dive4elements.wald.intevation.org