annotate flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java @ 5058:91630b503ca8 dami

Remove Catchment HWS and Line from the model
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 20 Feb 2013 15:43:11 +0100
parents f85f230c5c6c
children b296d435fc69
rev   line source
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.io.InputStream;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.io.IOException;
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
5 import java.util.ArrayList;
1597
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
6 import java.util.Date;
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
7 import java.util.List;
549
e74bf6bfeeb6 Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 547
diff changeset
8 import java.util.Map;
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import javax.xml.xpath.XPathConstants;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import org.w3c.dom.Document;
1597
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
13 import org.w3c.dom.Element;
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
14 import org.w3c.dom.NodeList;
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
16 import org.apache.log4j.Logger;
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
17
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import de.intevation.artifacts.common.ArtifactNamespaceContext;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import de.intevation.artifacts.common.utils.ClientProtocolUtils;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import de.intevation.artifacts.common.utils.XMLUtils;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import de.intevation.artifacts.httpclient.http.HttpClient;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 import de.intevation.flys.client.shared.Transform2D;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 import de.intevation.flys.client.shared.exceptions.ServerException;
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
29 import de.intevation.flys.client.shared.model.Axis;
1597
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
30 import de.intevation.flys.client.shared.model.DateAxis;
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
31 import de.intevation.flys.client.shared.model.NumberAxis;
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
32 import de.intevation.flys.client.shared.model.ChartInfo;
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 import de.intevation.flys.client.shared.model.Collection;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 import de.intevation.flys.client.client.services.ChartInfoService;
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 /**
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 * This service fetches a document that contains meta information for a specific
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 * chart.
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 *
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 */
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 public class ChartInfoServiceImpl
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 extends RemoteServiceServlet
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 implements ChartInfoService
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
48 private static final Logger logger =
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
49 Logger.getLogger(ChartInfoServiceImpl.class);
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
50
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
51
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 public static final String XPATH_TRANSFORM_MATRIX =
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
53 "/art:chartinfo/art:transformation-matrix/art:matrix";
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
55 public static final String XPATH_X_AXES =
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
56 "/art:chartinfo/art:axes/art:domain";
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
57
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
58 public static final String XPATH_Y_AXES =
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
59 "/art:chartinfo/art:axes/art:range";
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
60
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 public static final String EXCEPTION_STRING = "error_chart_info_service";
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
64 public ChartInfo getChartInfo(
549
e74bf6bfeeb6 Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 547
diff changeset
65 Collection collection,
e74bf6bfeeb6 Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 547
diff changeset
66 String locale,
e74bf6bfeeb6 Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 547
diff changeset
67 String type,
e74bf6bfeeb6 Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 547
diff changeset
68 Map<String, String> attr)
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 throws ServerException
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
71 logger.info("ChartInfoServiceImpl.getChartInfo");
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
73 String url = getServletContext().getInitParameter("server-url");
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
74
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 Document request = ClientProtocolUtils.newOutCollectionDocument(
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 collection.identifier(),
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 type,
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 type,
549
e74bf6bfeeb6 Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 547
diff changeset
79 ChartServiceHelper.getChartAttributes(attr));
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 try {
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 HttpClient client = new HttpClientImpl(url, locale);
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 InputStream in = client.collectionOut(
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 request,
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 collection.identifier(),
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 type + "_chartinfo");
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 Document info = XMLUtils.parseDocument(in);
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 return parseInfoDocument(info);
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 }
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 catch (IOException ioe) {
556
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
93 ioe.printStackTrace();
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
94 }
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
95 catch (Exception e) {
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
96 e.printStackTrace();
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 }
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
99 logger.debug("Error while fetching chart info.");
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 throw new ServerException(EXCEPTION_STRING);
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 }
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104
4053
f85f230c5c6c Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3379
diff changeset
105 /**
f85f230c5c6c Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3379
diff changeset
106 * Parse ChartInfo-Part of document, create Transforms and axes
f85f230c5c6c Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3379
diff changeset
107 * from it.
f85f230c5c6c Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3379
diff changeset
108 */
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
109 protected ChartInfo parseInfoDocument(Document doc) {
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
110 Transform2D[] transformer = parseTransformationMatrix(doc);
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
111 Axis[] xAxes = parseXAxes(doc);
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
112 Axis[] yAxes = parseYAxes(doc);
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
113
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
114 return new ChartInfo(xAxes, yAxes, transformer);
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
115 }
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
116
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
117
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
118 protected Axis[] parseXAxes(Document doc) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
119 logger.debug("ChartInfoServiceImpl.parseXAxes");
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
120
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
121 NodeList axes = (NodeList) XMLUtils.xpath(
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
122 doc,
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
123 XPATH_X_AXES,
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
124 XPathConstants.NODESET,
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
125 ArtifactNamespaceContext.INSTANCE);
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
126
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
127 return parseAxes(axes);
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
128 }
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
129
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
130
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
131 protected Axis[] parseYAxes(Document doc) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
132 logger.debug("ChartInfoServiceImpl.parseYAxes");
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
133
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
134 NodeList axes = (NodeList) XMLUtils.xpath(
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
135 doc,
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
136 XPATH_Y_AXES,
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
137 XPathConstants.NODESET,
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
138 ArtifactNamespaceContext.INSTANCE);
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
139
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
140 return parseAxes(axes);
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
141 }
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
142
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
143
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
144 protected Axis[] parseAxes(NodeList axes) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
145 logger.debug("ChartInfoServiceImpl.parseAxes");
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
146
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
147 int count = axes != null ? axes.getLength() : 0;
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
148
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
149 logger.debug("Chart has " + count + " axes.");
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
150
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
151 if (count == 0) {
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
152 return null;
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
153 }
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
154
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
155 Axis[] result = new Axis[count];
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
156
1597
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
157 String ns = ArtifactNamespaceContext.NAMESPACE_URI;
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
158
1597
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
159 for (int i = 0; i < count; i++) {
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
160 Element node = (Element) axes.item(i);
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
161
1597
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
162 String posStr = node.getAttributeNS(ns, "pos");
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
163 String fromStr = node.getAttributeNS(ns, "from");
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
164 String toStr = node.getAttributeNS(ns, "to");
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
165 String minStr = node.getAttributeNS(ns, "min");
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
166 String maxStr = node.getAttributeNS(ns, "max");
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
167 String axisType = node.getAttributeNS(ns, "axistype");
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
168
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
169 try {
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
170 int pos = Integer.parseInt(posStr);
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
171
556
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
172 if (pos >= result.length) {
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
173 // this should never happen
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
174 logger.debug("The axis is out of valid range: " + pos);
556
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
175 continue;
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
176 }
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
177
1597
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
178 if (axisType != null && axisType.equals(DateAxis.TYPE)) {
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
179 long from = Long.parseLong(fromStr);
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
180 long to = Long.parseLong(toStr);
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
181 long min = Long.parseLong(minStr);
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
182 long max = Long.parseLong(maxStr);
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
183
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
184 if (logger.isDebugEnabled()) {
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
185 logger.debug("date axis from: " + new Date(from));
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
186 logger.debug("date axis to : " + new Date(to));
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
187 logger.debug("date axis min : " + new Date(min));
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
188 logger.debug("date axis max : " + new Date(max));
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
189 }
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
190
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
191 result[pos] = new DateAxis(pos, from, to, min, max);
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
192 }
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
193 else {
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
194 double from = Double.parseDouble(fromStr);
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
195 double to = Double.parseDouble(toStr);
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
196 double min = Double.parseDouble(minStr);
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
197 double max = Double.parseDouble(maxStr);
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
198
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
199 result[pos] = new NumberAxis(pos, from, to, min, max);
8bbaa0d173cf Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1425
diff changeset
200 }
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
201 }
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
202 catch (NumberFormatException nfe) {
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
203 nfe.printStackTrace();
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
204 }
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
205 }
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
206
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
207 logger.debug("Parsed " + result.length + " axes");
552
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
208
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
209 return result;
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
210 }
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
211
6050d49eaba3 Adapted the ChartInfoService to return more information about charts than before. In addition, the PanControl is added to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
212
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 /**
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 * Parses the chart info document and extract the Transform2D values.
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 *
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 * @param doc The chart info document.
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 *
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 * @return a Transform2D object to transfrom pixel coordinates into chart
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219 * coordinates.
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 */
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
221 protected Transform2D[] parseTransformationMatrix(Document doc) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
222 logger.debug("ChartInfoServiceImpl.parseTransformationMatrix");
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
224 NodeList matrix = (NodeList) XMLUtils.xpath(
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225 doc,
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226 XPATH_TRANSFORM_MATRIX,
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
227 XPathConstants.NODESET,
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228 ArtifactNamespaceContext.INSTANCE);
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
229
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
230 int num = matrix != null ? matrix.getLength() : 0;
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
231
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
232 List<Transform2D> transformer = new ArrayList<Transform2D>(num);
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
233
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
234 for (int i = 0; i < num; i++) {
1598
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
235 Transform2D t = createTransformer((Element) matrix.item(i));
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
236
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
237 if (t == null) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
238 logger.warn("Broken transformation matrix at pos: " + i);
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
239 continue;
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
240 }
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
241
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
242 transformer.add(t);
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243 }
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244
3379
0de61fc9d281 Removed some superfluous casts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1610
diff changeset
245 return transformer.toArray(new Transform2D[num]);
561
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
246 }
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
247
460b8e0f0563 Parse the min/max axes ranges for the ChartInfo and modified the zoom and pan actions to match the current server implementation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 556
diff changeset
248
1598
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
249 protected Transform2D createTransformer(Element matrix) {
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
250 String ns = ArtifactNamespaceContext.NAMESPACE_URI;
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251
1598
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
252 String sx = matrix.getAttributeNS(ns, "sx");
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
253 String sy = matrix.getAttributeNS(ns, "sy");
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
254 String tx = matrix.getAttributeNS(ns, "tx");
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
255 String ty = matrix.getAttributeNS(ns, "ty");
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
256 String xType = matrix.getAttributeNS(ns, "xtype");
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
257 String yType = matrix.getAttributeNS(ns, "ytype");
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258
1598
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
259 xType = xType == null || xType.length() == 0 ? "number" : xType;
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
260 yType = yType == null || yType.length() == 0 ? "number" : yType;
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262 if (sx != null && sy != null && tx != null && ty != null) {
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 try {
1598
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
264 logger.debug("Create new Transform2D with x format: " + xType);
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
265 logger.debug("Create new Transform2D with y format: " + yType);
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
266
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267 return new Transform2D(
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 Double.parseDouble(sx),
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269 Double.parseDouble(sy),
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
270 Double.parseDouble(tx),
1598
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
271 Double.parseDouble(ty),
ef745bc6bed9 Distinguish between numbers and dates while parsing chart info documents; the MousePosition panel now displays the position on date axes correctly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1597
diff changeset
272 xType, yType);
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273 }
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274 catch (NumberFormatException nfe) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
275 logger.warn("Error while parsing matrix values.");
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
276 }
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
277 }
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
278
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
279 logger.warn("No matrix values found.");
535
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
280
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
281 return new Transform2D(1d, 1d, 0d, 0d);
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
282 }
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 }
017371801479 Added a chart info service to fetch the info document for a specific chart from artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
284 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org