Statistics
| Revision:

root / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / mosaic / gui / MosaicDialog.java @ 25142

History | View | Annotate | Download (20.2 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
         *
3
         * Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana.
4
         *
5
         * This program is free software; you can redistribute it and/or
6
         * modify it under the terms of the GNU General Public License
7
         * as published by the Free Software Foundation; either version 2
8
         * of the License, or (at your option) any later version.
9
         *
10
         * This program is distributed in the hope that it will be useful,
11
         * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
         * GNU General Public License for more details.
14
         *
15
         * You should have received a copy of the GNU General Public License
16
         * along with this program; if not, write to the Free Software
17
         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
         *
19
         * For more information, contact:
20
         *
21
         *  Generalitat Valenciana
22
         *   Conselleria d'Infraestructures i Transport
23
         *   Av. Blasco Iba?ez, 50
24
         *   46010 VALENCIA
25
         *   SPAIN
26
         *
27
         *      +34 963862235
28
         *   gvsig@gva.es
29
         *      www.gvsig.gva.es
30
         *
31
         *    or
32
         *
33
         *   Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
34
         *   Campus Universitario s/n
35
         *   02071 Alabacete
36
         *   Spain
37
         *
38
         *   +34 967 599 200
39
         */
40

    
41
package org.gvsig.remotesensing.mosaic.gui;
42

    
43

    
44
/**
45
 * Di?logo para la funcionalidad de mosaicos. 
46
 * 
47
 * @author aMu?oz (alejandro.munoz@uclm.es)
48
 * @version 24/4/2008
49
 * 
50
 * */
51

    
52
import java.awt.BorderLayout;
53
import java.awt.Dimension;
54
import java.awt.GridBagConstraints;
55
import java.awt.GridBagLayout;
56
import java.awt.Insets;
57
import java.awt.event.ActionEvent;
58
import java.awt.event.ActionListener;
59
import java.awt.event.FocusEvent;
60
import java.awt.event.FocusListener;
61
import java.beans.PropertyChangeEvent;
62
import java.beans.PropertyChangeListener;
63
import java.io.File;
64

    
65
import javax.swing.BorderFactory;
66
import javax.swing.ButtonGroup;
67
import javax.swing.JFileChooser;
68
import javax.swing.JLabel;
69
import javax.swing.JPanel;
70
import javax.swing.JRadioButton;
71
import javax.swing.JTabbedPane;
72
import javax.swing.JTextField;
73
import javax.swing.SwingConstants;
74
import javax.swing.border.TitledBorder;
75

    
76
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
77
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
78
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
79
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
80
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
81
import org.gvsig.raster.IProcessActions;
82
import org.gvsig.raster.RasterLibrary;
83
import org.gvsig.raster.buffer.BufferFactory;
84
import org.gvsig.raster.buffer.RasterBuffer;
85
import org.gvsig.raster.dataset.GeoRasterWriter;
86
import org.gvsig.raster.dataset.IRasterDataSource;
87
import org.gvsig.raster.datastruct.Histogram;
88
import org.gvsig.raster.hierarchy.IHistogramable;
89
import org.gvsig.raster.util.ExtendedFileFilter;
90
import org.gvsig.raster.util.PropertyEvent;
91
import org.gvsig.raster.util.PropertyListener;
92
import org.gvsig.raster.util.RasterNotLoadException;
93
import org.gvsig.raster.util.RasterToolsUtil;
94
import org.gvsig.rastertools.histogram.HistogramProcess;
95
import org.gvsig.remotesensing.mosaic.process.FeatherProcessBuff;
96
import org.gvsig.remotesensing.mosaic.process.HistogramMatchProcess;
97
import org.gvsig.remotesensing.mosaic.process.MosaicProcess;
98

    
99
import com.iver.andami.PluginServices;
100
import com.iver.andami.Utilities;
101
import com.iver.andami.ui.mdiManager.IWindow;
102
import com.iver.andami.ui.mdiManager.IWindowListener;
103
import com.iver.andami.ui.mdiManager.WindowInfo;
104
import com.iver.cit.gvsig.addlayer.fileopen.FileOpenWizard;
105
import com.iver.cit.gvsig.fmap.MapControl;
106
import com.iver.cit.gvsig.project.documents.view.gui.View;
107

    
108
public class MosaicDialog extends DefaultButtonsPanel implements PropertyListener, IWindow, IWindowListener, 
109
        ButtonsPanelListener,ActionListener,FocusListener,PropertyChangeListener,IProcessActions{
110

    
111
        private static final long serialVersionUID = 2847035927527203595L;
112
        private SelectLayersFromViewPanel northPanel = null;
113
        private MethodMosaicPanel southPanel = null;
114
        private MapControl mapControl = null;
115
        private View view=null;
116
        private JPanel                                         panelTab1=null;
117
        private JPanel                                         panelTab2=null;
118
        private JPanel                                         nombreCapa=null;
119
        private JRadioButton                         rButtonMemory=null;
120
        private JRadioButton                         rButtonFile=null;
121
        private JTextField                                 jTextNombreCapa=null;
122
        
123
        private final int HM = 0;
124
        private final int PREMOSAICING = 1;
125
        private final int MOSAICING = 2;
126
        private final int LOADING = 3;
127
        private int currentProcess = this.HM;
128
        
129
        private FLyrRasterSE hmMasterRaster = null;
130
        private int masterRasterPosition = 0 ;
131
        private FLyrRasterSE inputRasterLayers[];
132
        private FLyrRasterSE resultLayer = null;
133
        private boolean applyHistogramM = false;
134
        
135
        /**
136
         * Constructor
137
         * @param width Ancho del panel
138
         * @param height Alto del panel
139
         */
140
        public MosaicDialog(int width, int height, View view) {
141
                super();
142
                this.view= view;
143
                this.setSize(width, height);
144
                this.setLayout(new BorderLayout());
145
                JTabbedPane tabbedPane = new JTabbedPane();
146
                 tabbedPane.addTab(PluginServices.getText(this, "operacion"), getPanelTab1());
147
                tabbedPane.addTab(PluginServices.getText(this, "opciones"), getPanelTab2());
148
                this.add(tabbedPane, BorderLayout.CENTER);
149
                this.addButtonPressedListener(this);
150
        }
151
        
152
        
153
        public WindowInfo getWindowInfo() {
154
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.RESIZABLE);
155
                m_viewinfo.setTitle(PluginServices.getText(this, "mosaicos"));
156
                m_viewinfo.setHeight(this.getHeight());
157
                m_viewinfo.setWidth(this.getWidth());
158
                return m_viewinfo;
159
        }
160

    
161

    
162
        /**
163
         * Acciones a ejecutar cuando se cancela
164
         */
165
        public void close(){        
166
                try {
167
                        PluginServices.getMDIManager().closeWindow(this);
168
                } catch (ArrayIndexOutOfBoundsException ex) {
169
                        // Si la ventana no se puede eliminar no hacemos nada
170
                }
171
        }
172
                
173
        /**
174
         *  @return northPanel. Panel principal
175
         * */
176
        public SelectLayersFromViewPanel getPanelNorth() {
177
                if (northPanel == null){
178
                        northPanel = new SelectLayersFromViewPanel(view);
179
                        northPanel.getTableImages().addPropertyChangeListener(this);
180
                }
181
                return northPanel;
182
        }
183

    
184
        /**
185
         *  @return northPanel. Panel principal
186
         * */
187
        public MethodMosaicPanel getPanelSouth() {
188
                if (southPanel == null){
189
                        southPanel = new MethodMosaicPanel(northPanel.getSelectedLayers(),view);
190
                }
191
                return southPanel;
192
        }
193

    
194
        
195

    
196
        public MapControl getMapControl() {
197
                return mapControl;
198
        }
199

    
200
        
201
        /**
202
         * @return panel para el tab operacion.
203
         */
204
        private JPanel getPanelTab1(){         
205
                if (panelTab1==null){
206
                        panelTab1 = new JPanel();        
207
                        panelTab1.setLayout(new GridBagLayout());
208
                        JPanel selectionImagenPanel= new JPanel();
209
                        JPanel aux= new JPanel();
210
                        BorderLayout bd=new BorderLayout();
211
                        aux.setLayout(bd);
212
                        aux.add(getPanelNorth(),BorderLayout.NORTH);
213
                        aux.add(getPanelSouth(),BorderLayout.SOUTH);
214
                        selectionImagenPanel.add(aux);
215
                        GridBagConstraints c = new GridBagConstraints();
216
                        c.fill = GridBagConstraints.BOTH;
217
                        c.insets=new Insets(2,2,2,2);
218
                        c.weightx = 1;
219
                        c.weighty = 0.1;
220
                        c.gridx = 0;
221
                        c.gridy = 0;
222
                        panelTab1.add(selectionImagenPanel, c);
223
                 }
224
                 return panelTab1;
225
         }
226

    
227
         
228
         /**
229
          * @return Panel para el tab de opciones.
230
          */
231
        private JPanel getPanelTab2(){         
232
                if (panelTab2==null){
233
                        panelTab2 = new JPanel();        
234
                        panelTab2.setLayout(new GridBagLayout());
235
                                
236
                        JPanel parameterPanel= new JPanel();
237
                        TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this, "parametros"));
238
                        topBorder.setTitlePosition(TitledBorder.TOP);
239
                        JPanel aux= new JPanel();
240
                        aux.setPreferredSize(new Dimension(300,110));
241
                                
242
                        BorderLayout bd=new BorderLayout();
243
                        aux.setLayout(bd);
244
                        parameterPanel.add(aux);
245
                                
246
                        parameterPanel.setBorder(topBorder);
247
                        BorderLayout bordlayout= new BorderLayout();
248
                        parameterPanel.setLayout(bordlayout);
249
                        parameterPanel.add(new JPanel(),BorderLayout.NORTH);
250
                        GridBagConstraints c = new GridBagConstraints();
251
                        c.fill = GridBagConstraints.BOTH;
252
                        c.insets=new Insets(2,2,2,2);
253
                        c.weightx = 1;
254
                        c.weighty = 1;
255
                        c.gridx = 0;
256
                        c.gridy = 0;
257
                        panelTab2.add(parameterPanel, c);
258
                                
259
        
260
                        // Insercion del panel de las clases
261
                        c.fill = GridBagConstraints.BOTH;
262
                        c.insets=new Insets(2,2,2,2);
263
                        c.weightx = 0.05;
264
                        c.weighty = 0.05;
265
                        c.gridx = 0;
266
                        c.gridy = 1; 
267
                                
268
                        panelTab2.add(getOutputOptionsPanel(), c);                        
269
                }
270
                return panelTab2; 
271
         }
272
         
273
        
274
         /**
275
         * @return panel con las opciones de salida.
276
         */
277
        public JPanel getOutputOptionsPanel() {
278
                        
279
                if (nombreCapa==null){ 
280
                        nombreCapa=new JPanel();
281
                        nombreCapa.setPreferredSize(new Dimension(400,130));
282
                        TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this, "salida"));
283
                        topBorder.setTitlePosition(TitledBorder.TOP);
284
                        nombreCapa.setBorder(topBorder);
285
                        GridBagConstraints gridBagConstraints;
286
                        JPanel radioPanel = new JPanel();
287
                        radioPanel.setLayout(new GridBagLayout());
288
                        radioPanel.setBorder(BorderFactory.createTitledBorder(""));
289
                        ButtonGroup buttonGroup = new ButtonGroup();
290
                        buttonGroup.add(getRadioMemory());
291
                        gridBagConstraints = new java.awt.GridBagConstraints();
292
                        gridBagConstraints.gridx = 0;
293
                        gridBagConstraints.gridy = 1;
294
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
295
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
296
                        radioPanel.add(getRadioMemory(),gridBagConstraints);
297
                        buttonGroup.add(getRadioFile());
298
                        gridBagConstraints = new java.awt.GridBagConstraints();
299
                        gridBagConstraints.gridx = 0;
300
                        gridBagConstraints.gridy = 2;
301
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
302
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
303
                        radioPanel.add(getRadioFile(),gridBagConstraints);
304
                        //Establece la separacion entre los elementos
305
                        nombreCapa.setLayout(new GridBagLayout());
306
                        gridBagConstraints = new java.awt.GridBagConstraints();
307
                        gridBagConstraints.gridx = 0;
308
                        gridBagConstraints.gridy = 0;
309
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
310
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
311
                        nombreCapa.add(new JLabel(("Nombre:"),SwingConstants.RIGHT ),gridBagConstraints);
312
                                
313
                        gridBagConstraints = new java.awt.GridBagConstraints();
314
                        gridBagConstraints.gridx = 1;
315
                        gridBagConstraints.gridy = 0;
316
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
317
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
318
                        nombreCapa.add(getJTextNombreCapa(),gridBagConstraints);
319
                        
320
                        gridBagConstraints = new java.awt.GridBagConstraints();
321
                        gridBagConstraints.gridx = 2;
322
                        gridBagConstraints.gridy = 0;
323
                        gridBagConstraints.anchor = GridBagConstraints.WEST;
324
                        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
325
                        nombreCapa.add(radioPanel,gridBagConstraints);        
326
                }
327
                        return nombreCapa;
328
                }
329
                
330
                
331
                
332
        /**
333
         * @return JRadioButton de generar en memoria
334
         */
335
        public JRadioButton getRadioMemory(){
336
                if (rButtonMemory == null){
337
                        rButtonMemory = new JRadioButton(PluginServices.getText(this,"a_memoria"),true);
338
                        rButtonMemory.addActionListener(this);
339
                }
340
                return rButtonMemory;
341
        }
342
                
343
                
344
                
345
        /**
346
        * @return JRadioButton de generar fichero
347
        */        
348
        public JRadioButton getRadioFile(){
349
                        if (rButtonFile == null){
350
                                rButtonFile = new JRadioButton(PluginServices.getText(this,"a_fichero"));
351
                                rButtonFile.addActionListener(this);
352
                        }
353
                        return rButtonFile;
354
        }
355

    
356
        /**
357
         * @return javax.swing.JTextField
358
         */        
359
        public JTextField getJTextNombreCapa() {
360
                if (jTextNombreCapa==null) {
361
                        jTextNombreCapa=new JTextField(10);
362
                        jTextNombreCapa.setText(RasterLibrary.getOnlyLayerName());
363
                        jTextNombreCapa.addFocusListener(this);
364
                }
365
                        return jTextNombreCapa;        
366
        }
367
                 
368
                 
369
        /**
370
         * Especificar el nombre de la nueva capa para el recuadro de texto asign?ndo
371
         * en cada llamada un nombre consecutivo.
372
         */
373
         public void updateNewLayerText() {
374
                         getJTextNombreCapa().setText(RasterLibrary.getOnlyLayerName());
375
         }
376
        
377
         
378

    
379
        /**
380
         * Acciones ante la modificaci?n de las capas seleccionadas en panelNorth 
381
         * */
382
         public void propertyChange(PropertyChangeEvent evt) {
383
                getPanelSouth().setNameLayers(getPanelNorth().getSelectedLayers());
384
                getPanelSouth().updateCombo();
385
                getPanelSouth().updateRoisTable();
386
         }        
387
         
388
        
389
         /**
390
         * Devuelve la ruta del fichero donde se va a guardar, en caso de guardarse
391
         * en memoria, calcula el nombre sin preguntar y devuelve la ruta.
392
         * @return string con la ruta de salida
393
         */
394
        public String getFileSelected() {
395
                String path = "";
396
                if (getRadioFile().isSelected()) {
397
                        JFileChooser chooser = new JFileChooser(FileOpenWizard.getLastPath());
398
                        chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero"));
399
                        //A?adimos las extensiones que hayan sido registradas en el driver
400
                        String[] extList = GeoRasterWriter.getDriversExtensions();
401
                        for(int i=0;i<extList.length;i++)
402
                                chooser.addChoosableFileFilter(new ExtendedFileFilter(extList[i]));
403

    
404
                        if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION)
405
                                return null;
406

    
407
                        FileOpenWizard.setLastPath(chooser.getSelectedFile().getPath().substring(0, chooser.getSelectedFile().getPath().lastIndexOf(File.separator)));
408
                        ExtendedFileFilter fileFilter = (ExtendedFileFilter) chooser.getFileFilter();
409
                        path = fileFilter.getNormalizedFilename(chooser.getSelectedFile());
410
                        
411
                } else {
412
                        String file = getJTextNombreCapa().getText();
413
                        path = Utilities.createTempDirectory() + File.separator + getJTextNombreCapa().getText() + ".tif";
414
                        if(file.compareTo(RasterLibrary.getOnlyLayerName()) == 0) 
415
                                RasterLibrary.usesOnlyLayerName();
416
                        updateNewLayerText();
417
                }
418
                return path;        
419
        }
420
         
421
        
422
        /**
423
         * Acciones al presionar los botones aceptar, aplicar o cancelar
424
         * Cancelar se cierra el dialogo
425
         * Aceptar se comprueba las opciones seleccionadas. si la opcion de histogramMatching se encuentra seleccionada, si no se dispone del hostograma
426
         * de referencia.Obtenido el histograma (con un proceso histogramProcess), se lanza el proceso de HistogramMatching para cada una de las capas seleccionadas.
427
         * Una vez finalizado, se comprueba que la opci?n de mosaicos se encuentra activa. En caso afirmativo se lanza el proceso de mosaico con los par?metros 
428
         * correspondientes.
429
         * */
430
        public void actionButtonPressed(ButtonsPanelEvent e) {
431
                // Al pulsar Cancelar la ventana se cierra y se refresca la vista
432
                if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
433
                        close();
434
                }
435
                
436
                if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
437
                        apply();
438
                        close();
439
                }
440
                
441
                if (e.getButton() == ButtonsPanel.BUTTON_APPLY) {
442
                        apply();
443
                }
444
        }
445
        
446
        
447
        /** M?todo que lanza la ejecuci?n del histogramMatchProcess */
448
        private void applyHistogramMatchProcess(){
449
                try{
450
                        FLyrRasterSE capas[]= new FLyrRasterSE[getPanelSouth().getLayers().getLayersCount()];
451
                        hmMasterRaster= (FLyrRasterSE) getPanelSouth().getLayers().getLayer((String)getPanelSouth().getMasterImageCombo().getSelectedItem());
452
                        
453
                        IRasterDataSource dsetCopy = null; 
454
                        dsetCopy = hmMasterRaster.getDataSource().newDataset();
455
                        BufferFactory bufferFactory = new BufferFactory(dsetCopy);
456
                        bufferFactory.setDrawableBands(hmMasterRaster.getRenderBands());
457
                        if (!RasterBuffer.loadInMemory(dsetCopy))
458
                                bufferFactory.setReadOnly(true);        
459
                        bufferFactory.setAreaOfInterest();
460
                        Histogram histogramReference = bufferFactory.getRasterBuf().getHistogram();
461
                                
462
                        //Histogram histogramReference=hmMasterRaster.getDataSource().getHistogram();
463
                        for(int i=0; i<getPanelSouth().getLayers().getLayersCount();i++)
464
                                if(!hmMasterRaster.getName().equals(getPanelSouth().getLayers().getLayer(i).getName())){
465
                                        capas[i]= (FLyrRasterSE) getPanelSouth().getLayers().getLayer(i).cloneLayer();
466
                                }
467
                                else
468
                                        masterRasterPosition = i;
469
                
470
                        File tempHMDir = new File(Utilities.createTempDirectory()+File.separator+"HMResults");
471
                        tempHMDir.mkdir();
472
                        
473
                        HistogramMatchProcess proceso = new HistogramMatchProcess();
474
                        proceso.addParam("masterHistogram",histogramReference);
475
                        proceso.addParam("numbands",new Integer(3)); //*********************************
476
                        proceso.addParam("inputRasterLayers",capas);
477
                        proceso.addParam("outputPath",tempHMDir.getAbsolutePath());
478
                        proceso.setActions(this);
479
                        proceso.start();
480
        
481
                }catch (Exception e2) {                
482
                        RasterToolsUtil.messageBoxError(PluginServices.getText(this, "apply_histogramMatching_filter_error"), this, e2);                
483
                }
484
        }
485
        
486
        
487
         
488
        /**
489
         * Acciones que se realizan al finalizar de crear los recortes de imagen.
490
         * Este m?todo es llamado por el thread TailRasterProcess al finalizar.
491
         */
492
        public void loadLayerInToc(String fileName) {
493
                if(!new File(fileName).exists())
494
                        return;
495
                try {
496
                        RasterToolsUtil.loadLayer(PluginServices.getMDIManager().getWindowInfo(view).getTitle(), fileName, null);
497
                } catch (RasterNotLoadException e) {
498
                        RasterToolsUtil.messageBoxError("error_cargar_capa", this, e);
499
                }
500
        }
501

    
502
        /*
503
         * (non-Javadoc)
504
         * @see org.gvsig.rastertools.IProcessActions#end(java.lang.Object)
505
         */
506
        public void end(Object param) {        
507
                switch (currentProcess){
508
                case 0: //HM
509
                        currentProcess = this.PREMOSAICING;
510
                        applyHistogramMatchProcess();
511
                        break;
512
                case 1: //HMS
513
                        currentProcess = this.MOSAICING;
514
                        FLyrRasterSE inputRasterLayers[] =  (FLyrRasterSE[]) param;
515
                        if (applyHistogramM)
516
                                inputRasterLayers[masterRasterPosition] = hmMasterRaster;
517
                        if(getPanelSouth().getRButtomEdge().isSelected())
518
                                applyFeatherPorcess((FLyrRasterSE[]) inputRasterLayers);
519
                        else
520
                                applyBasicProcess((FLyrRasterSE[] )inputRasterLayers);
521
                        break;
522
                case 2: //MOSAICING
523
                        currentProcess = this.LOADING;
524
                        resultLayer = (FLyrRasterSE)param;
525
                        loadLayer();
526
                        //Borrar las ficheros intermedios (el resultado del H.M.)
527
                        File tempDir = new File(Utilities.createTempDirectory()+File.separator+"HMResults");
528
                        File filesToDelete[] = tempDir.listFiles();
529
                        if (filesToDelete!=null)
530
                                for (int i = 0; i<filesToDelete.length; i++)
531
                                        filesToDelete[i].delete();
532
                        tempDir.delete();
533
                        break;
534
                }
535
        }
536
        
537
        private void applyFeatherPorcess(FLyrRasterSE inputRasterLayers[]) {
538
                FeatherProcessBuff featherProcess= new FeatherProcessBuff();
539
                
540
                featherProcess.addParam("inputRasterLayers",inputRasterLayers);
541
                featherProcess.addParam("outputPath", getFileSelected());
542
                featherProcess.setActions(this);
543
                featherProcess.start();
544
        }
545

    
546

    
547
        private void applyBasicProcess(FLyrRasterSE inputRasterLayers[]) {
548
                MosaicProcess proceso= new MosaicProcess ();
549
                try {
550
                        proceso.addParam("inputRasterLayers",inputRasterLayers);
551
                        //proceso.addParam("layers",getPanelSouth().getLayers().cloneLayer());
552
                } catch (Exception e1) {
553
                        e1.printStackTrace();
554
                }
555
                proceso.addParam("methodCode",new Integer(getPanelSouth().getComboOverlapFunction().getSelectedIndex()));
556
                proceso.addParam("outputPath",getFileSelected());
557
                proceso.setActions(this);
558
                proceso.start();
559
        }
560

    
561

    
562
        private void loadLayer() {
563
                view.getMapControl().getMapContext().getLayers().addLayer(resultLayer);
564
                view.getMapControl().getMapContext().endAtomicEvent();
565
                view.getMapControl().getMapContext().invalidate();
566
        }
567

    
568

    
569
        public void windowActivated() {        
570
        }
571
        
572
        public void windowClosed() {
573
        }
574
        
575
        public void focusGained(FocusEvent arg0) {
576
        }
577

    
578
        public void focusLost(FocusEvent arg0) {
579
                // TODO Auto-generated method stub        
580
        }
581

    
582
        public void actionPerformed(ActionEvent e) {
583
                // TODO Auto-generated method stub
584
        }
585

    
586

    
587
        public void actionValueChanged(PropertyEvent e) {
588
                updateNewLayerText();
589
        }
590

    
591

    
592
        public void interrupted() {
593
                // TODO Auto-generated method stub
594
                
595
        }
596
        
597
        
598
        /** Acciones al aplicar */
599
        void apply(){
600
                applyHistogramM = getPanelSouth().getCheckHistogramMatching().isSelected();
601
                
602
                if(applyHistogramM){        
603
                        currentProcess = this.HM;
604
                        try{
605
                                FLyrRasterSE rasterReferencia= (FLyrRasterSE) getPanelSouth().getLayers().getLayer((String)getPanelSouth().getMasterImageCombo().getSelectedItem());
606
                                // Si el histograma no esta calculado se calcula
607
                                HistogramProcess histoCalculus= new HistogramProcess();
608
                                histoCalculus.addParam("histogramable", (IHistogramable)rasterReferencia.getDataSource());
609
                                histoCalculus.setActions(this);
610
                                histoCalculus.start();
611
                        
612
                                // cuando el proceso termina se lanzara e HistogramMatching;
613
                                        
614
                        }catch (Exception e2) {                
615
                                RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_getting_referenceHistogram"), this, e2);                
616
                        }        
617
                }
618
                else{
619
                        currentProcess = this.PREMOSAICING;
620
                        inputRasterLayers= new FLyrRasterSE[getPanelSouth().getLayers().getLayersCount()];
621
                        for(int i=0; i<inputRasterLayers.length;i++)
622
                                inputRasterLayers[i]=(FLyrRasterSE) getPanelSouth().getLayers().getLayer(i);
623
                        this.end(inputRasterLayers);
624
                }
625
        }
626

    
627

    
628
        public Object getWindowProfile() {
629
                return WindowInfo.PROPERTIES_PROFILE;
630
        }
631
        
632
}