annotate 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
rev   line source
2157
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.jfree;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import org.apache.log4j.Logger;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5 import java.util.Iterator;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7 import java.awt.Shape;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8 import java.awt.geom.Rectangle2D;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
9
2318
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
10 import org.jfree.chart.entity.EntityCollection;
2157
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import org.jfree.chart.annotations.XYTextAnnotation;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 import org.jfree.chart.axis.ValueAxis;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import org.jfree.chart.plot.PlotOrientation;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import org.jfree.chart.plot.XYPlot;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import org.jfree.chart.entity.XYAnnotationEntity;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 import org.jfree.chart.plot.PlotRenderingInfo;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import org.jfree.chart.plot.Plot;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import org.jfree.text.TextUtilities;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 import org.jfree.ui.RectangleEdge;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22
3023
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2318
diff changeset
23 import de.intevation.flys.jfree.JFreeUtil;
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2318
diff changeset
24
2157
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 /**
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 * Custom Annotations class that is drawn only if no collisions with other
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 * already drawn CustomAnnotations in current plot are found.
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 */
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30 public class CollisionFreeXYTextAnnotation extends XYTextAnnotation {
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 /** Logger for this class. */
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 private static Logger logger =
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 Logger.getLogger(CollisionFreeXYTextAnnotation.class);
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2157
diff changeset
36
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2157
diff changeset
37 public CollisionFreeXYTextAnnotation(String text, double x, double y) {
2157
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 super(text, x, y);
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 }
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 /**
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 * Draw the Annotation only if it does not collide with other
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 * already drawn Annotations- texts.
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 *
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 * @param g2 the graphics device.
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 * @param plot the plot.
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 * @param dataArea the data area.
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 * @param domainAxis the domain axis.
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 * @param rangeAxis the range axis.
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 * @param rendererIndex the render index.
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 * @param info state information, escpecially collects info about
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 * already drawn shapes (and thus annotations), used
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 * for collision detection.
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 */
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 @Override
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 public void draw(
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 java.awt.Graphics2D g2,
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 XYPlot plot,
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 java.awt.geom.Rectangle2D dataArea,
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 ValueAxis domainAxis,
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 ValueAxis rangeAxis,
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 int rendererIndex,
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 PlotRenderingInfo info
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65 ) {
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 // From superclass, adjusted access only.
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 PlotOrientation orientation = plot.getOrientation();
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 plot.getDomainAxisLocation(), orientation);
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 plot.getRangeAxisLocation(), orientation);
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 float anchorX = (float) domainAxis.valueToJava2D(
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 this.getX(), dataArea, domainEdge);
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 float anchorY = (float) rangeAxis.valueToJava2D(
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 this.getY(), dataArea, rangeEdge);
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 if (orientation == PlotOrientation.HORIZONTAL) {
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 float tempAnchor = anchorX;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80 anchorX = anchorY;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 anchorY = tempAnchor;
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 }
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84 g2.setFont(getFont());
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 Shape hotspot = TextUtilities.calculateRotatedStringBounds(
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 getText(), g2, anchorX, anchorY, getTextAnchor(),
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 getRotationAngle(), getRotationAnchor());
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
88
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
89 // Deviation from superclass: prevent collision.
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
90 Rectangle2D hotspotBox = hotspot.getBounds2D();
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2157
diff changeset
91
3023
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2318
diff changeset
92 if (JFreeUtil.collides(hotspot, info.getOwner().getEntityCollection(),
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2318
diff changeset
93 XYAnnotationEntity.class)) {
e19ff9086035 Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2318
diff changeset
94 return;
2157
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
95 }
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
96
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
97 if (this.getBackgroundPaint() != null) {
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
98 g2.setPaint(this.getBackgroundPaint());
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
99 g2.fill(hotspot);
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 }
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 g2.setPaint(getPaint());
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102 TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY,
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
103 getTextAnchor(), getRotationAngle(), getRotationAnchor());
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
104 if (this.isOutlineVisible()) {
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
105 g2.setStroke(this.getOutlineStroke());
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
106 g2.setPaint(this.getOutlinePaint());
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
107 g2.draw(hotspot);
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
108 }
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
109
2318
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
110 //String toolTip = getToolTipText();
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
111 //String url = getURL();
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
112 String toolTip = "CollisionFreeXYTextAnnotation";
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
113 String url = toolTip;
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
114
2157
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
115 if (toolTip != null || url != null) {
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
116 addEntity(info, hotspot, rendererIndex, toolTip, url);
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
117 }
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
118 else {
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
119 addEntity(info, hotspot, rendererIndex,
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
120 "CollisionFreeXYTextAnnotation",
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
121 "CollisionFreeXYTextAnnotation");
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
122 }
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
123 }
2318
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
124
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
125 /**
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
126 * A utility method for adding an {@link CollisionFreeXYAnnotationEntity} to
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
127 * a {@link PlotRenderingInfo} instance.
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
128 *
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
129 * @param info the plot rendering info (<code>null</code> permitted).
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
130 * @param hotspot the hotspot area.
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
131 * @param rendererIndex the renderer index.
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
132 * @param toolTipText the tool tip text.
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
133 * @param urlText the URL text.
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
134 */
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
135 protected void addEntity(PlotRenderingInfo info,
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
136 Shape hotspot, int rendererIndex,
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
137 String toolTipText, String urlText) {
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
138 if (info == null) {
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
139 return;
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
140 }
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
141 EntityCollection entities = info.getOwner().getEntityCollection();
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
142 if (entities == null) {
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
143 return;
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
144 }
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
145 CollisionFreeXYTextAnnotationEntity entity =
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
146 new CollisionFreeXYTextAnnotationEntity(hotspot,
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
147 rendererIndex, toolTipText, urlText);
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
148 entities.add(entity);
0b8c04c7f762 Avoid that annotations like the ones used for hyks prevent manual point text annotation rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
149 }
2157
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
150 }
c4ceade9d50e Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
151 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org