Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java @ 3194:e815cf20bab2
Add point labels to W/Q curve
flys-artifacts/trunk@4810 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Wed, 27 Jun 2012 14:48:35 +0000 |
parents | 2f922be407ea |
children | 099f18a4e227 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Wed Jun 27 13:45:55 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Wed Jun 27 14:48:35 2012 +0000 @@ -11,13 +11,21 @@ import de.intevation.flys.exports.ChartGenerator; +import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation; +import de.intevation.flys.jfree.FLYSAnnotation; import de.intevation.flys.jfree.JFreeUtil; import de.intevation.flys.jfree.StyledXYSeries; +import java.util.ArrayList; +import java.util.List; + import org.apache.log4j.Logger; +import org.jfree.chart.annotations.XYTextAnnotation; + import org.jfree.data.xy.XYSeries; + import org.w3c.dom.Document; public class FixWQCurveGenerator @@ -88,11 +96,8 @@ logger.debug("doSectorAverageOut"); QWD qwd = (QWD)aaf.getData(context); - if(qwd != null) { - XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc); - series.add(qwd.getQ(), qwd.getW()); - addAxisSeries(series, 0, visible); + addQWSeries(new QWD[] { qwd }, aaf, doc, visible); } else { logger.debug("doSectorAverageOut: qwd == null"); @@ -101,16 +106,11 @@ /** Add analysis event points to chart */ protected void doAnalysisEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible) { - logger.debug("doAnalysisEventsOut"); + logger.debug("doAnalysisEventsOut"); - QWD[] qwds = (QWD[])aaf.getData(context); - if(qwds != null) { - XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc); - for(QWD qwd : qwds) { - series.add(qwd.getQ(), qwd.getW()); - } - - addAxisSeries(series, 0, visible); + QWD[] qwds = (QWD[])aaf.getData(context); + if(qwds != null) { + addQWSeries(qwds, aaf, doc, visible); } else { logger.debug("doAnalysisEventsOut: qwds == null"); @@ -145,7 +145,7 @@ doc, aaf.getFacetDescription(), 500, // number of samples - 0.0 , // start + 0.0 , // start func.getMaxQ()); // end addAxisSeries(series, 0, visible); @@ -165,11 +165,27 @@ protected void addQWSeries(QW[] qws, ArtifactAndFacet aaf, Document doc, boolean visible) { if(qws != null) { XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc); + List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>(); + for(QW qw : qws) { series.add(qw.getQ(), qw.getW()); + + StringBuilder label = new StringBuilder(); + label.append(qw.getDate()); + label.append(" "); + label.append(qw.getDescription()); + + XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( + label.toString(), + qw.getQ(), + qw.getW()); + textAnnos.add(anno); } + FLYSAnnotation flysAnno = new FLYSAnnotation(null, null, null, doc); + flysAnno.setTextAnnotations(textAnnos); addAxisSeries(series, 0, visible); + addVisibleAnnotations(flysAnno); } }