comparison flys-client/src/main/java/de/intevation/flys/client/shared/model/FixAnalysisArtifact.java @ 2906:1780841d79af

Added navigation to fix analysis charts. flys-client/trunk@4673 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 15 Jun 2012 12:13:09 +0000
parents 93302bd16f42
children f14d4c668ec5
comparison
equal deleted inserted replaced
2905:51ed89b754ae 2906:1780841d79af
1 package de.intevation.flys.client.shared.model; 1 package de.intevation.flys.client.shared.model;
2 2
3 import java.util.List; 3 import java.util.List;
4
5 import com.google.gwt.core.client.GWT;
4 6
5 import de.intevation.flys.client.client.ui.fixation.FixationPanel; 7 import de.intevation.flys.client.client.ui.fixation.FixationPanel;
6 import de.intevation.flys.client.client.ui.fixation.FixationPanel.FixFilter; 8 import de.intevation.flys.client.client.ui.fixation.FixationPanel.FixFilter;
7 9
8 /** 10 /**
51 protected FixFilter createFilter() { 53 protected FixFilter createFilter() {
52 if (this.filter == null) { 54 if (this.filter == null) {
53 this.filter = new FixFilter(); 55 this.filter = new FixFilter();
54 } 56 }
55 DataList[] old = artifactDescription.getOldData(); 57 DataList[] old = artifactDescription.getOldData();
56 for (int i = 0; i < old.length; i++) { 58
57 DataList data = old[i]; 59 String river = artifactDescription.getDataValueAsString("river");
58 List<Data> items = data.getAll(); 60 if (river != null) {
59 String state = data.getState(); 61 this.filter.setRiver(river);
60 if (state.equals("state.fix.river")) { 62 }
61 Data d = getData(items, "river"); 63
62 this.filter.setRiver(d.getItems()[0].getLabel()); 64 String from = artifactDescription.getDataValueAsString("from");
65 if (from != null) {
66 try {
67 double fkm = Double.valueOf(from).doubleValue();
68 this.filter.setFromKm(fkm);
63 } 69 }
64 if (state.equals("state.fix.location")) { 70 catch(NumberFormatException nfe) {
65 Data df = getData(items, "from"); 71 GWT.log("Could not parse from km.");
66 Data dt = getData(items, "to");
67 try {
68 String from = df.getItems()[0].getLabel();
69 String to = dt.getItems()[0].getLabel();
70 double fkm = Double.valueOf(from).doubleValue();
71 double tkm = Double.valueOf(to).doubleValue();
72 this.filter.setFromKm(fkm);
73 this.filter.setToKm(tkm);
74 if (fkm > filter.getCurrentKm()) {
75 this.filter.setCurrentKm(fkm);
76 }
77 }
78 catch(NumberFormatException nfe) {
79 }
80 } 72 }
81 if (state.equals("state.fix.period")) { 73 }
82 Data ds = getData(items, "start"); 74
83 Data de = getData(items, "end"); 75 String to = artifactDescription.getDataValueAsString("to");
84 try { 76 if (to != null) {
85 String start = ds.getItems()[0].getStringValue(); 77 try {
86 String end = de.getItems()[0].getStringValue(); 78 double tkm = Double.valueOf(to).doubleValue();
87 long sp = Long.parseLong(start); 79 this.filter.setToKm(tkm);
88 long ep = Long.parseLong(end);
89 this.filter.setFromDate(sp);
90 this.filter.setToDate(ep);
91 }
92 catch(NumberFormatException nfe) {
93 }
94 } 80 }
95 if (state.equals("state.fix.gaugerange")) { 81 catch(NumberFormatException nfe) {
96 Data gr1 = getData(items, "q1"); 82 GWT.log("Could not parse to km");
97 Data gr2 = getData(items, "q2");
98 try {
99 String q1s = gr1.getItems()[0].getLabel();
100 String q2s = gr2.getItems()[0].getLabel();
101 int q1 = Integer.valueOf(q1s).intValue();
102 int q2 = Integer.valueOf(q2s).intValue();
103 this.filter.setFromClass(q1);
104 this.filter.setToClass(q2);
105 }
106 catch(NumberFormatException nfe) {
107 }
108 } 83 }
84 }
85
86 String start = artifactDescription.getDataValueAsString("start");
87 if (start != null) {
88 try {
89 long s = Long.parseLong(start);
90 this.filter.setFromDate(s);
91 }
92 catch(NumberFormatException nfe) {
93 GWT.log("Could not parse start date");
94 }
95 }
96
97 String end = artifactDescription.getDataValueAsString("end");
98 if (end != null) {
99 try {
100 long e = Long.parseLong(end);
101 this.filter.setToDate(e);
102 }
103 catch(NumberFormatException nfe) {
104 GWT.log("Could not parse end date");
105 }
106 }
107
108 String q1 = artifactDescription.getDataValueAsString("q1");
109 if (q1 != null) {
110 try {
111 int q1i = Integer.valueOf(q1).intValue();
112 this.filter.setFromClass(q1i);
113 }
114 catch(NumberFormatException nfe) {
115 GWT.log("Could not parse start class");
116 }
117 }
118
119 String q2 = artifactDescription.getDataValueAsString("q2");
120 if (q2 != null) {
121 try {
122 int q2i =Integer.valueOf(q2).intValue();
123 this.filter.setToClass(q2i);
124 }
125 catch(NumberFormatException nfe) {
126 GWT.log("could not parse end class");
127 }
128 }
129
130 for (DataList list: old) {
131 List<Data> items = list.getAll();
132 String state = list.getState();
109 if(state.equals("state.fix.eventselect")) { 133 if(state.equals("state.fix.eventselect")) {
110 Data de = getData(items, "events"); 134 Data de = getData(items, "events");
111 IntegerArrayData iad = (IntegerArrayData) de; 135 IntegerArrayData iad = (IntegerArrayData) de;
112 this.filter.setEvents(iad.getValues()); 136 this.filter.setEvents(iad.getValues());
113 } 137 }
114 } 138 }
139
115 return this.filter; 140 return this.filter;
116 } 141 }
117 142
118 protected Data getData(List<Data> data, String name) { 143 protected Data getData(List<Data> data, String name) {
119 for (Data d: data) { 144 for (Data d: data) {

http://dive4elements.wald.intevation.org