svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extRemoteSensing / src / org / gvsig / remotesensing / tasseledcap / TransformationPanel.java @ 26348
History | View | Annotate | Download (20.2 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 |
package org.gvsig.remotesensing.tasseledcap; |
41 |
|
42 |
import java.awt.BorderLayout; |
43 |
import java.awt.Color; |
44 |
import java.awt.Dimension; |
45 |
import java.awt.GridBagConstraints; |
46 |
import java.awt.GridBagLayout; |
47 |
import java.awt.event.ActionEvent; |
48 |
import java.awt.event.ActionListener; |
49 |
import java.awt.event.FocusEvent; |
50 |
import java.awt.event.FocusListener; |
51 |
import java.io.File; |
52 |
|
53 |
import javax.swing.BorderFactory; |
54 |
import javax.swing.ButtonGroup; |
55 |
import javax.swing.ComboBoxModel; |
56 |
import javax.swing.DefaultComboBoxModel; |
57 |
import javax.swing.JFileChooser; |
58 |
import javax.swing.JLabel; |
59 |
import javax.swing.JPanel; |
60 |
import javax.swing.JRadioButton; |
61 |
import javax.swing.JScrollPane; |
62 |
import javax.swing.JTable; |
63 |
import javax.swing.JTextField; |
64 |
import javax.swing.SwingConstants; |
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 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
71 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
72 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
73 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
74 |
import org.gvsig.raster.IProcessActions; |
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.raster.util.RasterToolsUtil; |
82 |
import org.gvsig.remotesensing.principalcomponents.PCStatistics; |
83 |
import org.gvsig.remotesensing.principalcomponents.PCStatisticsProcess; |
84 |
import org.gvsig.remotesensing.principalcomponents.gui.BandTableFormat; |
85 |
import org.gvsig.remotesensing.principalcomponents.gui.PrincipalComponentCalculusPanel; |
86 |
|
87 |
import com.iver.andami.PluginServices; |
88 |
import com.iver.andami.Utilities; |
89 |
import com.iver.andami.ui.mdiManager.IWindow; |
90 |
import com.iver.andami.ui.mdiManager.IWindowListener; |
91 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
92 |
import com.iver.cit.gvsig.addlayer.fileopen.FileOpenWizard; |
93 |
import com.iver.cit.gvsig.fmap.MapContext; |
94 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
95 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
96 |
import com.iver.utiles.swing.JComboBox; |
97 |
|
98 |
/**
|
99 |
* Clase que implementa la interfaz para las transformaciones multiespectrales de Componentes
|
100 |
* Principales y TasseledCap.
|
101 |
* @author aMu?oz (alejandro.munoz@uclm.es)
|
102 |
* @version 30/4/2008
|
103 |
* */
|
104 |
|
105 |
public class TransformationPanel extends DefaultButtonsPanel implements PropertyListener, IWindow, IWindowListener, |
106 |
ButtonsPanelListener,ActionListener,FocusListener, IProcessActions{ |
107 |
|
108 |
private static final long serialVersionUID = 1L; |
109 |
private int width=380; |
110 |
private int height=450; |
111 |
private MapContext m_MapContext=null; |
112 |
private JScrollPane scrollBandas=null; |
113 |
private BandTableFormat mModeloTabla=null; |
114 |
private JTable jTableBandas=null; |
115 |
private FLayers layers=null; |
116 |
private JComboBox comboLayers= null; |
117 |
private int[] bands= null; |
118 |
private JPanel panelSeleccion=null; |
119 |
private JRadioButton rButtonFile=null; |
120 |
private JRadioButton rButtonMemory =null; |
121 |
private JPanel nombreCapa=null; |
122 |
private JTextField jTextNombreCapa=null; |
123 |
private JPanel panelCentral= null; |
124 |
private JRadioButton rTasseledCapOption=null; |
125 |
private JComboBox typeTasseledCap=null; |
126 |
private JRadioButton rPrincipalComponentOption=null; |
127 |
private View view=null; |
128 |
private PCStatisticsProcess statisticsProcess= null; |
129 |
private boolean selectedBands[]= null; |
130 |
|
131 |
public void actionValueChanged(PropertyEvent e) { |
132 |
|
133 |
} |
134 |
|
135 |
public WindowInfo getWindowInfo() {
|
136 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
|
137 |
m_viewinfo.setWidth(width); |
138 |
m_viewinfo.setHeight(height); |
139 |
m_viewinfo.setTitle(PluginServices.getText(this,"transformacion_title")); |
140 |
m_viewinfo.setX(300);
|
141 |
return m_viewinfo;
|
142 |
} |
143 |
|
144 |
|
145 |
/**
|
146 |
* @param view vista de la aplicacion
|
147 |
*/
|
148 |
public TransformationPanel(View view) { |
149 |
m_MapContext = view.getModel().getMapContext(); |
150 |
this.view=view;
|
151 |
layers = m_MapContext.getLayers(); |
152 |
this.setPreferredSize(new Dimension(width, height)); |
153 |
this.setSize(width, height);
|
154 |
this.setLayout(new BorderLayout(3, 3)); |
155 |
this.addButtonPressedListener(this); |
156 |
initialize(); |
157 |
} |
158 |
|
159 |
|
160 |
/**
|
161 |
* Inicializaci?n del cuadro de dialogo
|
162 |
*/
|
163 |
private void initialize(){ |
164 |
BorderLayout bd=new BorderLayout(); |
165 |
this.setLayout(bd);
|
166 |
TitledBorder topBorder = BorderFactory.createTitledBorder(" "); |
167 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
168 |
this.setBorder(new CompoundBorder(topBorder,new EmptyBorder(0,5,5,5))); |
169 |
this.setLayout(new BorderLayout()); |
170 |
this.add(getSelectionImagePanel(), BorderLayout.NORTH); |
171 |
JPanel aux= new JPanel(); aux.setBackground(Color.RED); |
172 |
this.add(getPanelCentral(), BorderLayout.CENTER); |
173 |
this.add(getOutputOptionsPanel(), BorderLayout.SOUTH); |
174 |
getBandas(); |
175 |
} |
176 |
|
177 |
|
178 |
/**
|
179 |
* Toma las Bandas de la imagen seleccionada en el combo Imagen
|
180 |
*/
|
181 |
public void getBandas(){ |
182 |
|
183 |
// Antes de insertar se borra lo anterior
|
184 |
getModeloTabla().LimpiarLista(); |
185 |
|
186 |
FLyrRasterSE rasterLayer= (FLyrRasterSE)layers.getLayer((String)getComboCapas().getSelectedItem());
|
187 |
String bandas[]=new String[rasterLayer.getBandCount()]; |
188 |
bands= new int[rasterLayer.getBandCount()]; |
189 |
if (layers.getLayer((String)getComboCapas().getSelectedItem()) instanceof FLyrRasterSE ){ |
190 |
for (int j=0; j<rasterLayer.getBandCount(); j++){ |
191 |
String s=(PluginServices.getText(this,"banda"))+(j+1); |
192 |
bandas[j]=s; |
193 |
bands[j]=j; |
194 |
} |
195 |
for (int i=0;i<bandas.length;i++) |
196 |
getModeloTabla().addRow(bandas[i],true);
|
197 |
getTableBands().updateUI(); |
198 |
} |
199 |
} |
200 |
|
201 |
/**
|
202 |
* @return modelo de tabla
|
203 |
* @see BandTableFormat
|
204 |
*/
|
205 |
public BandTableFormat getModeloTabla() {
|
206 |
if(mModeloTabla==null){ |
207 |
mModeloTabla=new BandTableFormat();
|
208 |
} |
209 |
return mModeloTabla;
|
210 |
} |
211 |
|
212 |
/**
|
213 |
* @return scroll con bandas del r?ster
|
214 |
*/
|
215 |
public JScrollPane getScrollBands() { |
216 |
if (scrollBandas==null){ |
217 |
scrollBandas=new JScrollPane(); |
218 |
} |
219 |
getTableBands().getColumn("").setPreferredWidth(30); |
220 |
scrollBandas.setPreferredSize(new Dimension(250,80)); |
221 |
scrollBandas.setViewportView(getTableBands()); |
222 |
scrollBandas.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
223 |
return scrollBandas;
|
224 |
} |
225 |
|
226 |
/**
|
227 |
* @return tabla conlas bandas de la imagen
|
228 |
*/
|
229 |
private JTable getTableBands(){ |
230 |
if (jTableBandas==null){ |
231 |
jTableBandas=new JTable(getModeloTabla()); |
232 |
} |
233 |
return jTableBandas;
|
234 |
} |
235 |
|
236 |
|
237 |
/**
|
238 |
* @return JComboBox con los r?ster cargados en la vista.
|
239 |
*/
|
240 |
public JComboBox getComboCapas() { |
241 |
if (comboLayers==null){ |
242 |
ComboBoxModel jComboBoxLayersModel = new |
243 |
DefaultComboBoxModel(getLayerNames());
|
244 |
comboLayers = new JComboBox(); |
245 |
comboLayers.setModel(jComboBoxLayersModel); |
246 |
comboLayers.setEnabled(true);
|
247 |
comboLayers.addActionListener(this);
|
248 |
comboLayers.setSelectedIndex(0);
|
249 |
} |
250 |
return comboLayers;
|
251 |
} |
252 |
|
253 |
|
254 |
|
255 |
/**
|
256 |
* @return array de string con los nombre de las capas raster
|
257 |
*/
|
258 |
private String[] getLayerNames() { |
259 |
int i, capasraster=0; |
260 |
for (i = 0; i < layers.getLayersCount(); i++) { |
261 |
if (layers.getLayer(i)instanceof FLyrRasterSE) |
262 |
capasraster++; |
263 |
} |
264 |
// Solo se toman las capas raster.
|
265 |
String[] sNames = new String[capasraster]; |
266 |
capasraster=0;
|
267 |
|
268 |
for (i = 0; i < layers.getLayersCount(); i++) { |
269 |
if (layers.getLayer(i)instanceof FLyrRasterSE){ |
270 |
sNames[capasraster] =layers.getLayer(i).getName(); |
271 |
capasraster++; |
272 |
} |
273 |
} |
274 |
return sNames;
|
275 |
} |
276 |
|
277 |
|
278 |
public JPanel getSelectionImagePanel(){ |
279 |
if(panelSeleccion==null){ |
280 |
panelSeleccion= new JPanel(); |
281 |
TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this,"imagen")); |
282 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
283 |
panelSeleccion.setBorder(topBorder); |
284 |
JPanel aux= new JPanel(); |
285 |
aux.setPreferredSize(new Dimension(300,110)); |
286 |
BorderLayout bd=new BorderLayout(); |
287 |
aux.setLayout(bd); |
288 |
aux.add(getComboCapas(),BorderLayout.NORTH);
|
289 |
aux.add(getScrollBands(),BorderLayout.SOUTH);
|
290 |
panelSeleccion.add(aux); |
291 |
} |
292 |
return panelSeleccion;
|
293 |
} |
294 |
|
295 |
/**
|
296 |
*Actualizaci?n de las bandas cuando cambia la imagen seleccionada
|
297 |
*/
|
298 |
public void actionPerformed(ActionEvent arg0) { |
299 |
if(arg0.getSource()==getComboCapas()){
|
300 |
getBandas(); |
301 |
} |
302 |
if(arg0.getSource()==getRTasseledCapOption()){
|
303 |
getTypeTasseledCap().setEnabled(getRTasseledCapOption().isSelected()); |
304 |
} |
305 |
if(arg0.getSource()==getRPrincipalComponentOption()){
|
306 |
getTypeTasseledCap().setEnabled(getRTasseledCapOption().isSelected()); |
307 |
} |
308 |
} |
309 |
|
310 |
|
311 |
public void windowActivated() { |
312 |
// TODO Auto-generated method stub
|
313 |
|
314 |
} |
315 |
|
316 |
public void windowClosed() { |
317 |
// TODO Auto-generated method stub
|
318 |
|
319 |
} |
320 |
|
321 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
322 |
// Bot?n de Aceptar
|
323 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
324 |
aplicar(); |
325 |
close(); |
326 |
} |
327 |
|
328 |
// Bot?n de Aplicar
|
329 |
if (e.getButton() == ButtonsPanel.BUTTON_APPLY) {
|
330 |
aplicar(); |
331 |
} |
332 |
|
333 |
// Bot?n de Cerrar
|
334 |
if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
|
335 |
close(); |
336 |
} |
337 |
|
338 |
} |
339 |
|
340 |
public void focusGained(FocusEvent e) { |
341 |
// TODO Auto-generated method stub
|
342 |
|
343 |
} |
344 |
|
345 |
public void focusLost(FocusEvent e) { |
346 |
// TODO Auto-generated method stub
|
347 |
|
348 |
} |
349 |
|
350 |
|
351 |
/**
|
352 |
* @return panel con las opciones de salida.
|
353 |
*/
|
354 |
public JPanel getOutputOptionsPanel() { |
355 |
if (nombreCapa==null){ |
356 |
nombreCapa=new JPanel(); |
357 |
nombreCapa.setPreferredSize(new Dimension(400,130)); |
358 |
TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this, "salida")); |
359 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
360 |
nombreCapa.setBorder(topBorder); |
361 |
GridBagConstraints gridBagConstraints;
|
362 |
JPanel radioPanel = new JPanel(); |
363 |
radioPanel.setLayout(new GridBagLayout()); |
364 |
radioPanel.setBorder(BorderFactory.createTitledBorder("")); |
365 |
ButtonGroup buttonGroup = new ButtonGroup(); |
366 |
buttonGroup.add(getRadioMemory()); |
367 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
368 |
gridBagConstraints.gridx = 0;
|
369 |
gridBagConstraints.gridy = 1;
|
370 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
371 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
372 |
radioPanel.add(getRadioMemory(),gridBagConstraints); |
373 |
buttonGroup.add(getRadioFile()); |
374 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
375 |
gridBagConstraints.gridx = 0;
|
376 |
gridBagConstraints.gridy = 2;
|
377 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
378 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
379 |
radioPanel.add(getRadioFile(),gridBagConstraints); |
380 |
//Establece la separacion entre los elementos
|
381 |
nombreCapa.setLayout(new GridBagLayout()); |
382 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
383 |
gridBagConstraints.gridx = 0;
|
384 |
gridBagConstraints.gridy = 0;
|
385 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
386 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
387 |
nombreCapa.add(new JLabel(("Nombre:"),SwingConstants.RIGHT ),gridBagConstraints); |
388 |
|
389 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
390 |
gridBagConstraints.gridx = 1;
|
391 |
gridBagConstraints.gridy = 0;
|
392 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
393 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
394 |
nombreCapa.add(getJTextNombreCapa(),gridBagConstraints); |
395 |
|
396 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
397 |
gridBagConstraints.gridx = 2;
|
398 |
gridBagConstraints.gridy = 0;
|
399 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
400 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
401 |
nombreCapa.add(radioPanel,gridBagConstraints); |
402 |
} |
403 |
return nombreCapa;
|
404 |
} |
405 |
|
406 |
|
407 |
/**
|
408 |
* @return JRadioButton de generar fichero
|
409 |
*/
|
410 |
public JRadioButton getRadioFile(){ |
411 |
if (rButtonFile == null){ |
412 |
rButtonFile = new JRadioButton(PluginServices.getText(this,"a_fichero")); |
413 |
rButtonFile.addActionListener(this);
|
414 |
} |
415 |
return rButtonFile;
|
416 |
} |
417 |
|
418 |
/**
|
419 |
* @return JRadioButton de generar en memoria
|
420 |
*/
|
421 |
public JRadioButton getRadioMemory(){ |
422 |
if (rButtonMemory == null){ |
423 |
rButtonMemory = new JRadioButton(PluginServices.getText(this,"a_memoria"),true); |
424 |
rButtonMemory.addActionListener(this);
|
425 |
} |
426 |
return rButtonMemory;
|
427 |
} |
428 |
/**
|
429 |
* @return javax.swing.JTextField
|
430 |
*/
|
431 |
public JTextField getJTextNombreCapa() { |
432 |
if (jTextNombreCapa==null) { |
433 |
jTextNombreCapa=new JTextField(10); |
434 |
jTextNombreCapa.setText(RasterLibrary.getOnlyLayerName()); |
435 |
jTextNombreCapa.addFocusListener(this);
|
436 |
RasterLibrary.addOnlyLayerNameListener(this);
|
437 |
} |
438 |
return jTextNombreCapa;
|
439 |
} |
440 |
|
441 |
public JPanel getPanelCentral(){ |
442 |
if(panelCentral==null){ |
443 |
panelCentral= new JPanel(); |
444 |
panelCentral.setLayout(new BorderLayout()); |
445 |
//panelCentral.setBorder(new EmptyBorder(10,10,10,10));
|
446 |
TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this,"transformacion")); |
447 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
448 |
panelCentral.setBorder(topBorder); |
449 |
panelCentral.setEnabled(false);
|
450 |
// A?adir aqui si el panel tiene que contener alg?n par?metro
|
451 |
JPanel panel = new JPanel(); |
452 |
ButtonGroup btgr= new ButtonGroup(); |
453 |
btgr.add(getRPrincipalComponentOption()); |
454 |
btgr.add(getRTasseledCapOption()); |
455 |
panel.setPreferredSize(new Dimension(200,10)); |
456 |
panel.setBorder(new EmptyBorder(5,10,10,10)); |
457 |
BorderLayout bd= new BorderLayout(); |
458 |
panel.setLayout(bd); |
459 |
panel.add(getRPrincipalComponentOption(),BorderLayout.NORTH);
|
460 |
panel.add(getRTasseledCapOption(),BorderLayout.CENTER);
|
461 |
panel.add(getTypeTasseledCap(),BorderLayout.SOUTH);
|
462 |
panelCentral.add(panel,BorderLayout.CENTER);
|
463 |
} |
464 |
return panelCentral;
|
465 |
} |
466 |
|
467 |
public JRadioButton getRPrincipalComponentOption() { |
468 |
if(rPrincipalComponentOption==null){ |
469 |
rPrincipalComponentOption= new JRadioButton(PluginServices.getText(this,"principal_component")); |
470 |
rPrincipalComponentOption.setSelected(true);
|
471 |
rPrincipalComponentOption.addActionListener(this);
|
472 |
} |
473 |
return rPrincipalComponentOption;
|
474 |
} |
475 |
|
476 |
public JRadioButton getRTasseledCapOption() { |
477 |
if(rTasseledCapOption==null){ |
478 |
rTasseledCapOption= new JRadioButton(PluginServices.getText(this,"tasseledcap")); |
479 |
rTasseledCapOption.addActionListener(this);
|
480 |
} |
481 |
return rTasseledCapOption;
|
482 |
} |
483 |
|
484 |
public JComboBox getTypeTasseledCap() { |
485 |
if(typeTasseledCap==null){ |
486 |
typeTasseledCap= new JComboBox(); |
487 |
typeTasseledCap.setEnabled(false);
|
488 |
typeTasseledCap.addItem(new String(PluginServices.getText(this,"landsatMS"))); |
489 |
typeTasseledCap.addItem(new String(PluginServices.getText(this,"landsatTM"))); |
490 |
typeTasseledCap.addItem(new String(PluginServices.getText(this,"landsatETM"))); |
491 |
|
492 |
} |
493 |
return typeTasseledCap;
|
494 |
} |
495 |
|
496 |
|
497 |
/**
|
498 |
* Devuelve la ruta del fichero donde se va a guardar, en caso de guardarse
|
499 |
* en memoria, calcula el nombre sin preguntar y devuelve la ruta.
|
500 |
* @return string con la ruta de salida
|
501 |
*/
|
502 |
public String getFileSelected() { |
503 |
String path = ""; |
504 |
if (getRadioFile().isSelected()) {
|
505 |
JFileChooser chooser = new JFileChooser(FileOpenWizard.getLastPath()); |
506 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
507 |
//A?adimos las extensiones que hayan sido registradas en el driver
|
508 |
String[] extList = GeoRasterWriter.getDriversExtensions(); |
509 |
for(int i=0;i<extList.length;i++) |
510 |
chooser.addChoosableFileFilter(new ExtendedFileFilter(extList[i]));
|
511 |
|
512 |
if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) |
513 |
return null; |
514 |
|
515 |
FileOpenWizard.setLastPath(chooser.getSelectedFile().getPath().substring(0, chooser.getSelectedFile().getPath().lastIndexOf(File.separator))); |
516 |
ExtendedFileFilter fileFilter = (ExtendedFileFilter) chooser.getFileFilter(); |
517 |
path = fileFilter.getNormalizedFilename(chooser.getSelectedFile()); |
518 |
} else {
|
519 |
String file = getJTextNombreCapa().getText();
|
520 |
path = Utilities.createTempDirectory() + File.separator + getJTextNombreCapa().getText() + ".tif"; |
521 |
if(file.compareTo(RasterLibrary.getOnlyLayerName()) == 0) |
522 |
RasterLibrary.usesOnlyLayerName(); |
523 |
updateNewLayerText(); |
524 |
} |
525 |
return path;
|
526 |
} |
527 |
|
528 |
public void updateNewLayerText() { |
529 |
getJTextNombreCapa().setText(RasterLibrary.getOnlyLayerName()); |
530 |
} |
531 |
|
532 |
|
533 |
/** Se construye el proceso y se lanza a ejecuci?n*/
|
534 |
public void aplicar(){ |
535 |
FLyrRasterSE rasterLayer= (FLyrRasterSE)layers.getLayer((String)getComboCapas().getSelectedItem());
|
536 |
String filename= getFileSelected();
|
537 |
|
538 |
boolean bandsSelected[] = getModeloTabla().getSeleccionadas(); |
539 |
int bandCount = 0; |
540 |
for (int i= 0; i<bandsSelected.length;i++) |
541 |
if(bandsSelected[i]==true) |
542 |
bandCount++; |
543 |
int bandList[] = new int[bandCount]; |
544 |
int index = 0; |
545 |
for (int i = 0; i < bandsSelected.length; i++){ |
546 |
if (bandsSelected[i])
|
547 |
{ bandList[index]=i; |
548 |
index++; |
549 |
} |
550 |
} |
551 |
|
552 |
if(filename!=null){ |
553 |
|
554 |
if(getRTasseledCapOption().isSelected()){
|
555 |
// Comprobaciones
|
556 |
if(bandList.length!=4&& getTypeTasseledCap().getSelectedIndex()==0) |
557 |
{ |
558 |
RasterToolsUtil.messageBoxInfo(PluginServices.getText(this,"transformMSS_error"),"aviso" ); |
559 |
return;
|
560 |
} |
561 |
else if(bandList.length!=6 && getTypeTasseledCap().getSelectedIndex()==1) |
562 |
{ |
563 |
RasterToolsUtil.messageBoxInfo(PluginServices.getText(this,"transformTM_error"),"aviso" ); |
564 |
return;
|
565 |
} |
566 |
else if(bandList.length!=6 && getTypeTasseledCap().getSelectedIndex()==2){ |
567 |
RasterToolsUtil.messageBoxInfo(PluginServices.getText(this,"transformETM_error"),"aviso" ); |
568 |
return;
|
569 |
} |
570 |
|
571 |
else{
|
572 |
TasseledCapProcess process = new TasseledCapProcess();
|
573 |
process.addParam("filename",filename);
|
574 |
process.addParam("bands",bandList);
|
575 |
process.addParam("datawriter",new WriterBufferServer()); |
576 |
process.addParam("viewName", view.getName());
|
577 |
process.addParam("type",new Integer(getTypeTasseledCap().getSelectedIndex())); |
578 |
process.addParam("layer",rasterLayer);
|
579 |
process.start(); |
580 |
} |
581 |
} |
582 |
|
583 |
if(getRPrincipalComponentOption().isSelected()){
|
584 |
|
585 |
statisticsProcess = new PCStatisticsProcess();
|
586 |
selectedBands= getModeloTabla().getSeleccionadas(); |
587 |
statisticsProcess.addParam("selectedBands",selectedBands);
|
588 |
statisticsProcess.addParam("inputRasterLayer",rasterLayer);
|
589 |
statisticsProcess.setActions(this);
|
590 |
statisticsProcess.start(); |
591 |
} |
592 |
} |
593 |
} |
594 |
|
595 |
/**Cierra ventana actual*/
|
596 |
public void close(){ |
597 |
try {
|
598 |
RasterLibrary.removeOnlyLayerNameListener(this);
|
599 |
PluginServices.getMDIManager().closeWindow(this);
|
600 |
} catch (ArrayIndexOutOfBoundsException ex) { |
601 |
// Si la ventana no se puede eliminar no hacemos nada
|
602 |
} |
603 |
} |
604 |
|
605 |
public void interrupted() { |
606 |
// TODO Auto-generated method stub
|
607 |
|
608 |
} |
609 |
|
610 |
public void end(Object param) { |
611 |
String fileName = Utilities.createTempDirectory() + File.separator; |
612 |
fileName = fileName + RasterLibrary.getOnlyLayerName() + ".tif";
|
613 |
RasterLibrary.usesOnlyLayerName(); |
614 |
|
615 |
PrincipalComponentCalculusPanel altPrincipalComponentCalculusPanel = new PrincipalComponentCalculusPanel(view,(PCStatistics)param,statisticsProcess,selectedBands);
|
616 |
altPrincipalComponentCalculusPanel.setFilename(fileName); |
617 |
PluginServices.getMDIManager().addWindow(altPrincipalComponentCalculusPanel); |
618 |
} |
619 |
|
620 |
public Object getWindowProfile() { |
621 |
return WindowInfo.PROPERTIES_PROFILE;
|
622 |
} |
623 |
|
624 |
} |