Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
3193:2f922be407ea | 3194:e815cf20bab2 |
---|---|
9 import de.intevation.flys.artifacts.model.fixings.QW; | 9 import de.intevation.flys.artifacts.model.fixings.QW; |
10 import de.intevation.flys.artifacts.model.fixings.QWD; | 10 import de.intevation.flys.artifacts.model.fixings.QWD; |
11 | 11 |
12 import de.intevation.flys.exports.ChartGenerator; | 12 import de.intevation.flys.exports.ChartGenerator; |
13 | 13 |
14 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation; | |
15 import de.intevation.flys.jfree.FLYSAnnotation; | |
14 import de.intevation.flys.jfree.JFreeUtil; | 16 import de.intevation.flys.jfree.JFreeUtil; |
15 import de.intevation.flys.jfree.StyledXYSeries; | 17 import de.intevation.flys.jfree.StyledXYSeries; |
16 | 18 |
19 import java.util.ArrayList; | |
20 import java.util.List; | |
21 | |
17 import org.apache.log4j.Logger; | 22 import org.apache.log4j.Logger; |
18 | 23 |
24 import org.jfree.chart.annotations.XYTextAnnotation; | |
25 | |
19 import org.jfree.data.xy.XYSeries; | 26 import org.jfree.data.xy.XYSeries; |
27 | |
20 | 28 |
21 import org.w3c.dom.Document; | 29 import org.w3c.dom.Document; |
22 | 30 |
23 public class FixWQCurveGenerator | 31 public class FixWQCurveGenerator |
24 extends FixChartGenerator | 32 extends FixChartGenerator |
86 /** Add sector average points to chart */ | 94 /** Add sector average points to chart */ |
87 protected void doSectorAverageOut(ArtifactAndFacet aaf, Document doc, boolean visible) { | 95 protected void doSectorAverageOut(ArtifactAndFacet aaf, Document doc, boolean visible) { |
88 logger.debug("doSectorAverageOut"); | 96 logger.debug("doSectorAverageOut"); |
89 | 97 |
90 QWD qwd = (QWD)aaf.getData(context); | 98 QWD qwd = (QWD)aaf.getData(context); |
91 | |
92 if(qwd != null) { | 99 if(qwd != null) { |
93 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc); | 100 addQWSeries(new QWD[] { qwd }, aaf, doc, visible); |
94 series.add(qwd.getQ(), qwd.getW()); | |
95 addAxisSeries(series, 0, visible); | |
96 } | 101 } |
97 else { | 102 else { |
98 logger.debug("doSectorAverageOut: qwd == null"); | 103 logger.debug("doSectorAverageOut: qwd == null"); |
99 } | 104 } |
100 } | 105 } |
101 | 106 |
102 /** Add analysis event points to chart */ | 107 /** Add analysis event points to chart */ |
103 protected void doAnalysisEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible) { | 108 protected void doAnalysisEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible) { |
104 logger.debug("doAnalysisEventsOut"); | 109 logger.debug("doAnalysisEventsOut"); |
105 | 110 |
106 QWD[] qwds = (QWD[])aaf.getData(context); | 111 QWD[] qwds = (QWD[])aaf.getData(context); |
107 if(qwds != null) { | 112 if(qwds != null) { |
108 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc); | 113 addQWSeries(qwds, aaf, doc, visible); |
109 for(QWD qwd : qwds) { | |
110 series.add(qwd.getQ(), qwd.getW()); | |
111 } | |
112 | |
113 addAxisSeries(series, 0, visible); | |
114 } | 114 } |
115 else { | 115 else { |
116 logger.debug("doAnalysisEventsOut: qwds == null"); | 116 logger.debug("doAnalysisEventsOut: qwds == null"); |
117 } | 117 } |
118 } | 118 } |
143 StyledXYSeries series = JFreeUtil.sampleFunction2D( | 143 StyledXYSeries series = JFreeUtil.sampleFunction2D( |
144 func.getFunction(), | 144 func.getFunction(), |
145 doc, | 145 doc, |
146 aaf.getFacetDescription(), | 146 aaf.getFacetDescription(), |
147 500, // number of samples | 147 500, // number of samples |
148 0.0 , // start | 148 0.0 , // start |
149 func.getMaxQ()); // end | 149 func.getMaxQ()); // end |
150 | 150 |
151 addAxisSeries(series, 0, visible); | 151 addAxisSeries(series, 0, visible); |
152 } | 152 } |
153 else { | 153 else { |
163 } | 163 } |
164 | 164 |
165 protected void addQWSeries(QW[] qws, ArtifactAndFacet aaf, Document doc, boolean visible) { | 165 protected void addQWSeries(QW[] qws, ArtifactAndFacet aaf, Document doc, boolean visible) { |
166 if(qws != null) { | 166 if(qws != null) { |
167 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc); | 167 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc); |
168 List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>(); | |
169 | |
168 for(QW qw : qws) { | 170 for(QW qw : qws) { |
169 series.add(qw.getQ(), qw.getW()); | 171 series.add(qw.getQ(), qw.getW()); |
172 | |
173 StringBuilder label = new StringBuilder(); | |
174 label.append(qw.getDate()); | |
175 label.append(" "); | |
176 label.append(qw.getDescription()); | |
177 | |
178 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( | |
179 label.toString(), | |
180 qw.getQ(), | |
181 qw.getW()); | |
182 textAnnos.add(anno); | |
170 } | 183 } |
171 | 184 |
185 FLYSAnnotation flysAnno = new FLYSAnnotation(null, null, null, doc); | |
186 flysAnno.setTextAnnotations(textAnnos); | |
172 addAxisSeries(series, 0, visible); | 187 addAxisSeries(series, 0, visible); |
188 addVisibleAnnotations(flysAnno); | |
173 } | 189 } |
174 } | 190 } |
175 | 191 |
176 @Override | 192 @Override |
177 protected String getDefaultChartTitle() { | 193 protected String getDefaultChartTitle() { |