changeset 4320:c3ac330d9be4

NaviChartOutputTab: Slight refactoring to work not only with FixAnalysisArtifacts.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 30 Oct 2012 10:44:54 +0100
parents 8d3523bbb088
children e7f7be368cf3
files flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/NaviChartOutputTab.java
diffstat 1 files changed, 32 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/NaviChartOutputTab.java	Tue Oct 30 10:35:37 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/NaviChartOutputTab.java	Tue Oct 30 10:44:54 2012 +0100
@@ -34,13 +34,14 @@
 import de.intevation.flys.client.shared.model.Artifact;
 import de.intevation.flys.client.shared.model.Collection;
 import de.intevation.flys.client.shared.model.FixAnalysisArtifact;
+import de.intevation.flys.client.shared.model.FixFilter;
 import de.intevation.flys.client.shared.model.OutputMode;
 
 import java.util.Date;
 
 
 /**
- * Tab representing and showing one Chart-output.
+ * Tab representing and showing one Chart-output with a "navi" thing.
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
@@ -83,35 +84,52 @@
 
         form.setFields(currentkm);
         form.setWidth(60);
-        FixAnalysisArtifact fix = (FixAnalysisArtifact) art;
 
-        String s = fix.getArtifactDescription().getDataValueAsString("step");
-        try {
-            double ds = Double.parseDouble(s);
-            collectionView.setSteps(ds);
+        double fromKm;
+        double toKm;
+
+        if (art instanceof FixAnalysisArtifact) {
+            FixAnalysisArtifact fix = (FixAnalysisArtifact) art;
+            FixFilter fixFilter = fix.getFilter();
+            String s = fix.getArtifactDescription().getDataValueAsString("step");
+            try {
+                double ds = Double.parseDouble(s);
+                collectionView.setSteps(ds);
+            }
+            catch(NumberFormatException nfe) {
+                collectionView.setSteps(100d);
+            }
+            fromKm = fixFilter.getFromKm();
+            toKm   = fixFilter.getToKm();
         }
-        catch(NumberFormatException nfe) {
+        else {
+            // Probably WINFOArtifact kind of artifact.
+            // TODO Proper implementation
+            // collectionView set real steps.
             collectionView.setSteps(100d);
+            fromKm = 0d;
+            toKm = 93d;
         }
-        collectionView.setMinKm(fix.getFilter().getFromKm());
-        collectionView.setMaxKm(fix.getFilter().getToKm());
+
+        collectionView.setMinKm(fromKm);
+        collectionView.setMaxKm(toKm);
 
         final NumberFormat nf = NumberFormat.getDecimalFormat();
         if (collectionView.getCurrentKm() == -1d) {
             try {
-                double d = Double.valueOf(fix.getFilter().getFromKm());
+                double d = Double.valueOf(fromKm);
                 currentkm.setValue(nf.format(d));
             } catch (NumberFormatException e) {
-                currentkm.setValue(fix.getFilter().getFromKm());
+                currentkm.setValue(fromKm);
             }
-            collectionView.setCurrentKm(fix.getFilter().getFromKm());
+            collectionView.setCurrentKm(fromKm);
         }
         else {
             try {
-                double d = Double.valueOf(fix.getFilter().getFromKm());
+                double d = Double.valueOf(fromKm);
                 currentkm.setValue(nf.format(d));
             } catch (NumberFormatException e) {
-                currentkm.setValue(fix.getFilter().getFromKm());
+                currentkm.setValue(fromKm);
             }
             currentkm.setValue(collectionView.getCurrentKm());
         }

http://dive4elements.wald.intevation.org