Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/NaviChartOutputTab.java @ 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 |
comparison
equal
deleted
inserted
replaced
4319:8d3523bbb088 | 4320:c3ac330d9be4 |
---|---|
32 import de.intevation.flys.client.client.ui.CollectionView; | 32 import de.intevation.flys.client.client.ui.CollectionView; |
33 | 33 |
34 import de.intevation.flys.client.shared.model.Artifact; | 34 import de.intevation.flys.client.shared.model.Artifact; |
35 import de.intevation.flys.client.shared.model.Collection; | 35 import de.intevation.flys.client.shared.model.Collection; |
36 import de.intevation.flys.client.shared.model.FixAnalysisArtifact; | 36 import de.intevation.flys.client.shared.model.FixAnalysisArtifact; |
37 import de.intevation.flys.client.shared.model.FixFilter; | |
37 import de.intevation.flys.client.shared.model.OutputMode; | 38 import de.intevation.flys.client.shared.model.OutputMode; |
38 | 39 |
39 import java.util.Date; | 40 import java.util.Date; |
40 | 41 |
41 | 42 |
42 /** | 43 /** |
43 * Tab representing and showing one Chart-output. | 44 * Tab representing and showing one Chart-output with a "navi" thing. |
44 * | 45 * |
45 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 46 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
46 */ | 47 */ |
47 public class NaviChartOutputTab | 48 public class NaviChartOutputTab |
48 extends ChartOutputTab | 49 extends ChartOutputTab |
81 currentkm.setWidth(60); | 82 currentkm.setWidth(60); |
82 currentkm.setShowTitle(false); | 83 currentkm.setShowTitle(false); |
83 | 84 |
84 form.setFields(currentkm); | 85 form.setFields(currentkm); |
85 form.setWidth(60); | 86 form.setWidth(60); |
86 FixAnalysisArtifact fix = (FixAnalysisArtifact) art; | 87 |
87 | 88 double fromKm; |
88 String s = fix.getArtifactDescription().getDataValueAsString("step"); | 89 double toKm; |
89 try { | 90 |
90 double ds = Double.parseDouble(s); | 91 if (art instanceof FixAnalysisArtifact) { |
91 collectionView.setSteps(ds); | 92 FixAnalysisArtifact fix = (FixAnalysisArtifact) art; |
92 } | 93 FixFilter fixFilter = fix.getFilter(); |
93 catch(NumberFormatException nfe) { | 94 String s = fix.getArtifactDescription().getDataValueAsString("step"); |
95 try { | |
96 double ds = Double.parseDouble(s); | |
97 collectionView.setSteps(ds); | |
98 } | |
99 catch(NumberFormatException nfe) { | |
100 collectionView.setSteps(100d); | |
101 } | |
102 fromKm = fixFilter.getFromKm(); | |
103 toKm = fixFilter.getToKm(); | |
104 } | |
105 else { | |
106 // Probably WINFOArtifact kind of artifact. | |
107 // TODO Proper implementation | |
108 // collectionView set real steps. | |
94 collectionView.setSteps(100d); | 109 collectionView.setSteps(100d); |
95 } | 110 fromKm = 0d; |
96 collectionView.setMinKm(fix.getFilter().getFromKm()); | 111 toKm = 93d; |
97 collectionView.setMaxKm(fix.getFilter().getToKm()); | 112 } |
113 | |
114 collectionView.setMinKm(fromKm); | |
115 collectionView.setMaxKm(toKm); | |
98 | 116 |
99 final NumberFormat nf = NumberFormat.getDecimalFormat(); | 117 final NumberFormat nf = NumberFormat.getDecimalFormat(); |
100 if (collectionView.getCurrentKm() == -1d) { | 118 if (collectionView.getCurrentKm() == -1d) { |
101 try { | 119 try { |
102 double d = Double.valueOf(fix.getFilter().getFromKm()); | 120 double d = Double.valueOf(fromKm); |
103 currentkm.setValue(nf.format(d)); | 121 currentkm.setValue(nf.format(d)); |
104 } catch (NumberFormatException e) { | 122 } catch (NumberFormatException e) { |
105 currentkm.setValue(fix.getFilter().getFromKm()); | 123 currentkm.setValue(fromKm); |
106 } | 124 } |
107 collectionView.setCurrentKm(fix.getFilter().getFromKm()); | 125 collectionView.setCurrentKm(fromKm); |
108 } | 126 } |
109 else { | 127 else { |
110 try { | 128 try { |
111 double d = Double.valueOf(fix.getFilter().getFromKm()); | 129 double d = Double.valueOf(fromKm); |
112 currentkm.setValue(nf.format(d)); | 130 currentkm.setValue(nf.format(d)); |
113 } catch (NumberFormatException e) { | 131 } catch (NumberFormatException e) { |
114 currentkm.setValue(fix.getFilter().getFromKm()); | 132 currentkm.setValue(fromKm); |
115 } | 133 } |
116 currentkm.setValue(collectionView.getCurrentKm()); | 134 currentkm.setValue(collectionView.getCurrentKm()); |
117 } | 135 } |
118 | 136 |
119 lower.addClickHandler(new ClickHandler() { | 137 lower.addClickHandler(new ClickHandler() { |