Statistics
| Revision:

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

History | View | Annotate | Download (22 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, ArrayList ranges){
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
                init();
163
                this.setRanges(ranges);
164
                FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
165
                BandSetupPanel bandSetup = (BandSetupPanel)fr.getPanelByClassName("BandSetupPanel");
166
                bandSetup.getFileList().getJButtonAdd().setEnabled(false);
167
                bandSetup.getFileList().getJButtonRemove().setEnabled(false);
168
                this.setTranslation();
169
                
170
        }
171
        
172
        /**
173
         * Asigna los textos a los paneles
174
         */
175
        private void setTranslation(){
176
                FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
177
                BandSetupPanel bandSetup = (BandSetupPanel)fr.getPanelByClassName("BandSetupPanel");
178
                bandSetup.getFileList().getJButtonAdd().setText(PluginServices.getText(this,"add"));
179
                bandSetup.getFileList().getJButtonRemove().setText(PluginServices.getText(this,"remove"));
180
                bandSetup.getFileList().lbandasVisibles.setText(PluginServices.getText(this,"bands"));
181
                
182
                RasterTransparencyPanel tpan = (RasterTransparencyPanel)fr.getPanelByClassName("RasterTransparencyPanel");
183
                                
184
                tpan.getTransparencyCheck().setText(PluginServices.getText(this,"transparencia"));
185
                tpan.getOpacityCheck().setText(PluginServices.getText(this,"opacidad"));
186
                        
187
                EnhancedPanel ep =  (EnhancedPanel)fr.getPanelByClassName("EnhancedPanel");
188
                ep.lLineal.setText(PluginServices.getText(this,"lineal_directo"));
189
                ep.lQueue.setText(PluginServices.getText(this,"recorte_colas"));
190
                ep.lWithoutEnhanced.setText(PluginServices.getText(this,"sin_realce"));
191
                ep.lCut.setText(PluginServices.getText(this,"recorte"));
192
                ep.lRemove.setText(PluginServices.getText(this,"eliminar_extremos"));
193
                
194
                //Recorremos los Tab y traducimos el nombre
195
                for(int i=0;i<this.getTab().getTabCount();i++){
196
                        if(this.getTab().getTitleAt(i).equals("Info"))
197
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"info"));
198
                        if(this.getTab().getTitleAt(i).equals("Transparencia"))
199
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"transparencia"));
200
                        if(this.getTab().getTitleAt(i).equals("Bands"))
201
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"bands"));
202
                        if(this.getTab().getTitleAt(i).equals("Realce"))
203
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"realce"));
204
                }
205
                
206
                this.getAcceptButton().setText(PluginServices.getText(this,"ok"));
207
                this.getApplyButton().setText(PluginServices.getText(this,"apply"));
208
                this.getCancelButton().setText(PluginServices.getText(this,"cancel"));
209
        }
210
        
211
        /**
212
         * Assigns a FLayerRaster
213
         * @param layer        capa a asignar
214
         */
215
        public void setFLyrWMS(FLyrWMS layer){
216
                fLayer = layer;
217
        }
218
        
219
        /**
220
         * Dialog window constructor.
221
         */
222
        public WMSRasterPropsDialog() {
223
                init();
224
        }
225
                        
226
        /**
227
         * Loads the info panel data.
228
         */
229
        private void loadInfoData(){
230
                Rectangle2D r = fLayer.getFullExtent();
231
                if(fLayer!=null){
232
                        props = new Object[nprops][2];
233
                        props[0][0] = new String(PluginServices.getText(this,"Fichero"));
234
                        props[0][1] = "http://"+fLayer.host.getHost()+fLayer.host.getFile();
235
                        props[1][0] = new String(PluginServices.getText(this,"num_bandas"));
236
                        props[1][1] = new String(String.valueOf( grf.getBandCount()));
237
                        props[2][0] = new String(PluginServices.getText(this,"ancho_alto"));
238
                        props[2][1] = (int)(fLayer.getWidth())+" X "+(int)(fLayer.getHeight());
239
                        props[3][0] = new String(PluginServices.getText(this,"format"));
240
                        props[3][1] = fLayer.m_Format;
241
                        props[4][0] = new String(PluginServices.getText(this,"tipo_dato"));
242
                        String type = null;
243
                        switch(grf.getDataType()){
244
                                case 0: type = new String("BYTE");break;
245
                                case 1: type = new String("USHORT");break;
246
                                case 2: type = new String("SHORT");break;
247
                                case 3: type = new String("INT");break;
248
                                case 4: type = new String("FLOAT");break;
249
                                case 5: type = new String("DOUBLE");break;
250
                                default: type = new String("UNDEFINED");break;
251
                        }
252
                    props[4][1] = type;
253
                        props[5][0] = new String(PluginServices.getText(this,"coor_geograficas"));
254
                        props[6][0] = new String(PluginServices.getText(this,"xmin"));
255
                        props[6][1] = String.valueOf(fLayer.getMinX());
256
                        props[7][0] = new String(PluginServices.getText(this,"ymin"));
257
                        props[7][1] = String.valueOf(fLayer.getMinY());
258
                        props[8][0] = new String(PluginServices.getText(this,"xmax"));
259
                        props[8][1] = String.valueOf(fLayer.getMaxX());
260
                        props[9][0] = new String(PluginServices.getText(this,"ymax"));
261
                        props[9][1] = String.valueOf(fLayer.getMaxY());
262
                        
263
                }else{
264
                        props = new Object[1][2];
265
                        props[0][0] = new String("No props");
266
                        props[0][1] = new String("-");
267
                }
268
                
269
        }
270
        
271
        /**
272
         * A?ade bandas al contador de bandas del FilterRasterDialogPanel
273
         * @param numBands N?mero de bandas a a?adir
274
         */
275
        public void addNumBands(int numBands){
276
                nbands += numBands;
277
                FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
278
                RasterTransparencyPanel rasterTrans = (RasterTransparencyPanel)fr.getPanelByClassName("RasterTransparencyPanel");
279
                if(rasterTrans != null && rasterTrans.getPTranspByPixel().isControlEnabled())
280
                        rasterTrans.setActiveTransparencyControl(true); 
281
        }
282
        
283
        /**
284
         * Inits the jDialog        
285
         */    
286
        public void init() {
287
                
288
                //this.setLayout(new FlowLayout());
289
                        
290
                setName("filterRaster");
291
                                           
292
                   this.loadInfoData();
293
                super.init(props);
294
                this.setTabVisible("Pansharpening", false);
295
                
296
                //this.add(getContentPane());
297
        
298
                this.setSize(486, 318);
299
                
300
                //contentPane.getAcceptButton().setEnabled(false);
301
                this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() {
302
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
303
                                acceptButtonActionPerformed(evt);
304
                                closeJDialog();
305
                        }
306
                });
307
                this.getCancelButton().addActionListener(new java.awt.event.ActionListener() {
308
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
309
                                cancelButtonActionPerformed(evt);
310
                                closeJDialog();
311
                        }
312
                });
313
                this.getApplyButton().addActionListener(new java.awt.event.ActionListener() {
314
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
315
                                acceptButtonActionPerformed(evt);
316
                        }
317
                });
318
                BandSetupPanel bandSetup = (BandSetupPanel)((FilterRasterDialogPanel)this.getContentPane()).getPanelByClassName("BandSetupPanel");
319
                bandSetup.getFileList().getJButtonAdd().addActionListener(new java.awt.event.ActionListener() {
320
                        public void actionPerformed(java.awt.event.ActionEvent evt){
321
                                addFileBand(evt);
322
                                
323
                        }
324
                });
325
                bandSetup.getFileList().getJButtonRemove().addActionListener(new java.awt.event.ActionListener() {
326
                        public void actionPerformed(java.awt.event.ActionEvent evt){
327
                                delFileBand(evt);
328
                        }
329
                });
330

    
331
        
332
        }
333
        
334
        /**
335
         * Saves the initial state to restore it if cancel.
336
         */
337
        public void readStat(){
338
                FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
339
                RasterTransparencyPanel rasterTrans = (RasterTransparencyPanel)fr.getPanelByClassName("RasterTransparencyPanel");
340
                status = new Status(rasterTrans.getOpacityText().getText(),
341
                                                        getAssignedBand(GeoRasterFile.RED_BAND),
342
                                                        getAssignedBand(GeoRasterFile.GREEN_BAND),
343
                                                        getAssignedBand(GeoRasterFile.BLUE_BAND)
344
                                                        );                                
345
        }
346
        
347
        /**
348
         * This method initializes jContentPane                
349
         */    
350
        public Container getContentPane() {
351
                return this;
352
        }
353
        
354
        /**
355
         * Sets a projection.
356
         * 
357
         * @param prj
358
         */
359
        public void setProjection(IProjection prj) {
360
                this.currentProjection = prj;
361
        }
362
        
363
        
364
        
365
        public void closeJDialog() {
366
                PluginServices.getMDIManager().closeView(WMSRasterPropsDialog.this);
367
        }
368
        
369
        /**
370
         * Sets the RasterFilterStackManager
371
         * @param stackManager
372
         */
373
        public void setRasterFilterStackManager(RasterFilterStackManager stackManager){
374
                this.stackManager = stackManager;
375
                stackManager.resetTempFilters();
376
        }
377
        
378
        /**
379
         * 
380
         * @param flag
381
         * @return
382
         */
383
        public int getAssignedBand(int flag) {
384
                BandSetupPanel bandSetup = (BandSetupPanel)((FilterRasterDialogPanel)this.getContentPane()).getPanelByClassName("BandSetupPanel");
385
                return bandSetup.getAssignedBand(flag);
386
        }
387
        
388
        /**
389
         * Pressing OK with the bands panel selected makes its values to be
390
         * processed.
391
         * 
392
         * @return true if the bands panel was selected and the action is processed, false it
393
         * was not selected.
394
         */
395
        public boolean processBandPanel(){
396
                fLayer.setBandR(getAssignedBand(GeoRasterFile.RED_BAND));
397
                fLayer.setBandG(getAssignedBand(GeoRasterFile.GREEN_BAND));
398
                fLayer.setBandB(getAssignedBand(GeoRasterFile.BLUE_BAND));
399
                rasterStatus.bandR = getAssignedBand(GeoRasterFile.RED_BAND);
400
                rasterStatus.bandG = getAssignedBand(GeoRasterFile.GREEN_BAND);
401
                rasterStatus.bandB = getAssignedBand(GeoRasterFile.BLUE_BAND);
402
                        
403
                //Comprobamos si hay alguna banda que no est? asignada y aplicamos el filtro
404
                StringBuffer sb = new StringBuffer();
405
                if(getAssignedBand(GeoRasterFile.RED_BAND) == -1)
406
                        sb.append("R");
407
                if(getAssignedBand(GeoRasterFile.GREEN_BAND) == -1)
408
                        sb.append("G");
409
                if(getAssignedBand(GeoRasterFile.BLUE_BAND) == -1)
410
                        sb.append("B");
411
                        
412
                if(!sb.toString().equals(""))
413
                        stackManager.addRemoveBands(sb.toString());
414
                else
415
                        stackManager.removeFilter(stackManager.getTypeFilter("removebands"));
416
                        
417
                fLayer.getFMap().invalidate();
418
                return true;
419
        }
420
        
421
        /**
422
         * Pressing OK with the transparency panel selected makes its values to be processed.
423
         * @return true if the transparency panel was selected and the action is processed, false it
424
         * was not selected.
425
         */
426
        public boolean processTransparencyPanel(){
427
                //OPACIDAD
428
                RasterTransparencyPanel tpan = (RasterTransparencyPanel)((FilterRasterDialogPanel)this.getContentPane()).getPanelByClassName("RasterTransparencyPanel");
429
                String sOpac = tpan.getOpacityText().getText();
430
                if(!sOpac.equals("") && tpan.getOpacityCheck().isSelected()){
431
                        int opac = Integer.parseInt(sOpac);
432
                        opac = (int)((opac*255)/100);
433
                        px.setTransparency(true);
434
                        //px.setTransparency(255-opac);
435
                        fLayer.setTransparency(255-opac);
436
                        rasterStatus.transparency = 255-opac;
437
                }else{
438
                        px.setTransparency(false);
439
                        fLayer.setTransparency(0);
440
                        rasterStatus.transparency = 0;
441
                }
442
                                
443
                //TRANSPARENCIA
444
                if(        tpan.getTransparencyCheck().isSelected()){
445
                        
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(WMSRasterPropsDialog.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
}