svn-gvsig-desktop / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / gui / beans / OptionsPanel.java @ 20393
History | View | Annotate | Download (21.7 KB)
1 | 17517 | gsdiego | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Iba?ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
|
||
34 | * Campus Universitario s/n
|
||
35 | * 02071 Alabacete
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 967 599 200
|
||
39 | */
|
||
40 | |||
41 | package org.gvsig.remotesensing.gui.beans; |
||
42 | |||
43 | import info.clearthought.layout.TableLayout; |
||
44 | |||
45 | import java.awt.BorderLayout; |
||
46 | import java.awt.GridBagConstraints; |
||
47 | import java.awt.GridBagLayout; |
||
48 | import java.awt.event.ActionEvent; |
||
49 | import java.awt.event.ActionListener; |
||
50 | import java.awt.event.FocusEvent; |
||
51 | import java.awt.event.FocusListener; |
||
52 | import java.awt.event.KeyEvent; |
||
53 | import java.awt.event.KeyListener; |
||
54 | import java.util.ArrayList; |
||
55 | |||
56 | import javax.swing.BorderFactory; |
||
57 | import javax.swing.ButtonGroup; |
||
58 | import javax.swing.ComboBoxModel; |
||
59 | import javax.swing.DefaultComboBoxModel; |
||
60 | import javax.swing.JComboBox; |
||
61 | import javax.swing.JLabel; |
||
62 | import javax.swing.JPanel; |
||
63 | import javax.swing.JRadioButton; |
||
64 | import javax.swing.JTextField; |
||
65 | import javax.swing.border.CompoundBorder; |
||
66 | import javax.swing.border.EmptyBorder; |
||
67 | import javax.swing.border.TitledBorder; |
||
68 | |||
69 | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
||
70 | 18961 | nbrodin | import org.gvsig.raster.RasterLibrary; |
71 | 17517 | gsdiego | import org.gvsig.raster.grid.GridExtent; |
72 | import org.gvsig.raster.util.RasterToolsUtil; |
||
73 | |||
74 | import com.iver.andami.PluginServices; |
||
75 | import com.iver.cit.gvsig.fmap.MapContext; |
||
76 | import com.iver.cit.gvsig.fmap.layers.FLayers; |
||
77 | import com.iver.cit.gvsig.project.documents.view.gui.View; |
||
78 | |||
79 | /**
|
||
80 | * Panel de configuracion de las opciones de salida.
|
||
81 | * Puede ajustarse el extent de salida y las opciones habituales de salvado de la
|
||
82 | * capa.
|
||
83 | *
|
||
84 | * @author Alejandro Mu?oz S?nchez (alejandro.munoz@uclm.es)
|
||
85 | * @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)
|
||
86 | * @version 22/10/2007
|
||
87 | */
|
||
88 | public class OptionsPanel extends JPanel implements ActionListener,FocusListener,KeyListener { |
||
89 | |||
90 | private static final long serialVersionUID = 1L; |
||
91 | private JPanel namePanel = null; |
||
92 | private JPanel panelExtension = null; |
||
93 | private JPanel paramPanel = null; |
||
94 | |||
95 | private JTextField jTextNombreCapa = null; |
||
96 | private JTextField jTextRangoX1 = null; |
||
97 | private JTextField jTextRangoX2 = null; |
||
98 | private JTextField jTextRangoY1 = null; |
||
99 | private JTextField jTextRangoY2 = null; |
||
100 | private JTextField jTextCellSize = null; |
||
101 | private JTextField jTextNumFiCol1 = null; |
||
102 | private JTextField jTextNumFiCol2 = null; |
||
103 | private FLayers layers = null; |
||
104 | |||
105 | private JRadioButton rButtom1 = null; |
||
106 | private JRadioButton rButtom2 = null; |
||
107 | private JRadioButton rButtom4 = null; |
||
108 | private JRadioButton rButtonFile = null; |
||
109 | private JRadioButton rButtonMemory = null; |
||
110 | private JComboBox jComboCapas = null; |
||
111 | private MapContext mapContext = null; |
||
112 | private GridExtent outputExtent = null; |
||
113 | private ArrayList layersList = null; |
||
114 | |||
115 | |||
116 | /**
|
||
117 | * Constructor
|
||
118 | * @param vista vista de la aplicaci?n
|
||
119 | * @param cp calculatorPanel desde el que se invoca
|
||
120 | */
|
||
121 | public OptionsPanel(View vista) { |
||
122 | super();
|
||
123 | if (vista!=null){ |
||
124 | mapContext = vista.getModel().getMapContext(); |
||
125 | layers = mapContext.getLayers(); |
||
126 | } |
||
127 | Inicializar(); |
||
128 | } |
||
129 | |||
130 | /**
|
||
131 | * Inicializaci?n del panel
|
||
132 | */
|
||
133 | public void Inicializar(){ |
||
134 | BorderLayout bd=new BorderLayout(); |
||
135 | this.setLayout(bd);
|
||
136 | this.setBorder( new EmptyBorder(2, 2, 2, 2)); |
||
137 | this.add(getNamePanel(),BorderLayout.NORTH); |
||
138 | this.add(getPanelExtension(),BorderLayout.WEST); |
||
139 | this.add(getParameterPanel(),BorderLayout.CENTER); |
||
140 | 17846 | amunoz | this.updateNewLayerText();
|
141 | 17517 | gsdiego | getRadioMemory().setSelected(true);
|
142 | } |
||
143 | |||
144 | |||
145 | /**
|
||
146 | * @return JRadioButton de generar fichero
|
||
147 | */
|
||
148 | public JRadioButton getRadioFile(){ |
||
149 | if (rButtonFile == null){ |
||
150 | rButtonFile = new JRadioButton(PluginServices.getText(this,"a_fichero")); |
||
151 | rButtonFile.addActionListener(this);
|
||
152 | } |
||
153 | return rButtonFile;
|
||
154 | } |
||
155 | |||
156 | /**
|
||
157 | * @return JRadioButton de generar en memoria
|
||
158 | */
|
||
159 | public JRadioButton getRadioMemory(){ |
||
160 | if (rButtonMemory == null){ |
||
161 | rButtonMemory = new JRadioButton(PluginServices.getText(this,"a_memoria")); |
||
162 | rButtonMemory.addActionListener(this);
|
||
163 | } |
||
164 | return rButtonMemory;
|
||
165 | } |
||
166 | |||
167 | |||
168 | /**
|
||
169 | * @return panel que incluye el nombre de la capa y las opciones de almacenamieto de la capa de salida
|
||
170 | */
|
||
171 | public JPanel getNamePanel() { |
||
172 | |||
173 | if (namePanel==null){ |
||
174 | namePanel=new JPanel(); |
||
175 | GridBagConstraints gridBagConstraints;
|
||
176 | JPanel radioPanel = new JPanel(); |
||
177 | radioPanel.setLayout(new GridBagLayout()); |
||
178 | radioPanel.setBorder(BorderFactory.createTitledBorder("")); |
||
179 | ButtonGroup buttonGroup = new ButtonGroup(); |
||
180 | buttonGroup.add(getRadioMemory()); |
||
181 | gridBagConstraints = new java.awt.GridBagConstraints();
|
||
182 | gridBagConstraints.gridx = 0;
|
||
183 | gridBagConstraints.gridy = 1;
|
||
184 | gridBagConstraints.anchor = GridBagConstraints.WEST;
|
||
185 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
||
186 | radioPanel.add(getRadioMemory(),gridBagConstraints); |
||
187 | buttonGroup.add(getRadioFile()); |
||
188 | gridBagConstraints = new java.awt.GridBagConstraints();
|
||
189 | gridBagConstraints.gridx = 0;
|
||
190 | gridBagConstraints.gridy = 2;
|
||
191 | gridBagConstraints.anchor = GridBagConstraints.WEST;
|
||
192 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
||
193 | radioPanel.add(getRadioFile(),gridBagConstraints); |
||
194 | |||
195 | //Establece la separacin entre los elementos
|
||
196 | namePanel.setLayout(new GridBagLayout()); |
||
197 | |||
198 | gridBagConstraints = new java.awt.GridBagConstraints();
|
||
199 | gridBagConstraints.gridx = 0;
|
||
200 | gridBagConstraints.gridy = 0;
|
||
201 | gridBagConstraints.anchor = GridBagConstraints.WEST;
|
||
202 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
||
203 | namePanel.add(new JLabel(PluginServices.getText(this,"nombre_capa")),gridBagConstraints); |
||
204 | |||
205 | gridBagConstraints = new java.awt.GridBagConstraints();
|
||
206 | gridBagConstraints.gridx = 1;
|
||
207 | gridBagConstraints.gridy = 0;
|
||
208 | gridBagConstraints.anchor = GridBagConstraints.WEST;
|
||
209 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
||
210 | namePanel.add(getJTextNombreCapa(),gridBagConstraints); |
||
211 | |||
212 | gridBagConstraints = new java.awt.GridBagConstraints();
|
||
213 | gridBagConstraints.gridx = 2;
|
||
214 | gridBagConstraints.gridy = 0;
|
||
215 | gridBagConstraints.anchor = GridBagConstraints.WEST;
|
||
216 | gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
||
217 | namePanel.add(radioPanel,gridBagConstraints); |
||
218 | } |
||
219 | return namePanel;
|
||
220 | } |
||
221 | |||
222 | |||
223 | /**
|
||
224 | * @return textField con el nombre de la capa
|
||
225 | */
|
||
226 | public JTextField getJTextNombreCapa() { |
||
227 | if (jTextNombreCapa==null){ |
||
228 | jTextNombreCapa=new JTextField(15); |
||
229 | jTextNombreCapa.addFocusListener(this);
|
||
230 | } |
||
231 | return jTextNombreCapa;
|
||
232 | } |
||
233 | |||
234 | |||
235 | |||
236 | /**
|
||
237 | * @return panel con las opciones de configuraci?n de extent,
|
||
238 | * los radioButton y el comboCapas
|
||
239 | */
|
||
240 | public JPanel getPanelExtension() { |
||
241 | |||
242 | if (panelExtension==null){ |
||
243 | panelExtension=new JPanel(); |
||
244 | TitledBorder topBorder = BorderFactory.createTitledBorder((PluginServices.getText(this,"extension_from"))); |
||
245 | topBorder.setTitlePosition(TitledBorder.TOP);
|
||
246 | panelExtension.setBorder(new CompoundBorder(topBorder,new EmptyBorder(5,5,6,5))); |
||
247 | |||
248 | JPanel p=new JPanel(); |
||
249 | //p.setPreferredSize(new Dimension(200,130));
|
||
250 | TableLayout thisLayout = new TableLayout(new double[][] { |
||
251 | {200},
|
||
252 | {TableLayout.PREFERRED,TableLayout.PREFERRED,TableLayout.PREFERRED, TableLayout.PREFERRED}}); |
||
253 | //Establece la separacin entre los elementos
|
||
254 | thisLayout.setHGap(5);
|
||
255 | thisLayout.setVGap(5);
|
||
256 | panelExtension.setLayout(thisLayout); |
||
257 | p.setLayout(thisLayout); |
||
258 | ButtonGroup buttonGroup = new ButtonGroup(); |
||
259 | buttonGroup.add(getRButtom1()); |
||
260 | buttonGroup.add(getRButtom2()); |
||
261 | buttonGroup.add(getRButtom4()); |
||
262 | panelExtension.add(getRButtom1(),"0,0");
|
||
263 | panelExtension.add(getRButtom2(),"0,1");
|
||
264 | panelExtension.add(getRButtom4(),"0,2");
|
||
265 | panelExtension.add(getJComboCapas(),"0,3");
|
||
266 | |||
267 | } |
||
268 | |||
269 | return panelExtension;
|
||
270 | } |
||
271 | |||
272 | |||
273 | /**
|
||
274 | * @return panel con los parametros de configuraci?n de extensi?n de la salida raster.
|
||
275 | */
|
||
276 | public JPanel getParameterPanel() { |
||
277 | |||
278 | |||
279 | if (paramPanel==null){ |
||
280 | paramPanel=new JPanel(); |
||
281 | TitledBorder topBorder = BorderFactory.createTitledBorder((PluginServices.getText(this,"parametros"))); |
||
282 | topBorder.setTitlePosition(TitledBorder.TOP);
|
||
283 | paramPanel.setBorder(new CompoundBorder(topBorder,new EmptyBorder(5,5,6,5))); |
||
284 | |||
285 | |||
286 | JPanel p=new JPanel(); |
||
287 | // p.setPreferredSize(new Dimension(320,130));
|
||
288 | TableLayout thisLayout = new TableLayout(new double[][] { |
||
289 | {150,75, 75}, |
||
290 | {20,20,20,20}}); |
||
291 | //Establece la separacin entre los elementos
|
||
292 | thisLayout.setHGap(3);
|
||
293 | thisLayout.setVGap(3);
|
||
294 | p.setLayout(thisLayout); |
||
295 | |||
296 | //Aado los diferentes elementos
|
||
297 | p.add(new JLabel((PluginServices.getText(this,"rangox"))),"0,0"); |
||
298 | p.add(new JLabel((PluginServices.getText(this,"rangoy"))),"0,1"); |
||
299 | p.add(new JLabel((PluginServices.getText(this,"tamanio_celda"))),"0,2"); |
||
300 | p.add(new JLabel((PluginServices.getText(this,"num_filas_columnas"))),"0,3"); |
||
301 | p.add(getJTextCellSize(),"1,2");
|
||
302 | p.add(getJTextNumFiCol1(),"1,3");
|
||
303 | p.add(getJTextNumFiCol2(),"2,3");
|
||
304 | p.add(getJTextRangoX1(),"1,0");
|
||
305 | p.add(getJTextRangoX2(),"2,0");
|
||
306 | p.add(getJTextRangoY1(),"1,1");
|
||
307 | p.add(getJTextRangoY2(),"2,1");
|
||
308 | |||
309 | paramPanel.add(p); |
||
310 | } |
||
311 | return paramPanel;
|
||
312 | } |
||
313 | |||
314 | |||
315 | |||
316 | /**
|
||
317 | * @return JRadioButton ajustar a datos de entrada
|
||
318 | */
|
||
319 | public JRadioButton getRButtom1() { |
||
320 | if(rButtom1==null){ |
||
321 | rButtom1=new JRadioButton((PluginServices.getText(this,"ajustar_entrada")), true); |
||
322 | rButtom1.addActionListener(this);
|
||
323 | } |
||
324 | return rButtom1;
|
||
325 | } |
||
326 | |||
327 | |||
328 | |||
329 | /**
|
||
330 | * @return JRadioButton extension definida por el usuario
|
||
331 | */
|
||
332 | public JRadioButton getRButtom2() { |
||
333 | if(rButtom2==null){ |
||
334 | rButtom2=new JRadioButton((PluginServices.getText(this,"definida_usuario")), false); |
||
335 | rButtom2.addActionListener(this);
|
||
336 | } |
||
337 | return rButtom2;
|
||
338 | } |
||
339 | |||
340 | |||
341 | |||
342 | /**
|
||
343 | * @return JRadioButton extension ajustada a otra capa
|
||
344 | */
|
||
345 | public JRadioButton getRButtom4() { |
||
346 | if(rButtom4==null){ |
||
347 | rButtom4=new JRadioButton((PluginServices.getText(this,"extension_capa")), false); |
||
348 | rButtom4.addActionListener(this);
|
||
349 | } |
||
350 | return rButtom4;
|
||
351 | } |
||
352 | |||
353 | |||
354 | /**
|
||
355 | * @return JTextField tama?o de celda
|
||
356 | */
|
||
357 | public JTextField getJTextCellSize() { |
||
358 | if (jTextCellSize==null){ |
||
359 | jTextCellSize=new JTextField(15);; |
||
360 | jTextCellSize.setEditable(false);
|
||
361 | jTextCellSize.addKeyListener(this);
|
||
362 | } |
||
363 | return jTextCellSize;
|
||
364 | } |
||
365 | |||
366 | |||
367 | |||
368 | /**
|
||
369 | * @return JTextField numero de filas
|
||
370 | */
|
||
371 | public JTextField getJTextNumFiCol1() { |
||
372 | if (jTextNumFiCol1==null){ |
||
373 | jTextNumFiCol1=new JTextField (); |
||
374 | jTextNumFiCol1.setEditable(false);
|
||
375 | } |
||
376 | return jTextNumFiCol1;
|
||
377 | } |
||
378 | |||
379 | |||
380 | |||
381 | /**
|
||
382 | * @return JTextField coordenada x m?nima
|
||
383 | */
|
||
384 | public JTextField getJTextRangoX1() { |
||
385 | if (jTextRangoX1==null){ |
||
386 | jTextRangoX1 =new JTextField (); |
||
387 | jTextRangoX1.setEditable(false);
|
||
388 | jTextRangoX1.addKeyListener(this);
|
||
389 | |||
390 | } |
||
391 | return jTextRangoX1;
|
||
392 | } |
||
393 | |||
394 | |||
395 | |||
396 | /**
|
||
397 | * @return JTextField coordenada x m?xima
|
||
398 | */
|
||
399 | public JTextField getJTextRangoX2() { |
||
400 | if (jTextRangoX2==null){ |
||
401 | jTextRangoX2=new JTextField (); |
||
402 | jTextRangoX2.setEditable(false);
|
||
403 | jTextRangoX2.addKeyListener(this);
|
||
404 | |||
405 | } |
||
406 | return jTextRangoX2;
|
||
407 | } |
||
408 | |||
409 | |||
410 | |||
411 | |||
412 | /**
|
||
413 | * @return JTextField coordenada y m?mnima
|
||
414 | */
|
||
415 | public JTextField getJTextRangoY1() { |
||
416 | if (jTextRangoY1==null){ |
||
417 | jTextRangoY1=new JTextField (); |
||
418 | jTextRangoY1.setEditable(false);
|
||
419 | jTextRangoY1.addKeyListener(this);
|
||
420 | } |
||
421 | return jTextRangoY1;
|
||
422 | } |
||
423 | |||
424 | |||
425 | |||
426 | /**
|
||
427 | * @return JTextField coordenada y m?xima
|
||
428 | */
|
||
429 | public JTextField getJTextRangoY2() { |
||
430 | if (jTextRangoY2==null){ |
||
431 | jTextRangoY2=new JTextField (); |
||
432 | jTextRangoY2.setEditable(false);
|
||
433 | jTextRangoY2.addKeyListener(this);
|
||
434 | } |
||
435 | return jTextRangoY2;
|
||
436 | } |
||
437 | |||
438 | |||
439 | |||
440 | |||
441 | /**
|
||
442 | * @return JTextField numero de columnas
|
||
443 | */
|
||
444 | public JTextField getJTextNumFiCol2() { |
||
445 | if (jTextNumFiCol2==null){ |
||
446 | jTextNumFiCol2=new JTextField (); |
||
447 | jTextNumFiCol2.setEditable(false);
|
||
448 | } |
||
449 | return jTextNumFiCol2;
|
||
450 | } |
||
451 | |||
452 | |||
453 | |||
454 | /**
|
||
455 | * @return JCombo con las capas raster cargadas en la vista
|
||
456 | */
|
||
457 | public JComboBox getJComboCapas() { |
||
458 | if (jComboCapas==null){ |
||
459 | ComboBoxModel jComboBoxLayersModel = new DefaultComboBoxModel(getLayerNames()); |
||
460 | jComboCapas = new JComboBox(); |
||
461 | jComboCapas.setModel(jComboBoxLayersModel); |
||
462 | jComboCapas.setEnabled(false);
|
||
463 | jComboCapas.addActionListener(this);
|
||
464 | } |
||
465 | return jComboCapas;
|
||
466 | } |
||
467 | |||
468 | /**
|
||
469 | * @return array con el nombre de los ficheros cargados en la vista
|
||
470 | */
|
||
471 | private String[] getLayerNames() { |
||
472 | String[] sNames = {}; |
||
473 | if (layers!=null){ |
||
474 | sNames = new String[layers.getLayersCount()]; |
||
475 | for (int i = 0; i < layers.getLayersCount(); i++) { |
||
476 | sNames[i] = (layers.getLayer(i)).getName(); |
||
477 | } |
||
478 | } |
||
479 | return sNames;
|
||
480 | } |
||
481 | |||
482 | |||
483 | /**
|
||
484 | * Establece la opci?n por defecto cuando se crea en cuadro de dialogo
|
||
485 | */
|
||
486 | public void InicializarOpcion(){ |
||
487 | |||
488 | DesabilitarTodo(); |
||
489 | rButtom1.setSelected(true);
|
||
490 | // Establecemos la opcion por defecto.
|
||
491 | setAjustInDataExtent(); |
||
492 | } |
||
493 | |||
494 | |||
495 | /**
|
||
496 | * Deshabilita todos los componetes variables de la interfaz
|
||
497 | */
|
||
498 | public void DesabilitarTodo(){ |
||
499 | |||
500 | jComboCapas.setEnabled(false);
|
||
501 | jTextRangoX1.setEditable(false);
|
||
502 | jTextRangoX1.setEnabled(false);
|
||
503 | jTextRangoX2.setEditable(false);
|
||
504 | jTextRangoX2.setEnabled(false);
|
||
505 | jTextRangoY1.setEditable(false);
|
||
506 | jTextRangoY1.setEnabled(false);
|
||
507 | jTextRangoY2.setEditable(false);
|
||
508 | jTextRangoY2.setEnabled(false);
|
||
509 | jTextNumFiCol1.setEditable(false);
|
||
510 | jTextCellSize.setEditable(false);
|
||
511 | jTextCellSize.setEnabled(false);
|
||
512 | jTextNumFiCol1.setEnabled(false);
|
||
513 | jTextNumFiCol2.setEditable(false);
|
||
514 | jTextNumFiCol2.setEnabled(false);
|
||
515 | jComboCapas.updateUI(); |
||
516 | |||
517 | } |
||
518 | |||
519 | |||
520 | /**
|
||
521 | * Reestablece el numero de filas y columnas ante cuanquier variaci?n de la interfaz
|
||
522 | */
|
||
523 | public void extentHasChanged(){ |
||
524 | |||
525 | double dRangeX;
|
||
526 | double dRangeY;
|
||
527 | double dCellSize;
|
||
528 | int iRows;
|
||
529 | int iCols;
|
||
530 | // Se actualiza la X
|
||
531 | try {
|
||
532 | dRangeX = Math.abs(Double.parseDouble(getJTextRangoX2().getText()) |
||
533 | - Double.parseDouble(getJTextRangoX1().getText()));
|
||
534 | dCellSize = Double.parseDouble(getJTextCellSize().getText());
|
||
535 | iCols = (int) Math.floor(dRangeX / dCellSize); |
||
536 | getJTextNumFiCol2().setText(Integer.toString(iCols));
|
||
537 | |||
538 | // Se actualiza la Y
|
||
539 | dRangeY = Math.abs(Double.parseDouble(getJTextRangoY2().getText()) |
||
540 | - Double.parseDouble(getJTextRangoY1().getText()));
|
||
541 | dCellSize = Double.parseDouble(getJTextCellSize().getText());
|
||
542 | iRows = (int) Math.floor(dRangeY / dCellSize); |
||
543 | getJTextNumFiCol1().setText(Integer.toString(iRows));
|
||
544 | |||
545 | |||
546 | } catch (NumberFormatException e) { |
||
547 | RasterToolsUtil.messageBoxError(PluginServices.getText(this, "invalid_number"), this); |
||
548 | } |
||
549 | } |
||
550 | |||
551 | private void validateKeyTyping(KeyEvent event) { |
||
552 | jComboCapas.updateUI(); |
||
553 | switch (event.getKeyChar()) {
|
||
554 | |||
555 | case KeyEvent.VK_ENTER: |
||
556 | extentHasChanged(); |
||
557 | jComboCapas.updateUI(); |
||
558 | break;
|
||
559 | |||
560 | case KeyEvent.VK_BACK_SPACE: |
||
561 | extentHasChanged(); |
||
562 | break;
|
||
563 | case KeyEvent.VK_0 : |
||
564 | extentHasChanged(); |
||
565 | break;
|
||
566 | case KeyEvent.VK_1 : |
||
567 | extentHasChanged(); |
||
568 | break;
|
||
569 | case KeyEvent.VK_2 : |
||
570 | extentHasChanged(); |
||
571 | break;
|
||
572 | case KeyEvent.VK_3: |
||
573 | extentHasChanged(); |
||
574 | break;
|
||
575 | case KeyEvent.VK_4: |
||
576 | extentHasChanged(); |
||
577 | break;
|
||
578 | case KeyEvent.VK_5: |
||
579 | extentHasChanged(); |
||
580 | break;
|
||
581 | case KeyEvent.VK_6: |
||
582 | extentHasChanged(); |
||
583 | break;
|
||
584 | case KeyEvent.VK_7: |
||
585 | extentHasChanged(); |
||
586 | break;
|
||
587 | case KeyEvent.VK_8: |
||
588 | extentHasChanged(); |
||
589 | break;
|
||
590 | case KeyEvent.VK_9 : |
||
591 | extentHasChanged(); |
||
592 | break;
|
||
593 | } |
||
594 | } |
||
595 | |||
596 | |||
597 | |||
598 | /**
|
||
599 | * Fija las acciones que se realizan cuando se produce un evento
|
||
600 | * @param e Objeto que genera el evento
|
||
601 | */
|
||
602 | public void actionPerformed(ActionEvent e) { |
||
603 | |||
604 | //Radiobutton1
|
||
605 | if (e.getSource()==getRButtom1() || e.getSource()==getRButtom2() ||
|
||
606 | e.getSource()==getRButtom4() || e.getSource()==getJComboCapas()){ |
||
607 | updateParams(); |
||
608 | } |
||
609 | |||
610 | else if (e.getSource()==getRadioFile()){ |
||
611 | rButtonFile.setSelected(true);
|
||
612 | } |
||
613 | |||
614 | else if (e.getSource()==getRadioMemory()){ |
||
615 | rButtonMemory.setSelected(true);
|
||
616 | } |
||
617 | |||
618 | } |
||
619 | |||
620 | /**
|
||
621 | * Actualizacion de los parametros ajustandolos a los de la capa seleccionada
|
||
622 | */
|
||
623 | private void updateParams(){ |
||
624 | double dCoord;
|
||
625 | if (getRButtom4().isSelected()){
|
||
626 | |||
627 | DesabilitarTodo(); |
||
628 | rButtom4.setSelected(true);
|
||
629 | jComboCapas.setEnabled(true);
|
||
630 | jTextCellSize.setEditable(true);
|
||
631 | jTextCellSize.setEnabled(true);
|
||
632 | getJComboCapas().updateUI(); |
||
633 | try {
|
||
634 | FLyrRasterSE rasterLayer = (FLyrRasterSE)mapContext.getLayers().getLayer((String)getJComboCapas().getSelectedItem());
|
||
635 | dCoord = rasterLayer.getFullExtent().getMinX(); |
||
636 | getJTextRangoX1().setText(new Double(dCoord).toString()); |
||
637 | dCoord = rasterLayer.getFullExtent().getMaxX(); |
||
638 | getJTextRangoX2().setText(new Double(dCoord).toString()); |
||
639 | dCoord = rasterLayer.getFullExtent().getMinY(); |
||
640 | getJTextRangoY1().setText(new Double(dCoord).toString()); |
||
641 | dCoord = rasterLayer.getFullExtent().getMaxY(); |
||
642 | getJTextRangoY2().setText(new Double(dCoord).toString()); |
||
643 | if (rasterLayer instanceof FLyrRasterSE){ |
||
644 | getJTextCellSize().setText(new Double( |
||
645 | 17687 | nbrodin | ((FLyrRasterSE) rasterLayer).getCellSize()) |
646 | 17517 | gsdiego | .toString()); |
647 | } |
||
648 | extentHasChanged(); |
||
649 | } catch (Exception ex) {} |
||
650 | }else if(getRButtom2().isSelected()){ |
||
651 | DesabilitarTodo(); |
||
652 | rButtom2.setSelected(true);
|
||
653 | getJTextRangoX1().setEnabled(true);
|
||
654 | getJTextRangoX1().setEditable(true);
|
||
655 | getJTextRangoX2().setEnabled(true);
|
||
656 | getJTextRangoX2().setEditable(true);
|
||
657 | getJTextRangoY1().setEnabled(true);
|
||
658 | getJTextRangoY1().setEditable(true);
|
||
659 | getJTextRangoY2().setEditable(true);
|
||
660 | getJTextRangoY2().setEnabled(true);
|
||
661 | getJTextCellSize().setEditable(true);
|
||
662 | getJTextCellSize().setEnabled(true);
|
||
663 | |||
664 | }else if(getRButtom1().isSelected()){ |
||
665 | DesabilitarTodo(); |
||
666 | setAjustInDataExtent(); |
||
667 | } |
||
668 | |||
669 | } |
||
670 | |||
671 | |||
672 | |||
673 | /**
|
||
674 | * Establece el extent de salida ajustandolo a los datos de entrada.
|
||
675 | */
|
||
676 | private void setAjustInDataExtent(){ |
||
677 | if( getLayersList().size() > 0){ |
||
678 | |||
679 | String layerName = null; |
||
680 | FLyrRasterSE rasterLayer = null;
|
||
681 | double xMin = 0; |
||
682 | double xMax = 0; |
||
683 | double yMin = 0; |
||
684 | double yMax = 0; |
||
685 | double cellSize= 0 ; |
||
686 | boolean existLayers = false; |
||
687 | |||
688 | int i = 0; |
||
689 | for (i=0;i<getLayersList().size();i++){ |
||
690 | layerName = (String)getLayersList().get(i);
|
||
691 | 20393 | dguerrero | if (!layerName.equals("")){ |
692 | layerName = layerName.substring(0,layerName.indexOf("[")); |
||
693 | rasterLayer = (FLyrRasterSE)mapContext.getLayers().getLayer(layerName); |
||
694 | if (rasterLayer!=null){ |
||
695 | xMin =rasterLayer.getFullRasterExtent().minX(); |
||
696 | xMax =rasterLayer.getFullRasterExtent().maxX(); |
||
697 | yMin =rasterLayer.getFullRasterExtent().minY(); |
||
698 | yMax =rasterLayer.getFullRasterExtent().maxY(); |
||
699 | cellSize=rasterLayer.getCellSize(); |
||
700 | existLayers = true;
|
||
701 | } |
||
702 | 17517 | gsdiego | } |
703 | } |
||
704 | |||
705 | for (;i<getLayersList().size();i++){
|
||
706 | layerName = (String)getLayersList().get(i);
|
||
707 | layerName = layerName.substring(0,layerName.indexOf("[")); |
||
708 | rasterLayer = (FLyrRasterSE)mapContext.getLayers().getLayer(layerName); |
||
709 | |||
710 | if(rasterLayer != null){ |
||
711 | 17687 | nbrodin | xMin = Math.min(xMin,rasterLayer.getFullRasterExtent().minX());
|
712 | xMax = Math.max(rasterLayer.getFullRasterExtent().maxX(),xMax);
|
||
713 | yMin = Math.min(yMin,rasterLayer.getFullRasterExtent().minY());
|
||
714 | yMax = Math.max(yMax,rasterLayer.getFullRasterExtent().maxY());
|
||
715 | cellSize = Math.min(cellSize,rasterLayer.getCellSize());
|
||
716 | 17517 | gsdiego | } |
717 | } |
||
718 | |||
719 | if (existLayers){
|
||
720 | getOutputExtent().setXRange(xMin,xMax); |
||
721 | getOutputExtent().setYRange(yMin,yMax); |
||
722 | getOutputExtent().setCellSize(cellSize); |
||
723 | |||
724 | getJTextRangoX1().setText(String.valueOf(getOutputExtent().minX()));
|
||
725 | getJTextRangoX2().setText(String.valueOf(getOutputExtent().maxX()));
|
||
726 | getJTextRangoY1().setText(String.valueOf(getOutputExtent().minY()));
|
||
727 | getJTextRangoY2().setText(String.valueOf(getOutputExtent().maxY()));
|
||
728 | getJTextCellSize().setText(String.valueOf(cellSize));
|
||
729 | 20393 | dguerrero | |
730 | extentHasChanged(); |
||
731 | 17517 | gsdiego | } |
732 | else{
|
||
733 | getJTextRangoX1().setText("");
|
||
734 | getJTextRangoX2().setText("");
|
||
735 | getJTextRangoY1().setText("");
|
||
736 | getJTextRangoY2().setText("");
|
||
737 | getJTextCellSize().setText("");
|
||
738 | } |
||
739 | } |
||
740 | } |
||
741 | |||
742 | /**
|
||
743 | * Eventos del teclado
|
||
744 | */
|
||
745 | public void keyReleased(KeyEvent e) { |
||
746 | |||
747 | if(e.getSource()==getJTextRangoX1()){
|
||
748 | validateKeyTyping(e); |
||
749 | } |
||
750 | |||
751 | if(e.getSource()==getJTextRangoX2()){
|
||
752 | validateKeyTyping(e); |
||
753 | } |
||
754 | |||
755 | if(e.getSource()==getJTextRangoY1()){
|
||
756 | validateKeyTyping(e); |
||
757 | } |
||
758 | |||
759 | if(e.getSource()==getJTextRangoY2()){
|
||
760 | validateKeyTyping(e); |
||
761 | } |
||
762 | |||
763 | if (e.getSource()==getJTextCellSize()){
|
||
764 | |||
765 | validateKeyTyping(e); |
||
766 | } |
||
767 | } |
||
768 | |||
769 | /**
|
||
770 | * Especificar el nombre de la nueva capa para el recuadro de texto asign?ndo
|
||
771 | * en cada llamada un nombre consecutivo.
|
||
772 | */
|
||
773 | 17846 | amunoz | public void updateNewLayerText() { |
774 | 18961 | nbrodin | getJTextNombreCapa().setText(RasterLibrary.getOnlyLayerName()); |
775 | 17846 | amunoz | } |
776 | 17517 | gsdiego | |
777 | public void focusGained(FocusEvent arg0) { |
||
778 | |||
779 | } |
||
780 | |||
781 | public void focusLost(FocusEvent arg0) { |
||
782 | |||
783 | } |
||
784 | |||
785 | |||
786 | |||
787 | public void keyPressed(KeyEvent arg0) { |
||
788 | |||
789 | } |
||
790 | |||
791 | |||
792 | |||
793 | public void keyTyped(KeyEvent arg0) { |
||
794 | |||
795 | } |
||
796 | |||
797 | public GridExtent getOutputExtent() {
|
||
798 | if (outputExtent == null) |
||
799 | outputExtent = new GridExtent();
|
||
800 | return outputExtent;
|
||
801 | } |
||
802 | |||
803 | public ArrayList getLayersList() { |
||
804 | if (layersList == null) |
||
805 | layersList = new ArrayList(); |
||
806 | return layersList;
|
||
807 | } |
||
808 | |||
809 | public void setLayersList(ArrayList layersList) { |
||
810 | this.layersList = layersList;
|
||
811 | updateParams(); |
||
812 | } |
||
813 | } |