root / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / tasseledcap / gui / TasseledCapPanel.java @ 24986
History | View | Annotate | Download (17.5 KB)
1 |
/* 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.tasseledcap.gui; |
42 |
import info.clearthought.layout.TableLayout; |
43 |
|
44 |
import java.awt.BorderLayout; |
45 |
import java.awt.Dimension; |
46 |
import java.awt.GridBagConstraints; |
47 |
import java.awt.GridBagLayout; |
48 |
import java.awt.Insets; |
49 |
import java.awt.event.ActionEvent; |
50 |
import java.awt.event.ActionListener; |
51 |
import java.awt.event.FocusEvent; |
52 |
import java.awt.event.FocusListener; |
53 |
import java.io.File; |
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.JFileChooser; |
61 |
import javax.swing.JLabel; |
62 |
import javax.swing.JPanel; |
63 |
import javax.swing.JRadioButton; |
64 |
import javax.swing.JTextField; |
65 |
import javax.swing.SwingConstants; |
66 |
import javax.swing.border.CompoundBorder; |
67 |
import javax.swing.border.EmptyBorder; |
68 |
import javax.swing.border.TitledBorder; |
69 |
|
70 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
71 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
72 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
73 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
74 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
75 |
import org.gvsig.raster.RasterLibrary; |
76 |
import org.gvsig.raster.buffer.WriterBufferServer; |
77 |
import org.gvsig.raster.dataset.GeoRasterWriter; |
78 |
import org.gvsig.raster.util.ExtendedFileFilter; |
79 |
import org.gvsig.raster.util.PropertyEvent; |
80 |
import org.gvsig.raster.util.PropertyListener; |
81 |
import org.gvsig.remotesensing.tasseledcap.TasseledCapProcess; |
82 |
|
83 |
import com.iver.andami.PluginServices; |
84 |
import com.iver.andami.Utilities; |
85 |
import com.iver.andami.ui.mdiManager.IWindow; |
86 |
import com.iver.andami.ui.mdiManager.IWindowListener; |
87 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
88 |
import com.iver.cit.gvsig.addlayer.fileopen.FileOpenWizard; |
89 |
import com.iver.cit.gvsig.fmap.MapContext; |
90 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
91 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
92 |
import com.iver.utiles.swing.JComboBox; |
93 |
|
94 |
/**
|
95 |
* Clase que define la interfaz para el proceso de transformaci?n Tasseled Cap de una imagen.
|
96 |
* Recoge la imagen a clasificar y el tipo de transformaci?n.Posibilita configurar las opciones
|
97 |
* de salida.
|
98 |
*
|
99 |
* @author Alejandro Mu?oz Sanchez (alejandro.munoz@uclm.es)
|
100 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)
|
101 |
* @version 19/10/2007
|
102 |
*/
|
103 |
|
104 |
public class TasseledCapPanel extends DefaultButtonsPanel implements PropertyListener, IWindow, IWindowListener, |
105 |
ButtonsPanelListener,ActionListener,FocusListener { |
106 |
|
107 |
private static final long serialVersionUID = 1L; |
108 |
private JPanel centerPanel; |
109 |
private JPanel panelTipo; |
110 |
private MapContext m_MapContext;
|
111 |
private int wPanel=422; |
112 |
private int hPanel=265; |
113 |
private JComboBox comboCapas; |
114 |
private JComboBox comboTipos; |
115 |
private FLayers layers;
|
116 |
private JPanel panelImagen; |
117 |
private final int TIPOLANDSAT_ETM= 2; |
118 |
private final int TIPOLANDSAT_TM=1; |
119 |
private final int TIPOLANDSAT_MS=0; |
120 |
private DefaultComboBoxModel jComboBoxLayersModel; |
121 |
private JTextField jTextNombreCapa; |
122 |
private JPanel nombreCapa; |
123 |
private JRadioButton rButtonFile = null; |
124 |
private JRadioButton rButtonMemory = null; |
125 |
private View view=null; |
126 |
|
127 |
/**
|
128 |
* @param vista vista actual
|
129 |
*/
|
130 |
public TasseledCapPanel(View vista) { |
131 |
super();
|
132 |
view= vista; |
133 |
m_MapContext = vista.getModel().getMapContext(); |
134 |
layers = m_MapContext.getLayers(); |
135 |
this.addButtonPressedListener(this); |
136 |
Inicializar(); |
137 |
} |
138 |
|
139 |
|
140 |
/**
|
141 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
142 |
*/
|
143 |
public WindowInfo getWindowInfo() {
|
144 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.PALETTE);
|
145 |
m_viewinfo.setWidth(wPanel); |
146 |
m_viewinfo.setHeight(hPanel); |
147 |
m_viewinfo.setTitle(PluginServices.getText(this,"tasseled_cap")); |
148 |
m_viewinfo.setX(300);
|
149 |
return m_viewinfo;
|
150 |
} |
151 |
|
152 |
|
153 |
/**
|
154 |
* inicializaci?n del cuadro de di?logo
|
155 |
*/
|
156 |
private void Inicializar(){ |
157 |
BorderLayout bd=new BorderLayout(); |
158 |
this.setLayout(bd);
|
159 |
TitledBorder topBorder = BorderFactory.createTitledBorder((PluginServices.getText(this,""))); |
160 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
161 |
this.setBorder(new CompoundBorder(topBorder,new EmptyBorder(5,5,5,5))); |
162 |
this.add(getCenterPanel(), BorderLayout.CENTER); |
163 |
actualizarCombo(getComboTipos().getSelectedIndex()); |
164 |
updateUI(); |
165 |
} |
166 |
|
167 |
|
168 |
/*
|
169 |
* (non-Javadoc)
|
170 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
171 |
*/
|
172 |
public void actionPerformed(ActionEvent e) { |
173 |
if (e.getSource()==getComboTipos()){
|
174 |
actualizarCombo(getComboTipos().getSelectedIndex()); |
175 |
} |
176 |
} |
177 |
|
178 |
/**
|
179 |
* @return panel con los combos para le seleccion de transformacion e imagen
|
180 |
*/
|
181 |
public JPanel getCenterPanel(){ |
182 |
if (centerPanel==null){ |
183 |
centerPanel=new JPanel(); |
184 |
centerPanel.setLayout(new GridBagLayout()); |
185 |
TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this,"salida_raster"));; |
186 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
187 |
centerPanel.setBorder(topBorder); |
188 |
GridBagConstraints c = new GridBagConstraints(); |
189 |
c.fill = GridBagConstraints.BOTH;
|
190 |
c.insets=new Insets(8,8,0,8); |
191 |
c.weightx = 1;
|
192 |
c.gridx = 0;
|
193 |
c.gridy = 0;
|
194 |
centerPanel.add(getNombreCapa(), c); |
195 |
c.insets=new Insets(8,8,8,8); |
196 |
c.weightx = 1.0;
|
197 |
c.gridx = 0;
|
198 |
c.gridy = 1;
|
199 |
// Agregar panel que contiene los paneles con los combos
|
200 |
TableLayout thisLayout2 = new TableLayout(new double[][] { |
201 |
{50 ,TableLayout.PREFERRED,50}, |
202 |
{TableLayout.PREFERRED, TableLayout.PREFERRED}}); |
203 |
|
204 |
JPanel p2=new JPanel(); |
205 |
p2.setLayout(thisLayout2); |
206 |
TitledBorder topBorder2 = BorderFactory.createTitledBorder(PluginServices.getText(this,"imagen_transformar"));; |
207 |
topBorder2.setTitlePosition(TitledBorder.TOP);
|
208 |
p2.setBorder(new CompoundBorder(topBorder2,new EmptyBorder(5,5,5,5))); |
209 |
p2.add(getPanelTipo(),"1,0");
|
210 |
p2.add(getPanelImagen(),"1,1");
|
211 |
centerPanel.add(p2, c); |
212 |
} |
213 |
return centerPanel;
|
214 |
} |
215 |
|
216 |
|
217 |
/**
|
218 |
* @return panel con el combo de imagenes
|
219 |
*/
|
220 |
public JPanel getPanelImagen() { |
221 |
if (panelImagen==null){ |
222 |
panelImagen=new JPanel(); |
223 |
|
224 |
// Nuevo panel al que se aaden los elementos
|
225 |
JPanel p=new JPanel(); |
226 |
TableLayout thisLayout = new TableLayout(new double[][] { |
227 |
{ 5, 50,150}, |
228 |
{TableLayout.PREFERRED}}); |
229 |
//Establece la separacion entre los elementos
|
230 |
thisLayout.setHGap(5);
|
231 |
thisLayout.setVGap(5);
|
232 |
p.setLayout(thisLayout); |
233 |
p.add(getComboCapas(),"2,0");
|
234 |
p.add(new JLabel((PluginServices.getText(this,"imagen"))),"1,0"); |
235 |
|
236 |
panelImagen.add(p); |
237 |
} |
238 |
return panelImagen;
|
239 |
} |
240 |
|
241 |
|
242 |
/**
|
243 |
* @return panel con el combo de tipos
|
244 |
*/
|
245 |
public JPanel getPanelTipo() { |
246 |
if (panelTipo==null){ |
247 |
panelTipo=new JPanel(); |
248 |
JPanel p=new JPanel(); |
249 |
TableLayout thisLayout = new TableLayout(new double[][] { |
250 |
{ 5.0, 50,150}, |
251 |
{TableLayout.PREFERRED}}); |
252 |
thisLayout.setHGap(5);
|
253 |
thisLayout.setVGap(5);
|
254 |
p.setLayout(thisLayout); |
255 |
p.add(getComboTipos(),"2,0");
|
256 |
p.add(new JLabel((PluginServices.getText(this,"tipo"))),"1,0"); |
257 |
panelTipo.add(p); |
258 |
} |
259 |
return panelTipo;
|
260 |
} |
261 |
|
262 |
|
263 |
/**
|
264 |
* @return modelo de Combo
|
265 |
*/
|
266 |
public DefaultComboBoxModel getComboModel(){ |
267 |
if(jComboBoxLayersModel==null){ |
268 |
jComboBoxLayersModel=new DefaultComboBoxModel(getLayerNames(TIPOLANDSAT_MS)); |
269 |
} |
270 |
return jComboBoxLayersModel;
|
271 |
} |
272 |
|
273 |
|
274 |
/**
|
275 |
* @return panel que incluye el nombre de la capa y las opciones de almacenamieto de la capa de salida
|
276 |
*/
|
277 |
public JPanel getNombreCapa() { |
278 |
if (nombreCapa==null){ |
279 |
|
280 |
nombreCapa=new JPanel(); |
281 |
nombreCapa.setPreferredSize(new Dimension(300,200)); |
282 |
GridBagConstraints gridBagConstraints;
|
283 |
JPanel radioPanel = new JPanel(); |
284 |
radioPanel.setLayout(new GridBagLayout()); |
285 |
radioPanel.setBorder(BorderFactory.createTitledBorder("")); |
286 |
ButtonGroup buttonGroup = new ButtonGroup(); |
287 |
buttonGroup.add(getRadioMemory()); |
288 |
|
289 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
290 |
gridBagConstraints.gridx = 0;
|
291 |
gridBagConstraints.gridy = 1;
|
292 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
293 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
294 |
radioPanel.add(getRadioMemory(),gridBagConstraints); |
295 |
buttonGroup.add(getRadioFile()); |
296 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
297 |
gridBagConstraints.gridx = 0;
|
298 |
gridBagConstraints.gridy = 2;
|
299 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
300 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
301 |
radioPanel.add(getRadioFile(),gridBagConstraints); |
302 |
//Establece la separacion entre los elementos
|
303 |
nombreCapa.setLayout(new GridBagLayout()); |
304 |
|
305 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
306 |
gridBagConstraints.gridx = 0;
|
307 |
gridBagConstraints.gridy = 0;
|
308 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
309 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
310 |
nombreCapa.add(new JLabel( (PluginServices.getText(this,"nombre_capa")),SwingConstants.RIGHT ),gridBagConstraints); |
311 |
|
312 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
313 |
gridBagConstraints.gridx = 1;
|
314 |
gridBagConstraints.gridy = 0;
|
315 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
316 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
317 |
nombreCapa.add(getJTextNombreCapa(),gridBagConstraints); |
318 |
|
319 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
320 |
gridBagConstraints.gridx = 2;
|
321 |
gridBagConstraints.gridy = 0;
|
322 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
323 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
324 |
nombreCapa.add(radioPanel,gridBagConstraints); |
325 |
} |
326 |
return nombreCapa;
|
327 |
} |
328 |
|
329 |
|
330 |
/**
|
331 |
* @return javax.swing.JTextField
|
332 |
*/
|
333 |
public JTextField getJTextNombreCapa() { |
334 |
if (jTextNombreCapa==null){ |
335 |
jTextNombreCapa=new JTextField(10); |
336 |
jTextNombreCapa.setText(RasterLibrary.getOnlyLayerName()); |
337 |
jTextNombreCapa.addFocusListener(this);
|
338 |
RasterLibrary.addOnlyLayerNameListener(this);
|
339 |
} |
340 |
|
341 |
return jTextNombreCapa;
|
342 |
} |
343 |
|
344 |
|
345 |
|
346 |
public void updateNewLayerText() { |
347 |
getJTextNombreCapa().setText(RasterLibrary.getOnlyLayerName()); |
348 |
} |
349 |
|
350 |
|
351 |
/**
|
352 |
* Cuando alguien ha cambiado la propiedad del nombre de la
|
353 |
* capa se actualiza autom?ticamente
|
354 |
*/
|
355 |
|
356 |
public void actionValueChanged(PropertyEvent e) { |
357 |
updateNewLayerText(); |
358 |
} |
359 |
|
360 |
|
361 |
/**
|
362 |
* @return combo con el nombre de las im?genes cargadas
|
363 |
*/
|
364 |
public JComboBox getComboCapas() { |
365 |
if (comboCapas==null){ |
366 |
comboCapas = new JComboBox(); |
367 |
comboCapas.setModel(getComboModel()); |
368 |
comboCapas.setEnabled(true);
|
369 |
comboCapas.addActionListener(this);
|
370 |
} |
371 |
return comboCapas;
|
372 |
} |
373 |
|
374 |
|
375 |
/**
|
376 |
* actualiza el combo de im?genes con las que se ajustan al tipo pasado como parametro
|
377 |
*/
|
378 |
private void actualizarCombo(int tipo){ |
379 |
getComboModel().removeAllElements(); |
380 |
String []a = getLayerNames(tipo); |
381 |
for (int i=0;i<a.length;i++) |
382 |
getComboModel().addElement(new String(a[i])); |
383 |
|
384 |
if(getComboCapas().getSelectedIndex()==-1){ |
385 |
getButtonsPanel().getButton(1).setEnabled(false); |
386 |
getButtonsPanel().getButton(3).setEnabled(false); |
387 |
} |
388 |
else{
|
389 |
getButtonsPanel().getButton(1).setEnabled(true); |
390 |
getButtonsPanel().getButton(3).setEnabled(true); |
391 |
} |
392 |
updateUI(); |
393 |
} |
394 |
|
395 |
/**
|
396 |
* @param tipo de transformacion
|
397 |
* @return nombres de las capas que se ajustan al tipo de entrada
|
398 |
*/
|
399 |
private String[] getLayerNames(int tipo) { |
400 |
|
401 |
getComboCapas().removeAllItems(); |
402 |
int i,j=0; |
403 |
ArrayList sNames= new ArrayList(); |
404 |
|
405 |
for (i = 0; i < layers.getLayersCount(); i++) { |
406 |
if (layers.getLayer(i)instanceof FLyrRasterSE){ |
407 |
FLyrRasterSE rasterLayer = (FLyrRasterSE)layers.getLayer(i); |
408 |
int bandCount = rasterLayer.getBandCount();
|
409 |
|
410 |
if(tipo==TIPOLANDSAT_MS){
|
411 |
if(bandCount==4){ |
412 |
sNames.add(new String((layers.getLayer(i)).getName())); |
413 |
j++; |
414 |
} |
415 |
} |
416 |
|
417 |
if (tipo==TIPOLANDSAT_ETM){
|
418 |
if(bandCount==6 || bandCount==7){ |
419 |
sNames.add(new String((layers.getLayer(i)).getName())); |
420 |
j++; |
421 |
} |
422 |
} |
423 |
|
424 |
if(tipo==TIPOLANDSAT_TM){
|
425 |
if(bandCount==6 || bandCount==7 ){ |
426 |
sNames.add(new String((layers.getLayer(i)).getName())); |
427 |
j++; |
428 |
} |
429 |
} |
430 |
} |
431 |
} |
432 |
|
433 |
String[] sCapas = new String[sNames.size()]; |
434 |
for(int k=0; k<sNames.size();k++) |
435 |
sCapas[k]=(String)sNames.get(k);
|
436 |
|
437 |
return sCapas;
|
438 |
} |
439 |
|
440 |
|
441 |
/**
|
442 |
* @return JComboBox con tipos
|
443 |
*/
|
444 |
public JComboBox getComboTipos() { |
445 |
|
446 |
if(comboTipos==null){ |
447 |
String a[]= {"LandSat MS","LandSat TM","LandaSat ETM+"}; |
448 |
ComboBoxModel jComboBoxLayersModel = new DefaultComboBoxModel(a); |
449 |
comboTipos = new JComboBox(); |
450 |
comboTipos.setModel(jComboBoxLayersModel); |
451 |
comboTipos.setEnabled(true);
|
452 |
comboTipos.addActionListener(this);
|
453 |
} |
454 |
return comboTipos;
|
455 |
} |
456 |
|
457 |
/**
|
458 |
* @return JRadioButton de generar fichero
|
459 |
*/
|
460 |
public JRadioButton getRadioFile(){ |
461 |
if (rButtonFile == null){ |
462 |
rButtonFile = new JRadioButton(PluginServices.getText(this,"a_fichero")); |
463 |
rButtonFile.addActionListener(this);
|
464 |
} |
465 |
return rButtonFile;
|
466 |
} |
467 |
|
468 |
/**
|
469 |
* @return JRadioButton de generar en memoria
|
470 |
*/
|
471 |
public JRadioButton getRadioMemory(){ |
472 |
if (rButtonMemory == null){ |
473 |
rButtonMemory = new JRadioButton(PluginServices.getText(this,"a_memoria"),true); |
474 |
rButtonMemory.addActionListener(this);
|
475 |
} |
476 |
return rButtonMemory;
|
477 |
} |
478 |
|
479 |
/*
|
480 |
* (non-Javadoc)
|
481 |
* @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
|
482 |
*/
|
483 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
484 |
// Bot?n de Aceptar
|
485 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
486 |
aplicar(); |
487 |
close(); |
488 |
} |
489 |
|
490 |
// Bot?n de Aplicar
|
491 |
if (e.getButton() == ButtonsPanel.BUTTON_APPLY) {
|
492 |
aplicar(); |
493 |
} |
494 |
|
495 |
// Bot?n de Cerrar
|
496 |
if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
|
497 |
close(); |
498 |
} |
499 |
} |
500 |
|
501 |
|
502 |
/** Se construye el proceso y se lanza a ejecuci?n*/
|
503 |
public void aplicar(){ |
504 |
FLyrRasterSE rasterLayer= (FLyrRasterSE)layers.getLayer((String)getComboCapas().getSelectedItem());
|
505 |
String filename= getFileSelected();
|
506 |
if(filename!=null){ |
507 |
TasseledCapProcess process = new TasseledCapProcess();
|
508 |
process.addParam("filename",filename);
|
509 |
process.addParam("datawriter",new WriterBufferServer()); |
510 |
process.addParam("viewName", view.getName());
|
511 |
process.addParam("type",new Integer(getComboTipos().getSelectedIndex())); |
512 |
process.addParam("layer",rasterLayer);
|
513 |
process.start(); |
514 |
} |
515 |
} |
516 |
|
517 |
/**Cierra ventana actual*/
|
518 |
public void close(){ |
519 |
try {
|
520 |
RasterLibrary.removeOnlyLayerNameListener(this);
|
521 |
PluginServices.getMDIManager().closeWindow(this);
|
522 |
} catch (ArrayIndexOutOfBoundsException ex) { |
523 |
// Si la ventana no se puede eliminar no hacemos nada
|
524 |
} |
525 |
} |
526 |
|
527 |
|
528 |
/**
|
529 |
* Devuelve la ruta del fichero donde se va a guardar, en caso de guardarse
|
530 |
* en memoria, calcula el nombre sin preguntar y devuelve la ruta.
|
531 |
* @return string con la ruta de salida
|
532 |
*/
|
533 |
public String getFileSelected() { |
534 |
String path = ""; |
535 |
if (getRadioFile().isSelected()) {
|
536 |
JFileChooser chooser = new JFileChooser(FileOpenWizard.getLastPath()); |
537 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
538 |
//A?adimos las extensiones que hayan sido registradas en el driver
|
539 |
String[] extList = GeoRasterWriter.getDriversExtensions(); |
540 |
for(int i=0;i<extList.length;i++) |
541 |
chooser.addChoosableFileFilter(new ExtendedFileFilter(extList[i]));
|
542 |
|
543 |
if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) |
544 |
return null; |
545 |
|
546 |
FileOpenWizard.setLastPath(chooser.getSelectedFile().getPath().substring(0, chooser.getSelectedFile().getPath().lastIndexOf(File.separator))); |
547 |
ExtendedFileFilter fileFilter = (ExtendedFileFilter) chooser.getFileFilter(); |
548 |
path = fileFilter.getNormalizedFilename(chooser.getSelectedFile()); |
549 |
} else {
|
550 |
String file = getJTextNombreCapa().getText();
|
551 |
path = Utilities.createTempDirectory() + File.separator + getJTextNombreCapa().getText() + ".tif"; |
552 |
if(file.compareTo(RasterLibrary.getOnlyLayerName()) == 0) |
553 |
RasterLibrary.usesOnlyLayerName(); |
554 |
updateNewLayerText(); |
555 |
} |
556 |
|
557 |
return path;
|
558 |
} |
559 |
|
560 |
|
561 |
public void focusGained(FocusEvent arg0) {} |
562 |
|
563 |
public void focusLost(FocusEvent arg0) {} |
564 |
|
565 |
|
566 |
|
567 |
public void windowActivated() { |
568 |
// TODO Auto-generated method stub
|
569 |
|
570 |
} |
571 |
|
572 |
|
573 |
public void windowClosed() { |
574 |
// TODO Auto-generated method stub
|
575 |
|
576 |
} |
577 |
|
578 |
|
579 |
public Object getWindowProfile() { |
580 |
return WindowInfo.PROPERTIES_PROFILE;
|
581 |
} |
582 |
|
583 |
|
584 |
} |
585 |
|
586 |
|