Statistics
| Revision:

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

History | View | Annotate | Download (19.3 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.JButton;
58
import javax.swing.JFileChooser;
59
import javax.swing.JLabel;
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.WindowInfo;
90
import com.iver.cit.gvsig.addlayer.fileopen.FileOpenWizard;
91
import com.iver.cit.gvsig.fmap.MapContext;
92
import com.iver.cit.gvsig.fmap.layers.FLayers;
93
import com.iver.cit.gvsig.project.documents.view.gui.View;
94
import com.iver.utiles.swing.JComboBox;
95

    
96

    
97
/**
98
 * Clase que implementa la interfaz del proceso de clasificacion de una imagen.
99
 * 
100
 * */
101
public class ClassificationPanel extends DefaultButtonsPanel implements IWindow, ButtonsPanelListener,ActionListener,FocusListener{
102

    
103
        private static final long                 serialVersionUID = 1L;
104
        private View                                         view = null;
105
        private ClassificationPanel         classificationPanel= null;
106
        private int                                         width=400;
107
        private int                                         height=550;
108
        private MapContext                                 m_MapContext=null;
109
        private FLayers                                 layers=null;
110
        private int nMethods                        = 2;
111
        private JRadioButton                         rButtonFile=null;
112
        private JRadioButton                         rButtonMemory =null;
113
        private JTextField                                 jTextNombreCapa=null;
114
        private JPanel                                         panelTab1=null;
115
        private JPanel                                         panelTab2=null;
116
        private JScrollPane                                scrollBandas=null;
117
        private JScrollPane                                scrollTable=null;
118
        private JComboBox                                comboLayers= null;
119
        private JComboBox                                comboMethods= null;
120

    
121
        
122
        private ROIsTablePanel                         roisTablePanel= null;
123
        private BandTableFormat                 mModeloTabla=null;
124
        private JTable                                         jTableBandas=null;
125
        private JPanel                                         nombreCapa=null;
126
        private int[]                                         bands= null;
127
        
128
        
129
        public WindowInfo getWindowInfo(){
130
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
131
                m_viewinfo.setWidth(width);
132
                m_viewinfo.setHeight(height);
133
                m_viewinfo.setTitle(PluginServices.getText(this,"classification"));
134
                m_viewinfo.setX(300);
135
                return m_viewinfo;
136
        }
137

    
138
        
139
        public ClassificationPanel(View view) {
140
                this.view = view;
141
                m_MapContext = view.getModel().getMapContext();
142
                layers = m_MapContext.getLayers();
143
                this.setPreferredSize(new Dimension(width, height));
144
                this.setSize(width, height);
145
                this.setLayout(new BorderLayout(1, 1));
146
                this.addButtonPressedListener(this);
147
                Inicializar();
148
        }
149

    
150
        public ClassificationPanel getClasificatorPanel() {
151
                if (classificationPanel==null){
152
                        classificationPanel = new ClassificationPanel(view);
153
                        classificationPanel.addButtonPressedListener(this);
154
                }
155
                return classificationPanel;
156
        }
157
        
158
        
159
        private void Inicializar(){
160
                
161
                BorderLayout bd=new BorderLayout();
162
                this.setLayout(bd);
163
                TitledBorder topBorder = BorderFactory.createTitledBorder(" ");
164
                topBorder.setTitlePosition(TitledBorder.TOP);
165
                this.setBorder(new CompoundBorder(topBorder,new EmptyBorder(0,5,5,5)));
166
                JTabbedPane tabbedPane = new JTabbedPane();
167
                 tabbedPane.addTab(PluginServices.getText(this, "operacion"), getPanelTab1());
168
                tabbedPane.addTab(PluginServices.getText(this, "opciones"), getPanelTab2());
169
                this.setLayout(new BorderLayout());
170
                this.add(tabbedPane, BorderLayout.CENTER);
171
                getBandas();
172
        }
173

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

    
304
                
305
        /**
306
         * Especificar el nombre de la nueva capa para el recuadro de texto asign?ndo
307
         * en cada llamada un nombre consecutivo.
308
         */
309
        public void setNewLayerText() {
310
                getJTextNombreCapa().setText("NewLayer_" + RasterModule.layerCount);
311
                RasterModule.layerCount++;
312
        }
313
        
314
        
315

    
316
        public JRadioButton getRadioFile(){
317
                if (rButtonFile == null){
318
                        rButtonFile = new JRadioButton(PluginServices.getText(this,"a_fichero"));
319
                        rButtonFile.addActionListener(this);
320
                }
321
                return rButtonFile;
322
        }
323
        
324
        public JRadioButton getRadioMemory(){
325
                if (rButtonMemory == null){
326
                        rButtonMemory = new JRadioButton(PluginServices.getText(this,"a_memoria"),true);
327
                        rButtonMemory.addActionListener(this);
328
                }
329
                return rButtonMemory;
330
        }
331
        
332
        
333

    
334
         public JComboBox getComboCapas() {
335
                if (comboLayers==null){                
336
                        ComboBoxModel jComboBoxLayersModel = new 
337
                DefaultComboBoxModel(getLayerNames());
338
                        comboLayers = new JComboBox();
339
                        comboLayers.setModel(jComboBoxLayersModel);
340
                        comboLayers.setEnabled(true);
341
                        comboLayers.addActionListener(this);        
342
                        comboLayers.setSelectedIndex(0);
343
                }                                
344
                return comboLayers;
345
        }
346
         
347
        
348
        
349
        public void close(){        
350
                try {
351
                        getRoisTablePanel().clearRoiGraphics();
352
                        getRoisTablePanel().getMapControl().rePaintDirtyLayers();
353
                        
354
                        getRoisTablePanel().setPreviousTool();
355
                        PluginServices.getMDIManager().closeWindow(this);
356
                } catch (ArrayIndexOutOfBoundsException ex) {
357
                        // Si la ventana no se puede eliminar no hacemos nada
358
                }
359
        }
360

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

    
418
                                
419
        public void accept(){
420
                        
421
                // Imagen que va a ser clasificada
422
                IRasterDataSource rasterLayer= ((FLyrRasterSE)layers.getLayer((String) getComboCapas().getSelectedItem())).getDataSource();
423
                ClassificationGeneralProcess process=null;
424
                if(getComboMethods().getSelectedIndex()==0)
425
                        process = new ClassificationMaximumLikelihoodProcess(rasterLayer,getRoisTablePanel().getROIs(),view,getFileSelected());
426
                if(getComboMethods().getSelectedIndex()==1)
427
                        process =  new ClassificationMinimumDistanceProcess(rasterLayer,getRoisTablePanel().getROIs(),view,getFileSelected());
428
                
429
                IncrementableTask incrementableTask = new IncrementableTask(process);        
430
                process.setIncrementableTask(incrementableTask);
431
                incrementableTask.showWindow();
432
                process.start();
433
                incrementableTask.start();        
434
                        
435
        }                
436
                
437
        public void actionButtonPressed(ButtonsPanelEvent e) {
438
                        // Bot?n de Aceptar
439
                if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
440
                        accept();
441
                        close();
442
                }
443

    
444
                // Bot?n de Aplicar
445
                if (e.getButton() == ButtonsPanel.BUTTON_APPLY) {
446
                        accept();
447
                }
448

    
449
                // Bot?n de Cerrar
450
                if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
451
                        close();
452
                }                        
453
         }
454
                
455
        public void actionPerformed(ActionEvent arg0) {
456
                if(arg0.getSource()==getComboCapas()){
457
                        getBandas();                
458
                }
459
                                                
460
        }
461

    
462
                
463
        public void focusGained(FocusEvent arg0) {
464
        
465
        }
466

    
467
        public void focusLost(FocusEvent arg0) {
468
                                
469
        }
470

    
471

    
472
        private JTable getTableBands(){
473
                if (jTableBandas==null){        
474
                        jTableBandas=new JTable(getModeloTabla());
475
                }
476
                return jTableBandas;
477
        }
478
                 
479
                  
480
        public BandTableFormat getModeloTabla() {         
481
                if(mModeloTabla==null){
482
                        mModeloTabla=new BandTableFormat(); 
483
                } 
484
                return mModeloTabla;        
485
        }
486
                 
487
                
488
        public JScrollPane getScrollBands() {        
489
                if (scrollBandas==null){
490
                        scrollBandas=new JScrollPane();                                
491
                }        
492
                getTableBands().getColumn("").setPreferredWidth(30);
493
                scrollBandas.setPreferredSize(new Dimension(250,80));
494
                scrollBandas.setViewportView(getTableBands());
495
                scrollBandas.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
496
                return scrollBandas;        
497
        }
498

    
499
                
500
        public ROIsTablePanel getRoisTablePanel() {
501
                if (roisTablePanel==null){        
502
                        roisTablePanel= new ROIsTablePanel();
503
                }
504
                return roisTablePanel;
505
        }
506

    
507

    
508
        public JComboBox getComboMethods() {        
509
                if (comboMethods==null){
510
                        comboMethods= new JComboBox();
511
                        String[] sNames = new String[nMethods];
512
                        sNames[0]= new String(PluginServices.getText(this, "metodo_maxima_probabilidad"));
513
                        sNames[1]= new String(PluginServices.getText(this, "metodo_minima_diatancia"));
514
                        ComboBoxModel jComboBoxLayersModel = new  DefaultComboBoxModel(sNames);
515
                        comboMethods.setModel(jComboBoxLayersModel);
516
                        comboMethods.setEnabled(true);
517
                        comboMethods.addActionListener(this);                
518
                }                
519
                return comboMethods;
520
        }
521
                
522
        // Toma las Bandas de la imagen seleccionada en el combo Imagen
523
        public void getBandas(){
524
                
525
                // Antes de insertar se borra lo anterior
526
                getModeloTabla().LimpiarLista();
527
                         
528
                FLyrRasterSE rasterLayer= (FLyrRasterSE)layers.getLayer((String)getComboCapas().getSelectedItem());
529
                String bandas[]=new String[rasterLayer.getBandCount()];        
530
                bands= new int[rasterLayer.getBandCount()];
531
                if (layers.getLayer((String)getComboCapas().getSelectedItem()) instanceof  FLyrRasterSE ){                
532
                        for (int j=0; j<rasterLayer.getBandCount(); j++){
533
                                        String s=(PluginServices.getText(this,"banda"))+(j+1);
534
                                        bandas[j]=s;
535
                                        bands[j]=j;
536
                                }        
537
                        for (int i=0;i<bandas.length;i++)
538
                                getModeloTabla().addRow(bandas[i]); 
539
                        getTableBands().updateUI();
540
                        
541
                        // PROVISIONAL
542
                        getRoisTablePanel().setFLayer((FLyrRasterSE)layers.getLayer((String)getComboCapas().getSelectedItem()));
543
                }        
544
        }
545
                 
546
                 
547
        /**Panel que incluye el nombre de la capa y las opciones de almacenamieto del grid generado*/
548
        public JPanel getNombreCapa() {
549
                         
550
                        
551
                if (nombreCapa==null){ 
552
                        nombreCapa=new JPanel();
553
                        nombreCapa.setPreferredSize(new Dimension(400,130));
554
                        TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this, "salida"));
555
                        topBorder.setTitlePosition(TitledBorder.TOP);
556
                        nombreCapa.setBorder(topBorder);
557
                        GridBagConstraints gridBagConstraints;
558
                        JPanel radioPanel = new JPanel();
559
                        radioPanel.setLayout(new GridBagLayout());
560
                        radioPanel.setBorder(BorderFactory.createTitledBorder(""));
561
                        ButtonGroup buttonGroup = new ButtonGroup();
562
                        buttonGroup.add(getRadioMemory());
563
                        gridBagConstraints = new java.awt.GridBagConstraints();
564
                        gridBagConstraints.gridx = 0;
565
                        gridBagConstraints.gridy = 1;
566
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
567
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
568
                        radioPanel.add(getRadioMemory(),gridBagConstraints);
569
                        buttonGroup.add(getRadioFile());
570
                        gridBagConstraints = new java.awt.GridBagConstraints();
571
                        gridBagConstraints.gridx = 0;
572
                        gridBagConstraints.gridy = 2;
573
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
574
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
575
                        radioPanel.add(getRadioFile(),gridBagConstraints);
576
                        //Establece la separacion entre los elementos
577
                        nombreCapa.setLayout(new GridBagLayout());
578
                        gridBagConstraints = new java.awt.GridBagConstraints();
579
                        gridBagConstraints.gridx = 0;
580
                        gridBagConstraints.gridy = 0;
581
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
582
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
583
                        nombreCapa.add(new JLabel(("Nombre:"),SwingConstants.RIGHT ),gridBagConstraints);
584
                                
585
                        gridBagConstraints = new java.awt.GridBagConstraints();
586
                        gridBagConstraints.gridx = 1;
587
                        gridBagConstraints.gridy = 0;
588
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
589
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
590
                        nombreCapa.add(getJTextNombreCapa(),gridBagConstraints);
591
                        
592
                        gridBagConstraints = new java.awt.GridBagConstraints();
593
                        gridBagConstraints.gridx = 2;
594
                        gridBagConstraints.gridy = 0;
595
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
596
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
597
                        nombreCapa.add(radioPanel,gridBagConstraints);        
598
                }
599
                         
600
                return nombreCapa;
601
                        
602
        }
603
                 
604
}
605

    
606
/**
607
 * @author Nacho Brodin <brodin_ign@gva.es>
608
 * Filtro para el selector de formatos de escritura
609
 */
610
class WriterFilter extends javax.swing.filechooser.FileFilter {
611
        private String                                filter;
612

    
613
        public WriterFilter(String fil) {
614
                this.filter = fil;
615
        }
616

    
617
        public boolean accept(File f) {
618
                return f.isDirectory() || f.getName().toLowerCase().endsWith("." + filter);
619
        }
620

    
621
        public String getDescription() {
622
                return "." + filter;
623
        }
624
}
625

    
626

    
627

    
628

    
629

    
630

    
631

    
632

    
633

    
634

    
635

    
636