Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/server/ChartInfoServiceImpl.java @ 8203:238fc722f87a
sed 's/logger/log/g' src/**/*.java
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Sep 2014 13:19:22 +0200 |
parents | ea9eef426962 |
children | 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8202:e4606eae8ea5 | 8203:238fc722f87a |
---|---|
51 */ | 51 */ |
52 public class ChartInfoServiceImpl | 52 public class ChartInfoServiceImpl |
53 extends RemoteServiceServlet | 53 extends RemoteServiceServlet |
54 implements ChartInfoService | 54 implements ChartInfoService |
55 { | 55 { |
56 private static final Logger logger = | 56 private static final Logger log = |
57 Logger.getLogger(ChartInfoServiceImpl.class); | 57 Logger.getLogger(ChartInfoServiceImpl.class); |
58 | 58 |
59 public static final String XPATH_TRANSFORM_MATRIX = | 59 public static final String XPATH_TRANSFORM_MATRIX = |
60 "/art:chartinfo/art:transformation-matrix/art:matrix"; | 60 "/art:chartinfo/art:transformation-matrix/art:matrix"; |
61 | 61 |
73 String locale, | 73 String locale, |
74 String type, | 74 String type, |
75 Map<String, String> attr) | 75 Map<String, String> attr) |
76 throws ServerException | 76 throws ServerException |
77 { | 77 { |
78 logger.info("ChartInfoServiceImpl.getChartInfo"); | 78 log.info("ChartInfoServiceImpl.getChartInfo"); |
79 | 79 |
80 String url = getServletContext().getInitParameter("server-url"); | 80 String url = getServletContext().getInitParameter("server-url"); |
81 | 81 |
82 Document request = ClientProtocolUtils.newOutCollectionDocument( | 82 Document request = ClientProtocolUtils.newOutCollectionDocument( |
83 collection.identifier(), | 83 collection.identifier(), |
101 } | 101 } |
102 catch (Exception e) { | 102 catch (Exception e) { |
103 e.printStackTrace(); | 103 e.printStackTrace(); |
104 } | 104 } |
105 | 105 |
106 logger.debug("Error while fetching chart info."); | 106 log.debug("Error while fetching chart info."); |
107 | 107 |
108 throw new ServerException(EXCEPTION_STRING); | 108 throw new ServerException(EXCEPTION_STRING); |
109 } | 109 } |
110 | 110 |
111 | 111 |
121 return new ChartInfo(xAxes, yAxes, transformer); | 121 return new ChartInfo(xAxes, yAxes, transformer); |
122 } | 122 } |
123 | 123 |
124 | 124 |
125 protected Axis[] parseXAxes(Document doc) { | 125 protected Axis[] parseXAxes(Document doc) { |
126 logger.debug("ChartInfoServiceImpl.parseXAxes"); | 126 log.debug("ChartInfoServiceImpl.parseXAxes"); |
127 | 127 |
128 NodeList axes = (NodeList) XMLUtils.xpath( | 128 NodeList axes = (NodeList) XMLUtils.xpath( |
129 doc, | 129 doc, |
130 XPATH_X_AXES, | 130 XPATH_X_AXES, |
131 XPathConstants.NODESET, | 131 XPathConstants.NODESET, |
134 return parseAxes(axes); | 134 return parseAxes(axes); |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 protected Axis[] parseYAxes(Document doc) { | 138 protected Axis[] parseYAxes(Document doc) { |
139 logger.debug("ChartInfoServiceImpl.parseYAxes"); | 139 log.debug("ChartInfoServiceImpl.parseYAxes"); |
140 | 140 |
141 NodeList axes = (NodeList) XMLUtils.xpath( | 141 NodeList axes = (NodeList) XMLUtils.xpath( |
142 doc, | 142 doc, |
143 XPATH_Y_AXES, | 143 XPATH_Y_AXES, |
144 XPathConstants.NODESET, | 144 XPathConstants.NODESET, |
147 return parseAxes(axes); | 147 return parseAxes(axes); |
148 } | 148 } |
149 | 149 |
150 | 150 |
151 protected Axis[] parseAxes(NodeList axes) { | 151 protected Axis[] parseAxes(NodeList axes) { |
152 logger.debug("ChartInfoServiceImpl.parseAxes"); | 152 log.debug("ChartInfoServiceImpl.parseAxes"); |
153 | 153 |
154 int count = axes != null ? axes.getLength() : 0; | 154 int count = axes != null ? axes.getLength() : 0; |
155 | 155 |
156 logger.debug("Chart has " + count + " axes."); | 156 log.debug("Chart has " + count + " axes."); |
157 | 157 |
158 if (count == 0) { | 158 if (count == 0) { |
159 return null; | 159 return null; |
160 } | 160 } |
161 | 161 |
176 try { | 176 try { |
177 int pos = Integer.parseInt(posStr); | 177 int pos = Integer.parseInt(posStr); |
178 | 178 |
179 if (pos >= result.length) { | 179 if (pos >= result.length) { |
180 // this should never happen | 180 // this should never happen |
181 logger.debug("The axis is out of valid range: " + pos); | 181 log.debug("The axis is out of valid range: " + pos); |
182 continue; | 182 continue; |
183 } | 183 } |
184 | 184 |
185 if (axisType != null && axisType.equals(DateAxis.TYPE)) { | 185 if (axisType != null && axisType.equals(DateAxis.TYPE)) { |
186 long from = Long.parseLong(fromStr); | 186 long from = Long.parseLong(fromStr); |
187 long to = Long.parseLong(toStr); | 187 long to = Long.parseLong(toStr); |
188 long min = Long.parseLong(minStr); | 188 long min = Long.parseLong(minStr); |
189 long max = Long.parseLong(maxStr); | 189 long max = Long.parseLong(maxStr); |
190 | 190 |
191 if (logger.isDebugEnabled()) { | 191 if (log.isDebugEnabled()) { |
192 logger.debug("date axis from: " + new Date(from)); | 192 log.debug("date axis from: " + new Date(from)); |
193 logger.debug("date axis to : " + new Date(to)); | 193 log.debug("date axis to : " + new Date(to)); |
194 logger.debug("date axis min : " + new Date(min)); | 194 log.debug("date axis min : " + new Date(min)); |
195 logger.debug("date axis max : " + new Date(max)); | 195 log.debug("date axis max : " + new Date(max)); |
196 } | 196 } |
197 | 197 |
198 result[pos] = new DateAxis(pos, from, to, min, max); | 198 result[pos] = new DateAxis(pos, from, to, min, max); |
199 } | 199 } |
200 else { | 200 else { |
209 catch (NumberFormatException nfe) { | 209 catch (NumberFormatException nfe) { |
210 nfe.printStackTrace(); | 210 nfe.printStackTrace(); |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 logger.debug("Parsed " + result.length + " axes"); | 214 log.debug("Parsed " + result.length + " axes"); |
215 | 215 |
216 return result; | 216 return result; |
217 } | 217 } |
218 | 218 |
219 | 219 |
224 * | 224 * |
225 * @return a Transform2D object to transfrom pixel coordinates into chart | 225 * @return a Transform2D object to transfrom pixel coordinates into chart |
226 * coordinates. | 226 * coordinates. |
227 */ | 227 */ |
228 protected Transform2D[] parseTransformationMatrix(Document doc) { | 228 protected Transform2D[] parseTransformationMatrix(Document doc) { |
229 logger.debug("ChartInfoServiceImpl.parseTransformationMatrix"); | 229 log.debug("ChartInfoServiceImpl.parseTransformationMatrix"); |
230 | 230 |
231 NodeList matrix = (NodeList) XMLUtils.xpath( | 231 NodeList matrix = (NodeList) XMLUtils.xpath( |
232 doc, | 232 doc, |
233 XPATH_TRANSFORM_MATRIX, | 233 XPATH_TRANSFORM_MATRIX, |
234 XPathConstants.NODESET, | 234 XPathConstants.NODESET, |
240 | 240 |
241 for (int i = 0; i < num; i++) { | 241 for (int i = 0; i < num; i++) { |
242 Transform2D t = createTransformer((Element) matrix.item(i)); | 242 Transform2D t = createTransformer((Element) matrix.item(i)); |
243 | 243 |
244 if (t == null) { | 244 if (t == null) { |
245 logger.warn("Broken transformation matrix at pos: " + i); | 245 log.warn("Broken transformation matrix at pos: " + i); |
246 continue; | 246 continue; |
247 } | 247 } |
248 | 248 |
249 transformer.add(t); | 249 transformer.add(t); |
250 } | 250 } |
266 xType = xType == null || xType.length() == 0 ? "number" : xType; | 266 xType = xType == null || xType.length() == 0 ? "number" : xType; |
267 yType = yType == null || yType.length() == 0 ? "number" : yType; | 267 yType = yType == null || yType.length() == 0 ? "number" : yType; |
268 | 268 |
269 if (sx != null && sy != null && tx != null && ty != null) { | 269 if (sx != null && sy != null && tx != null && ty != null) { |
270 try { | 270 try { |
271 logger.debug("Create new Transform2D with x format: " + xType); | 271 log.debug("Create new Transform2D with x format: " + xType); |
272 logger.debug("Create new Transform2D with y format: " + yType); | 272 log.debug("Create new Transform2D with y format: " + yType); |
273 | 273 |
274 return new Transform2D( | 274 return new Transform2D( |
275 Double.parseDouble(sx), | 275 Double.parseDouble(sx), |
276 Double.parseDouble(sy), | 276 Double.parseDouble(sy), |
277 Double.parseDouble(tx), | 277 Double.parseDouble(tx), |
278 Double.parseDouble(ty), | 278 Double.parseDouble(ty), |
279 xType, yType); | 279 xType, yType); |
280 } | 280 } |
281 catch (NumberFormatException nfe) { | 281 catch (NumberFormatException nfe) { |
282 logger.warn("Error while parsing matrix values."); | 282 log.warn("Error while parsing matrix values."); |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 logger.warn("No matrix values found."); | 286 log.warn("No matrix values found."); |
287 | 287 |
288 return new Transform2D(1d, 1d, 0d, 0d); | 288 return new Transform2D(1d, 1d, 0d, 0d); |
289 } | 289 } |
290 } | 290 } |
291 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 291 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |