Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 1035:9f69a5f0af98
Started implementation of CustomAnnotation to plot collision-free annotations.
flys-artifacts/trunk@2496 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 16 Aug 2011 13:24:50 +0000 |
parents | bf3b3a8d089b |
children | e6aff80b59ff |
comparison
equal
deleted
inserted
replaced
1034:bf3b3a8d089b | 1035:9f69a5f0af98 |
---|---|
13 import org.jfree.chart.plot.XYPlot; | 13 import org.jfree.chart.plot.XYPlot; |
14 import org.jfree.chart.title.TextTitle; | 14 import org.jfree.chart.title.TextTitle; |
15 import org.jfree.data.Range; | 15 import org.jfree.data.Range; |
16 import org.jfree.data.xy.XYSeries; | 16 import org.jfree.data.xy.XYSeries; |
17 import org.jfree.ui.TextAnchor; | 17 import org.jfree.ui.TextAnchor; |
18 import org.jfree.chart.plot.PlotRenderingInfo; | |
18 | 19 |
19 import org.w3c.dom.Document; | 20 import org.w3c.dom.Document; |
20 | 21 |
21 import de.intevation.artifacts.Artifact; | 22 import de.intevation.artifacts.Artifact; |
22 | 23 |
26 | 27 |
27 import de.intevation.flys.artifacts.model.FacetTypes; | 28 import de.intevation.flys.artifacts.model.FacetTypes; |
28 import de.intevation.flys.artifacts.model.WQKms; | 29 import de.intevation.flys.artifacts.model.WQKms; |
29 | 30 |
30 import de.intevation.flys.model.Annotation; | 31 import de.intevation.flys.model.Annotation; |
32 | |
33 /** | |
34 * Custom annotations class that is drawn only if no collisions with other | |
35 * already drawn CustomAnnotations in current plot are found. | |
36 */ | |
37 class CustomAnnotation extends XYTextAnnotation{ | |
38 | |
39 /** | |
40 * Trivial constructor. | |
41 * | |
42 * @param text Text to display. | |
43 * @param x X-position in dataspace (typical horizontal, in km). | |
44 * @param y Y-position in dataspace (typical vertical, in m). | |
45 */ | |
46 public CustomAnnotation(String text, float x, float y) { | |
47 super(text, x, y); | |
48 } | |
49 | |
50 | |
51 /** | |
52 * Yet trivial draw without implementing any CustomAnnotation-specific | |
53 * feature. | |
54 */ | |
55 public void draw( | |
56 java.awt.Graphics2D g2, | |
57 XYPlot plot, | |
58 java.awt.geom.Rectangle2D dataArea, | |
59 ValueAxis domainAxis, | |
60 ValueAxis rangeAxis, | |
61 int rendererIndex, | |
62 PlotRenderingInfo info) { | |
63 super.draw(g2, plot, dataArea, domainAxis, rangeAxis, rendererIndex, info); | |
64 } | |
65 } | |
66 | |
31 | 67 |
32 /** | 68 /** |
33 * An OutGenerator that generates discharge curves. | 69 * An OutGenerator that generates discharge curves. |
34 * | 70 * |
35 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 71 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
153 for (Annotation a: annotations) { | 189 for (Annotation a: annotations) { |
154 float posX = (float) a.getRange().getA().doubleValue(); | 190 float posX = (float) a.getRange().getA().doubleValue(); |
155 if (posX < freeFrom) { continue; } | 191 if (posX < freeFrom) { continue; } |
156 String text = a.getPosition().getValue(); | 192 String text = a.getPosition().getValue(); |
157 | 193 |
158 XYTextAnnotation ta = new XYTextAnnotation(text, posX, posY); | 194 XYTextAnnotation ta = new CustomAnnotation(text, posX, posY); |
159 double rotation = 270.0f * (Math.PI / 180.0f); | 195 double rotation = 270.0f * (Math.PI / 180.0f); |
160 ta.setRotationAngle(rotation); | 196 ta.setRotationAngle(rotation); |
161 ta.setRotationAnchor(TextAnchor.CENTER_LEFT); | 197 ta.setRotationAnchor(TextAnchor.CENTER_LEFT); |
162 ta.setTextAnchor(TextAnchor.CENTER_LEFT); | 198 ta.setTextAnchor(TextAnchor.CENTER_LEFT); |
163 plot.getRenderer().addAnnotation(ta); | 199 plot.getRenderer().addAnnotation(ta); |