Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / classification / gui / ClassificationPanel.java @ 16074

History | View | Annotate | Download (21.7 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.classification.gui;
41

    
42
import java.awt.BorderLayout;
43
import java.awt.Dimension;
44
import java.awt.GridBagConstraints;
45
import java.awt.GridBagLayout;
46
import java.awt.Insets;
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.JOptionPane;
60
import javax.swing.JPanel;
61
import javax.swing.JRadioButton;
62
import javax.swing.JScrollPane;
63
import javax.swing.JTabbedPane;
64
import javax.swing.JTable;
65
import javax.swing.JTextField;
66
import javax.swing.SwingConstants;
67
import javax.swing.border.CompoundBorder;
68
import javax.swing.border.EmptyBorder;
69
import javax.swing.border.TitledBorder;
70

    
71
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
72
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
73
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
74
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
75
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
76
import org.gvsig.gui.beans.incrementabletask.IncrementableTask;
77
import org.gvsig.raster.dataset.GeoRasterWriter;
78
import org.gvsig.raster.dataset.IRasterDataSource;
79
import org.gvsig.rastertools.RasterModule;
80
import org.gvsig.rastertools.roi.ui.ROIsTablePanel;
81
import org.gvsig.remotesensing.classification.ClassificationGeneralProcess;
82
import org.gvsig.remotesensing.classification.ClassificationMaximumLikelihoodProcess;
83
import org.gvsig.remotesensing.classification.ClassificationMinimumDistanceProcess;
84
import org.gvsig.remotesensing.principalcomponents.gui.BandTableFormat;
85

    
86
import com.iver.andami.PluginServices;
87
import com.iver.andami.Utilities;
88
import com.iver.andami.ui.mdiManager.IWindow;
89
import com.iver.andami.ui.mdiManager.IWindowListener;
90
import com.iver.andami.ui.mdiManager.WindowInfo;
91
import com.iver.cit.gvsig.addlayer.fileopen.FileOpenWizard;
92
import com.iver.cit.gvsig.fmap.MapContext;
93
import com.iver.cit.gvsig.fmap.layers.FLayers;
94
import com.iver.cit.gvsig.project.documents.view.gui.View;
95
import com.iver.utiles.swing.JComboBox;
96

    
97
/**
98
 * Clase que define la interfaz del proceso de clasificacion de una imagen. Recoge la
99
 * imagen a clasificar con la selecci?n de bandas correspondiente. Posibilita la elecci?n del 
100
 * m?todo empleado y da la posibilidad de manejar la lista de clases que intervienen en el proceso.
101
 * Permite ajustar algunos parametros del proceso y configurar las opciones de salida. 
102
 * 
103
 * @author Alejandro Mu?oz Sanchez (alejandro.munoz@uclm.es)
104
 * @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)  
105
 * @version 19/10/2007
106
 */
107
public class ClassificationPanel extends DefaultButtonsPanel implements IWindow, IWindowListener, 
108
        ButtonsPanelListener,ActionListener,FocusListener{
109

    
110
        private static final long                 serialVersionUID = 1L;
111
        private View                                         view = null;
112
        private int                                         width=400;
113
        private int                                         height=550;
114
        private MapContext                                 m_MapContext=null;
115
        private FLayers                                 layers=null;
116
        private int nMethods                        = 2;
117
        private JRadioButton                         rButtonFile=null;
118
        private JRadioButton                         rButtonMemory =null;
119
        private JTextField                                 jTextNombreCapa=null;
120
        private JPanel                                         panelTab1=null;
121
        private JPanel                                         panelTab2=null;
122
        private JScrollPane                                scrollBandas=null;
123
        private JScrollPane                                scrollTable=null;
124
        private JComboBox                                comboLayers= null;
125
        private JComboBox                                comboMethods= null;
126
        private ROIsTablePanel                         roisTablePanel= null;
127
        private BandTableFormat                 mModeloTabla=null;
128
        private JTable                                         jTableBandas=null;
129
        private JPanel                                         nombreCapa=null;
130
        private int[]                                         bands= null;
131
        
132
        
133
        /**
134
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
135
         */
136
        public WindowInfo getWindowInfo(){
137
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
138
                m_viewinfo.setWidth(width);
139
                m_viewinfo.setHeight(height);
140
                m_viewinfo.setTitle(PluginServices.getText(this,"classification"));
141
                m_viewinfo.setX(300);
142
                return m_viewinfo;
143
        }
144

    
145
        /**
146
         * @param view vista de la aplicacion
147
         */
148
        public ClassificationPanel(View view) {
149
                this.view = view;
150
                m_MapContext = view.getModel().getMapContext();
151
                layers = m_MapContext.getLayers();
152
                this.setPreferredSize(new Dimension(width, height));
153
                this.setSize(width, height);
154
                this.setLayout(new BorderLayout(1, 1));
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
                JTabbedPane tabbedPane = new JTabbedPane();
170
                 tabbedPane.addTab(PluginServices.getText(this, "operacion"), getPanelTab1());
171
                tabbedPane.addTab(PluginServices.getText(this, "opciones"), getPanelTab2());
172
                this.setLayout(new BorderLayout());
173
                this.add(tabbedPane, BorderLayout.CENTER);
174
                getBandas();
175
        }
176

    
177
        /**
178
         * @return panel para el tab operacion.
179
         */
180
         private JPanel getPanelTab1(){         
181
                if (panelTab1==null){
182
                        panelTab1 = new JPanel();        
183
                        panelTab1.setLayout(new GridBagLayout());
184
                        
185
                        // Panel superior opcion Selecion de imagen y bandas
186
                        JPanel selectionImagenPanel= new JPanel();
187
                        TitledBorder topBorder = BorderFactory.createTitledBorder(" Imagen");
188
                        topBorder.setTitlePosition(TitledBorder.TOP);
189
                        JPanel aux= new JPanel();
190
                        aux.setPreferredSize(new Dimension(300,110));
191
                        
192
                        BorderLayout bd=new BorderLayout();
193
                        aux.setLayout(bd);
194
                
195
                        aux.add(getComboCapas(),BorderLayout.NORTH);
196
                        aux.add(getScrollBands(),BorderLayout.SOUTH);
197
                        selectionImagenPanel.add(aux);
198
                        
199
                        selectionImagenPanel.setBorder(topBorder);
200
                        GridBagConstraints c = new GridBagConstraints();
201
                        c.fill = GridBagConstraints.BOTH;
202
                        c.insets=new Insets(2,2,2,2);
203
                        c.weightx = 1;
204
                        c.weighty = 0.1;
205
                        c.gridx = 0;
206
                        c.gridy = 0;
207
                        panelTab1.add(selectionImagenPanel, c);
208
                        
209
                
210
                        // Panel seleccion metodo
211
                        JPanel methodPanel= new JPanel();
212
                        TitledBorder topBorderMethod = BorderFactory.createTitledBorder("Metodo");
213
                        topBorder.setTitlePosition(TitledBorder.TOP);
214
                        methodPanel.setBorder(topBorderMethod);
215
                        methodPanel.add(new JLabel(PluginServices.getText(this, "metodo")));
216
                        methodPanel.add(getComboMethods());
217
                        c.fill = GridBagConstraints.BOTH;
218
                        c.insets=new Insets(2,2,2,2);
219
                        c.weightx = 1;
220
                        c.weighty = 0.1;
221
                        c.gridx = 0;
222
                        c.gridy = 1;
223
                        panelTab1.add(methodPanel, c);
224
                        
225
                        // Insercion del panel de las clases
226
                        c.fill = GridBagConstraints.BOTH;
227
                        c.insets=new Insets(2,2,2,2);
228
                        c.weightx = 1;
229
                        c.weighty = 1;
230
                        c.gridx = 0;
231
                        c.gridy = 2; 
232
                        panelTab1.add(getRoisTablePanel(), c);         
233
                 }
234
                 return panelTab1;
235
         }
236
         
237
         /**
238
          * @return Panel para el tab de opciones.
239
          */
240
         private JPanel getPanelTab2(){         
241
                if (panelTab2==null){
242
                        panelTab2 = new JPanel();        
243
                        panelTab2.setLayout(new GridBagLayout());
244
                                
245
                        JPanel parameterPanel= new JPanel();
246
                        TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this, "parametros"));
247
                        topBorder.setTitlePosition(TitledBorder.TOP);
248
                        JPanel aux= new JPanel();
249
                        aux.setPreferredSize(new Dimension(300,110));
250
                                
251
                        BorderLayout bd=new BorderLayout();
252
                        aux.setLayout(bd);
253
                        
254
                        //aux.add(new JButton(),BorderLayout.NORTH);
255
                        parameterPanel.add(aux);
256
                                
257
                        parameterPanel.setBorder(topBorder);
258
                        GridBagConstraints c = new GridBagConstraints();
259
                        c.fill = GridBagConstraints.BOTH;
260
                        c.insets=new Insets(2,2,2,2);
261
                        c.weightx = 1;
262
                        c.weighty = 1;
263
                        c.gridx = 0;
264
                        c.gridy = 0;
265
                        panelTab2.add(parameterPanel, c);
266
                                
267
        
268
                        // Insercion del panel de las clases
269
                        c.fill = GridBagConstraints.BOTH;
270
                        c.insets=new Insets(2,2,2,2);
271
                        c.weightx = 0.05;
272
                        c.weighty = 0.05;
273
                        c.gridx = 0;
274
                        c.gridy = 1; 
275
                                
276
                        panelTab2.add(getOutputOptionsPanel(), c);
277
                                        
278
                }
279
                return panelTab2; 
280
         }
281
         
282
         /** 
283
         * @return  Scroll con la tabla de clases intervienen en el proceso de clasificaci?n.
284
         */
285
         public JScrollPane getScrollTable() {
286
                        
287
                if(scrollTable==null){
288
                        scrollTable=new JScrollPane();
289
                        TitledBorder topBorder = BorderFactory.createTitledBorder((PluginServices.getText(this,"clases")));
290
                    topBorder.setTitlePosition(TitledBorder.TOP);
291
                    scrollTable.setBorder(new CompoundBorder(topBorder,new EmptyBorder(2,2,2,2)));                
292
                        scrollTable.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
293
                        scrollTable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);        
294
                }
295
                return scrollTable;
296
        }
297

    
298
         /**
299
          * @return javax.swing.JTextField
300
          */        
301
         public JTextField getJTextNombreCapa() {
302
                if (jTextNombreCapa==null){
303
                        jTextNombreCapa=new JTextField(10);
304
                        jTextNombreCapa.setText("NewLayer_" + RasterModule.layerCount);
305
                        RasterModule.layerCount++;
306
                        jTextNombreCapa.addFocusListener(this);
307
                        }
308
                return jTextNombreCapa;
309
        }
310

    
311
                
312
        /**
313
         * Especificar el nombre de la nueva capa para el recuadro de texto asign?ndo
314
         * en cada llamada un nombre consecutivo.
315
         */
316
        public void setNewLayerText() {
317
                getJTextNombreCapa().setText("NewLayer_" + RasterModule.layerCount);
318
                RasterModule.layerCount++;
319
        }
320
        
321
        /**
322
         * @return JRadioButton de generar fichero
323
         */
324
        public JRadioButton getRadioFile(){
325
                if (rButtonFile == null){
326
                        rButtonFile = new JRadioButton(PluginServices.getText(this,"a_fichero"));
327
                        rButtonFile.addActionListener(this);
328
                }
329
                return rButtonFile;
330
        }
331
        
332
        /**
333
         * @return JRadioButton de generar en memoria
334
         */
335
        public JRadioButton getRadioMemory(){
336
                if (rButtonMemory == null){
337
                        rButtonMemory = new JRadioButton(PluginServices.getText(this,"a_memoria"),true);
338
                        rButtonMemory.addActionListener(this);
339
                }
340
                return rButtonMemory;
341
        }
342
        
343
        
344
        /**
345
         * @return JComboBox con los r?ster cargados en la vista.
346
         */
347
         public JComboBox getComboCapas() {
348
                if (comboLayers==null){                
349
                        ComboBoxModel jComboBoxLayersModel = new 
350
                DefaultComboBoxModel(getLayerNames());
351
                        comboLayers = new JComboBox();
352
                        comboLayers.setModel(jComboBoxLayersModel);
353
                        comboLayers.setEnabled(true);
354
                        comboLayers.addActionListener(this);        
355
                        comboLayers.setSelectedIndex(0);
356
                }                                
357
                return comboLayers;
358
        }
359
         
360
        
361
        /**
362
         * Acciones a ejecuar al cerrar el di?logo.
363
         */
364
        public void close(){        
365
                try {
366
                        PluginServices.getMDIManager().closeWindow(this);
367
                } catch (ArrayIndexOutOfBoundsException ex) {
368
                        // Si la ventana no se puede eliminar no hacemos nada
369
                }
370
        }
371

    
372
        
373
        /**
374
         * @return array de string con los nombre de las capas raster
375
         */
376
        private String[] getLayerNames() {                
377
                  
378
                int i, capasraster=0; 
379
                for (i = 0; i < layers.getLayersCount(); i++) {                      
380
                        if (layers.getLayer(i)instanceof  FLyrRasterSE)
381
                                capasraster++;     
382
                }
383
                // Solo se toman las capas raster. 
384
                String[] sNames = new String[capasraster];
385
                capasraster=0;
386
                 
387
                for (i = 0; i < layers.getLayersCount(); i++) {                      
388
                        if (layers.getLayer(i)instanceof FLyrRasterSE){
389
                                sNames[capasraster] =layers.getLayer(i).getName();
390
                                capasraster++;
391
                        }
392
                }    
393
                return sNames;
394
        }
395
        
396
         
397
        /**
398
         * @return path con el fichero seleccionado
399
         */
400
        public String getFileSelected() {
401
        
402
                String path = "";
403
                if (getRadioFile().isSelected()) {        
404
                        JFileChooser chooser = new JFileChooser(FileOpenWizard.getLastPath());
405
                        chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero"));
406
                        
407
                        //A?adimos las extensiones que hayan sido registradas en el driver
408
                        
409
                        String[] extList = GeoRasterWriter.getDriversExtensions();
410
                        for(int i=0;i<extList.length;i++)
411
                                chooser.addChoosableFileFilter(new WriterFilter(extList[i]));
412
                        if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION)
413
                                return null;
414
                        
415
                        String fName = chooser.getSelectedFile().toString();                                
416
                        String ext = ((WriterFilter)chooser.getFileFilter()).getDescription();
417
                        ext = ext.toLowerCase().substring(ext.lastIndexOf(".") + 1, ext.length());
418
                        if ((fName != null) && !fName.equals(""))
419
                                if (!fName.endsWith("." + ext))        
420
                                        fName = fName + "." + ext;
421
                        FileOpenWizard.setLastPath(chooser.getSelectedFile().getPath().substring(0, chooser.getSelectedFile().getPath().lastIndexOf(File.separator)));
422
                                path = fName;
423
                } else {
424
                        path = Utilities.createTempDirectory() + File.separator +getJTextNombreCapa().getText() + ".tif";
425
                        setNewLayerText();        
426
                }
427
                        
428
                return path;        
429
        }
430

    
431
                
432
        /**
433
         * Acciones al aceptar
434
         */
435
        public void accept(){
436
                        
437
                // Imagen que va a ser clasificada
438
                IRasterDataSource rasterLayer= ((FLyrRasterSE)layers.getLayer((String) getComboCapas().getSelectedItem())).getDataSource();
439
                /*
440
                 * Bandas que intervienen en la clasificaci?n.
441
                 */
442
                boolean bandsSelected[] = getModeloTabla().getSeleccionadas();
443
                int bandCount = 0;
444
                for (int i= 0; i<bandsSelected.length;i++)
445
                        if(bandsSelected[i]==true)
446
                                bandCount++;
447
                int bandList[] = new int[bandCount];
448
                int index = 0;
449
                for (int i = 0; i < bandsSelected.length; i++){
450
                        if (bandsSelected[i])
451
                                {        bandList[index]=i;
452
                                        index++;
453
                                }
454
                }        
455
                
456
                ClassificationGeneralProcess process=null;
457
                if(getComboMethods().getSelectedIndex()==0)
458
                        process = new ClassificationMaximumLikelihoodProcess(rasterLayer, getRoisTablePanel().getROIs(), bandList, view, getFileSelected());
459
                if(getComboMethods().getSelectedIndex()==1)
460
                        process =  new ClassificationMinimumDistanceProcess(rasterLayer, getRoisTablePanel().getROIs(), bandList, view, getFileSelected());
461
        
462
                        IncrementableTask incrementableTask = new IncrementableTask(process);        
463
                        process.setIncrementableTask(incrementableTask);
464
                        incrementableTask.showWindow();
465
                        process.start();
466
                        incrementableTask.start();        
467
        
468
        }                
469
        
470
        /*
471
         * (non-Javadoc)
472
         * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
473
         */
474
        public void actionButtonPressed(ButtonsPanelEvent e) {
475
                        // Bot?n de Aceptar
476
                if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
477
                        if(!getRoisTablePanel().getROIs().isEmpty())
478
                                {accept(); close();}
479
                        else
480
                                JOptionPane.showMessageDialog(null,        PluginServices.getText(this,"no_clases"), PluginServices.getText(this,"no_clases"),JOptionPane.WARNING_MESSAGE);
481
                }
482

    
483
                // Bot?n de Aplicar
484
                if (e.getButton() == ButtonsPanel.BUTTON_APPLY) {
485
                        if(!getRoisTablePanel().getROIs().isEmpty())
486
                                accept();
487
                        else
488
                                JOptionPane.showMessageDialog(null,        PluginServices.getText(this,"no_clases"), PluginServices.getText(this,"clasificacion"),JOptionPane.WARNING_MESSAGE);
489
                }
490

    
491
                // Bot?n de Cerrar
492
                if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
493
                        close();
494
                }                        
495
         }
496
                
497
        /**
498
          *Actualizaci?n de las bandas cuando cambia la imagen seleccionada
499
          */        
500
        public void actionPerformed(ActionEvent arg0) {
501
                if(arg0.getSource()==getComboCapas()){
502
                        getBandas();                
503
                }                                
504
        }
505
                
506

    
507
        /**
508
         * @return tabla conlas bandas de la imagen
509
         */
510
        private JTable getTableBands(){
511
                if (jTableBandas==null){        
512
                        jTableBandas=new JTable(getModeloTabla());
513
                }
514
                return jTableBandas;
515
        }
516
                 
517
                  
518
        /**
519
         * @return modelo de tabla
520
         * @see BandTableFormat
521
         */
522
        public BandTableFormat getModeloTabla() {         
523
                if(mModeloTabla==null){
524
                        mModeloTabla=new BandTableFormat(); 
525
                } 
526
                return mModeloTabla;        
527
        }
528
                 
529
                
530
        /**
531
         * @return scroll con bandas del r?ster 
532
         */
533
        public JScrollPane getScrollBands() {        
534
                if (scrollBandas==null){
535
                        scrollBandas=new JScrollPane();                                
536
                }        
537
                getTableBands().getColumn("").setPreferredWidth(30);
538
                scrollBandas.setPreferredSize(new Dimension(250,80));
539
                scrollBandas.setViewportView(getTableBands());
540
                scrollBandas.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
541
                return scrollBandas;        
542
        }
543

    
544
                
545
        /**
546
         * @return panel de gesti?n de ROIs
547
         */
548
        public ROIsTablePanel getRoisTablePanel() {
549
                if (roisTablePanel==null){        
550
                        roisTablePanel= new ROIsTablePanel();
551
                }
552
                return roisTablePanel;
553
        }
554

    
555

    
556
        /**
557
         * @return JComboBox con los m?todos de clasificaci?n
558
         */
559
        public JComboBox getComboMethods() {        
560
                if (comboMethods==null){
561
                        comboMethods= new JComboBox();
562
                        String[] sNames = new String[nMethods];
563
                        sNames[0]= new String(PluginServices.getText(this, "metodo_maxima_probabilidad"));
564
                        sNames[1]= new String(PluginServices.getText(this, "metodo_minima_diatancia"));
565
                        ComboBoxModel jComboBoxLayersModel = new  DefaultComboBoxModel(sNames);
566
                        comboMethods.setModel(jComboBoxLayersModel);
567
                        comboMethods.setEnabled(true);
568
                        comboMethods.addActionListener(this);                
569
                }                
570
                return comboMethods;
571
        }
572
                
573
        /**
574
         * Toma las Bandas de la imagen seleccionada en el combo Imagen
575
         */
576
        public void getBandas(){
577
                
578
                // Antes de insertar se borra lo anterior
579
                getModeloTabla().LimpiarLista();
580
                         
581
                FLyrRasterSE rasterLayer= (FLyrRasterSE)layers.getLayer((String)getComboCapas().getSelectedItem());
582
                String bandas[]=new String[rasterLayer.getBandCount()];        
583
                bands= new int[rasterLayer.getBandCount()];
584
                if (layers.getLayer((String)getComboCapas().getSelectedItem()) instanceof  FLyrRasterSE ){                
585
                        for (int j=0; j<rasterLayer.getBandCount(); j++){
586
                                        String s=(PluginServices.getText(this,"banda"))+(j+1);
587
                                        bandas[j]=s;
588
                                        bands[j]=j;
589
                                }        
590
                        for (int i=0;i<bandas.length;i++)
591
                                getModeloTabla().addRow(bandas[i]); 
592
                        getTableBands().updateUI();
593
                        
594
                        // PROVISIONAL
595
                        getRoisTablePanel().setFLayer((FLyrRasterSE)layers.getLayer((String)getComboCapas().getSelectedItem()));
596
                }        
597
        }
598
                 
599
                 
600
        /**
601
         * @return panel con las opciones de salida.
602
         */
603
        public JPanel getOutputOptionsPanel() {
604
                if (nombreCapa==null){ 
605
                        nombreCapa=new JPanel();
606
                        nombreCapa.setPreferredSize(new Dimension(400,130));
607
                        TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this, "salida"));
608
                        topBorder.setTitlePosition(TitledBorder.TOP);
609
                        nombreCapa.setBorder(topBorder);
610
                        GridBagConstraints gridBagConstraints;
611
                        JPanel radioPanel = new JPanel();
612
                        radioPanel.setLayout(new GridBagLayout());
613
                        radioPanel.setBorder(BorderFactory.createTitledBorder(""));
614
                        ButtonGroup buttonGroup = new ButtonGroup();
615
                        buttonGroup.add(getRadioMemory());
616
                        gridBagConstraints = new java.awt.GridBagConstraints();
617
                        gridBagConstraints.gridx = 0;
618
                        gridBagConstraints.gridy = 1;
619
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
620
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
621
                        radioPanel.add(getRadioMemory(),gridBagConstraints);
622
                        buttonGroup.add(getRadioFile());
623
                        gridBagConstraints = new java.awt.GridBagConstraints();
624
                        gridBagConstraints.gridx = 0;
625
                        gridBagConstraints.gridy = 2;
626
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
627
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
628
                        radioPanel.add(getRadioFile(),gridBagConstraints);
629
                        //Establece la separacion entre los elementos
630
                        nombreCapa.setLayout(new GridBagLayout());
631
                        gridBagConstraints = new java.awt.GridBagConstraints();
632
                        gridBagConstraints.gridx = 0;
633
                        gridBagConstraints.gridy = 0;
634
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
635
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
636
                        nombreCapa.add(new JLabel(("Nombre:"),SwingConstants.RIGHT ),gridBagConstraints);
637
                                
638
                        gridBagConstraints = new java.awt.GridBagConstraints();
639
                        gridBagConstraints.gridx = 1;
640
                        gridBagConstraints.gridy = 0;
641
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
642
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
643
                        nombreCapa.add(getJTextNombreCapa(),gridBagConstraints);
644
                        
645
                        gridBagConstraints = new java.awt.GridBagConstraints();
646
                        gridBagConstraints.gridx = 2;
647
                        gridBagConstraints.gridy = 0;
648
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
649
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
650
                        nombreCapa.add(radioPanel,gridBagConstraints);        
651
                }
652
                return nombreCapa;
653
        }
654

    
655
        
656
        /**
657
          * Acciones al cerrar.
658
          */        
659
        public void windowClosed() {
660
                /*
661
                 * Limpiar los gr?ficos de la vista:
662
                 */
663
                getRoisTablePanel().clearRoiGraphics();
664
                getRoisTablePanel().getMapControl().rePaintDirtyLayers();
665
                
666
                getRoisTablePanel().setPreviousTool();
667
        }
668

    
669
        public void focusGained(FocusEvent arg0) {
670
                // TODO Auto-generated method stub
671
                
672
        }
673

    
674
        public void focusLost(FocusEvent arg0) {
675
                // TODO Auto-generated method stub
676
                
677
        }
678
        
679
        public void windowActivated() {}        
680
}
681

    
682
/**
683
 * @author Nacho Brodin <brodin_ign@gva.es>
684
 * Filtro para el selector de formatos de escritura
685
 */
686
class WriterFilter extends javax.swing.filechooser.FileFilter {
687
        private String                                filter;
688

    
689
        public WriterFilter(String fil) {
690
                this.filter = fil;
691
        }
692

    
693
        public boolean accept(File f) {
694
                return f.isDirectory() || f.getName().toLowerCase().endsWith("." + filter);
695
        }
696

    
697
        public String getDescription() {
698
                return "." + filter;
699
        }
700
}
701

    
702

    
703

    
704

    
705

    
706

    
707

    
708

    
709

    
710

    
711

    
712