Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java @ 1712:7e19449d7826
#253 Modified the title creation of chart curves - titles will now equal the Facet's description.
flys-artifacts/trunk@2984 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 17 Oct 2011 10:47:36 +0000 |
parents | bdb05dc9b763 |
children | 41ba2276d785 |
comparison
equal
deleted
inserted
replaced
1711:f708120cb7bc | 1712:7e19449d7826 |
---|---|
1 package de.intevation.flys.exports; | 1 package de.intevation.flys.exports; |
2 | |
3 import java.util.Date; | |
4 import java.util.List; | |
5 | 2 |
6 import org.apache.log4j.Logger; | 3 import org.apache.log4j.Logger; |
7 | 4 |
8 import org.w3c.dom.Document; | 5 import org.w3c.dom.Document; |
9 | 6 |
15 | 12 |
16 import de.intevation.artifacts.Artifact; | 13 import de.intevation.artifacts.Artifact; |
17 | 14 |
18 import de.intevation.artifactdatabase.state.Facet; | 15 import de.intevation.artifactdatabase.state.Facet; |
19 | 16 |
20 import de.intevation.flys.model.DischargeTable; | |
21 import de.intevation.flys.model.Gauge; | 17 import de.intevation.flys.model.Gauge; |
22 import de.intevation.flys.model.River; | 18 import de.intevation.flys.model.River; |
23 import de.intevation.flys.model.TimeInterval; | |
24 | 19 |
25 import de.intevation.flys.artifacts.WINFOArtifact; | 20 import de.intevation.flys.artifacts.WINFOArtifact; |
26 | 21 |
27 import de.intevation.flys.artifacts.model.WQKms; | 22 import de.intevation.flys.artifacts.model.WQKms; |
28 | 23 |
109 return; | 104 return; |
110 } | 105 } |
111 | 106 |
112 WINFOArtifact flysArtifact = (WINFOArtifact) artifact; | 107 WINFOArtifact flysArtifact = (WINFOArtifact) artifact; |
113 | 108 |
114 facet = flysArtifact.getNativeFacet(facet); | 109 Facet nativeFacet = flysArtifact.getNativeFacet(facet); |
115 | 110 |
116 if (facet == null) { | 111 if (nativeFacet == null) { |
117 logger.debug("no facet found"); | 112 logger.debug("no facet found"); |
118 return; | 113 return; |
119 } | 114 } |
120 | 115 |
121 WQKms wqkms = (WQKms)facet.getData(flysArtifact, context); | 116 WQKms wqkms = (WQKms)nativeFacet.getData(flysArtifact, context); |
122 | 117 |
123 String gaugeName = wqkms.getName(); | 118 String gaugeName = wqkms.getName(); |
124 | 119 |
125 River river = FLYSUtils.getRiver(flysArtifact); | 120 River river = FLYSUtils.getRiver(flysArtifact); |
126 | 121 |
134 if (gauge == null) { | 129 if (gauge == null) { |
135 logger.debug("no gauge found"); | 130 logger.debug("no gauge found"); |
136 return; | 131 return; |
137 } | 132 } |
138 | 133 |
139 String seriesName = getSeriesName(gauge); | |
140 | |
141 double [][] values = new double [][] { | 134 double [][] values = new double [][] { |
142 wqkms.getQs(), wqkms.getWs() }; | 135 wqkms.getQs(), wqkms.getWs() }; |
143 | 136 |
144 int size = values != null ? values[0].length : 0; | 137 int size = values != null ? values[0].length : 0; |
145 | 138 |
146 XYSeries series = new StyledXYSeries(seriesName, attr); | 139 XYSeries series = new StyledXYSeries(facet.getDescription(), attr); |
147 | 140 |
148 for (int i = 0; i < size; i++) { | 141 for (int i = 0; i < size; i++) { |
149 series.add(values[0][i], values[1][i]); | 142 series.add(values[0][i], values[1][i]); |
150 } | 143 } |
151 | 144 |
152 addFirstAxisSeries(series, visible); | 145 addFirstAxisSeries(series, visible); |
153 } | 146 } |
154 | |
155 | |
156 protected String getSeriesName(Gauge gauge) { | |
157 //XXX The following code stops the artifact server accepting new HTTP | |
158 //requests. It needs more analysis! Is loading the discharge table a | |
159 //memory problem? Or is the time interval the problem? | |
160 | |
161 List<DischargeTable> dts = gauge.getDischargeTables(); | |
162 | |
163 for (DischargeTable dt: dts) { | |
164 if (dt.getKind() == 0) { | |
165 TimeInterval ti = dt.getTimeInterval(); | |
166 | |
167 Date start = ti.getStartTime(); | |
168 Date end = ti.getStopTime(); | |
169 | |
170 String name = gauge.getName(); | |
171 | |
172 if (end == null) { | |
173 Object[] args = new Object[] { name, start }; | |
174 return msg( | |
175 "chart.discharge.curve.curve.valid.from", | |
176 "", | |
177 args); | |
178 } | |
179 else { | |
180 Object[] args = new Object[] { name, start, end }; | |
181 return msg( | |
182 "chart.discharge.curve.curve.valid.range", | |
183 "", | |
184 args); | |
185 } | |
186 } | |
187 } | |
188 | |
189 return gauge.getName(); | |
190 } | |
191 } | 147 } |
192 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 148 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |