Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
1027:a60d2a46f0a8 | 1028:10bafb4f46cc |
---|---|
1 package de.intevation.flys.exports; | 1 package de.intevation.flys.exports; |
2 | 2 |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
3 import org.apache.log4j.Logger; | 6 import org.apache.log4j.Logger; |
4 | 7 |
8 import org.jfree.chart.annotations.XYLineAnnotation; | |
9 import org.jfree.chart.annotations.XYTextAnnotation; | |
5 import org.jfree.chart.JFreeChart; | 10 import org.jfree.chart.JFreeChart; |
6 import org.jfree.chart.axis.NumberAxis; | 11 import org.jfree.chart.axis.NumberAxis; |
7 import org.jfree.chart.axis.ValueAxis; | 12 import org.jfree.chart.axis.ValueAxis; |
8 import org.jfree.chart.plot.XYPlot; | 13 import org.jfree.chart.plot.XYPlot; |
9 import org.jfree.chart.title.TextTitle; | 14 import org.jfree.chart.title.TextTitle; |
19 import de.intevation.flys.artifacts.FLYSArtifact; | 24 import de.intevation.flys.artifacts.FLYSArtifact; |
20 | 25 |
21 import de.intevation.flys.artifacts.model.FacetTypes; | 26 import de.intevation.flys.artifacts.model.FacetTypes; |
22 import de.intevation.flys.artifacts.model.WQKms; | 27 import de.intevation.flys.artifacts.model.WQKms; |
23 | 28 |
29 import de.intevation.flys.model.Annotation; | |
24 | 30 |
25 /** | 31 /** |
26 * An OutGenerator that generates discharge curves. | 32 * An OutGenerator that generates discharge curves. |
27 * | 33 * |
28 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 34 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
56 public static final String I18N_2YAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; | 62 public static final String I18N_2YAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; |
57 | 63 |
58 | 64 |
59 protected boolean inverted; | 65 protected boolean inverted; |
60 | 66 |
67 protected List<Annotation> annotations; | |
61 | 68 |
62 public LongitudinalSectionGenerator() { | 69 public LongitudinalSectionGenerator() { |
63 super(); | 70 super(); |
71 annotations = new ArrayList<Annotation>(); | |
64 } | 72 } |
65 | 73 |
66 | 74 |
67 protected String getChartTitle() { | 75 protected String getChartTitle() { |
68 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | 76 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); |
88 | 96 |
89 String subtitle = msg(I18N_CHART_SUBTITLE, "", args); | 97 String subtitle = msg(I18N_CHART_SUBTITLE, "", args); |
90 chart.addSubtitle(new TextTitle(subtitle)); | 98 chart.addSubtitle(new TextTitle(subtitle)); |
91 } | 99 } |
92 | 100 |
101 @Override | |
102 public JFreeChart generateChart() { | |
103 JFreeChart c = super.generateChart(); | |
104 XYPlot p = (XYPlot) c.getPlot(); | |
105 | |
106 for (Annotation a: annotations) { | |
107 double pos = a.getRange().getA().doubleValue(); | |
108 XYTextAnnotation ta = new XYTextAnnotation(a.getPosition().getValue(), pos, 140); | |
109 ta.setRotationAngle(270.0 / (Math.PI * 2.0)); | |
110 p.addAnnotation(ta); | |
111 XYLineAnnotation la = new XYLineAnnotation(pos, 0, pos, 140); | |
112 p.addAnnotation(la); | |
113 } | |
114 return c; | |
115 } | |
116 | |
93 | 117 |
94 protected String getXAxisLabel() { | 118 protected String getXAxisLabel() { |
95 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); | 119 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); |
96 } | 120 } |
97 | 121 |
165 doWOut((WQKms) f.getData(artifact, context), attr); | 189 doWOut((WQKms) f.getData(artifact, context), attr); |
166 } | 190 } |
167 else if (name.equals(LONGITUDINAL_Q)) { | 191 else if (name.equals(LONGITUDINAL_Q)) { |
168 doQOut((WQKms) f.getData(artifact, context), attr); | 192 doQOut((WQKms) f.getData(artifact, context), attr); |
169 } | 193 } |
194 else if (name.equals(LONGITUDINAL_ANNOTATION)) { | |
195 doAnnotationsOut(f.getData(artifact, context), attr); | |
196 } | |
170 else { | 197 else { |
171 logger.warn("Unknown facet name: " + name); | 198 logger.warn("Unknown facet name: " + name); |
172 return; | 199 return; |
173 } | 200 } |
201 } | |
202 | |
203 | |
204 protected void doAnnotationsOut(Object o, Document theme) { | |
205 logger.debug("LongitudinalSectionGenerator.doAnnotationsOut"); | |
206 this.annotations = (List<Annotation>) o; | |
174 } | 207 } |
175 | 208 |
176 | 209 |
177 /** | 210 /** |
178 * Process the output for W facets in a longitudinal section curve. | 211 * Process the output for W facets in a longitudinal section curve. |