changeset 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
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java
diffstat 2 files changed, 44 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Aug 16 11:43:47 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Aug 16 13:24:50 2011 +0000
@@ -1,3 +1,10 @@
+2011-08-16  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Implemented (yet dummy) custom Annotation class.
+
+	* src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java:
+	  Added implementation of yet dummy CustomAnnotation class.
+
 2011-08-16  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	Slightly improved rendering of annotations.
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Tue Aug 16 11:43:47 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Tue Aug 16 13:24:50 2011 +0000
@@ -15,6 +15,7 @@
 import org.jfree.data.Range;
 import org.jfree.data.xy.XYSeries;
 import org.jfree.ui.TextAnchor;
+import org.jfree.chart.plot.PlotRenderingInfo;
 
 import org.w3c.dom.Document;
 
@@ -30,6 +31,41 @@
 import de.intevation.flys.model.Annotation;
 
 /**
+ * Custom annotations class that is drawn only if no collisions with other
+ * already drawn CustomAnnotations in current plot are found.
+ */
+class CustomAnnotation extends XYTextAnnotation{
+
+    /**
+     * Trivial constructor.
+     *
+     * @param text Text to display.
+     * @param x    X-position in dataspace (typical horizontal, in km).
+     * @param y    Y-position in dataspace (typical vertical, in m).
+     */
+    public CustomAnnotation(String text, float x, float y) {
+        super(text, x, y);
+    }
+
+
+    /**
+     * Yet trivial draw without implementing any CustomAnnotation-specific
+     * feature.
+     */
+    public void draw(
+       java.awt.Graphics2D g2,
+       XYPlot plot,
+       java.awt.geom.Rectangle2D dataArea,
+       ValueAxis domainAxis,
+       ValueAxis rangeAxis,
+       int rendererIndex,
+       PlotRenderingInfo info) {
+        super.draw(g2, plot, dataArea, domainAxis, rangeAxis, rendererIndex, info);
+    }
+}
+
+
+/**
  * An OutGenerator that generates discharge curves.
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
@@ -155,7 +191,7 @@
             if (posX < freeFrom) { continue; }
             String text = a.getPosition().getValue();
 
-            XYTextAnnotation ta = new XYTextAnnotation(text, posX, posY);
+            XYTextAnnotation ta = new CustomAnnotation(text, posX, posY);
             double rotation = 270.0f * (Math.PI / 180.0f);
             ta.setRotationAngle(rotation);
             ta.setRotationAnchor(TextAnchor.CENTER_LEFT);

http://dive4elements.wald.intevation.org