Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/jfree/CollisionFreeXYTextAnnotation.java @ 8341:130160b8d245
Introduce annotations, which know to which axis they belong.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 30 Sep 2014 11:50:43 +0200 |
parents | af13ceeba52a |
children | 0beb34d55630 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4048
diff
changeset
|
9 package org.dive4elements.river.jfree; |
2157
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import java.awt.Shape; |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 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
|
13 |
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
|
14 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
|
15 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
|
16 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
|
17 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
|
18 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
|
19 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
|
20 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
|
21 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
|
22 |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 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
|
24 |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 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
|
26 |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 /** |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 * 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
|
29 * 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
|
30 */ |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 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
|
32 |
2161
c68f4f227c09
Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2157
diff
changeset
|
33 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
|
34 super(text, x, y); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 } |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 /** |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 * 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
|
40 * already drawn Annotations- texts. |
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 * @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
|
43 * @param plot the plot. |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 * @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
|
45 * @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
|
46 * @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
|
47 * @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
|
48 * @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
|
49 * 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
|
50 * for collision detection. |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 */ |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 @Override |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 public void draw( |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 java.awt.Graphics2D g2, |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 XYPlot plot, |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 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
|
57 ValueAxis domainAxis, |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 ValueAxis rangeAxis, |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 int rendererIndex, |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 PlotRenderingInfo info |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 ) { |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 // 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
|
63 PlotOrientation orientation = plot.getOrientation(); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 plot.getDomainAxisLocation(), orientation); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 plot.getRangeAxisLocation(), orientation); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 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
|
70 this.getX(), dataArea, domainEdge); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 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
|
72 this.getY(), dataArea, rangeEdge); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 if (orientation == PlotOrientation.HORIZONTAL) { |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 float tempAnchor = anchorX; |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 anchorX = anchorY; |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 anchorY = tempAnchor; |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 } |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
79 |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 g2.setFont(getFont()); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 Shape hotspot = TextUtilities.calculateRotatedStringBounds( |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 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
|
83 getRotationAngle(), getRotationAnchor()); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 // Deviation from superclass: prevent collision. |
3023
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2318
diff
changeset
|
86 if (JFreeUtil.collides(hotspot, info.getOwner().getEntityCollection(), |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2318
diff
changeset
|
87 XYAnnotationEntity.class)) { |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2318
diff
changeset
|
88 return; |
2157
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
89 } |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
90 |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
91 if (this.getBackgroundPaint() != null) { |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 g2.setPaint(this.getBackgroundPaint()); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
93 g2.fill(hotspot); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 } |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 g2.setPaint(getPaint()); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 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
|
97 getTextAnchor(), getRotationAngle(), getRotationAnchor()); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 if (this.isOutlineVisible()) { |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 g2.setStroke(this.getOutlineStroke()); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
100 g2.setPaint(this.getOutlinePaint()); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
101 g2.draw(hotspot); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 } |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
103 |
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
|
104 //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
|
105 //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
|
106 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
|
107 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
|
108 |
2157
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
109 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
|
110 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
|
111 } |
4048
6ed8ebd48d6e
Removed dead code.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3317
diff
changeset
|
112 // XXX: DEAD CODE (as long as a hard value is assigned to toolTip |
6ed8ebd48d6e
Removed dead code.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3317
diff
changeset
|
113 /* |
2157
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
114 else { |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
115 addEntity(info, hotspot, rendererIndex, |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
116 "CollisionFreeXYTextAnnotation", |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
117 "CollisionFreeXYTextAnnotation"); |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
118 } |
4048
6ed8ebd48d6e
Removed dead code.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3317
diff
changeset
|
119 */ |
2157
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
120 } |
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
|
121 |
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
|
122 /** |
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
|
123 * 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
|
124 * 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
|
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 * @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
|
127 * @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
|
128 * @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
|
129 * @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
|
130 * @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
|
131 */ |
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 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
|
133 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
|
134 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
|
135 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
|
136 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
|
137 } |
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 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
|
139 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
|
140 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
|
141 } |
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 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
|
143 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
|
144 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
|
145 entities.add(entity); |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3026
diff
changeset
|
146 } |
2157
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
147 } |
c4ceade9d50e
Added new Annotation class that prevents collisions (to replace StickyAxisAnnotation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
148 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |