Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixFunctionSelect.java @ 3846:84a48acabd78
Show full function instead of internal function name (#873).
flys-client/trunk@5573 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Sat, 22 Sep 2012 22:26:38 +0000 |
parents | 8bedd1fcaeee |
children |
comparison
equal
deleted
inserted
replaced
3845:9d0ea03a8e9e | 3846:84a48acabd78 |
---|---|
1 package de.intevation.flys.client.client.ui.fixation; | 1 package de.intevation.flys.client.client.ui.fixation; |
2 | |
3 import java.util.Iterator; | |
4 import java.util.LinkedHashMap; | |
5 import java.util.Map; | |
6 | 2 |
7 import com.smartgwt.client.types.VerticalAlignment; | 3 import com.smartgwt.client.types.VerticalAlignment; |
8 import com.smartgwt.client.widgets.Canvas; | 4 import com.smartgwt.client.widgets.Canvas; |
9 import com.smartgwt.client.widgets.Label; | 5 import com.smartgwt.client.widgets.Label; |
10 import com.smartgwt.client.widgets.form.DynamicForm; | 6 import com.smartgwt.client.widgets.form.DynamicForm; |
16 import de.intevation.flys.client.shared.model.DataItem; | 12 import de.intevation.flys.client.shared.model.DataItem; |
17 import de.intevation.flys.client.shared.model.DataList; | 13 import de.intevation.flys.client.shared.model.DataList; |
18 import de.intevation.flys.client.shared.model.DefaultData; | 14 import de.intevation.flys.client.shared.model.DefaultData; |
19 import de.intevation.flys.client.shared.model.DefaultDataItem; | 15 import de.intevation.flys.client.shared.model.DefaultDataItem; |
20 | 16 |
17 import java.util.HashMap; | |
18 import java.util.Iterator; | |
19 import java.util.LinkedHashMap; | |
20 import java.util.Map; | |
21 | |
21 public class FixFunctionSelect extends FixationPanel { | 22 public class FixFunctionSelect extends FixationPanel { |
23 private static final Map<String, String> funcDesc = new HashMap<String, String>(); | |
24 | |
25 static { | |
26 funcDesc.put("log", "W(Q) = m*ln(Q + b)"); | |
27 funcDesc.put("linear", "W(Q) = m * Q + b"); | |
28 funcDesc.put("log-linear", "W(Q) = a*ln(m*Q+b)"); | |
29 funcDesc.put("exp", "W(Q) = m * a^Q + b"); | |
30 funcDesc.put("quad", "W(Q) = n*Q^2+m*Q+b"); | |
31 funcDesc.put("pow", "W(Q) = a * Q^c + d"); | |
32 funcDesc.put("sq-pow", "S(Q) = a * Q^b"); | |
33 } | |
34 | |
22 /** The combobox.*/ | 35 /** The combobox.*/ |
23 protected DynamicForm form; | 36 protected DynamicForm form; |
24 | 37 |
25 @Override | 38 @Override |
26 public Canvas createWidget(DataList data) { | 39 public Canvas createWidget(DataList data) { |
43 label.setWidth(400); | 56 label.setWidth(400); |
44 | 57 |
45 SelectItem combobox = new SelectItem(d.getLabel()); | 58 SelectItem combobox = new SelectItem(d.getLabel()); |
46 combobox.setWidth(250); | 59 combobox.setWidth(250); |
47 | 60 |
48 LinkedHashMap<String, String> it = new LinkedHashMap<String, String>(); | 61 LinkedHashMap<String, String> funcTypes = new LinkedHashMap<String, String>(); |
49 | 62 |
50 boolean defaultSet = false; | 63 boolean defaultSet = false; |
51 boolean first = true; | 64 boolean first = true; |
52 | 65 |
53 DataItem def = d.getDefault(); | 66 DataItem def = d.getDefault(); |
63 if (!defaultSet && first) { | 76 if (!defaultSet && first) { |
64 initial.put(d.getLabel(), item.getStringValue()); | 77 initial.put(d.getLabel(), item.getStringValue()); |
65 first = false; | 78 first = false; |
66 } | 79 } |
67 | 80 |
68 it.put(item.getStringValue(), item.getLabel()); | 81 funcTypes.put(item.getStringValue(), item.getLabel()); |
69 } | 82 } |
70 | 83 |
71 label.setWidth(50); | 84 label.setWidth(50); |
72 combobox.setValueMap(it); | 85 combobox.setValueMap(funcTypes); |
73 combobox.setShowTitle(false); | 86 combobox.setShowTitle(false); |
74 form.setItems(combobox); | 87 form.setItems(combobox); |
75 | 88 |
76 layout.addMember(label); | 89 layout.addMember(label); |
77 layout.addMember(form); | 90 layout.addMember(form); |
83 | 96 |
84 return layout; | 97 return layout; |
85 } | 98 } |
86 | 99 |
87 | 100 |
101 @Override | |
88 public Canvas createOld(DataList dataList) { | 102 public Canvas createOld(DataList dataList) { |
89 HLayout layout = new HLayout(); | 103 HLayout layout = new HLayout(); |
90 VLayout vLayout = new VLayout(); | 104 VLayout vLayout = new VLayout(); |
91 layout.setWidth("400px"); | 105 layout.setWidth("400px"); |
92 | 106 |
99 DataItem[] items = data.getItems(); | 113 DataItem[] items = data.getItems(); |
100 | 114 |
101 for (DataItem item: items) { | 115 for (DataItem item: items) { |
102 HLayout hLayout = new HLayout(); | 116 HLayout hLayout = new HLayout(); |
103 | 117 |
118 String desc = funcDesc.containsKey(item.getLabel()) ? | |
119 funcDesc.get(item.getLabel()) : item.getLabel(); | |
104 hLayout.addMember(label); | 120 hLayout.addMember(label); |
105 hLayout.addMember(new Label(item.getLabel())); | 121 hLayout.addMember(new Label(desc)); |
106 | 122 |
107 vLayout.addMember(hLayout); | 123 vLayout.addMember(hLayout); |
108 vLayout.setWidth("130px"); | 124 vLayout.setWidth("130px"); |
109 } | 125 } |
110 } | 126 } |
117 | 133 |
118 return layout; | 134 return layout; |
119 } | 135 } |
120 | 136 |
121 | 137 |
138 @Override | |
122 public Data[] getData() { | 139 public Data[] getData() { |
123 Map values = form.getValues(); | 140 Map values = form.getValues(); |
124 Iterator keys = values.keySet().iterator(); | 141 Iterator keys = values.keySet().iterator(); |
125 | 142 |
126 Data[] list = new Data[values.size()]; | 143 Data[] list = new Data[values.size()]; |