# HG changeset patch # User Felix Wolfsteller # Date 1313501090 0 # Node ID 9f69a5f0af98f3bb1251f2e31b4e9b96a70a4f59 # Parent bf3b3a8d089bc90750b97c345b648f0b41e8caee Started implementation of CustomAnnotation to plot collision-free annotations. flys-artifacts/trunk@2496 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r bf3b3a8d089b -r 9f69a5f0af98 flys-artifacts/ChangeLog --- 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 + + 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 Slightly improved rendering of annotations. diff -r bf3b3a8d089b -r 9f69a5f0af98 flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java --- 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 Ingo Weinzierl @@ -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);