Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWCS / src / com / iver / cit / gvsig / gui / dialog / WCSRasterPropsDialog.java @ 4578

History | View | Annotate | Download (22.1 KB)

1
/*
2
 * Creado el 7-marzo-2005
3
 */
4
package com.iver.cit.gvsig.gui.dialog;
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.drivers.RasterDriver;
35
import com.iver.cit.gvsig.fmap.layers.FLyrWCS;
36
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
37
import com.iver.cit.gvsig.fmap.layers.StatusLayerRaster;
38

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

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

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

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

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