Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.exports; | |
2 | |
3 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
4 import org.dive4elements.river.artifacts.FLYSArtifact; | |
5 import org.dive4elements.river.artifacts.model.FacetTypes; | |
6 import org.dive4elements.river.artifacts.model.WQKms; | |
7 import org.dive4elements.river.jfree.Bounds; | |
8 import org.dive4elements.river.jfree.FLYSAnnotation; | |
9 import org.dive4elements.river.jfree.StyledXYSeries; | |
10 import org.dive4elements.river.model.Gauge; | |
11 import org.dive4elements.river.model.River; | |
12 import org.dive4elements.river.utils.FLYSUtils; | |
13 | |
14 import org.apache.log4j.Logger; | |
15 import org.jfree.chart.axis.ValueAxis; | |
16 import org.jfree.chart.plot.XYPlot; | |
17 import org.jfree.data.Range; | |
18 import org.jfree.data.xy.XYSeries; | |
19 import org.w3c.dom.Document; | |
20 | |
21 | |
22 /** | |
23 * An OutGenerator that generates discharge curves. | |
24 * | |
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
26 */ | |
27 public class DischargeCurveGenerator | |
28 extends XYChartGenerator | |
29 implements FacetTypes { | |
30 | |
31 public static enum YAXIS { | |
32 W(0); | |
33 protected int idx; | |
34 private YAXIS(int c) { | |
35 idx = c; | |
36 } | |
37 } | |
38 | |
39 /** The logger used in this generator. */ | |
40 private static Logger logger = | |
41 Logger.getLogger(DischargeCurveGenerator.class); | |
42 | |
43 public static final String I18N_CHART_TITLE = | |
44 "chart.discharge.curve.title"; | |
45 | |
46 public static final String I18N_CHART_SUBTITLE = | |
47 "chart.discharge.curve.subtitle"; | |
48 | |
49 public static final String I18N_XAXIS_LABEL = | |
50 "chart.discharge.curve.xaxis.label"; | |
51 | |
52 public static final String I18N_YAXIS_LABEL = | |
53 "chart.discharge.curve.yaxis.label"; | |
54 | |
55 public static final String I18N_CHART_TITLE_DEFAULT = "Abflusskurven"; | |
56 public static final String I18N_XAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; | |
57 public static final String I18N_YAXIS_LABEL_DEFAULT = "W [cm]"; | |
58 | |
59 | |
60 public DischargeCurveGenerator() { | |
61 super(); | |
62 } | |
63 | |
64 | |
65 @Override | |
66 protected YAxisWalker getYAxisWalker() { | |
67 return new YAxisWalker() { | |
68 @Override | |
69 public int length() { | |
70 return YAXIS.values().length; | |
71 } | |
72 | |
73 @Override | |
74 public String getId(int idx) { | |
75 YAXIS[] yaxes = YAXIS.values(); | |
76 return yaxes[idx].toString(); | |
77 } | |
78 }; | |
79 } | |
80 | |
81 | |
82 /** | |
83 * Returns always null to suppress subtitles. | |
84 */ | |
85 @Override | |
86 protected String getDefaultChartTitle() { | |
87 return null; | |
88 } | |
89 | |
90 | |
91 @Override | |
92 protected String getDefaultXAxisLabel() { | |
93 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); | |
94 } | |
95 | |
96 @Override | |
97 protected String getDefaultYAxisLabel(int pos) { | |
98 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); | |
99 } | |
100 | |
101 | |
102 /* TODO is this one really needed? */ | |
103 @Override | |
104 protected boolean zoomX(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) { | |
105 boolean zoomin = super.zoom(plot, axis, bounds, x); | |
106 | |
107 if (!zoomin) { | |
108 axis.setLowerBound(0d); | |
109 } | |
110 | |
111 return zoomin; | |
112 } | |
113 | |
114 | |
115 @Override | |
116 public void doOut( | |
117 ArtifactAndFacet artifactFacet, | |
118 Document theme, | |
119 boolean visible | |
120 ) { | |
121 String name = artifactFacet.getFacetName(); | |
122 logger.debug("DischargeCurveGenerator.doOut: " + name); | |
123 | |
124 if (name.equals(DISCHARGE_CURVE) | |
125 || name.equals(GAUGE_DISCHARGE_CURVE)) { | |
126 doDischargeOut( | |
127 (FLYSArtifact)artifactFacet.getArtifact(), | |
128 artifactFacet.getData(context), | |
129 artifactFacet.getFacetDescription(), | |
130 theme, | |
131 visible); | |
132 } | |
133 else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_Q) | |
134 || name.equals(MAINVALUES_Q) | |
135 || name.equals(COMPUTED_DISCHARGE_MAINVALUES_W) | |
136 || name.equals(MAINVALUES_W)) | |
137 { | |
138 doAnnotations((FLYSAnnotation) artifactFacet.getData(context), | |
139 artifactFacet, theme, visible); | |
140 } | |
141 else if (FacetTypes.IS.MANUALPOINTS(name)) { | |
142 doPoints(artifactFacet.getData(context), | |
143 artifactFacet, | |
144 theme, visible, YAXIS.W.idx); | |
145 } | |
146 else { | |
147 logger.warn("DischargeCurveGenerator.doOut: Unknown facet name: " + name); | |
148 return; | |
149 } | |
150 } | |
151 | |
152 | |
153 /** | |
154 * Add series with discharge curve to diagram. | |
155 */ | |
156 protected void doDischargeOut( | |
157 FLYSArtifact artifact, | |
158 Object o, | |
159 String description, | |
160 Document theme, | |
161 boolean visible) | |
162 { | |
163 WQKms wqkms = (WQKms) o; | |
164 | |
165 String gaugeName = wqkms.getName(); | |
166 | |
167 River river = FLYSUtils.getRiver(artifact); | |
168 | |
169 if (river == null) { | |
170 logger.debug("no river found"); | |
171 return; | |
172 } | |
173 | |
174 Gauge gauge = river.determineGaugeByName(gaugeName); | |
175 | |
176 if (gauge == null) { | |
177 logger.debug("no gauge found"); | |
178 return; | |
179 } | |
180 | |
181 XYSeries series = new StyledXYSeries(description, theme); | |
182 | |
183 StyledSeriesBuilder.addPointsQW(series, wqkms); | |
184 | |
185 addAxisSeries(series, YAXIS.W.idx, visible); | |
186 } | |
187 } | |
188 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |