Statistics
| Revision:

svn-gvsig-desktop / tags / Root_v06 / extensions / extWCS / src / com / iver / cit / gvsig / gui / panels / PropertiesWCSDialog.java @ 4811

History | View | Annotate | Download (21.8 KB)

1
/*
2
 * Creado el 7-marzo-2005
3
 */
4
package com.iver.cit.gvsig.gui.panels;
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 PropertiesWCSDialog 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(PropertiesWCSDialog 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.getWCSAdaptor().setTransparency(255-opac);
102
                        
103
                        if (fLayer != null) {
104
                                fLayer.getWCSAdaptor().setBandR(bandR);
105
                                fLayer.getWCSAdaptor().setBandG(bandG);
106
                                fLayer.getWCSAdaptor().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 PropertiesWCSDialog(FLyrWCS layer, int[][] rangeR, int[][] rangeG, int[][] rangeB){
152
                super();
153
                fLayer = layer;
154
                this.px = layer.getWCSAdaptor().getPxRaster();
155
                this.grf = layer.getWCSAdaptor().getGeoRasterFile();
156
                if(fLayer.getStatus()==null){
157
                        rasterStatus = new StatusLayerRaster();
158
                        fLayer.setStatus(rasterStatus);
159
                }else
160
                        rasterStatus = (StatusLayerRaster)fLayer.getStatus();
161
                initialize();
162
                this.setRanges(rangeR, rangeG, rangeB);
163
                FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane());
164
                fr.getBandSetup().getFileList().getJButtonAdd().setEnabled(false);
165
                fr.getBandSetup().getFileList().getJButtonRemove().setEnabled(false);
166
                this.setTranslation();
167
                
168
        }
169
        
170
        /**
171
         * Asigna los textos a los paneles
172
         */
173
        private void setTranslation(){
174
                this.getBandSetup().getFileList().getJButtonAdd().setText(PluginServices.getText(this,"Anadir"));
175
                this.getBandSetup().getFileList().getJButtonRemove().setText(PluginServices.getText(this,"Eliminar"));
176
                this.getBandSetup().getFileList().lbandasVisibles.setText(PluginServices.getText(this,"bandas"));
177
                
178
                RasterTransparencyPanel tpan = this.getTransparencyPanel();
179
                
180
                tpan.lGreenValue.setText(PluginServices.getText(this,"Valor_verde"));
181
                tpan.lRedValue.setText(PluginServices.getText(this,"Valor_rojo"));
182
                tpan.lBlueValue.setText(PluginServices.getText(this,"Valor_azul"));
183
                tpan.getTransparencyCheck().setText(PluginServices.getText(this,"transparencia"));
184
                tpan.getOpacityCheck().setText(PluginServices.getText(this,"opacidad"));
185
                tpan.lRange.setText(PluginServices.getText(this,"usar_rango"));
186
                tpan.lPixelValue.setText(PluginServices.getText(this,"valor_pixel")+": 0 a 255");
187
                
188
                EnhancedPanel ep = this.getEnhancedPanel();
189
                ep.lLineal.setText(PluginServices.getText(this,"lineal_directo"));
190
                ep.lQueue.setText(PluginServices.getText(this,"recorte_colas"));
191
                ep.lWithoutEnhanced.setText(PluginServices.getText(this,"sin_realce"));
192
                ep.lCut.setText(PluginServices.getText(this,"recorte"));
193
                ep.lRemove.setText(PluginServices.getText(this,"eliminar_extremos"));
194
                
195
                //Recorremos los Tab y traducimos el nombre
196
                for(int i=0;i<this.getTab().getTabCount();i++){
197
                        if(this.getTab().getTitleAt(i).equals("Info"))
198
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"info"));
199
                        if(this.getTab().getTitleAt(i).equals("Transparencia"))
200
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"Transparencia"));
201
                        if(this.getTab().getTitleAt(i).equals("Bandas"))
202
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"bandas"));
203
                        if(this.getTab().getTitleAt(i).equals("Realce"))
204
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"realce"));
205
                }
206
                
207
                this.getAcceptButton().setText(PluginServices.getText(this,"Aceptar"));
208
                this.getApplyButton().setText(PluginServices.getText(this,"Aplicar"));
209
                this.getCancelButton().setText(PluginServices.getText(this,"Cancelar"));
210
        }
211
        
212
        /**
213
         * Assigns a FLayerRaster
214
         * @param layer        capa a asignar
215
         */
216
        public void setFLyrWCS(FLyrWCS layer){
217
                fLayer = layer;
218
        }
219
        
220
        /**
221
         * Dialog window constructor.
222
         */
223
        public PropertiesWCSDialog() {
224
                initialize();
225
        }
226
                        
227
        /**
228
         * Loads the info panel data.
229
         */
230
        private void loadInfoData(){
231
                Rectangle2D r = fLayer.getFullExtent();
232
                if(fLayer.getWCSAdaptor()!=null){
233
                        props = new Object[nprops][2];
234
                        props[0][0] = new String(PluginServices.getText(this,"Fichero"));
235
                        props[0][1] = fLayer.getHost();
236
                        props[1][0] = new String(PluginServices.getText(this,"num_bandas"));
237
                        props[1][1] = new String(String.valueOf( grf.getBandCount()));
238
                        props[2][0] = new String(PluginServices.getText(this,"ancho_alto"));
239
                        props[2][1] = (int)(r.getWidth()/fLayer.getMaxResolution().getX())+" X "+(int)(r.getHeight()/fLayer.getMaxResolution().getY());
240
                        props[3][0] = new String(PluginServices.getText(this,"formato"));
241
                        props[3][1] = grf.getName().substring(
242
                                        grf.getName().lastIndexOf('.')+1, 
243
                                        grf.getName().length());
244
                        props[4][0] = new String(PluginServices.getText(this,"tipo_dato"));
245
                        String type = null;
246
                        switch(grf.getDataType()){
247
                                case 0: type = new String("BYTE");break;
248
                                case 1: type = new String("USHORT");break;
249
                                case 2: type = new String("SHORT");break;
250
                                case 3: type = new String("INT");break;
251
                                case 4: type = new String("FLOAT");break;
252
                                case 5: type = new String("DOUBLE");break;
253
                                default: type = new String("UNDEFINED");break;
254
                        }
255
                    props[4][1] = type;
256
                        props[5][0] = new String(PluginServices.getText(this,"coor_geograficas"));
257
                        props[6][0] = new String(PluginServices.getText(this,"xmin"));
258
                        props[6][1] = String.valueOf(px.getExtent().minX());
259
                        props[7][0] = new String(PluginServices.getText(this,"ymin"));
260
                        props[7][1] = String.valueOf(px.getExtent().minY());
261
                        props[8][0] = new String(PluginServices.getText(this,"xmax"));
262
                        props[8][1] = String.valueOf(px.getExtent().maxX());
263
                        props[9][0] = new String(PluginServices.getText(this,"ymax"));
264
                        props[9][1] = String.valueOf(px.getExtent().maxY());
265
                        
266
                }else{
267
                        props = new Object[1][2];
268
                        props[0][0] = new String("No props");
269
                        props[0][1] = new String("-");
270
                }
271
                
272
        }
273
        
274
        /**
275
         * A?ade bandas al contador de bandas del FilterRasterDialogPanel
276
         * @param numBands N?mero de bandas a a?adir
277
         */
278
        public void addNumBands(int numBands){
279
                nbands += numBands;
280
                if(this.getTransparencyPanel() != null && this.getTransparencyPanel().getTRojo().isEnabled())
281
                        this.getTransparencyPanel().setActiveTransparencyControl(true); 
282
        }
283
        
284
        /**
285
         * Inits the jDialog        
286
         */    
287
        private void initialize() {
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
                this.getBandSetup().getFileList().getJButtonAdd().addActionListener(new java.awt.event.ActionListener() {
320
                        public void actionPerformed(java.awt.event.ActionEvent evt){
321
                                addFileBand(evt);
322
                                
323
                        }
324
                });
325
                this.getBandSetup().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
                status = new Status(((FilterRasterDialogPanel)this).getTransparencyPanel().getOpacityText().getText(),
339
                                                        getAssignedBand(GeoRasterFile.RED_BAND),
340
                                                        getAssignedBand(GeoRasterFile.GREEN_BAND),
341
                                                        getAssignedBand(GeoRasterFile.BLUE_BAND)
342
                                                        );                                
343
        }
344
        
345
        /**
346
         * This method initializes jContentPane                
347
         */    
348
        public Container getContentPane() {
349
                return this;
350
        }
351
        
352
        /**
353
         * Sets a projection.
354
         * 
355
         * @param prj
356
         */
357
        public void setProjection(IProjection prj) {
358
                this.currentProjection = prj;
359
        }
360
        
361
        
362
        
363
        public void closeJDialog() {
364
                PluginServices.getMDIManager().closeView(PropertiesWCSDialog.this);
365
        }
366
        
367
        /**
368
         * Sets the RasterFilterStackManager
369
         * @param stackManager
370
         */
371
        public void setRasterFilterStackManager(RasterFilterStackManager stackManager){
372
                this.stackManager = stackManager;
373
                stackManager.resetTempFilters();
374
        }
375
        
376
        /**
377
         * 
378
         * @param flag
379
         * @return
380
         */
381
        public int getAssignedBand(int flag) {
382
                return this.getBandSetup().getAssignedBand(flag);
383
        }
384
        
385
        /**
386
         * Pressing OK with the bands panel selected makes its values to be
387
         * processed.
388
         * 
389
         * @return true if the bands panel was selected and the action is processed, false it
390
         * was not selected.
391
         */
392
        public boolean processBandPanel(){
393
                fLayer.getWCSAdaptor().setBandR(getAssignedBand(GeoRasterFile.RED_BAND));
394
                fLayer.getWCSAdaptor().setBandG(getAssignedBand(GeoRasterFile.GREEN_BAND));
395
                fLayer.getWCSAdaptor().setBandB(getAssignedBand(GeoRasterFile.BLUE_BAND));
396
                rasterStatus.bandR = getAssignedBand(GeoRasterFile.RED_BAND);
397
                rasterStatus.bandG = getAssignedBand(GeoRasterFile.GREEN_BAND);
398
                rasterStatus.bandB = getAssignedBand(GeoRasterFile.BLUE_BAND);
399
                        
400
                //Comprobamos si hay alguna banda que no est? asignada y aplicamos el filtro
401
                StringBuffer sb = new StringBuffer();
402
                if(getAssignedBand(GeoRasterFile.RED_BAND) == -1)
403
                        sb.append("R");
404
                if(getAssignedBand(GeoRasterFile.GREEN_BAND) == -1)
405
                        sb.append("G");
406
                if(getAssignedBand(GeoRasterFile.BLUE_BAND) == -1)
407
                        sb.append("B");
408
                        
409
                if(!sb.toString().equals(""))
410
                        stackManager.addRemoveBands(sb.toString());
411
                else
412
                        stackManager.removeFilter(stackManager.getTypeFilter("removebands"));
413
                        
414
                fLayer.getFMap().invalidate();
415
                return true;
416
        }
417
        
418
        /**
419
         * Pressing OK with the transparency panel selected makes its values to be processed.
420
         * @return true if the transparency panel was selected and the action is processed, false it
421
         * was not selected.
422
         */
423
        public boolean processTransparencyPanel(){
424
                //OPACIDAD
425
                String sOpac = this.getTransparencyPanel().getOpacityText().getText();
426
                if(!sOpac.equals("") && this.getTransparencyPanel().getOpacityCheck().isSelected()){
427
                        int opac = Integer.parseInt(sOpac);
428
                        opac = (int)((opac*255)/100);
429
                        px.setTransparency(true);
430
                        //px.setTransparency(255-opac);
431
                        fLayer.getWCSAdaptor().setTransparency(255-opac);
432
                        rasterStatus.transparency = 255-opac;
433
                }else{
434
                        px.setTransparency(false);
435
                        fLayer.getWCSAdaptor().setTransparency(0);
436
                        rasterStatus.transparency = 0;
437
                }
438
                                
439
                //TRANSPARENCIA
440
                if(        this.getTransparencyPanel().getTransparencyCheck().isSelected()){
441
                        this.checkTransparencyValues();
442
                        stackManager.addTransparencyFilter(        this.getRangeRed(),
443
                                                                                                        this.getRangeGreen(),
444
                                                                                                        this.getRangeBlue(),
445
                                                                                                        0x10,        //Transparencia
446
                                                                                                        0xff,        //Color Transparencia R
447
                                                                                                        0xff,        //Color Transparencia G
448
                                                                                                        0xff);        //Color Transparencia B
449
                }else
450
                        px.filterStack.removeFilter(stackManager.getTypeFilter("transparency"));
451
                        
452
                fLayer.getFMap().invalidate();
453
                return true;        
454
        }
455
        
456
        /**
457
         * Pressing OK with the enhancement panel selected makes its values to be processed.
458
         * @return true if the enhancement panel was selected and the action is processed, false it
459
         * was not selected.
460
         */
461
        public boolean processEnhancedPanel(){
462
                //Filtro lineal seleccionado
463
                if(        this.getEnhancedPanel().getLinealDirectoRadioButton().isSelected()){
464
                        if(        this.getEnhancedPanel().getRemoveCheck().isSelected() &&
465
                                !this.getEnhancedPanel().getTailCheck().isSelected())
466
                                stackManager.addEnhancedFilter(true);
467
                        else
468
                                stackManager.addEnhancedFilter(false);
469
                                                        
470
                        //Recorte de colas seleccionado
471
                        if(this.getEnhancedPanel().getTailCheck().isSelected()){
472
                                stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
473
                                double recorte = Double.parseDouble(this.getEnhancedPanel().getTailText().getText())/100;
474
                                if(this.getEnhancedPanel().getRemoveCheck().isSelected())
475
                                        stackManager.addTailFilter( recorte, 0D, true);
476
                                else
477
                                        stackManager.addTailFilter( recorte, 0D, false);                                                                
478
                        }else{
479
                                stackManager.removeFilter(stackManager.getTypeFilter("tail"));
480
                                stackManager.addComputeMinMaxFilter();
481
                        }        
482
                }
483
                        
484
                //Sin filtro lineal seleccionado
485
                if(this.getEnhancedPanel().getSinRealceRadioButton().isSelected()){
486
                        stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
487
                        stackManager.removeFilter(stackManager.getTypeFilter("tail"));
488
                        stackManager.removeFilter(stackManager.getTypeFilter("enhanced"));
489
                }
490
                fLayer.getFMap().invalidate();
491
                        
492
                return true;
493
        }
494
        
495
        /**
496
         * Manages the action perfomed when Apply/OK is pressed or Apply at the raster
497
         * properties control.
498
         * @param e
499
         */
500
        private void acceptButtonActionPerformed(ActionEvent e) {
501
                this.processBandPanel();
502
                this.processTransparencyPanel();        
503
                this.processEnhancedPanel();        
504
        }
505
        
506
        /**
507
         * Adds a band to the raster.
508
         * @param e
509
         */
510
        private void addFileBand(ActionEvent e){
511
                String[] driverNames = null;
512
                String rasterDriver = null;
513
                                
514
                //Creaci?n del dialogo para selecci?n de ficheros
515
                
516
                fileChooser = new JFileChooser(lastPath);
517
                fileChooser.setMultiSelectionEnabled(true);
518
                fileChooser.setAcceptAllFileFilterUsed(false);
519
        try {
520
                        driverNames = LayerFactory.getDM().getDriverNames();
521
                        FileFilter defaultFileFilter = null, auxF;
522
                        for (int i = 0; i < driverNames.length; i++) {
523
                                
524
                                if (driverNames[i].endsWith("gvSIG Image Driver")){
525
                                        rasterDriver = driverNames[i];
526
                                    auxF = new DriverFileFilter(driverNames[i]);
527
                                        fileChooser.addChoosableFileFilter(auxF);
528
                                        defaultFileFilter = auxF;
529
                                }
530
                        }
531
                } catch (DriverLoadException e1) {
532
                        NotificationManager.addError("No se pudo acceder a los drivers", e1);
533
                }
534
                int result = fileChooser.showOpenDialog(PropertiesWCSDialog.this);
535
                
536
                if(result == JFileChooser.APPROVE_OPTION){
537
                        File[] files = fileChooser.getSelectedFiles();
538
                         FileFilter filter = fileChooser.getFileFilter();
539
                         BandSetupPanel bandSetup = ((FilterRasterDialogPanel)this.getContentPane()).getBandSetup();
540
                         lastPath = files[0].getPath();
541
                         
542
                         //Lo a?adimos a la capa si no esta
543
                         
544
                         Vector v = new Vector();
545
            for(int i=0;i<files.length;i++){
546
                    boolean exist = false;
547
                    for(int j=0;j<px.getFiles().length;j++){
548
                            if(px.getFiles()[j].getName().endsWith(files[i].getName()))
549
                                    exist = true;
550
                    }
551
                    if(!exist){
552
                            try{
553
                                    Rectangle2D extentOrigin = fLayer.getFullExtent();
554
                                    
555
                                    Extent extentNewFile = GeoRasterFile.openFile(fLayer.getProjection(), files[i].getAbsolutePath()).getExtent();
556
                                    
557
                                                //Comprobamos que el extent y tama?o del fichero a?adido sea igual al 
558
                                                //fichero original. Si no es as? no abrimos la capa y mostramos un aviso
559
                                                
560
                                    double widthNewFile = (extentNewFile.getMax().getX()-extentNewFile.getMin().getX());
561
                                    double heightNewFile = (extentNewFile.getMax().getY()-extentNewFile.getMin().getY());
562
                                                                                                                                            
563
                                    if( (widthNewFile-extentOrigin.getWidth()) > 1.0 ||
564
                                            (widthNewFile-extentOrigin.getWidth()) < -1.0 ||
565
                                            (heightNewFile-extentOrigin.getHeight()) > 1.0 ||
566
                                            (heightNewFile-extentOrigin.getHeight()) < -1.0){       
567
                                            JOptionPane.showMessageDialog(        null,
568
                                                                                                            PluginServices.getText(this, "extents_no_coincidentes"), 
569
                                                                                                                        "",
570
                                                                                                                        JOptionPane.ERROR_MESSAGE);
571
                                            return;
572
                                    }
573
                                                                            
574
                                    if(        (extentNewFile.getMax().getX()-extentNewFile.getMin().getX())!=extentOrigin.getWidth() ||
575
                                                                (extentNewFile.getMax().getY()-extentNewFile.getMin().getY())!=extentOrigin.getHeight()        ){
576
                                            JOptionPane.showMessageDialog(null, 
577
                                                                        PluginServices.getText(this, "extents_no_coincidentes"), "", JOptionPane.ERROR_MESSAGE);
578
                                                        return;
579
                                    }
580
                                                                                                                
581
                            }catch(Exception exc){
582
                                    exc.printStackTrace();
583
                            }
584
                            
585
                            //Lo a?adimos a la capa
586
                            px.addFile(files[i].getAbsolutePath());
587

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