Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWMS / src / com / iver / cit / gvsig / gui / dialogs / WMSRasterPropsDialog.java @ 3746

History | View | Annotate | Download (21.5 KB)

1
/*
2
 * Creado el 7-marzo-2005
3
 */
4
package com.iver.cit.gvsig.gui.dialogs;
5

    
6
import java.awt.Container;
7
import java.awt.event.ActionEvent;
8
import java.awt.geom.Rectangle2D;
9
import java.io.File;
10
import java.util.ArrayList;
11
import java.util.Vector;
12

    
13
import javax.swing.JFileChooser;
14
import javax.swing.JOptionPane;
15
import javax.swing.JPanel;
16
import javax.swing.filechooser.FileFilter;
17

    
18
import org.cresques.cts.IProjection;
19
import org.cresques.io.GeoRasterFile;
20
import org.cresques.io.raster.RasterFilterStackManager;
21
import org.cresques.px.Extent;
22
import org.cresques.px.PxRaster;
23
import org.cresques.ui.raster.BandSetupPanel;
24
import org.cresques.ui.raster.EnhancedPanel;
25
import org.cresques.ui.raster.FilterRasterDialogPanel;
26
import org.cresques.ui.raster.RasterTransparencyPanel;
27

    
28
import com.hardcode.driverManager.Driver;
29
import com.hardcode.driverManager.DriverLoadException;
30
import com.iver.andami.PluginServices;
31
import com.iver.andami.messages.NotificationManager;
32
import com.iver.andami.ui.mdiManager.View;
33
import com.iver.andami.ui.mdiManager.ViewInfo;
34
import com.iver.cit.gvsig.fmap.DriverException;
35
import com.iver.cit.gvsig.fmap.drivers.RasterDriver;
36
import com.iver.cit.gvsig.fmap.layers.FLyrWMS;
37
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
38
import com.iver.cit.gvsig.fmap.layers.StatusLayerRaster;
39

    
40
/**
41
 * <P>
42
 * Dialog for the properties of a WMS layer. It manages the avants and aplies
43
 * filters to the raster through the filter stack manager according to the user's
44
 * selection. This dialog contains some panels.
45
 * </P>
46
 * <UL>
47
 * <LI>Propierties</LI>
48
 * <LI>Band selection</LI>
49
 * <LI>Transparency</LI>
50
 * <LI>Enhancement</LI>
51
 * </UL>
52
 * @author Nacho Brodin (brodin_ign@gva.es)
53
 */
54
public class WMSRasterPropsDialog extends FilterRasterDialogPanel implements View {
55
        
56
        private FilterRasterDialogPanel                                 contentPane = null;          
57
        private JPanel                                                                        propPanel = null;
58
        private IProjection                                                         currentProjection = null;
59
        private FLyrWMS                                                                         fLayer = null;
60
        private static final int                                                nprops = 11;
61
        private Object[][]                                                                props = null;
62
        private RasterFilterStackManager                                 stackManager = null;
63
        private Status                                                                        status = null;
64
        private StatusLayerRaster                                                rasterStatus = null;
65
        private JFileChooser                                                        fileChooser = null;
66
        private String                                                                        lastPath = new String("./");
67
        private        PxRaster                                                                px = null;
68
        private GeoRasterFile                                                        grf = null;
69
        
70
        /**
71
         * Class that holds the dialog state and restores the initial state if it
72
         * is cancelled.
73
         * @author Nacho Brodin <brodin_ign@gva.es>
74
         */
75
        class Status{
76
                public String                                        inicAlpha;
77
                public int                                                 bandR;
78
                public int                                                 bandG;
79
                public int                                                 bandB;
80
                private ArrayList                                filters = new ArrayList();
81
                
82
                public Status(String alpha, int bandR, int bandG, int bandB){
83
                        this.inicAlpha = alpha;
84
                        this.bandR = bandR;
85
                        this.bandG = bandG;
86
                        this.bandB = bandB;
87
                        filters = stackManager.getStringsFromStack();
88
                }
89
                                
90
                /**
91
                 * Restaura el Estado salvado 
92
                 * @param status Estado
93
                 */
94
                public void restoreStatus(WMSRasterPropsDialog props){
95
                        //Devolvemos la pila de filtros al estado inicial
96
                        /*if(stackManager != null)
97
                                stackManager.deleteTempFilters();*/
98
                        
99
                        //Devolvemos el alpha al estado inicial
100
                        int opac = Integer.parseInt(status.inicAlpha);
101
                        opac = (int)((opac*255)/100);
102
                        fLayer.setTransparency(255-opac);
103
                        
104
                        if (fLayer != null) {
105
                                fLayer.setBandR(bandR);
106
                                fLayer.setBandG(bandG);
107
                                fLayer.setBandB(bandB);
108
                        }
109
                        
110
                        //Restauramos los filtros
111
                        if(filters!=null)
112
                                stackManager.createStackFromStrings(filters);
113
                        
114
                        fLayer.getFMap().invalidate();
115
                        
116
                }
117
        }
118
        
119
        public class DriverFileFilter extends FileFilter{
120
                
121
                private Driver driver;
122
                
123
                public DriverFileFilter(String driverName) throws DriverLoadException{
124
                        driver = LayerFactory.getDM().getDriver(driverName);
125
                }
126

    
127
                /**
128
                 * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
129
                 */
130
                public boolean accept(File f) {
131
                        if (f.isDirectory()) return true;
132
                        if (driver instanceof RasterDriver){
133
                                return ((RasterDriver) driver).fileAccepted(f);
134
                        }else{
135
                                throw new RuntimeException("Tipo no reconocido");
136
                        }
137
                }
138

    
139
                /**
140
                 * @see javax.swing.filechooser.FileFilter#getDescription()
141
                 */
142
                public String getDescription() {
143
                        return ((Driver) driver).getName();
144
                }
145
        }
146
        
147
        /**
148
         * Dialog window constructor.
149
         * 
150
         * @param app
151
         */
152
        public WMSRasterPropsDialog(FLyrWMS layer, int[][] rangeR, int[][] rangeG, int[][] rangeB){
153
                super();
154
                fLayer = layer;
155
                this.px = layer.getPxRaster();
156
                this.grf = layer.getGeoRasterFile();
157
                if(fLayer.getStatus()==null){
158
                        rasterStatus = new StatusLayerRaster();
159
                        fLayer.setStatus(rasterStatus);
160
                }else
161
                        rasterStatus = (StatusLayerRaster)fLayer.getStatus();
162
                initialize();
163
                this.setRanges(rangeR, rangeG, rangeB);
164
                FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
165
                fr.getBandSetup().getFileList().getJButtonAdd().setEnabled(false);
166
                fr.getBandSetup().getFileList().getJButtonRemove().setEnabled(false);
167
                this.setTranslation();
168
                
169
        }
170
        
171
        /**
172
         * Asigna los textos a los paneles
173
         */
174
        private void setTranslation(){
175
                this.getBandSetup().getFileList().getJButtonAdd().setText(PluginServices.getText(this,"Anadir"));
176
                this.getBandSetup().getFileList().getJButtonRemove().setText(PluginServices.getText(this,"Eliminar"));
177
                this.getBandSetup().getFileList().lbandasVisibles.setText(PluginServices.getText(this,"bandas"));
178
                
179
                RasterTransparencyPanel tpan = this.getTransparencyPanel();
180
                
181
                tpan.lGreenValue.setText(PluginServices.getText(this,"Valor_verde"));
182
                tpan.lRedValue.setText(PluginServices.getText(this,"Valor_rojo"));
183
                tpan.lBlueValue.setText(PluginServices.getText(this,"Valor_azul"));
184
                tpan.getTransparencyCheck().setText(PluginServices.getText(this,"transparencia"));
185
                tpan.getOpacityCheck().setText(PluginServices.getText(this,"opacidad"));
186
                tpan.lRange.setText(PluginServices.getText(this,"usar_rango"));
187
                tpan.lPixelValue.setText(PluginServices.getText(this,"valor_pixel")+": 0 a 255");
188
                
189
                EnhancedPanel ep = this.getEnhancedPanel();
190
                ep.lLineal.setText(PluginServices.getText(this,"lineal_directo"));
191
                ep.lQueue.setText(PluginServices.getText(this,"recorte_colas"));
192
                ep.lWithoutEnhanced.setText(PluginServices.getText(this,"sin_realce"));
193
                ep.lCut.setText(PluginServices.getText(this,"recorte"));
194
                ep.lRemove.setText(PluginServices.getText(this,"eliminar_extremos"));
195
                
196
                //Recorremos los Tab y traducimos el nombre
197
                for(int i=0;i<this.getTab().getTabCount();i++){
198
                        if(this.getTab().getTitleAt(i).equals("Info"))
199
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"info"));
200
                        if(this.getTab().getTitleAt(i).equals("Transparencia"))
201
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"Transparencia"));
202
                        if(this.getTab().getTitleAt(i).equals("Bandas"))
203
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"bandas"));
204
                        if(this.getTab().getTitleAt(i).equals("Realce"))
205
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"realce"));
206
                }
207
                
208
                this.getAcceptButton().setText(PluginServices.getText(this,"Aceptar"));
209
                this.getApplyButton().setText(PluginServices.getText(this,"Aplicar"));
210
                this.getCancelButton().setText(PluginServices.getText(this,"Cancelar"));
211
        }
212
        
213
        /**
214
         * Assigns a FLayerRaster
215
         * @param layer        capa a asignar
216
         */
217
        public void setFLyrWMS(FLyrWMS layer){
218
                fLayer = layer;
219
        }
220
        
221
        /**
222
         * Dialog window constructor.
223
         */
224
        public WMSRasterPropsDialog() {
225
                initialize();
226
        }
227
                        
228
        /**
229
         * Loads the info panel data.
230
         */
231
        private void loadInfoData(){
232
                Rectangle2D r = fLayer.getFullExtent();
233
                if(fLayer!=null){
234
                        props = new Object[nprops][2];
235
                        props[0][0] = new String(PluginServices.getText(this,"Fichero_"));
236
                        props[0][1] = "http://"+fLayer.host.getHost()+fLayer.host.getFile();
237
                        props[1][0] = new String(PluginServices.getText(this,"num_bandas"));
238
                        props[1][1] = new String(String.valueOf( grf.getBandCount()));
239
                        props[2][0] = new String(PluginServices.getText(this,"ancho_alto"));
240
                        props[2][1] = (int)(fLayer.getWidth())+" X "+(int)(fLayer.getHeight());
241
                        props[3][0] = new String(PluginServices.getText(this,"formato"));
242
                        props[3][1] = fLayer.m_Format;
243
                        props[4][0] = new String(PluginServices.getText(this,"tipo_dato"));
244
                        String type = null;
245
                        switch(grf.getDataType()){
246
                                case 0: type = new String("BYTE");break;
247
                                case 1: type = new String("USHORT");break;
248
                                case 2: type = new String("SHORT");break;
249
                                case 3: type = new String("INT");break;
250
                                case 4: type = new String("FLOAT");break;
251
                                case 5: type = new String("DOUBLE");break;
252
                                default: type = new String("UNDEFINED");break;
253
                        }
254
                    props[4][1] = type;
255
                        props[5][0] = new String(PluginServices.getText(this,"coor_geograficas"));
256
                        props[6][0] = new String(PluginServices.getText(this,"xmin"));
257
                        props[6][1] = String.valueOf(px.getExtent().minX());
258
                        props[7][0] = new String(PluginServices.getText(this,"ymin"));
259
                        props[7][1] = String.valueOf(px.getExtent().minY());
260
                        props[8][0] = new String(PluginServices.getText(this,"xmax"));
261
                        props[8][1] = String.valueOf(px.getExtent().maxX());
262
                        props[9][0] = new String(PluginServices.getText(this,"ymax"));
263
                        props[9][1] = String.valueOf(px.getExtent().maxY());
264
                        
265
                }else{
266
                        props = new Object[1][2];
267
                        props[0][0] = new String("No props");
268
                        props[0][1] = new String("-");
269
                }
270
                
271
        }
272
        
273
        /**
274
         * A?ade bandas al contador de bandas del FilterRasterDialogPanel
275
         * @param numBands N?mero de bandas a a?adir
276
         */
277
        public void addNumBands(int numBands){
278
                nbands += numBands;
279
                if(this.getTransparencyPanel() != null && this.getTransparencyPanel().getTRojo().isEnabled())
280
                        this.getTransparencyPanel().setActiveTransparencyControl(true); 
281
        }
282
        
283
        /**
284
         * Inits the jDialog        
285
         */    
286
        private void initialize() {
287
                
288
                //this.setLayout(new FlowLayout());
289
                        
290
                setName("filterRaster");
291
                                           
292
                   this.loadInfoData();
293
                super.init(props);
294
                //this.add(getContentPane());
295
        
296
                this.setSize(486, 318);
297
                
298
                //contentPane.getAcceptButton().setEnabled(false);
299
                this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() {
300
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
301
                                acceptButtonActionPerformed(evt);
302
                                closeJDialog();
303
                        }
304
                });
305
                this.getCancelButton().addActionListener(new java.awt.event.ActionListener() {
306
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
307
                                cancelButtonActionPerformed(evt);
308
                                closeJDialog();
309
                        }
310
                });
311
                this.getApplyButton().addActionListener(new java.awt.event.ActionListener() {
312
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
313
                                acceptButtonActionPerformed(evt);
314
                        }
315
                });
316
                this.getBandSetup().getFileList().getJButtonAdd().addActionListener(new java.awt.event.ActionListener() {
317
                        public void actionPerformed(java.awt.event.ActionEvent evt){
318
                                addFileBand(evt);
319
                                
320
                        }
321
                });
322
                this.getBandSetup().getFileList().getJButtonRemove().addActionListener(new java.awt.event.ActionListener() {
323
                        public void actionPerformed(java.awt.event.ActionEvent evt){
324
                                delFileBand(evt);
325
                        }
326
                });
327

    
328
        
329
        }
330
        
331
        /**
332
         * Saves the initial state to restore it if cancel.
333
         */
334
        public void readStat(){
335
                status = new Status(((FilterRasterDialogPanel)this).getTransparencyPanel().getOpacityText().getText(),
336
                                                        getAssignedBand(GeoRasterFile.RED_BAND),
337
                                                        getAssignedBand(GeoRasterFile.GREEN_BAND),
338
                                                        getAssignedBand(GeoRasterFile.BLUE_BAND)
339
                                                        );                                
340
        }
341
        
342
        /**
343
         * This method initializes jContentPane                
344
         */    
345
        public Container getContentPane() {
346
                return this;
347
        }
348
        
349
        /**
350
         * Sets a projection.
351
         * 
352
         * @param prj
353
         */
354
        public void setProjection(IProjection prj) {
355
                this.currentProjection = prj;
356
        }
357
        
358
        
359
        
360
        public void closeJDialog() {
361
                PluginServices.getMDIManager().closeView(WMSRasterPropsDialog.this);
362
        }
363
        
364
        /**
365
         * Sets the RasterFilterStackManager
366
         * @param stackManager
367
         */
368
        public void setRasterFilterStackManager(RasterFilterStackManager stackManager){
369
                this.stackManager = stackManager;
370
                stackManager.resetTempFilters();
371
        }
372
        
373
        /**
374
         * 
375
         * @param flag
376
         * @return
377
         */
378
        public int getAssignedBand(int flag) {
379
                return this.getBandSetup().getAssignedBand(flag);
380
        }
381
        
382
        /**
383
         * Pressing OK with the bands panel selected makes its values to be
384
         * processed.
385
         * 
386
         * @return true if the bands panel was selected and the action is processed, false it
387
         * was not selected.
388
         */
389
        public boolean processBandPanel(){
390
                fLayer.setBandR(getAssignedBand(GeoRasterFile.RED_BAND));
391
                fLayer.setBandG(getAssignedBand(GeoRasterFile.GREEN_BAND));
392
                fLayer.setBandB(getAssignedBand(GeoRasterFile.BLUE_BAND));
393
                rasterStatus.bandR = getAssignedBand(GeoRasterFile.RED_BAND);
394
                rasterStatus.bandG = getAssignedBand(GeoRasterFile.GREEN_BAND);
395
                rasterStatus.bandB = getAssignedBand(GeoRasterFile.BLUE_BAND);
396
                        
397
                //Comprobamos si hay alguna banda que no est? asignada y aplicamos el filtro
398
                StringBuffer sb = new StringBuffer();
399
                if(getAssignedBand(GeoRasterFile.RED_BAND) == -1)
400
                        sb.append("R");
401
                if(getAssignedBand(GeoRasterFile.GREEN_BAND) == -1)
402
                        sb.append("G");
403
                if(getAssignedBand(GeoRasterFile.BLUE_BAND) == -1)
404
                        sb.append("B");
405
                        
406
                if(!sb.toString().equals(""))
407
                        stackManager.addRemoveBands(sb.toString());
408
                else
409
                        stackManager.removeFilter(stackManager.getTypeFilter("removebands"));
410
                        
411
                fLayer.getFMap().invalidate();
412
                return true;
413
        }
414
        
415
        /**
416
         * Pressing OK with the transparency panel selected makes its values to be processed.
417
         * @return true if the transparency panel was selected and the action is processed, false it
418
         * was not selected.
419
         */
420
        public boolean processTransparencyPanel(){
421
                //OPACIDAD
422
                String sOpac = this.getTransparencyPanel().getOpacityText().getText();
423
                if(!sOpac.equals("") && this.getTransparencyPanel().getOpacityCheck().isSelected()){
424
                        int opac = Integer.parseInt(sOpac);
425
                        opac = (int)((opac*255)/100);
426
                        px.setTransparency(true);
427
                        //px.setTransparency(255-opac);
428
                        fLayer.setTransparency(255-opac);
429
                        rasterStatus.transparency = 255-opac;
430
                }else{
431
                        px.setTransparency(false);
432
                        fLayer.setTransparency(0);
433
                        rasterStatus.transparency = 0;
434
                }
435
                                
436
                //TRANSPARENCIA
437
                if(        this.getTransparencyPanel().getTransparencyCheck().isSelected()){
438
                        this.checkTransparencyValues();
439
                        stackManager.addTransparencyFilter(        this.getRangeRed(),
440
                                                                                                        this.getRangeGreen(),
441
                                                                                                        this.getRangeBlue(),
442
                                                                                                        0x10,        //Transparencia
443
                                                                                                        0xff,        //Color Transparencia R
444
                                                                                                        0xff,        //Color Transparencia G
445
                                                                                                        0xff);        //Color Transparencia B
446
                }else
447
                        px.filterStack.removeFilter(stackManager.getTypeFilter("transparency"));
448
                        
449
                fLayer.getFMap().invalidate();
450
                return true;        
451
        }
452
        
453
        /**
454
         * Pressing OK with the enhancement panel selected makes its values to be processed.
455
         * @return true if the enhancement panel was selected and the action is processed, false it
456
         * was not selected.
457
         */
458
        public boolean processEnhancedPanel(){
459
                //Filtro lineal seleccionado
460
                if(        this.getEnhancedPanel().getLinealDirectoRadioButton().isSelected()){
461
                        if(        this.getEnhancedPanel().getRemoveCheck().isSelected() &&
462
                                !this.getEnhancedPanel().getTailCheck().isSelected())
463
                                stackManager.addEnhancedFilter(true);
464
                        else
465
                                stackManager.addEnhancedFilter(false);
466
                                                        
467
                        //Recorte de colas seleccionado
468
                        if(this.getEnhancedPanel().getTailCheck().isSelected()){
469
                                stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
470
                                double recorte = Double.parseDouble(this.getEnhancedPanel().getTailText().getText())/100;
471
                                if(this.getEnhancedPanel().getRemoveCheck().isSelected())
472
                                        stackManager.addTailFilter( recorte, 0D, true);
473
                                else
474
                                        stackManager.addTailFilter( recorte, 0D, false);                                                                
475
                        }else{
476
                                stackManager.removeFilter(stackManager.getTypeFilter("tail"));
477
                                stackManager.addComputeMinMaxFilter();
478
                        }        
479
                }
480
                        
481
                //Sin filtro lineal seleccionado
482
                if(this.getEnhancedPanel().getSinRealceRadioButton().isSelected()){
483
                        stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
484
                        stackManager.removeFilter(stackManager.getTypeFilter("tail"));
485
                        stackManager.removeFilter(stackManager.getTypeFilter("enhanced"));
486
                }
487
                fLayer.getFMap().invalidate();
488
                        
489
                return true;
490
        }
491
        
492
        /**
493
         * Manages the action perfomed when Apply/OK is pressed or Apply at the raster
494
         * properties control.
495
         * @param e
496
         */
497
        private void acceptButtonActionPerformed(ActionEvent e) {
498
                this.processBandPanel();
499
                this.processTransparencyPanel();        
500
                this.processEnhancedPanel();        
501
        }
502
        
503
        /**
504
         * Adds a band to the raster.
505
         * @param e
506
         */
507
        private void addFileBand(ActionEvent e){
508
                String[] driverNames = null;
509
                String rasterDriver = null;
510
                                
511
                //Creaci?n del dialogo para selecci?n de ficheros
512
                
513
                fileChooser = new JFileChooser(lastPath);
514
                fileChooser.setMultiSelectionEnabled(true);
515
                fileChooser.setAcceptAllFileFilterUsed(false);
516
        try {
517
                        driverNames = LayerFactory.getDM().getDriverNames();
518
                        FileFilter defaultFileFilter = null, auxF;
519
                        for (int i = 0; i < driverNames.length; i++) {
520
                                
521
                                if (driverNames[i].endsWith("gvSIG Image Driver")){
522
                                        rasterDriver = driverNames[i];
523
                                    auxF = new DriverFileFilter(driverNames[i]);
524
                                        fileChooser.addChoosableFileFilter(auxF);
525
                                        defaultFileFilter = auxF;
526
                                }
527
                        }
528
                } catch (DriverLoadException e1) {
529
                        NotificationManager.addError("No se pudo acceder a los drivers", e1);
530
                }
531
                int result = fileChooser.showOpenDialog(WMSRasterPropsDialog.this);
532
                
533
                if(result == JFileChooser.APPROVE_OPTION){
534
                        File[] files = fileChooser.getSelectedFiles();
535
                         FileFilter filter = fileChooser.getFileFilter();
536
                         BandSetupPanel bandSetup = ((FilterRasterDialogPanel)this.getContentPane()).getBandSetup();
537
                         lastPath = files[0].getPath();
538
                         
539
                         //Lo a?adimos a la capa si no esta
540
                         
541
                         Vector v = new Vector();
542
            for(int i=0;i<files.length;i++){
543
                    boolean exist = false;
544
                    for(int j=0;j<px.getFiles().length;j++){
545
                            if(px.getFiles()[j].getName().endsWith(files[i].getName()))
546
                                    exist = true;
547
                    }
548
                    if(!exist){
549
                            try{
550
                                    Rectangle2D extentOrigin = fLayer.getFullExtent();
551
                                    
552
                                    Extent extentNewFile = GeoRasterFile.openFile(fLayer.getProjection(), files[i].getAbsolutePath()).getExtent();
553
                                    
554
                                                //Comprobamos que el extent y tama?o del fichero a?adido sea igual al 
555
                                                //fichero original. Si no es as? no abrimos la capa y mostramos un aviso
556
                                                
557
                                    double widthNewFile = (extentNewFile.getMax().getX()-extentNewFile.getMin().getX());
558
                                    double heightNewFile = (extentNewFile.getMax().getY()-extentNewFile.getMin().getY());
559
                                                                                                                                            
560
                                    if( (widthNewFile-extentOrigin.getWidth()) > 1.0 ||
561
                                            (widthNewFile-extentOrigin.getWidth()) < -1.0 ||
562
                                            (heightNewFile-extentOrigin.getHeight()) > 1.0 ||
563
                                            (heightNewFile-extentOrigin.getHeight()) < -1.0){       
564
                                            JOptionPane.showMessageDialog(        null,
565
                                                                                                            PluginServices.getText(this, "extents_no_coincidentes"), 
566
                                                                                                                        "",
567
                                                                                                                        JOptionPane.ERROR_MESSAGE);
568
                                            return;
569
                                    }
570
                                                                            
571
                                    if(        (extentNewFile.getMax().getX()-extentNewFile.getMin().getX())!=extentOrigin.getWidth() ||
572
                                                                (extentNewFile.getMax().getY()-extentNewFile.getMin().getY())!=extentOrigin.getHeight()        ){
573
                                            JOptionPane.showMessageDialog(null, 
574
                                                                        PluginServices.getText(this, "extents_no_coincidentes"), "", JOptionPane.ERROR_MESSAGE);
575
                                                        return;
576
                                    }
577
                                                                                                                
578
                            }catch(Exception exc){
579
                                    exc.printStackTrace();
580
                            }
581
                            
582
                            //Lo a?adimos a la capa
583
                            px.addFile(files[i].getAbsolutePath());
584

    
585
                    }else{
586
                            JOptionPane.showMessageDialog(null, 
587
                                                        PluginServices.getText(this, "fichero_existe")+" "+files[i].getAbsolutePath(), "", JOptionPane.ERROR_MESSAGE);
588
                    }
589
            }
590
                                     
591
            //A?adimos los georasterfile a la tabla del Panel
592
            
593
            v = new Vector();
594
            for(int i=0;i<px.getFiles().length;i++){
595
                    boolean exist = false;
596
                    for(int j=0;j<bandSetup.getNBands();j++){
597
                            if(px.getFiles()[i].getName().endsWith(bandSetup.getBandName(j)))
598
                                    exist = true;
599
                    }
600
                    if(!exist)
601
                            v.add(px.getFiles()[i]);
602
            }
603
            
604
            GeoRasterFile[] grf = new GeoRasterFile[v.size()];
605
            for(int i=0;i<grf.length;i++){
606
                    grf[i] = (GeoRasterFile)v.get(i);
607
            }
608
            bandSetup.addFiles(grf);
609
                }
610
        }
611
        
612
        /**
613
         * Deletes a band from the raster. If there is only a file or no band is
614
         * selected then it does nothing.
615
         * 
616
         * @param e
617
         */
618
        private void delFileBand(ActionEvent e){
619
                BandSetupPanel bandSetup = ((FilterRasterDialogPanel)this.getContentPane()).getBandSetup();
620
        
621
                if(        bandSetup.getFileList().getJList().getSelectedValue()!=null &&
622
                        bandSetup.getFileList().getNFiles() > 1){
623
                        String pathName = bandSetup.getFileList().getJList().getSelectedValue().toString();
624
                        px.delFile(pathName);
625
                        String file = pathName.substring(pathName.lastIndexOf("/")+1);
626
                        file = file.substring(file.lastIndexOf("\\")+1);
627
                        bandSetup.removeFile(file);
628
                        
629
                }                
630
        }
631
        
632
        /**
633
         * The cancel button restores the previous state to the loading of this dialog
634
         * @param e        Evento
635
         */
636
        private void cancelButtonActionPerformed(ActionEvent e) {
637
                this.status.restoreStatus(this);
638
                fLayer.getFMap().invalidate();
639
        }
640
        
641
        /**
642
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
643
         */
644
        public ViewInfo getViewInfo() {
645
                ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
646
                    m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_raster"));
647
                return m_viewinfo;
648
        }
649
        
650
        
651
}