diff flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java @ 1597:8bbaa0d173cf

Save zoom parameters as Number; added new Axis types NumberAxis and DateAxis. flys-client/trunk@3923 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 06 Feb 2012 13:27:05 +0000
parents bc06a671ef60
children ef745bc6bed9
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java	Mon Feb 06 12:38:48 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java	Mon Feb 06 13:27:05 2012 +0000
@@ -3,12 +3,14 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
 import javax.xml.xpath.XPathConstants;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -26,6 +28,8 @@
 import de.intevation.flys.client.shared.Transform2D;
 import de.intevation.flys.client.shared.exceptions.ServerException;
 import de.intevation.flys.client.shared.model.Axis;
+import de.intevation.flys.client.shared.model.DateAxis;
+import de.intevation.flys.client.shared.model.NumberAxis;
 import de.intevation.flys.client.shared.model.ChartInfo;
 import de.intevation.flys.client.shared.model.Collection;
 
@@ -147,30 +151,20 @@
 
         Axis[] result = new Axis[count];
 
-        for (int i = 0; i < count; i++) {
-            Node node = axes.item(i);
-
-            String posStr = XMLUtils.xpathString(
-                node, "@art:pos", ArtifactNamespaceContext.INSTANCE);
+        String ns = ArtifactNamespaceContext.NAMESPACE_URI;
 
-            String fromStr = XMLUtils.xpathString(
-                node, "@art:from", ArtifactNamespaceContext.INSTANCE);
+        for (int i = 0; i < count; i++) {
+            Element node = (Element) axes.item(i);
 
-            String toStr = XMLUtils.xpathString(
-                node, "@art:to", ArtifactNamespaceContext.INSTANCE);
-
-            String minStr = XMLUtils.xpathString(
-                node, "@art:min", ArtifactNamespaceContext.INSTANCE);
-
-            String maxStr = XMLUtils.xpathString(
-                node, "@art:max", ArtifactNamespaceContext.INSTANCE);
+            String posStr   = node.getAttributeNS(ns, "pos");
+            String fromStr  = node.getAttributeNS(ns, "from");
+            String toStr    = node.getAttributeNS(ns, "to");
+            String minStr   = node.getAttributeNS(ns, "min");
+            String maxStr   = node.getAttributeNS(ns, "max");
+            String axisType = node.getAttributeNS(ns, "axistype");
 
             try {
                 int    pos  = Integer.parseInt(posStr);
-                double from = Double.parseDouble(fromStr);
-                double to   = Double.parseDouble(toStr);
-                double min  = Double.parseDouble(minStr);
-                double max  = Double.parseDouble(maxStr);
 
                 if (pos >= result.length) {
                     // this should never happen
@@ -178,7 +172,29 @@
                     continue;
                 }
 
-                result[pos] = new Axis(pos, from, to, min, max);
+                if (axisType != null && axisType.equals(DateAxis.TYPE)) {
+                    long from = Long.parseLong(fromStr);
+                    long to   = Long.parseLong(toStr);
+                    long min  = Long.parseLong(minStr);
+                    long max  = Long.parseLong(maxStr);
+
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("date axis from: " + new Date(from));
+                        logger.debug("date axis to  : " + new Date(to));
+                        logger.debug("date axis min : " + new Date(min));
+                        logger.debug("date axis max : " + new Date(max));
+                    }
+
+                    result[pos] = new DateAxis(pos, from, to, min, max);
+                }
+                else {
+                    double from = Double.parseDouble(fromStr);
+                    double to   = Double.parseDouble(toStr);
+                    double min  = Double.parseDouble(minStr);
+                    double max  = Double.parseDouble(maxStr);
+
+                    result[pos] = new NumberAxis(pos, from, to, min, max);
+                }
             }
             catch (NumberFormatException nfe) {
                 nfe.printStackTrace();

http://dive4elements.wald.intevation.org