Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 1028:10bafb4f46cc
Made (kind of dummy-) Annotations in LongitudinalSection diagrams visible.
flys-artifacts/trunk@2488 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 11 Aug 2011 12:48:31 +0000 |
parents | 0cb1a70b8b92 |
children | bf3b3a8d089b |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Thu Aug 11 12:43:00 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Thu Aug 11 12:48:31 2011 +0000 @@ -1,7 +1,12 @@ package de.intevation.flys.exports; +import java.util.ArrayList; +import java.util.List; + import org.apache.log4j.Logger; +import org.jfree.chart.annotations.XYLineAnnotation; +import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; @@ -21,6 +26,7 @@ import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.WQKms; +import de.intevation.flys.model.Annotation; /** * An OutGenerator that generates discharge curves. @@ -58,9 +64,11 @@ protected boolean inverted; + protected List<Annotation> annotations; public LongitudinalSectionGenerator() { super(); + annotations = new ArrayList<Annotation>(); } @@ -90,6 +98,22 @@ chart.addSubtitle(new TextTitle(subtitle)); } + @Override + public JFreeChart generateChart() { + JFreeChart c = super.generateChart(); + XYPlot p = (XYPlot) c.getPlot(); + + for (Annotation a: annotations) { + double pos = a.getRange().getA().doubleValue(); + XYTextAnnotation ta = new XYTextAnnotation(a.getPosition().getValue(), pos, 140); + ta.setRotationAngle(270.0 / (Math.PI * 2.0)); + p.addAnnotation(ta); + XYLineAnnotation la = new XYLineAnnotation(pos, 0, pos, 140); + p.addAnnotation(la); + } + return c; + } + protected String getXAxisLabel() { return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); @@ -167,6 +191,9 @@ else if (name.equals(LONGITUDINAL_Q)) { doQOut((WQKms) f.getData(artifact, context), attr); } + else if (name.equals(LONGITUDINAL_ANNOTATION)) { + doAnnotationsOut(f.getData(artifact, context), attr); + } else { logger.warn("Unknown facet name: " + name); return; @@ -174,6 +201,12 @@ } + protected void doAnnotationsOut(Object o, Document theme) { + logger.debug("LongitudinalSectionGenerator.doAnnotationsOut"); + this.annotations = (List<Annotation>) o; + } + + /** * Process the output for W facets in a longitudinal section curve. *