Statistics
| Revision:

root / branches / gvSIG_GisPlanet / applications / appgvSIG / src / com / iver / cit / gvsig / gui / Panels / PropertiesRasterDialog.java @ 2185

History | View | Annotate | Download (26.2 KB)

1
/*
2
 * Created on 17-feb-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package com.iver.cit.gvsig.gui.Panels;
48

    
49
import java.awt.Container;
50
import java.awt.event.ActionEvent;
51
import java.awt.geom.Rectangle2D;
52
import java.io.File;
53
import java.util.ArrayList;
54
import java.util.Vector;
55

    
56
import javax.swing.JFileChooser;
57
import javax.swing.JOptionPane;
58
import javax.swing.JPanel;
59
import javax.swing.filechooser.FileFilter;
60
import javax.swing.table.JTableHeader;
61

    
62
import org.cresques.cts.IProjection;
63
import org.cresques.io.GeoRasterFile;
64
import org.cresques.io.raster.RasterFilterStackManager;
65
import org.cresques.px.Extent;
66
import org.cresques.ui.raster.BandSetupPanel;
67
import org.cresques.ui.raster.EnhancedPanel;
68
import org.cresques.ui.raster.FilterRasterDialogPanel;
69
import org.cresques.ui.raster.RasterTransparencyPanel;
70

    
71
import com.hardcode.driverManager.Driver;
72
import com.hardcode.driverManager.DriverLoadException;
73
import com.iver.andami.PluginServices;
74
import com.iver.andami.messages.NotificationManager;
75
import com.iver.andami.ui.mdiManager.View;
76
import com.iver.andami.ui.mdiManager.ViewInfo;
77
import com.iver.cit.gvsig.fmap.drivers.RasterDriver;
78
import com.iver.cit.gvsig.fmap.layers.FLyrRaster;
79
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
80
import com.iver.cit.gvsig.fmap.layers.StatusLayerRaster;
81

    
82
/**
83
 * <P>
84
 * Dialogo para las propiedades de un raster. Esta maneja los eventos y aplica
85
 * filtros sobre el raster a trav?s de l gestor de la pila de filtros seg?n la
86
 * selecci?n del usuario. Este dialogo contiene varios paneles:
87
 * </P>
88
 * <UL>
89
 * <LI>Propiedades</LI>
90
 * <LI>Selecci?n de bandas</LI>
91
 * <LI>Transparencia</LI>
92
 * <LI>Realce</LI>
93
 * </UL>
94
 * @author Nacho Brodin <brodin_ign@gva.es>
95
 */
96
public class PropertiesRasterDialog extends FilterRasterDialogPanel implements View {
97
                 
98
        private JPanel                                                                        propPanel = null;
99
        private IProjection                                                         currentProjection = null;
100
        private FLyrRaster                                                                 fLayer = null;
101
        private static final int                                                nprops = 11;
102
        private Object[][]                                                                props = null;
103
        private RasterFilterStackManager                                 stackManager = null;
104
        private Status                                                                        status = null;
105
        private String                                                                         filename = null;
106
        private        long                                                                         filesize = 0;
107
        private        int                                                                         width = 0;
108
        private        int                                                                         height = 0;
109
        private JFileChooser                                                        fileChooser = null;
110
        private String                                                                        lastPath = new String("./");
111
        private StatusLayerRaster                                                rasterStatus = null;
112
        private int                                                                                sizeX = 486, sizeY = 318;
113
        
114
        /**
115
         * Clase que guarda el estado del dialogo y gestiona la restauraci?n
116
         * del estado inicial en caso de cancelar.
117
         * @author Nacho Brodin <brodin_ign@gva.es>
118
         */
119
        class Status{
120
                public String                                        inicAlpha;
121
                public int                                                 bandR;
122
                public int                                                 bandG;
123
                public int                                                 bandB;
124
                private ArrayList                                filesAdd = new ArrayList();
125
                private ArrayList                                filesRem = new ArrayList();
126
                private ArrayList                                filters = null;
127
                
128
                
129
                public Status(String alpha, int bandR, int bandG, int bandB){
130
                        this.inicAlpha = alpha;
131
                        this.bandR = bandR;
132
                        this.bandG = bandG;
133
                        this.bandB = bandB;
134
                        filters = stackManager.getStringsFromStack();
135
                }
136
                
137
                /**
138
                 * A?ade un fichero  a la lista de a?adidos. Si estaba en la de eliminados
139
                 * lo quitamos.
140
                 * @param file Fichero a?adido
141
                 */
142
                public void addFile(String file){
143
                        filesAdd.add(file);
144
                        for(int j=0;j<filesRem.size();j++){
145
                                if(file.equals((String)filesRem.get(j)))
146
                                                filesRem.remove(j);
147
                        }
148
                        
149
                }
150
                
151
                /**
152
                 * Elimina un fichero de la lista de a?adidos si ha sido a?adido. Si ya estaba
153
                 * antes no estar? en la lista de a?adidos por lo que habr? que ponerlo en la 
154
                 * lista de eliminados.
155
                 * @param file        Fichero eliminado
156
                 */
157
                public void removeFile(String file){
158
                        boolean isAdd = false;
159
                        for(int i=0;i<filesAdd.size();i++){
160
                                if(((String)filesAdd.get(i)).equals(file)){
161
                                        filesAdd.remove(i);
162
                                        isAdd =  true;
163
                                }
164
                        }
165
                        if(!isAdd)
166
                                filesRem.add(file);
167
        
168
                }
169
                
170
                /**
171
                 * Restaura el Estado salvado 
172
                 * @param status Estado
173
                 */
174
                public void restoreStatus(PropertiesRasterDialog props){
175
                        //Devolvemos la pila de filtros al estado inicial
176
                        //if(stackManager != null)
177
                        //        stackManager.deleteTempFilters();
178
                        
179
                        //Devolvemos el alpha al estado inicial
180
                        int opac = Integer.parseInt(status.inicAlpha);
181
                        opac = (int)((opac*255)/100);
182
                        fLayer.getSource().setTransparency(true);
183
                        fLayer.setTransparency(255-opac);
184
                        rasterStatus.transparency = 255-opac;
185
                        
186
                        //Devolvemos el estado inicial de las bandas
187
                        
188
                        if (fLayer != null) {
189
                                fLayer.getSource().setBand(GeoRasterFile.RED_BAND, status.bandR);
190
                                fLayer.getSource().setBand(GeoRasterFile.GREEN_BAND, status.bandG);
191
                                fLayer.getSource().setBand(GeoRasterFile.BLUE_BAND, status.bandB);
192
                                rasterStatus.bandR = status.bandR;
193
                                rasterStatus.bandG = status.bandG;
194
                                rasterStatus.bandB = status.bandB;
195
                        }
196
                        
197
                        BandSetupPanel bandSetup = ((FilterRasterDialogPanel)props.getContentPane()).getBandSetup();
198
                        
199
                        //Los que han sido a?adidos los quitamos
200
                        for(int i=0;i<filesAdd.size();i++)
201
                                fLayer.delFile((String)this.filesAdd.get(i));
202
                                                        
203
                        //Los que fueron quitados los a?adimos
204
                        for(int i=0;i<filesRem.size();i++)
205
                                fLayer.addFiles((String)this.filesRem.get(i));
206
                                
207
                        //Restauramos los filtros
208
                        if(filters!=null)
209
                                stackManager.createStackFromStrings(filters);
210
                                                
211
                        fLayer.getFMap().invalidate();
212
                        //this.show();
213
                }
214
                
215
                public void show(){
216
                        System.out.println("***Lista A?adidos***");
217
                        for(int i=0;i<filesAdd.size();i++){
218
                                System.out.println(filesAdd.get(i).toString());
219
                        }
220
                        System.out.println("***Lista Eliminados***");
221
                        for(int i=0;i<filesRem.size();i++){
222
                                System.out.println(filesRem.get(i).toString());
223
                        }
224
                        System.out.println("*********************");
225
                }
226
                
227
        }
228
        
229
        public class DriverFileFilter extends FileFilter{
230
                
231
                private Driver driver;
232
                
233
                public DriverFileFilter(String driverName) throws DriverLoadException{
234
                        driver = LayerFactory.getDM().getDriver(driverName);
235
                }
236

    
237
                /**
238
                 * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
239
                 */
240
                public boolean accept(File f) {
241
                        if (f.isDirectory()) return true;
242
                        if (driver instanceof RasterDriver){
243
                                return ((RasterDriver) driver).fileAccepted(f);
244
                        }else{
245
                                throw new RuntimeException("Tipo no reconocido");
246
                        }
247
                }
248

    
249
                /**
250
                 * @see javax.swing.filechooser.FileFilter#getDescription()
251
                 */
252
                public String getDescription() {
253
                        return ((Driver) driver).getName();
254
                }
255
        }
256
        
257
        /**
258
         * Constructor de la ventana de dialogo.
259
         * @param app
260
         */
261
        public PropertiesRasterDialog(FLyrRaster layer, int[][] rangeR, int[][] rangeG, int[][] rangeB){
262
                super();
263
                fLayer = layer;
264
                if(fLayer.getStatus()==null){
265
                        rasterStatus = new StatusLayerRaster();
266
                        fLayer.setStatus(rasterStatus);
267
                }else
268
                        rasterStatus = (StatusLayerRaster)fLayer.getStatus();
269
                initialize();                        
270
                this.setRanges(rangeR, rangeG, rangeB);
271
                setTranslation();
272
        }
273
        
274
        /**
275
         * Asigna los textos a los paneles
276
         */
277
        private void setTranslation(){
278
                
279
                this.getBandSetup().getFileList().getJButton2().setText(PluginServices.getText(this,"Anadir"));
280
                this.getBandSetup().getFileList().getJButton3().setText(PluginServices.getText(this,"Eliminar"));
281
                        
282
                RasterTransparencyPanel tpan = this.getTransparencyPanel();
283
                if(tpan.nBands==1)
284
                        tpan.jLabel1.setText(PluginServices.getText(this,"Valor_banda"));
285
                else
286
                        tpan.jLabel1.setText(PluginServices.getText(this,"Valor_verde")+":");
287
                tpan.jLabel.setText(PluginServices.getText(this,"Valor_rojo")+":");
288
                tpan.jLabel2.setText(PluginServices.getText(this,"Valor_azul")+":");
289
                tpan.getTransparencyCheck().setText(PluginServices.getText(this,"transparencia"));
290
                tpan.getOpacityCheck().setText(PluginServices.getText(this,"opacidad"));
291
                tpan.jLabel3.setText(PluginServices.getText(this,"usar_rango")+": 1,3,5:8");
292
                tpan.jLabel4.setText(PluginServices.getText(this,"valor_pixel")+": 0 a 255");
293
                                
294
                EnhancedPanel ep = this.getEnhancedPanel();
295
                ep.jLabel.setText(PluginServices.getText(this,"lineal_directo"));
296
                ep.jLabel1.setText(PluginServices.getText(this,"recorte_colas"));
297
                ep.jLabel2.setText(PluginServices.getText(this,"sin_realce"));
298
                ep.jLabel4.setText("% "+PluginServices.getText(this,"recorte"));
299
                ep.jLabel5.setText(PluginServices.getText(this,"eliminar_extremos"));
300
                                
301
                //Recorremos los Tab y traducimos el nombre
302
                for(int i=0;i<this.getTab().getTabCount();i++){
303
                        if(this.getTab().getTitleAt(i).equals("Info"))
304
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"Info"));
305
                        if(this.getTab().getTitleAt(i).equals("Transparencia"))
306
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"Transparencia"));
307
                        if(this.getTab().getTitleAt(i).equals("Bandas"))
308
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"Bandas"));
309
                        if(this.getTab().getTitleAt(i).equals("Realce"))
310
                                this.getTab().setTitleAt(i,PluginServices.getText(this,"realce"));
311
                }
312
        }
313
        
314
        /**
315
         * Asigna un FLayerRaster
316
         * @param layer        capa a asignar
317
         */
318
        public void setFLyrRaster(FLyrRaster layer){
319
                fLayer = layer;
320
        }
321
        
322
        /**
323
         * Constructor de la ventana de dialogo.
324
         */
325
        public PropertiesRasterDialog() {
326
                initialize();
327
        }
328
                
329
        
330
        
331
        /**
332
         * Carga los datos del panel info.
333
         */
334
        private void loadInfoData(){
335
                if(fLayer.getSource()!=null){
336
                        props = new Object[nprops][2];
337
                        props[0][0] = new String(PluginServices.getText(this,"Fichero")+":");
338
                        props[0][1] = filename;
339
                        props[1][0] = new String(PluginServices.getText(this,"num_bandas")+":");
340
                        props[1][1] = new String(String.valueOf(fLayer.getSource().getNumBands()));
341
                        props[2][0] = new String(PluginServices.getText(this,"ancho_alto")+":");
342
                        props[2][1] = this.width+" X "+this.height;
343
                        props[3][0] = new String(PluginServices.getText(this,"formato")+":");
344
                        props[3][1] = filename.substring(
345
                                                filename.lastIndexOf('.')+1, 
346
                                                filename.length());
347
                        props[4][0] = new String(PluginServices.getText(this,"tipo_dato")+":");
348
                        String type = null;
349
                        switch(fLayer.getSource().getDataType()){
350
                                case 0: type = new String("BYTE");break;
351
                                case 1: type = new String("USHORT");break;
352
                                case 2: type = new String("SHORT");break;
353
                                case 3: type = new String("INT");break;
354
                                case 4: type = new String("FLOAT");break;
355
                                case 5: type = new String("DOUBLE");break;
356
                                default: type = new String("UNDEFINED");break;
357
                        }
358
                    props[4][1] = type;
359
                        props[5][0] = new String(PluginServices.getText(this,"coor_geograficas"));
360
                        props[6][0] = new String(PluginServices.getText(this,"xmin")+":");
361
                        props[6][1] = String.valueOf(fLayer.getSource().getFullExtent().getMinX());
362
                        props[7][0] = new String(PluginServices.getText(this,"ymin")+":");
363
                        props[7][1] = String.valueOf(fLayer.getSource().getFullExtent().getMinY());
364
                        props[8][0] = new String(PluginServices.getText(this,"xmax")+":");
365
                        props[8][1] = String.valueOf(fLayer.getSource().getFullExtent().getMaxX());
366
                        props[9][0] = new String(PluginServices.getText(this,"ymax")+":");
367
                        props[9][1] = String.valueOf(fLayer.getSource().getFullExtent().getMaxY());
368
                        
369
                }else{
370
                        props = new Object[1][2];
371
                        props[0][0] = new String("No props");
372
                        props[0][1] = new String("-");
373
                }
374
                
375
        }
376
        
377
        /**
378
         * A?ade bandas al contador de bandas del FilterRasterDialogPanel
379
         * @param numBands N?mero de bandas a a?adir
380
         */
381
        public void addNumBands(int numBands){
382
                nbands += numBands;
383
        }
384
        
385
        /**
386
         * Inicializa el jDialog                
387
         */    
388
        private void initialize() {
389
                
390
                //this.setLayout(new FlowLayout());
391
                        
392
                setName("filterRaster");
393
                ArrayList attr = ((FLyrRaster)fLayer).getSource().getAttributes();
394
                   for (int i=0; i<attr.size(); i++) {
395
                        Object[] a = (Object []) attr.get(i);
396
                        if(a[0].toString().equals("Filename"))
397
                                filename = a[1].toString();
398
                        if(a[0].toString().equals("Filesize"))
399
                                filesize = ((Long)a[1]).intValue();
400
                        if(a[0].toString().equals("Width"))
401
                                width = ((Integer)a[1]).intValue();
402
                        if(a[0].toString().equals("Height"))
403
                                height = ((Integer)a[1]).intValue();
404
                }
405
                   
406
                   this.loadInfoData();
407
                super.init(props);
408
                
409
                this.getInfoPanel().columnNames[0] = PluginServices.getText(this,"propiedad");
410
                this.getInfoPanel().columnNames[1] = PluginServices.getText(this,"Valor");
411
                this.getInfoPanel().resetTable();
412
                this.getInfoPanel().initialize();
413
                
414
                //this.add(getContentPane());
415
        
416
                this.setSize(this.sizeX, this.sizeY);
417
                
418
                //contentPane.getAcceptButton().setEnabled(false);
419
                this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() {
420
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
421
                                acceptButtonActionPerformed(evt);
422
                                //Solo cuando le damos a aceptar guardamos la situaci?n actual de los
423
                                //ficheros cargados en el StatusLayerRaster
424
                                if(rasterStatus!=null){
425
                                        ArrayList rs = new ArrayList();
426
                                        for(int i=0;i<fLayer.getSource().getFiles().length;i++)
427
                                                rs.add(fLayer.getSource().getFiles()[i].getName());
428
                                        rasterStatus.files = rs;
429
                                }
430
                                closeJDialog();
431
                        }
432
                });
433
                this.getCancelButton().addActionListener(new java.awt.event.ActionListener() {
434
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
435
                                cancelButtonActionPerformed(evt);
436
                                closeJDialog();
437
                        }
438
                });
439
                this.getApplyButton().addActionListener(new java.awt.event.ActionListener() {
440
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
441
                                acceptButtonActionPerformed(evt);
442
                        }
443
                });
444
                this.getBandSetup().getFileList().getJButton2().addActionListener(new java.awt.event.ActionListener() {
445
                        public void actionPerformed(java.awt.event.ActionEvent evt){
446
                                addFileBand(evt);
447
                                
448
                        }
449
                });
450
                this.getBandSetup().getFileList().getJButton3().addActionListener(new java.awt.event.ActionListener() {
451
                        public void actionPerformed(java.awt.event.ActionEvent evt){
452
                                delFileBand(evt);
453
                        }
454
                });
455
                
456
        
457
        }
458
        
459
        /**
460
         * Salva el estado inicial por si se cancela
461
         */
462
        public void readStat(){
463
                status = new Status(((FilterRasterDialogPanel)this).getTransparencyPanel().getOpacityText().getText(),
464
                                                        getAssignedBand(GeoRasterFile.RED_BAND),
465
                                                        getAssignedBand(GeoRasterFile.GREEN_BAND),
466
                                                        getAssignedBand(GeoRasterFile.BLUE_BAND));                                
467
        }
468
        
469
        /**
470
         * This method initializes jContentPane                
471
         */    
472
        public Container getContentPane() {
473
                return this;
474
        }
475
        
476
        /**
477
         * Asigna una proyecci?n
478
         * @param prj
479
         */
480
        public void setProjection(IProjection prj) {
481
                this.currentProjection = prj;
482
        }
483
        
484
        
485
        
486
        public void closeJDialog() {
487
                PluginServices.getMDIManager().closeView(PropertiesRasterDialog.this);
488
        }
489
        
490
        /**
491
         * Asigna el RasterFilterStackManager
492
         * @param stackManager
493
         */
494
        public void setRasterFilterStackManager(RasterFilterStackManager stackManager){
495
                this.stackManager = stackManager;
496
                stackManager.resetTempFilters();
497
        }
498
        
499
        /**
500
         * 
501
         * @param flag
502
         * @return
503
         */
504
        public int getAssignedBand(int flag) {
505
                return this.getBandSetup().getAssignedBand(flag);
506
        }
507
        
508
        /**
509
         * Pulsar aceptar con el panel de bandas seleccionado hace que se procesen los valores
510
         * introducidos en este.
511
         * @return true si estaba seleccionado el panel de bandas y se ha procesado la
512
         * acci?n y false si no lo estaba.
513
         */
514
        public boolean processBandPanel(){
515
                if(this.getTab().getSelectedComponent() == this.getBandSetup()){                
516
                        fLayer.getSource().setBand(GeoRasterFile.RED_BAND,
517
                                                getAssignedBand(GeoRasterFile.RED_BAND));
518
                        fLayer.getSource().setBand(GeoRasterFile.GREEN_BAND,
519
                                                getAssignedBand(GeoRasterFile.GREEN_BAND));
520
                        fLayer.getSource().setBand(GeoRasterFile.BLUE_BAND,
521
                                                getAssignedBand(GeoRasterFile.BLUE_BAND));
522
                        
523
                        rasterStatus.bandR = getAssignedBand(GeoRasterFile.RED_BAND);
524
                        rasterStatus.bandG = getAssignedBand(GeoRasterFile.GREEN_BAND);
525
                        rasterStatus.bandB = getAssignedBand(GeoRasterFile.BLUE_BAND);
526
                        fLayer.getFMap().invalidate();
527
                        return true;
528
                }
529
                return false;
530
        }
531
        
532
        /**
533
         * Pulsar aceptar con el panel de transparecias seleccionado hace que se procesen los valores
534
         * introducidos en este.
535
         * @return true si estaba seleccionado el panel de transparencias y se ha procesado la
536
         * acci?n y false si no lo estaba.
537
         */
538
        public boolean processTransparencyPanel(){
539

    
540
                if(this.getTab().getSelectedComponent() == this.getTransparencyPanel()){
541
                        
542
                        //OPACIDAD
543
                        String sOpac = this.getTransparencyPanel().getOpacityText().getText();
544
                        if(!sOpac.equals("") && this.getTransparencyPanel().getOpacityCheck().isSelected()){
545
                                int opac = Integer.parseInt(sOpac);
546
                                opac = (int)((opac*255)/100);
547
                                fLayer.getSource().setTransparency(true);
548
                                fLayer.setTransparency(255-opac);
549
                                rasterStatus.transparency = 255-opac;
550
                        }else{
551
                                fLayer.getSource().setTransparency(false);
552
                                fLayer.setTransparency(0);
553
                                rasterStatus.transparency = 0;
554
                        }
555
                                
556
                        //TRANSPARENCIA
557
                        if(        this.getTransparencyPanel().getTransparencyCheck().isSelected()){
558
                                this.checkTransparencyValues();
559
                                stackManager.addTransparencyFilter(        this.getRangeRed(),
560
                                                                                                        this.getRangeGreen(),
561
                                                                                                        this.getRangeBlue(),
562
                                                                                                        0x10,        //Transparencia
563
                                                                                                        0xff,        //Color Transparencia R
564
                                                                                                        0xff,        //Color Transparencia G
565
                                                                                                        0xff);        //Color Transparencia B
566
                        }else{
567
                                fLayer.getSource().getFilterStack().removeFilter(stackManager.getTypeFilter("transparency"));
568
                        }
569
                        
570
                        return true;
571
                }
572
                                
573
                return false;
574
        }
575
        
576
        /**
577
         * Pulsar aceptar con el panel de realce seleccionado hace que se procesen los valores
578
         * introducidos en este.
579
         * @return true si estaba seleccionado el panel de realce y se ha procesado la
580
         * acci?n y false si no lo estaba.
581
         */
582
        public boolean processEnhancedPanel(){
583
                if(this.getTab().getSelectedComponent() == this.getEnhancedPanel()){
584
                        
585
                        //Filtro lineal seleccionado
586
                        if(        this.getEnhancedPanel().getLinealDirectoRadioButton().isSelected()){
587
                                if(        this.getEnhancedPanel().getRemoveCheck().isSelected() &&
588
                                        !this.getEnhancedPanel().getTailCheck().isSelected())
589
                                        stackManager.addEnhancedFilter(true, fLayer.getSource().getFiles()[0].getName());
590
                                else
591
                                        stackManager.addEnhancedFilter(false, fLayer.getSource().getFiles()[0].getName());
592
                                
593
                                //Recorte de colas seleccionado
594
                                if(this.getEnhancedPanel().getTailCheck().isSelected()){
595
                                        stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
596
                                        double recorte = Double.parseDouble(this.getEnhancedPanel().getTailText().getText())/100;
597
                                        if(this.getEnhancedPanel().getRemoveCheck().isSelected())
598
                                                stackManager.addTailFilter( recorte, 0D, true);
599
                                        else
600
                                                stackManager.addTailFilter( recorte, 0D, false);
601
                                }else{
602
                                        stackManager.removeFilter(stackManager.getTypeFilter("tail"));
603
                                        stackManager.addComputeMinMaxFilter();
604
                                }        
605
                        }
606
                        
607
                        //Sin filtro lineal seleccionado
608
                        if(this.getEnhancedPanel().getSinRealceRadioButton().isSelected()){
609
                                stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
610
                                stackManager.removeFilter(stackManager.getTypeFilter("tail"));
611
                                stackManager.removeFilter(stackManager.getTypeFilter("enhanced"));
612
                        }
613
                        fLayer.getFMap().invalidate();
614
                        
615
                        return true;
616
                }
617
                return false;
618
        }
619
        
620
        /**
621
         * Gestiona la acci?n cuando se pulsa aplicar/aceptar o aplicar en el control
622
         * de propiedades de raster
623
         * @param e
624
         */
625
        private void acceptButtonActionPerformed(ActionEvent e) {
626
                this.processBandPanel();
627
                this.processTransparencyPanel();        
628
                this.processEnhancedPanel();        
629
        }
630
        
631
        /**
632
         * A?ade una banda al raster
633
         * @param e
634
         */
635
        private void addFileBand(ActionEvent e){
636
                String[] driverNames = null;
637
                String rasterDriver = null;
638
                                                
639
                //Creaci?n del dialogo para selecci?n de ficheros
640
                
641
                fileChooser = new JFileChooser(lastPath);
642
                fileChooser.setMultiSelectionEnabled(true);
643
                fileChooser.setAcceptAllFileFilterUsed(false);
644
        try {
645
                        driverNames = LayerFactory.getDM().getDriverNames();
646
                        FileFilter defaultFileFilter = null, auxF;
647
                        for (int i = 0; i < driverNames.length; i++) {
648
                                
649
                                if (driverNames[i].endsWith("gvSIG Image Driver")){
650
                                        rasterDriver = driverNames[i];
651
                                    auxF = new DriverFileFilter(driverNames[i]);
652
                                        fileChooser.addChoosableFileFilter(auxF);
653
                                        defaultFileFilter = auxF;
654
                                }
655
                        }
656
                } catch (DriverLoadException e1) {
657
                        NotificationManager.addError("No se pudo acceder a los drivers", e1);
658
                }
659
                int result = fileChooser.showOpenDialog(PropertiesRasterDialog.this);
660
                
661
                if(result == JFileChooser.APPROVE_OPTION){
662
                        File[] files = fileChooser.getSelectedFiles();
663
                         FileFilter filter = fileChooser.getFileFilter();
664
                         BandSetupPanel bandSetup = ((FilterRasterDialogPanel)this.getContentPane()).getBandSetup();
665
                         lastPath = files[0].getPath();
666
                         
667
                         //Lo a?adimos a la capa si no esta
668
                         
669
                         Vector v = new Vector();
670
            for(int i=0;i<files.length;i++){
671
                    
672
                    //Comprobamos que el fichero no est?
673
                    boolean exist = false;
674
                    for(int j=0;j<fLayer.getSource().getFiles().length;j++){
675
                            if(fLayer.getSource().getFiles()[j].getName().endsWith(files[i].getName()))
676
                                    exist = true;
677
                    }
678
                    if(!exist){
679
                            try{
680
                                    Rectangle2D extentOrigin = fLayer.getFullExtent();
681
                                    
682
                                    GeoRasterFile geoRasterFile = GeoRasterFile.openFile(fLayer.getProjection(), files[i].getAbsolutePath());
683
                                    Extent extentNewFile = geoRasterFile.getExtent();
684
                                    nbands += geoRasterFile.getBandCount();
685
                                    
686
                                                //Comprobamos que el extent y tama?o del fichero a?adido sea igual al 
687
                                                //fichero original. Si no es as? no abrimos la capa y mostramos un aviso
688
                                                
689
                                    double widthNewFile = (extentNewFile.getMax().getX()-extentNewFile.getMin().getX());
690
                                    double heightNewFile = (extentNewFile.getMax().getY()-extentNewFile.getMin().getY());
691
                                                                                                                                            
692
                                    if( (widthNewFile-extentOrigin.getWidth()) > 1.0 ||
693
                                            (widthNewFile-extentOrigin.getWidth()) < -1.0 ||
694
                                            (heightNewFile-extentOrigin.getHeight()) > 1.0 ||
695
                                            (heightNewFile-extentOrigin.getHeight()) < -1.0){       
696
                                            JOptionPane.showMessageDialog(        null,
697
                                                                                                            PluginServices.getText(this, "extents_no_coincidentes"), 
698
                                                                                                                        "",
699
                                                                                                                        JOptionPane.ERROR_MESSAGE);
700
                                            return;
701
                                    }
702
                                                                            
703
                                    if(        (extentNewFile.getMax().getX()-extentNewFile.getMin().getX())!=extentOrigin.getWidth() ||
704
                                                                (extentNewFile.getMax().getY()-extentNewFile.getMin().getY())!=extentOrigin.getHeight()        ){
705
                                            JOptionPane.showMessageDialog(null, 
706
                                                                        PluginServices.getText(this, "extents_no_coincidentes"), "", JOptionPane.ERROR_MESSAGE);
707
                                                        return;
708
                                    }
709
                                                                                                                
710
                            }catch(Exception exc){
711
                                    exc.printStackTrace();
712
                            }
713
                            
714
                            //Lo a?adimos a la capa
715
                            fLayer.addFiles(files[i].getAbsolutePath());
716
                            //Mantiene la lista de ficheros a?adidos por si se cancela
717
                            status.addFile(files[i].getAbsolutePath());
718
                            
719
                    
720
                    }else{
721
                            JOptionPane.showMessageDialog(null, 
722
                                                        PluginServices.getText(this, "fichero_existe")+" "+files[i].getAbsolutePath(), "", JOptionPane.ERROR_MESSAGE);
723
                    }
724
            }
725
                                     
726
            //A?adimos los georasterfile a la tabla del Panel
727
            
728
            v = new Vector();
729
            for(int i=0;i<fLayer.getSource().getFiles().length;i++){
730
                    boolean exist = false;
731
                    for(int j=0;j<bandSetup.getNBands();j++){
732
                            if(fLayer.getSource().getFiles()[i].getName().endsWith(bandSetup.getBandName(j)))
733
                                    exist = true;
734
                    }
735
                    if(!exist)
736
                            v.add(fLayer.getSource().getFiles()[i]);
737
            }
738
            
739
            GeoRasterFile[] grf = new GeoRasterFile[v.size()];
740
            for(int i=0;i<grf.length;i++){
741
                    grf[i] = (GeoRasterFile)v.get(i);
742
            }
743
            bandSetup.addFiles(grf);
744
                }
745
        }
746
        
747
        /**
748
         * Elimina una banda del raster. Si queda solo un fichero o no se ha 
749
         * seleccionado ninguna banda no hace nada.
750
         * @param e
751
         */
752
        private void delFileBand(ActionEvent e){
753
                BandSetupPanel bandSetup = ((FilterRasterDialogPanel)this.getContentPane()).getBandSetup();
754
        
755
                if(        bandSetup.getFileList().getJList().getSelectedValue()!=null &&
756
                        bandSetup.getFileList().getNFiles() > 1){
757
                        String pathName = bandSetup.getFileList().getJList().getSelectedValue().toString();
758
                        GeoRasterFile geoRasterFile = GeoRasterFile.openFile(fLayer.getProjection(), pathName);
759
                        nbands -= geoRasterFile.getBandCount();
760
                        fLayer.delFile(pathName);
761
                        String file = pathName.substring(pathName.lastIndexOf("/")+1);
762
                        file = file.substring(file.lastIndexOf("\\")+1);
763
                        bandSetup.removeFile(file);
764
                        
765
                        //Mantiene la lista de ficheros eliminados por si se cancela
766
                        status.removeFile(pathName);
767
                }                
768
        }
769
        
770
        /**
771
         * El bot?n de cancelar recupera el estado anterior a la apertura de
772
         * este dialogo.
773
         * @param e        Evento
774
         */
775
        private void cancelButtonActionPerformed(ActionEvent e) {
776
                this.status.restoreStatus(this);
777
                fLayer.getFMap().invalidate();
778
        }
779
        
780
                
781
        /**
782
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
783
         */
784
        public ViewInfo getViewInfo() {
785
                ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
786
                    m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_raster"));
787
                return m_viewinfo;
788
        }
789
        
790
        
791
}