annotate flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java @ 1577:322f2626fb5d

Create a better label in IntegerRangeData for the selected item. flys-client/trunk@3843 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 31 Jan 2012 15:42:02 +0000
parents bc06a671ef60
children 8bbaa0d173cf
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;
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
6 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
7 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
8
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 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
10
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 import org.w3c.dom.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
12 import org.w3c.dom.Node;
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
13 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
14
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
15 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
16
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
17 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
18
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 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
20 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
21 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
22
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 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
24 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
25
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 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
27 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
28 import de.intevation.flys.client.shared.model.Axis;
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.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
30 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
31
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
32 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
33
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 /**
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 * 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
37 * 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
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 * @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
40 */
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 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
42 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
43 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
44 {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
45 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
46 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
47
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
48
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
49 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
50 "/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
51
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
52 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
53 "/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
54
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_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
56 "/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
57
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
58 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
59
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
60
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
61 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
62 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
63 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
64 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
65 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
66 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
67 {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
68 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
69
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
70 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
71
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 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
73 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
74 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
75 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
76 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
77
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 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
79 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
80 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
81 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
82 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
83 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
84
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 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
86
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 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
88 }
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 catch (IOException ioe) {
556
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
90 ioe.printStackTrace();
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
91 }
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
92 catch (Exception e) {
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
93 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
94 }
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
95
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
96 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
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 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
99 }
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
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
102 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
103 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
104 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
105 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
106
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
107 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
108 }
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
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
110
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
111 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
112 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
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 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
115 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
116 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
117 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
118 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
119
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 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
121 }
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
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
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 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
125 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
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 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
128 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
129 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
130 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
131 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
132
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 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
134 }
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
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
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 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
138 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
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 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
141
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
142 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
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 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
145 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
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
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 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
149
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 for (int i = 0; i < count; i++) {
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 Node node = axes.item(i);
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
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 String posStr = XMLUtils.xpathString(
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 node, "@art:pos", 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
155
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 String fromStr = XMLUtils.xpathString(
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
157 node, "@art:from", 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
158
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
159 String toStr = XMLUtils.xpathString(
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
160 node, "@art:to", 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
161
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
162 String minStr = XMLUtils.xpathString(
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
163 node, "@art:min", ArtifactNamespaceContext.INSTANCE);
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
164
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
165 String maxStr = XMLUtils.xpathString(
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
166 node, "@art:max", ArtifactNamespaceContext.INSTANCE);
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
167
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
168 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
169 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
170 double from = Double.parseDouble(fromStr);
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 double to = Double.parseDouble(toStr);
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
172 double min = Double.parseDouble(minStr);
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
173 double max = Double.parseDouble(maxStr);
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
174
556
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
175 if (pos >= result.length) {
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
176 // 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
177 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
178 continue;
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
179 }
046f43e1d305 Avoid NPE while parsing axes in ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 553
diff changeset
180
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
181 result[pos] = new Axis(pos, from, to, min, max);
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
182 }
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
183 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
184 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
185 }
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
186 }
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
187
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
188 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
189
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
190 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
191 }
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
192
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
193
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
194 /**
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
195 * 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
196 *
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
197 * @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
198 *
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
199 * @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
200 * 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
201 */
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
202 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
203 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
204
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
205 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
206 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
207 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
208 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
209 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
210
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
211 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
212
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
213 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
214
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
215 for (int i = 0; i < num; i++) {
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
216 Transform2D t = createTransformer(matrix.item(i));
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
217
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
218 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
219 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
220 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
221 }
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
222
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
223 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
224 }
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
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
226 return (Transform2D[]) transformer.toArray(new 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
227 }
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
228
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
229
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 protected Transform2D createTransformer(Node 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
231 String sx = XMLUtils.xpathString(
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
232 matrix, "@art:sx", 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
233
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
234 String sy = XMLUtils.xpathString(
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
235 matrix, "@art:sy", 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
236
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
237 String tx = XMLUtils.xpathString(
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
238 matrix, "@art:tx", 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
239
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
240 String ty = XMLUtils.xpathString(
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
241 matrix, "@art:ty", 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
242
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 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
244 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
245 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
246 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
247 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
248 Double.parseDouble(tx),
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
249 Double.parseDouble(ty));
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
250 }
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 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
252 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
253 }
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
254 }
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
255
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 561
diff changeset
256 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
257
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 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
259 }
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
260 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org