Revision 13173 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/colortable/panels/TabInterpolated.java
TabInterpolated.java | ||
---|---|---|
21 | 21 |
import java.awt.GridBagConstraints; |
22 | 22 |
import java.awt.GridBagLayout; |
23 | 23 |
import java.awt.Insets; |
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
24 | 26 |
import java.util.ArrayList; |
25 | 27 |
|
26 | 28 |
import javax.swing.BorderFactory; |
... | ... | |
44 | 46 |
* @version 27/06/2007 |
45 | 47 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
46 | 48 |
*/ |
47 |
public class TabInterpolated extends JPanel implements ColorSliderListener, ColorButtonListener { |
|
49 |
public class TabInterpolated extends JPanel implements ColorSliderListener, ColorButtonListener, ActionListener {
|
|
48 | 50 |
private static final long serialVersionUID = -5208861410196059899L; |
49 | 51 |
|
50 | 52 |
private double min = Double.POSITIVE_INFINITY; |
... | ... | |
57 | 59 |
private JLabel jLabelColor = null; |
58 | 60 |
private JPanel jPanelLimits = null; |
59 | 61 |
private JCheckBox jCheckBoxLimits = null; |
60 |
private JLabel jLabel1 = null;
|
|
61 |
private JLabel jLabel2 = null;
|
|
62 |
private JLabel jLabelMinimum = null;
|
|
63 |
private JLabel jLabelMaximum = null;
|
|
62 | 64 |
private JTextField jTextFieldMinimum = null; |
63 | 65 |
|
64 | 66 |
private JTextField jTextFieldMaximum = null; |
... | ... | |
110 | 112 |
add(getJPanelLimits(), gridBagConstraints); |
111 | 113 |
} |
112 | 114 |
|
115 |
private JLabel getJLabelMinimum() { |
|
116 |
if (jLabelMinimum == null) { |
|
117 |
jLabelMinimum = new JLabel(); |
|
118 |
jLabelMinimum.setText("M\u00ednimo: "); |
|
119 |
jLabelMinimum.setEnabled(false); |
|
120 |
} |
|
121 |
return jLabelMinimum; |
|
122 |
} |
|
123 |
|
|
124 |
private JLabel getJLabelMaximum() { |
|
125 |
if (jLabelMaximum == null) { |
|
126 |
jLabelMaximum = new JLabel(); |
|
127 |
jLabelMaximum.setText("M\u00e1ximo: "); |
|
128 |
jLabelMaximum.setEnabled(false); |
|
129 |
} |
|
130 |
return jLabelMaximum; |
|
131 |
} |
|
132 |
|
|
133 |
private JTextField getJTextFieldMinimum() { |
|
134 |
if (jTextFieldMinimum == null) { |
|
135 |
jTextFieldMinimum = new JTextField(); |
|
136 |
jTextFieldMinimum.setText("0"); |
|
137 |
jTextFieldMinimum.setEnabled(false); |
|
138 |
} |
|
139 |
return jTextFieldMinimum; |
|
140 |
} |
|
141 |
|
|
142 |
private JTextField getJTextFieldMaximum() { |
|
143 |
if (jTextFieldMaximum == null) { |
|
144 |
jTextFieldMaximum = new JTextField(); |
|
145 |
jTextFieldMaximum.setText("255"); |
|
146 |
jTextFieldMaximum.setEnabled(false); |
|
147 |
} |
|
148 |
return jTextFieldMaximum; |
|
149 |
} |
|
150 |
|
|
151 |
private JCheckBox getJCheckBoxLimits() { |
|
152 |
if (jCheckBoxLimits == null) { |
|
153 |
jCheckBoxLimits = new JCheckBox(); |
|
154 |
jCheckBoxLimits.setText("Ajustar a l\u00edmites"); |
|
155 |
jCheckBoxLimits.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
156 |
jCheckBoxLimits.setMargin(new Insets(0, 0, 0, 0)); |
|
157 |
jCheckBoxLimits.addActionListener(this); |
|
158 |
} |
|
159 |
return jCheckBoxLimits; |
|
160 |
} |
|
161 |
|
|
113 | 162 |
private JPanel getJPanelLimits() { |
114 | 163 |
if (jPanelLimits == null) { |
115 | 164 |
java.awt.GridBagConstraints gridBagConstraints; |
116 | 165 |
|
117 | 166 |
jPanelLimits = new JPanel(); |
118 |
jCheckBoxLimits = new JCheckBox(); |
|
119 |
jLabel1 = new JLabel(); |
|
120 |
jLabel2 = new JLabel(); |
|
121 |
jTextFieldMinimum = new JTextField(); |
|
122 |
jTextFieldMaximum = new JTextField(); |
|
123 |
|
|
124 | 167 |
jPanelLimits.setLayout(new GridBagLayout()); |
125 | 168 |
|
126 | 169 |
jPanelLimits.setBorder(BorderFactory.createTitledBorder("L\u00edmites")); |
127 |
jCheckBoxLimits.setText("Ajustar a l\u00edmites"); |
|
128 |
jCheckBoxLimits.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
129 |
jCheckBoxLimits.setMargin(new Insets(0, 0, 0, 0)); |
|
130 | 170 |
gridBagConstraints = new GridBagConstraints(); |
131 | 171 |
gridBagConstraints.gridwidth = 2; |
132 | 172 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; |
133 | 173 |
gridBagConstraints.insets = new Insets(5, 5, 2, 5); |
134 |
jPanelLimits.add(jCheckBoxLimits, gridBagConstraints);
|
|
174 |
jPanelLimits.add(getJCheckBoxLimits(), gridBagConstraints);
|
|
135 | 175 |
|
136 |
jLabel1.setText("M\u00ednimo: "); |
|
137 | 176 |
gridBagConstraints = new GridBagConstraints(); |
138 | 177 |
gridBagConstraints.gridx = 0; |
139 | 178 |
gridBagConstraints.gridy = 1; |
140 | 179 |
gridBagConstraints.anchor = GridBagConstraints.EAST; |
141 | 180 |
gridBagConstraints.insets = new Insets(2, 5, 2, 2); |
142 |
jPanelLimits.add(jLabel1, gridBagConstraints);
|
|
181 |
jPanelLimits.add(getJLabelMinimum(), gridBagConstraints);
|
|
143 | 182 |
|
144 |
jLabel2.setText("M\u00e1ximo: "); |
|
145 | 183 |
gridBagConstraints = new GridBagConstraints(); |
146 | 184 |
gridBagConstraints.gridx = 0; |
147 | 185 |
gridBagConstraints.gridy = 2; |
148 | 186 |
gridBagConstraints.anchor = GridBagConstraints.EAST; |
149 | 187 |
gridBagConstraints.insets = new Insets(2, 5, 5, 2); |
150 |
jPanelLimits.add(jLabel2, gridBagConstraints);
|
|
188 |
jPanelLimits.add(getJLabelMaximum(), gridBagConstraints);
|
|
151 | 189 |
|
152 | 190 |
gridBagConstraints = new GridBagConstraints(); |
153 | 191 |
gridBagConstraints.gridx = 1; |
... | ... | |
156 | 194 |
gridBagConstraints.anchor = GridBagConstraints.WEST; |
157 | 195 |
gridBagConstraints.weightx = 1.0; |
158 | 196 |
gridBagConstraints.insets = new Insets(2, 2, 2, 5); |
159 |
jTextFieldMinimum.setText("0"); |
|
160 |
jPanelLimits.add(jTextFieldMinimum, gridBagConstraints); |
|
197 |
jPanelLimits.add(getJTextFieldMinimum(), gridBagConstraints); |
|
161 | 198 |
|
162 | 199 |
gridBagConstraints = new GridBagConstraints(); |
163 | 200 |
gridBagConstraints.gridx = 1; |
... | ... | |
166 | 203 |
gridBagConstraints.anchor = GridBagConstraints.WEST; |
167 | 204 |
gridBagConstraints.weightx = 1.0; |
168 | 205 |
gridBagConstraints.insets = new Insets(2, 2, 5, 5); |
169 |
jTextFieldMaximum.setText("255"); |
|
170 |
jPanelLimits.add(jTextFieldMaximum, gridBagConstraints); |
|
206 |
jPanelLimits.add(getJTextFieldMaximum(), gridBagConstraints); |
|
171 | 207 |
} |
172 | 208 |
return jPanelLimits; |
173 | 209 |
} |
... | ... | |
256 | 292 |
* @throws NotInitializeException |
257 | 293 |
*/ |
258 | 294 |
public ArrayList getPalette() { |
295 |
double min2 = min; |
|
296 |
double max2 = max; |
|
297 |
|
|
298 |
if (getJCheckBoxLimits().isSelected()) { |
|
299 |
min2 = Double.parseDouble(getJTextFieldMinimum().getText()); |
|
300 |
max2 = Double.parseDouble(getJTextFieldMaximum().getText()); |
|
301 |
} |
|
302 |
|
|
303 |
|
|
259 | 304 |
ArrayList arrayList = new ArrayList(); |
260 | 305 |
ArrayList items = getColorSliderEdition().getItemsShowed(); |
261 | 306 |
|
... | ... | |
265 | 310 |
colorItem.setColor(item.getColor()); |
266 | 311 |
colorItem.setInterpolated(item.getInterpolated()); |
267 | 312 |
colorItem.setNameClass(""); |
268 |
colorItem.setValue(min); |
|
313 |
colorItem.setValue(min2);
|
|
269 | 314 |
arrayList.add(colorItem); |
270 | 315 |
|
271 | 316 |
for (int i = 0; i < items.size(); i++) { |
... | ... | |
275 | 320 |
colorItem.setInterpolated((int) item.getInterpolated()); |
276 | 321 |
colorItem.setNameClass(item.getName()); |
277 | 322 |
|
278 |
colorItem.setValue(min + ((item.getValue() * (max - min)) / 100.0d));
|
|
323 |
colorItem.setValue(min2 + ((item.getValue() * (max2 - min2)) / 100.0d));
|
|
279 | 324 |
|
280 | 325 |
arrayList.add(colorItem); |
281 | 326 |
} |
... | ... | |
286 | 331 |
colorItem.setColor(item.getColor()); |
287 | 332 |
colorItem.setInterpolated(item.getInterpolated()); |
288 | 333 |
colorItem.setNameClass(""); |
289 |
colorItem.setValue(max); |
|
334 |
colorItem.setValue(max2);
|
|
290 | 335 |
arrayList.add(colorItem); |
291 | 336 |
|
292 | 337 |
|
293 | 338 |
return arrayList; |
294 | 339 |
} |
340 |
|
|
341 |
public void actionPerformed(ActionEvent e) { |
|
342 |
if (e.getSource() == getJCheckBoxLimits()) { |
|
343 |
getJTextFieldMaximum().setEnabled(getJCheckBoxLimits().isSelected()); |
|
344 |
getJTextFieldMinimum().setEnabled(getJCheckBoxLimits().isSelected()); |
|
345 |
getJLabelMaximum().setEnabled(getJCheckBoxLimits().isSelected()); |
|
346 |
getJLabelMinimum().setEnabled(getJCheckBoxLimits().isSelected()); |
|
347 |
callValueColorChanged(); |
|
348 |
} |
|
349 |
} |
|
295 | 350 |
} |
Also available in: Unified diff