Statistics
| Revision:

root / trunk / extensions / extWCS / src / com / iver / cit / gvsig / gui / Panels / PropertiesWCSDialog.java @ 2674

History | View | Annotate | Download (21.7 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().getJButton2().setEnabled(false);
165
                fr.getBandSetup().getFileList().getJButton3().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().getJButton2().setText(PluginServices.getText(this,"Anadir"));
175
                this.getBandSetup().getFileList().getJButton3().setText(PluginServices.getText(this,"Eliminar"));
176
                this.getBandSetup().getFileList().bandasVisibles.setText(PluginServices.getText(this,"bandas"));
177
                
178
                RasterTransparencyPanel tpan = this.getTransparencyPanel();
179
                
180
                tpan.greenValue.setText(PluginServices.getText(this,"Valor_verde"));
181
                tpan.redValue.setText(PluginServices.getText(this,"Valor_rojo"));
182
                tpan.blueValue.setText(PluginServices.getText(this,"Valor_azul"));
183
                tpan.getTransparencyCheck().setText(PluginServices.getText(this,"transparencia"));
184
                tpan.getOpacityCheck().setText(PluginServices.getText(this,"opacidad"));
185
                tpan.range.setText(PluginServices.getText(this,"usar_rango"));
186
                tpan.jLabel4.setText(PluginServices.getText(this,"valor_pixel")+": 0 a 255");
187
                
188
                EnhancedPanel ep = this.getEnhancedPanel();
189
                ep.jLabel.setText(PluginServices.getText(this,"lineal_directo"));
190
                ep.jLabel1.setText(PluginServices.getText(this,"recorte_colas"));
191
                ep.jLabel2.setText(PluginServices.getText(this,"sin_realce"));
192
                ep.jLabel4.setText(PluginServices.getText(this,"recorte"));
193
                ep.jLabel5.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] = grf.getName();
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.add(getContentPane());
296
        
297
                this.setSize(486, 318);
298
                
299
                //contentPane.getAcceptButton().setEnabled(false);
300
                this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() {
301
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
302
                                acceptButtonActionPerformed(evt);
303
                                closeJDialog();
304
                        }
305
                });
306
                this.getCancelButton().addActionListener(new java.awt.event.ActionListener() {
307
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
308
                                cancelButtonActionPerformed(evt);
309
                                closeJDialog();
310
                        }
311
                });
312
                this.getApplyButton().addActionListener(new java.awt.event.ActionListener() {
313
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
314
                                acceptButtonActionPerformed(evt);
315
                        }
316
                });
317
                this.getBandSetup().getFileList().getJButton2().addActionListener(new java.awt.event.ActionListener() {
318
                        public void actionPerformed(java.awt.event.ActionEvent evt){
319
                                addFileBand(evt);
320
                                
321
                        }
322
                });
323
                this.getBandSetup().getFileList().getJButton3().addActionListener(new java.awt.event.ActionListener() {
324
                        public void actionPerformed(java.awt.event.ActionEvent evt){
325
                                delFileBand(evt);
326
                        }
327
                });
328

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

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