svn-gvsig-desktop / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / gridmath / gui / OutputOptionsPanel.java @ 20826
History | View | Annotate | Download (23.2 KB)
1 | 13790 | dguerrero | /* 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 | 17254 | gsdiego | package org.gvsig.remotesensing.gridmath.gui; |
42 | 13790 | dguerrero | |
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 | |||
55 | import javax.swing.BorderFactory; |
||
56 | import javax.swing.ButtonGroup; |
||
57 | import javax.swing.ComboBoxModel; |
||
58 | import javax.swing.DefaultComboBoxModel; |
||
59 | import javax.swing.JComboBox; |
||
60 | import javax.swing.JLabel; |
||
61 | import javax.swing.JPanel; |
||
62 | import javax.swing.JRadioButton; |
||
63 | import javax.swing.JTextField; |
||
64 | import javax.swing.border.CompoundBorder; |
||
65 | import javax.swing.border.EmptyBorder; |
||
66 | import javax.swing.border.TitledBorder; |
||
67 | |||
68 | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
||
69 | 18961 | nbrodin | import org.gvsig.raster.RasterLibrary; |
70 | import org.gvsig.raster.util.PropertyEvent; |
||
71 | import org.gvsig.raster.util.PropertyListener; |
||
72 | 16587 | amunoz | import org.gvsig.raster.util.RasterToolsUtil; |
73 | 13790 | dguerrero | |
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 | 14835 | amunoz | /**
|
80 | 17254 | gsdiego | * Panel de configuracion de las opciones de salida.
|
81 | 14835 | amunoz | * 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 | 13790 | dguerrero | */
|
88 | 17844 | amunoz | public class OutputOptionsPanel extends JPanel implements ActionListener,FocusListener,KeyListener,PropertyListener { |
89 | |||
90 | 14835 | amunoz | private static final long serialVersionUID = 1L; |
91 | 13790 | dguerrero | 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 | 20826 | dguerrero | private JTextField jTextCellSizeX = null; |
101 | private JTextField jTextCellSizeY = null; |
||
102 | 13790 | dguerrero | private JTextField jTextNumFiCol1 = null; |
103 | private JTextField jTextNumFiCol2 = null; |
||
104 | private FLayers layers = null; |
||
105 | |||
106 | private JRadioButton rButtom1 = null; |
||
107 | private JRadioButton rButtom2 = null; |
||
108 | private JRadioButton rButtom4 = null; |
||
109 | private JRadioButton rButtonFile = null; |
||
110 | private JRadioButton rButtonMemory = null; |
||
111 | private JComboBox jComboCapas = null; |
||
112 | private MapContext mapContext = null; |
||
113 | 17207 | gsdiego | private GridMathPanel cp = null; |
114 | 13790 | dguerrero | |
115 | 14835 | amunoz | |
116 | /**
|
||
117 | * Constructor
|
||
118 | * @param vista vista de la aplicaci?n
|
||
119 | * @param cp calculatorPanel desde el que se invoca
|
||
120 | */
|
||
121 | 17207 | gsdiego | public OutputOptionsPanel(View vista, GridMathPanel cp) { |
122 | 13790 | dguerrero | super();
|
123 | if (vista!=null){ |
||
124 | mapContext = vista.getModel().getMapContext(); |
||
125 | layers = mapContext.getLayers(); |
||
126 | } |
||
127 | this.cp=cp;
|
||
128 | Inicializar(); |
||
129 | } |
||
130 | |||
131 | 14835 | amunoz | /**
|
132 | * Inicializaci?n del panel
|
||
133 | */
|
||
134 | 13790 | dguerrero | public void Inicializar(){ |
135 | BorderLayout bd=new BorderLayout(); |
||
136 | this.setLayout(bd);
|
||
137 | 16088 | amunoz | this.setBorder( new EmptyBorder(2, 2, 2, 2)); |
138 | 13790 | dguerrero | this.add(getNamePanel(),BorderLayout.NORTH); |
139 | this.add(getPanelExtension(),BorderLayout.WEST); |
||
140 | this.add(getParameterPanel(),BorderLayout.CENTER); |
||
141 | 14835 | amunoz | getRadioMemory().setSelected(true);
|
142 | 13790 | dguerrero | } |
143 | |||
144 | |||
145 | 14835 | amunoz | /**
|
146 | * @return JRadioButton de generar fichero
|
||
147 | */
|
||
148 | 13790 | dguerrero | 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 | 14835 | amunoz | /**
|
157 | * @return JRadioButton de generar en memoria
|
||
158 | */
|
||
159 | 13790 | dguerrero | 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 | 14518 | amunoz | |
168 | 14835 | amunoz | /**
|
169 | * @return panel que incluye el nombre de la capa y las opciones de almacenamieto de la capa de salida
|
||
170 | */
|
||
171 | 13790 | dguerrero | 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 | 14518 | amunoz | namePanel.add(new JLabel(PluginServices.getText(this,"nombre_capa")),gridBagConstraints); |
204 | 13790 | dguerrero | |
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 | 17844 | amunoz | /**
|
224 | * @return javax.swing.JTextField
|
||
225 | */
|
||
226 | public JTextField getJTextNombreCapa() { |
||
227 | if (jTextNombreCapa==null) { |
||
228 | jTextNombreCapa=new JTextField(10); |
||
229 | 18961 | nbrodin | jTextNombreCapa.setText(RasterLibrary.getOnlyLayerName()); |
230 | 13790 | dguerrero | jTextNombreCapa.addFocusListener(this);
|
231 | 18961 | nbrodin | RasterLibrary.addOnlyLayerNameListener(this);
|
232 | 13790 | dguerrero | } |
233 | return jTextNombreCapa;
|
||
234 | } |
||
235 | |||
236 | |||
237 | |||
238 | 17844 | amunoz | |
239 | 14835 | amunoz | /**
|
240 | * @return panel con las opciones de configuraci?n de extent,
|
||
241 | * los radioButton y el comboCapas
|
||
242 | */
|
||
243 | 13790 | dguerrero | public JPanel getPanelExtension() { |
244 | |||
245 | if (panelExtension==null){ |
||
246 | panelExtension=new JPanel(); |
||
247 | TitledBorder topBorder = BorderFactory.createTitledBorder((PluginServices.getText(this,"extension_from"))); |
||
248 | topBorder.setTitlePosition(TitledBorder.TOP);
|
||
249 | 16088 | amunoz | panelExtension.setBorder(new CompoundBorder(topBorder,new EmptyBorder(5,5,6,5))); |
250 | 13790 | dguerrero | |
251 | JPanel p=new JPanel(); |
||
252 | 16088 | amunoz | //p.setPreferredSize(new Dimension(200,130));
|
253 | 13790 | dguerrero | TableLayout thisLayout = new TableLayout(new double[][] { |
254 | 16088 | amunoz | {200},
|
255 | {TableLayout.PREFERRED,TableLayout.PREFERRED,TableLayout.PREFERRED, TableLayout.PREFERRED}}); |
||
256 | 13790 | dguerrero | //Establece la separacin entre los elementos
|
257 | thisLayout.setHGap(5);
|
||
258 | 16088 | amunoz | thisLayout.setVGap(5);
|
259 | panelExtension.setLayout(thisLayout); |
||
260 | 13790 | dguerrero | p.setLayout(thisLayout); |
261 | 14538 | amunoz | ButtonGroup buttonGroup = new ButtonGroup(); |
262 | buttonGroup.add(getRButtom1()); |
||
263 | buttonGroup.add(getRButtom2()); |
||
264 | buttonGroup.add(getRButtom4()); |
||
265 | 16088 | amunoz | panelExtension.add(getRButtom1(),"0,0");
|
266 | panelExtension.add(getRButtom2(),"0,1");
|
||
267 | panelExtension.add(getRButtom4(),"0,2");
|
||
268 | panelExtension.add(getJComboCapas(),"0,3");
|
||
269 | |||
270 | 13790 | dguerrero | } |
271 | |||
272 | return panelExtension;
|
||
273 | } |
||
274 | |||
275 | |||
276 | 14835 | amunoz | /**
|
277 | * @return panel con los parametros de configuraci?n de extensi?n de la salida raster.
|
||
278 | */
|
||
279 | 13790 | dguerrero | public JPanel getParameterPanel() { |
280 | |||
281 | |||
282 | if (paramPanel==null){ |
||
283 | paramPanel=new JPanel(); |
||
284 | TitledBorder topBorder = BorderFactory.createTitledBorder((PluginServices.getText(this,"parametros"))); |
||
285 | topBorder.setTitlePosition(TitledBorder.TOP);
|
||
286 | 16088 | amunoz | paramPanel.setBorder(new CompoundBorder(topBorder,new EmptyBorder(5,5,6,5))); |
287 | 13790 | dguerrero | |
288 | |||
289 | JPanel p=new JPanel(); |
||
290 | 16088 | amunoz | // p.setPreferredSize(new Dimension(320,130));
|
291 | 13790 | dguerrero | TableLayout thisLayout = new TableLayout(new double[][] { |
292 | {150,75, 75}, |
||
293 | 16088 | amunoz | {20,20,20,20}}); |
294 | 13790 | dguerrero | //Establece la separacin entre los elementos
|
295 | 16088 | amunoz | thisLayout.setHGap(3);
|
296 | thisLayout.setVGap(3);
|
||
297 | 13790 | dguerrero | p.setLayout(thisLayout); |
298 | |||
299 | //Aado los diferentes elementos
|
||
300 | 16088 | amunoz | p.add(new JLabel((PluginServices.getText(this,"rangox"))),"0,0"); |
301 | p.add(new JLabel((PluginServices.getText(this,"rangoy"))),"0,1"); |
||
302 | p.add(new JLabel((PluginServices.getText(this,"tamanio_celda"))),"0,2"); |
||
303 | p.add(new JLabel((PluginServices.getText(this,"num_filas_columnas"))),"0,3"); |
||
304 | 20826 | dguerrero | p.add(getJTextCellSizeX(),"1,2");
|
305 | p.add(getJTextCellSizeY(),"2,2");
|
||
306 | 16088 | amunoz | p.add(getJTextNumFiCol1(),"1,3");
|
307 | p.add(getJTextNumFiCol2(),"2,3");
|
||
308 | p.add(getJTextRangoX1(),"1,0");
|
||
309 | p.add(getJTextRangoX2(),"2,0");
|
||
310 | p.add(getJTextRangoY1(),"1,1");
|
||
311 | p.add(getJTextRangoY2(),"2,1");
|
||
312 | 13790 | dguerrero | |
313 | paramPanel.add(p); |
||
314 | } |
||
315 | return paramPanel;
|
||
316 | } |
||
317 | |||
318 | |||
319 | |||
320 | 14835 | amunoz | /**
|
321 | * @return JRadioButton ajustar a datos de entrada
|
||
322 | */
|
||
323 | 13790 | dguerrero | public JRadioButton getRButtom1() { |
324 | if(rButtom1==null){ |
||
325 | rButtom1=new JRadioButton((PluginServices.getText(this,"ajustar_entrada")), true); |
||
326 | rButtom1.addActionListener(this);
|
||
327 | } |
||
328 | return rButtom1;
|
||
329 | } |
||
330 | |||
331 | |||
332 | |||
333 | 14835 | amunoz | /**
|
334 | * @return JRadioButton extension definida por el usuario
|
||
335 | */
|
||
336 | 13790 | dguerrero | public JRadioButton getRButtom2() { |
337 | if(rButtom2==null){ |
||
338 | rButtom2=new JRadioButton((PluginServices.getText(this,"definida_usuario")), false); |
||
339 | rButtom2.addActionListener(this);
|
||
340 | } |
||
341 | return rButtom2;
|
||
342 | } |
||
343 | |||
344 | |||
345 | |||
346 | 14835 | amunoz | /**
|
347 | * @return JRadioButton extension ajustada a otra capa
|
||
348 | */
|
||
349 | 13790 | dguerrero | public JRadioButton getRButtom4() { |
350 | if(rButtom4==null){ |
||
351 | rButtom4=new JRadioButton((PluginServices.getText(this,"extension_capa")), false); |
||
352 | rButtom4.addActionListener(this);
|
||
353 | } |
||
354 | return rButtom4;
|
||
355 | } |
||
356 | |||
357 | |||
358 | 14835 | amunoz | /**
|
359 | * @return JTextField tama?o de celda
|
||
360 | */
|
||
361 | 20826 | dguerrero | public JTextField getJTextCellSizeX() { |
362 | if (jTextCellSizeX==null){ |
||
363 | jTextCellSizeX=new JTextField(15);; |
||
364 | jTextCellSizeX.setEditable(false);
|
||
365 | jTextCellSizeX.addKeyListener(this);
|
||
366 | 13790 | dguerrero | } |
367 | 20826 | dguerrero | return jTextCellSizeX;
|
368 | 13790 | dguerrero | } |
369 | 20826 | dguerrero | |
370 | /**
|
||
371 | * @return JTextField tama?o de celda
|
||
372 | */
|
||
373 | public JTextField getJTextCellSizeY() { |
||
374 | if (jTextCellSizeY==null){ |
||
375 | jTextCellSizeY=new JTextField(15);; |
||
376 | jTextCellSizeY.setEditable(false);
|
||
377 | jTextCellSizeY.addKeyListener(this);
|
||
378 | } |
||
379 | return jTextCellSizeY;
|
||
380 | } |
||
381 | 13790 | dguerrero | |
382 | |||
383 | 14835 | amunoz | |
384 | /**
|
||
385 | * @return JTextField numero de filas
|
||
386 | */
|
||
387 | 13790 | dguerrero | public JTextField getJTextNumFiCol1() { |
388 | if (jTextNumFiCol1==null){ |
||
389 | jTextNumFiCol1=new JTextField (); |
||
390 | jTextNumFiCol1.setEditable(false);
|
||
391 | } |
||
392 | return jTextNumFiCol1;
|
||
393 | } |
||
394 | |||
395 | |||
396 | |||
397 | 14835 | amunoz | /**
|
398 | * @return JTextField coordenada x m?nima
|
||
399 | */
|
||
400 | 13790 | dguerrero | public JTextField getJTextRangoX1() { |
401 | 14835 | amunoz | if (jTextRangoX1==null){ |
402 | 13790 | dguerrero | jTextRangoX1 =new JTextField (); |
403 | jTextRangoX1.setEditable(false);
|
||
404 | jTextRangoX1.addKeyListener(this);
|
||
405 | |||
406 | } |
||
407 | return jTextRangoX1;
|
||
408 | } |
||
409 | |||
410 | |||
411 | |||
412 | 14835 | amunoz | /**
|
413 | * @return JTextField coordenada x m?xima
|
||
414 | */
|
||
415 | 13790 | dguerrero | public JTextField getJTextRangoX2() { |
416 | if (jTextRangoX2==null){ |
||
417 | jTextRangoX2=new JTextField (); |
||
418 | jTextRangoX2.setEditable(false);
|
||
419 | jTextRangoX2.addKeyListener(this);
|
||
420 | |||
421 | } |
||
422 | return jTextRangoX2;
|
||
423 | } |
||
424 | |||
425 | |||
426 | |||
427 | 14835 | amunoz | |
428 | /**
|
||
429 | * @return JTextField coordenada y m?mnima
|
||
430 | */
|
||
431 | 13790 | dguerrero | public JTextField getJTextRangoY1() { |
432 | if (jTextRangoY1==null){ |
||
433 | jTextRangoY1=new JTextField (); |
||
434 | jTextRangoY1.setEditable(false);
|
||
435 | jTextRangoY1.addKeyListener(this);
|
||
436 | } |
||
437 | return jTextRangoY1;
|
||
438 | } |
||
439 | |||
440 | |||
441 | 14835 | amunoz | |
442 | /**
|
||
443 | * @return JTextField coordenada y m?xima
|
||
444 | */
|
||
445 | 13790 | dguerrero | public JTextField getJTextRangoY2() { |
446 | if (jTextRangoY2==null){ |
||
447 | jTextRangoY2=new JTextField (); |
||
448 | jTextRangoY2.setEditable(false);
|
||
449 | jTextRangoY2.addKeyListener(this);
|
||
450 | } |
||
451 | return jTextRangoY2;
|
||
452 | } |
||
453 | |||
454 | |||
455 | |||
456 | 14835 | amunoz | |
457 | /**
|
||
458 | * @return JTextField numero de columnas
|
||
459 | */
|
||
460 | 13790 | dguerrero | public JTextField getJTextNumFiCol2() { |
461 | if (jTextNumFiCol2==null){ |
||
462 | jTextNumFiCol2=new JTextField (); |
||
463 | 14835 | amunoz | jTextNumFiCol2.setEditable(false);
|
464 | 13790 | dguerrero | } |
465 | return jTextNumFiCol2;
|
||
466 | } |
||
467 | |||
468 | |||
469 | |||
470 | 14835 | amunoz | /**
|
471 | * @return JCombo con las capas raster cargadas en la vista
|
||
472 | */
|
||
473 | 13790 | dguerrero | public JComboBox getJComboCapas() { |
474 | if (jComboCapas==null){ |
||
475 | ComboBoxModel jComboBoxLayersModel = new DefaultComboBoxModel(getLayerNames()); |
||
476 | jComboCapas = new JComboBox(); |
||
477 | jComboCapas.setModel(jComboBoxLayersModel); |
||
478 | jComboCapas.setEnabled(false);
|
||
479 | jComboCapas.addActionListener(this);
|
||
480 | 14835 | amunoz | } |
481 | 13790 | dguerrero | return jComboCapas;
|
482 | } |
||
483 | |||
484 | 14835 | amunoz | /**
|
485 | * @return array con el nombre de los ficheros cargados en la vista
|
||
486 | */
|
||
487 | 13790 | dguerrero | private String[] getLayerNames() { |
488 | String[] sNames = {}; |
||
489 | if (layers!=null){ |
||
490 | sNames = new String[layers.getLayersCount()]; |
||
491 | for (int i = 0; i < layers.getLayersCount(); i++) { |
||
492 | sNames[i] = (layers.getLayer(i)).getName(); |
||
493 | } |
||
494 | } |
||
495 | return sNames;
|
||
496 | } |
||
497 | |||
498 | 14835 | amunoz | |
499 | /**
|
||
500 | * Establece la opci?n por defecto cuando se crea en cuadro de dialogo
|
||
501 | */
|
||
502 | 13790 | dguerrero | public void InicializarOpcion(){ |
503 | |||
504 | DesabilitarTodo(); |
||
505 | rButtom1.setSelected(true);
|
||
506 | // Comprobar que todas las variables estan asignadas
|
||
507 | boolean allAssigned = false; |
||
508 | 17207 | gsdiego | for (int i=0; i<cp.getCalculatorPanel().getJTableVariables().getTableFormat().getRowCount(); i++){ |
509 | 13790 | dguerrero | allAssigned = true;
|
510 | 17207 | gsdiego | if (cp.getCalculatorPanel().getJTableVariables().getTableFormat().getValueAt(i,1).toString().equals("")) |
511 | 13790 | dguerrero | { |
512 | allAssigned=false;
|
||
513 | break;
|
||
514 | } |
||
515 | } |
||
516 | if(allAssigned){
|
||
517 | 14518 | amunoz | // Establecemos la opcion por defecto.
|
518 | setAjustInDataExtent(); |
||
519 | 13790 | dguerrero | } |
520 | } |
||
521 | |||
522 | |||
523 | 14835 | amunoz | /**
|
524 | * Deshabilita todos los componetes variables de la interfaz
|
||
525 | */
|
||
526 | 13790 | dguerrero | public void DesabilitarTodo(){ |
527 | |||
528 | jComboCapas.setEnabled(false);
|
||
529 | jTextRangoX1.setEditable(false);
|
||
530 | jTextRangoX1.setEnabled(false);
|
||
531 | jTextRangoX2.setEditable(false);
|
||
532 | jTextRangoX2.setEnabled(false);
|
||
533 | jTextRangoY1.setEditable(false);
|
||
534 | jTextRangoY1.setEnabled(false);
|
||
535 | jTextRangoY2.setEditable(false);
|
||
536 | jTextRangoY2.setEnabled(false);
|
||
537 | jTextNumFiCol1.setEditable(false);
|
||
538 | 20826 | dguerrero | jTextCellSizeX.setEditable(false);
|
539 | jTextCellSizeX.setEnabled(false);
|
||
540 | jTextCellSizeY.setEditable(false);
|
||
541 | jTextCellSizeY.setEnabled(false);
|
||
542 | 13790 | dguerrero | jTextNumFiCol1.setEnabled(false);
|
543 | jTextNumFiCol2.setEditable(false);
|
||
544 | jTextNumFiCol2.setEnabled(false);
|
||
545 | jComboCapas.updateUI(); |
||
546 | |||
547 | } |
||
548 | |||
549 | 14835 | amunoz | |
550 | /**
|
||
551 | * Reestablece el numero de filas y columnas ante cuanquier variaci?n de la interfaz
|
||
552 | */
|
||
553 | public void extentHasChanged(){ |
||
554 | 13790 | dguerrero | |
555 | double dRangeX;
|
||
556 | double dRangeY;
|
||
557 | 20826 | dguerrero | double dCellSizeX;
|
558 | double dCellSizeY;
|
||
559 | 13790 | dguerrero | int iRows;
|
560 | int iCols;
|
||
561 | // Se actualiza la X
|
||
562 | try {
|
||
563 | dRangeX = Math.abs(Double.parseDouble(getJTextRangoX2().getText()) |
||
564 | - Double.parseDouble(getJTextRangoX1().getText()));
|
||
565 | 20826 | dguerrero | dCellSizeX = Double.parseDouble(getJTextCellSizeX().getText());
|
566 | iCols = (int) Math.floor(dRangeX / dCellSizeX); |
||
567 | 13790 | dguerrero | getJTextNumFiCol2().setText(Integer.toString(iCols));
|
568 | |||
569 | 16587 | amunoz | // Se actualiza la Y
|
570 | dRangeY = Math.abs(Double.parseDouble(getJTextRangoY2().getText()) |
||
571 | 13790 | dguerrero | - Double.parseDouble(getJTextRangoY1().getText()));
|
572 | 20826 | dguerrero | dCellSizeY = Double.parseDouble(getJTextCellSizeY().getText());
|
573 | iRows = (int) Math.floor(dRangeY / dCellSizeY); |
||
574 | 13790 | dguerrero | getJTextNumFiCol1().setText(Integer.toString(iRows));
|
575 | |||
576 | |||
577 | } catch (NumberFormatException e) { |
||
578 | 16587 | amunoz | RasterToolsUtil.messageBoxError(PluginServices.getText(this, "invalid_number"), this); |
579 | 13790 | dguerrero | } |
580 | } |
||
581 | |||
582 | private void validateKeyTyping(KeyEvent event) { |
||
583 | jComboCapas.updateUI(); |
||
584 | switch (event.getKeyChar()) {
|
||
585 | |||
586 | case KeyEvent.VK_ENTER: |
||
587 | extentHasChanged(); |
||
588 | jComboCapas.updateUI(); |
||
589 | break;
|
||
590 | |||
591 | case KeyEvent.VK_BACK_SPACE: |
||
592 | extentHasChanged(); |
||
593 | break;
|
||
594 | case KeyEvent.VK_0 : |
||
595 | extentHasChanged(); |
||
596 | break;
|
||
597 | case KeyEvent.VK_1 : |
||
598 | extentHasChanged(); |
||
599 | break;
|
||
600 | case KeyEvent.VK_2 : |
||
601 | extentHasChanged(); |
||
602 | break;
|
||
603 | case KeyEvent.VK_3: |
||
604 | extentHasChanged(); |
||
605 | break;
|
||
606 | case KeyEvent.VK_4: |
||
607 | extentHasChanged(); |
||
608 | break;
|
||
609 | case KeyEvent.VK_5: |
||
610 | extentHasChanged(); |
||
611 | break;
|
||
612 | case KeyEvent.VK_6: |
||
613 | extentHasChanged(); |
||
614 | break;
|
||
615 | case KeyEvent.VK_7: |
||
616 | extentHasChanged(); |
||
617 | break;
|
||
618 | case KeyEvent.VK_8: |
||
619 | extentHasChanged(); |
||
620 | break;
|
||
621 | case KeyEvent.VK_9 : |
||
622 | extentHasChanged(); |
||
623 | break;
|
||
624 | } |
||
625 | } |
||
626 | |||
627 | 14835 | amunoz | |
628 | |||
629 | /**
|
||
630 | * Fija las acciones que se realizan cuando se produce un evento
|
||
631 | * @param e Objeto que genera el evento
|
||
632 | */
|
||
633 | 13790 | dguerrero | public void actionPerformed(ActionEvent e) { |
634 | |||
635 | //Radiobutton1
|
||
636 | if (e.getSource()==getRButtom1()){
|
||
637 | 14575 | amunoz | DesabilitarTodo(); |
638 | 14518 | amunoz | setAjustInDataExtent(); |
639 | 14590 | amunoz | updateParams(); |
640 | 13790 | dguerrero | } |
641 | |||
642 | // RadioButtom2
|
||
643 | else if (e.getSource()==getRButtom2()){ |
||
644 | |||
645 | DesabilitarTodo(); |
||
646 | rButtom2.setSelected(true);
|
||
647 | getJTextRangoX1().setEnabled(true);
|
||
648 | getJTextRangoX1().setEditable(true);
|
||
649 | getJTextRangoX2().setEnabled(true);
|
||
650 | getJTextRangoX2().setEditable(true);
|
||
651 | getJTextRangoY1().setEnabled(true);
|
||
652 | getJTextRangoY1().setEditable(true);
|
||
653 | getJTextRangoY2().setEditable(true);
|
||
654 | getJTextRangoY2().setEnabled(true);
|
||
655 | 20826 | dguerrero | getJTextCellSizeX().setEditable(true);
|
656 | getJTextCellSizeX().setEnabled(true);
|
||
657 | getJTextCellSizeY().setEditable(true);
|
||
658 | getJTextCellSizeY().setEnabled(true);
|
||
659 | 14590 | amunoz | updateParams(); |
660 | 13790 | dguerrero | } |
661 | |||
662 | |||
663 | // RadioButtom4
|
||
664 | else if (e.getSource()==getRButtom4()){ |
||
665 | |||
666 | DesabilitarTodo(); |
||
667 | rButtom4.setSelected(true);
|
||
668 | jComboCapas.setEnabled(true);
|
||
669 | 20826 | dguerrero | jTextCellSizeX.setEditable(true);
|
670 | jTextCellSizeX.setEnabled(true);
|
||
671 | jTextCellSizeY.setEditable(true);
|
||
672 | jTextCellSizeY.setEnabled(true);
|
||
673 | 13790 | dguerrero | getJComboCapas().updateUI(); |
674 | 14590 | amunoz | updateParams(); |
675 | 13790 | dguerrero | } |
676 | |||
677 | else if (e.getSource()==getRadioFile()){ |
||
678 | rButtonFile.setSelected(true);
|
||
679 | } |
||
680 | |||
681 | else if (e.getSource()==getRadioMemory()){ |
||
682 | rButtonMemory.setSelected(true);
|
||
683 | } |
||
684 | |||
685 | // ComboCapas
|
||
686 | else if (e.getSource()==getJComboCapas()){ |
||
687 | 14590 | amunoz | updateParams(); |
688 | 13790 | dguerrero | |
689 | } |
||
690 | } |
||
691 | |||
692 | 14835 | amunoz | /**
|
693 | * Actualizacion de los parametros ajustandolos a los de la capa seleccionada
|
||
694 | */
|
||
695 | 14590 | amunoz | private void updateParams(){ |
696 | 13790 | dguerrero | double dCoord;
|
697 | if (getRButtom4().isSelected()){
|
||
698 | try {
|
||
699 | 14389 | amunoz | FLyrRasterSE rasterLayer = (FLyrRasterSE)mapContext.getLayers().getLayer((String)getJComboCapas().getSelectedItem());
|
700 | dCoord = rasterLayer.getFullExtent().getMinX(); |
||
701 | 13790 | dguerrero | getJTextRangoX1().setText(new Double(dCoord).toString()); |
702 | 14389 | amunoz | dCoord = rasterLayer.getFullExtent().getMaxX(); |
703 | 13790 | dguerrero | getJTextRangoX2().setText(new Double(dCoord).toString()); |
704 | 14389 | amunoz | dCoord = rasterLayer.getFullExtent().getMinY(); |
705 | 13790 | dguerrero | getJTextRangoY1().setText(new Double(dCoord).toString()); |
706 | 14389 | amunoz | dCoord = rasterLayer.getFullExtent().getMaxY(); |
707 | 13790 | dguerrero | getJTextRangoY2().setText(new Double(dCoord).toString()); |
708 | 14389 | amunoz | if (rasterLayer instanceof FLyrRasterSE){ |
709 | 20826 | dguerrero | getJTextCellSizeX().setText(new Double( |
710 | Math.abs(((FLyrRasterSE) rasterLayer).getAffineTransform().getScaleX()))
|
||
711 | 13790 | dguerrero | .toString()); |
712 | 20826 | dguerrero | getJTextCellSizeY().setText(new Double( |
713 | Math.abs(((FLyrRasterSE) rasterLayer).getAffineTransform().getScaleY()))
|
||
714 | .toString()); |
||
715 | 13790 | dguerrero | } |
716 | extentHasChanged(); |
||
717 | } catch (Exception ex) {} |
||
718 | } |
||
719 | |||
720 | } |
||
721 | |||
722 | 14590 | amunoz | |
723 | 14518 | amunoz | |
724 | 14835 | amunoz | /**
|
725 | * Establece el extent de salida ajustandolo a los datos de entrada.
|
||
726 | */
|
||
727 | 14518 | amunoz | private void setAjustInDataExtent(){ |
728 | 14575 | amunoz | // Si no hay variables asignadas no hace nada. No dejara lanzar el calculo
|
729 | 17207 | gsdiego | if( cp.getCalculatorPanel().getJTableVariables().getTableFormat().getRowCount()>0 && cp.getCalculatorPanel().getJTableVariables().getTableFormat().getValueAt(0,1).toString()!=""){ |
730 | 14518 | amunoz | |
731 | 17207 | gsdiego | String layerName = cp.getCalculatorPanel().getJTableVariables().getTableFormat().getValueAt(0,1).toString(); |
732 | 14518 | amunoz | layerName = layerName.substring(0,layerName.indexOf("[")); |
733 | 14575 | amunoz | FLyrRasterSE rasterLayer = (FLyrRasterSE)mapContext.getLayers().getLayer(layerName); |
734 | |||
735 | 17687 | nbrodin | double xMin =rasterLayer.getFullRasterExtent().minX();
|
736 | double xMax =rasterLayer.getFullRasterExtent().maxX();
|
||
737 | double yMin =rasterLayer.getFullRasterExtent().minY();
|
||
738 | double yMax =rasterLayer.getFullRasterExtent().maxY();
|
||
739 | 20826 | dguerrero | double cellSizeX = Math.abs(rasterLayer.getAffineTransform().getScaleX()); |
740 | double cellSizeY = Math.abs(rasterLayer.getAffineTransform().getScaleY()); |
||
741 | 14575 | amunoz | |
742 | 17207 | gsdiego | for (int i=0;i<cp.getCalculatorPanel().getJTableVariables().getTableFormat().getRowCount();i++){ |
743 | layerName = cp.getCalculatorPanel().getJTableVariables().getTableFormat().getValueAt(i,1).toString();
|
||
744 | 14575 | amunoz | layerName = layerName.substring(0,layerName.indexOf("[")); |
745 | rasterLayer = (FLyrRasterSE)mapContext.getLayers().getLayer(layerName); |
||
746 | 14518 | amunoz | |
747 | 17687 | nbrodin | xMin = Math.min(xMin,rasterLayer.getFullRasterExtent().minX());
|
748 | xMax = Math.max(rasterLayer.getFullRasterExtent().maxX(),xMax);
|
||
749 | yMin = Math.min(yMin,rasterLayer.getFullRasterExtent().minY());
|
||
750 | yMax = Math.max(yMax,rasterLayer.getFullRasterExtent().maxY());
|
||
751 | 20826 | dguerrero | cellSizeX = Math.min(cellSizeX,Math.abs(rasterLayer.getAffineTransform().getScaleX())); |
752 | cellSizeY = Math.min(cellSizeY,Math.abs(rasterLayer.getAffineTransform().getScaleY())); |
||
753 | 14575 | amunoz | } |
754 | 14518 | amunoz | |
755 | 14575 | amunoz | cp.getOutputExtent().setXRange(xMin,xMax); |
756 | cp.getOutputExtent().setYRange(yMin,yMax); |
||
757 | 14518 | amunoz | |
758 | 14575 | amunoz | getJTextRangoX1().setText(String.valueOf(cp.getOutputExtent().minX()));
|
759 | getJTextRangoX2().setText(String.valueOf(cp.getOutputExtent().maxX()));
|
||
760 | getJTextRangoY1().setText(String.valueOf(cp.getOutputExtent().minY()));
|
||
761 | getJTextRangoY2().setText(String.valueOf(cp.getOutputExtent().maxY()));
|
||
762 | 20826 | dguerrero | getJTextCellSizeX().setText(String.valueOf(cellSizeX));
|
763 | getJTextCellSizeY().setText(String.valueOf(cellSizeY));
|
||
764 | cp.getOutputExtent().setCellSizeX(cellSizeX); |
||
765 | cp.getOutputExtent().setCellSizeY(cellSizeY); |
||
766 | 14575 | amunoz | extentHasChanged(); |
767 | 14835 | amunoz | } |
768 | 14518 | amunoz | } |
769 | |||
770 | 14835 | amunoz | /**
|
771 | * Eventos del teclado
|
||
772 | */
|
||
773 | 13790 | dguerrero | public void keyReleased(KeyEvent e) { |
774 | |||
775 | if(e.getSource()==getJTextRangoX1()){
|
||
776 | validateKeyTyping(e); |
||
777 | } |
||
778 | |||
779 | if(e.getSource()==getJTextRangoX2()){
|
||
780 | validateKeyTyping(e); |
||
781 | } |
||
782 | |||
783 | if(e.getSource()==getJTextRangoY1()){
|
||
784 | validateKeyTyping(e); |
||
785 | } |
||
786 | |||
787 | if(e.getSource()==getJTextRangoY2()){
|
||
788 | validateKeyTyping(e); |
||
789 | } |
||
790 | |||
791 | 20826 | dguerrero | if (e.getSource()==getJTextCellSizeX()){
|
792 | 13790 | dguerrero | |
793 | validateKeyTyping(e); |
||
794 | } |
||
795 | 20826 | dguerrero | |
796 | if (e.getSource()==getJTextCellSizeY()){
|
||
797 | |||
798 | validateKeyTyping(e); |
||
799 | } |
||
800 | 13790 | dguerrero | } |
801 | |||
802 | /**
|
||
803 | * Especificar el nombre de la nueva capa para el recuadro de texto asign?ndo
|
||
804 | * en cada llamada un nombre consecutivo.
|
||
805 | */
|
||
806 | 17844 | amunoz | public void updateNewLayerText() { |
807 | 18961 | nbrodin | getJTextNombreCapa().setText(RasterLibrary.getOnlyLayerName()); |
808 | 17844 | amunoz | } |
809 | |||
810 | 13790 | dguerrero | |
811 | |||
812 | |||
813 | public void focusGained(FocusEvent arg0) { |
||
814 | // TODO Auto-generated method stub
|
||
815 | |||
816 | } |
||
817 | |||
818 | public void focusLost(FocusEvent arg0) { |
||
819 | // TODO Auto-generated method stub
|
||
820 | |||
821 | } |
||
822 | |||
823 | |||
824 | |||
825 | public void keyPressed(KeyEvent arg0) { |
||
826 | // TODO Auto-generated method stub
|
||
827 | |||
828 | } |
||
829 | |||
830 | |||
831 | |||
832 | public void keyTyped(KeyEvent arg0) { |
||
833 | // TODO Auto-generated method stub
|
||
834 | |||
835 | } |
||
836 | 17844 | amunoz | |
837 | public void actionValueChanged(PropertyEvent e) { |
||
838 | updateNewLayerText(); |
||
839 | } |
||
840 | 13790 | dguerrero | } |