Revision 26348 branches/v2_0_0_prep/extensions/extRemoteSensing/src/org/gvsig/remotesensing/mosaic/gui/MosaicDialog.java

View differences:

MosaicDialog.java
40 40

  
41 41
package org.gvsig.remotesensing.mosaic.gui;
42 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

  
43 52
import java.awt.BorderLayout;
44 53
import java.awt.Dimension;
45 54
import java.awt.GridBagConstraints;
......
51 60
import java.awt.event.FocusListener;
52 61
import java.beans.PropertyChangeEvent;
53 62
import java.beans.PropertyChangeListener;
63
import java.io.File;
54 64

  
55 65
import javax.swing.BorderFactory;
56 66
import javax.swing.ButtonGroup;
67
import javax.swing.JFileChooser;
57 68
import javax.swing.JLabel;
58 69
import javax.swing.JPanel;
59 70
import javax.swing.JRadioButton;
......
62 73
import javax.swing.SwingConstants;
63 74
import javax.swing.border.TitledBorder;
64 75

  
76
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
65 77
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
66 78
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
67 79
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
68 80
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
81
import org.gvsig.raster.IProcessActions;
69 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;
70 90
import org.gvsig.raster.util.PropertyEvent;
71 91
import org.gvsig.raster.util.PropertyListener;
72
import org.gvsig.remotesensing.mosaic.process.HistogramMatchingProcess;
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;
73 97
import org.gvsig.remotesensing.mosaic.process.MosaicProcess;
74 98

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

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

  
85 111
	private static final long serialVersionUID = 2847035927527203595L;
86 112
	private SelectLayersFromViewPanel northPanel = null;
......
94 120
	private JRadioButton 			rButtonFile=null;
95 121
	private JTextField 				jTextNombreCapa=null;
96 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
	
97 135
	/**
98 136
	 * Constructor
99 137
	 * @param width Ancho del panel
......
108 146
	 	tabbedPane.addTab(PluginServices.getText(this, "operacion"), getPanelTab1());
109 147
		tabbedPane.addTab(PluginServices.getText(this, "opciones"), getPanelTab2());
110 148
		this.add(tabbedPane, BorderLayout.CENTER);
111
		//this.add(getPanelSouth(), BorderLayout.CENTER);
112 149
		this.addButtonPressedListener(this);
113 150
	}
114 151
	
115 152
	
116 153
	public WindowInfo getWindowInfo() {
117
		WindowInfo m_viewinfo = new WindowInfo(WindowInfo.PALETTE);
154
		WindowInfo m_viewinfo = new WindowInfo(WindowInfo.RESIZABLE);
118 155
		m_viewinfo.setTitle(PluginServices.getText(this, "mosaicos"));
119 156
		m_viewinfo.setHeight(this.getHeight());
120 157
		m_viewinfo.setWidth(this.getWidth());
121 158
		return m_viewinfo;
122 159
	}
123 160

  
124
	public void actionButtonPressed(ButtonsPanelEvent e) {
125
		// Al pulsar Cancelar la ventana se cierra y se refresca la vista
126
		if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
127
			close();
128
		}
129 161

  
130
		// Al pulsar Aceptar simplemente la ventana se cierra
131
		if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
132
			
133
			if(getPanelSouth().getCheckHistogramMatching().isSelected()){
134
			
135
				HistogramMatchingProcess process= new HistogramMatchingProcess();
136
				try {
137
					process.addParam("rasterSource", getPanelSouth().getLayers().getLayer(0).cloneLayer());
138
				} catch (Exception e1) {
139
					// TODO Auto-generated catch block
140
					e1.printStackTrace();
141
				}
142
				process.addParam("rasterReference", getPanelSouth().getLayers().getLayer((String)getPanelSouth().getMasterImageCombo().getSelectedItem()));
143
				process.addParam("contexto",view.getMapControl().getMapContext());
144
				process.start();
145
			}
146
		
147
			if(getPanelSouth().getCheckFeathering().isSelected()){
148
				MosaicProcess proceso= new MosaicProcess ();
149
				try {
150
					proceso.addParam("layers",getPanelSouth().getLayers().cloneLayer());
151
				} catch (Exception e1) {
152
					// TODO Auto-generated catch block
153
					e1.printStackTrace();
154
				}
155
				proceso.addParam("numbands",new Integer(3));
156
				proceso.addParam("codOp",new Integer(getPanelSouth().getComboOverlapFunction().getSelectedIndex()));
157
				proceso.addParam("filename",new String(getJTextNombreCapa().getText()+".tif"));
158
				proceso.addParam("vista",view);
159
				proceso.start();
160
			}
161
			
162
			/**/
163

  
164
		}
165
	}
166
	
167 162
	/**
168 163
	 * Acciones a ejecutar cuando se cancela
169 164
	 */
......
174 169
			// Si la ventana no se puede eliminar no hacemos nada
175 170
		}
176 171
	}
177
	
178

  
179
	public void windowActivated() {	
180
	}
181

  
182
	
172
		
183 173
	/**
184
	 * M?todo que realiza acciones al cerrar el dialogo como eliminar los graphis 
185
	 * de la vista
186
	 * */
187
	public void windowClosed() {
188
	}
189

  
190

  
191
	
192
	/**
193 174
	 *  @return northPanel. Panel principal
194 175
	 * */
195 176
	public SelectLayersFromViewPanel getPanelNorth() {
......
216 197
		return mapControl;
217 198
	}
218 199

  
219

  
220

  
221
	public void propertyChange(PropertyChangeEvent evt) {
222
		getPanelSouth().setNameLayers(getPanelNorth().getSelectedLayers());
223
		getPanelSouth().updateCombo();
224
		getPanelSouth().updateRoisTable();
225
	}
226

  
227 200
	
228
	
229 201
	/**
230 202
	 * @return panel para el tab operacion.
231 203
	 */
......
248 220
			c.gridx = 0;
249 221
			c.gridy = 0;
250 222
			panelTab1.add(selectionImagenPanel, c);
251
			
252 223
		 }
253 224
		 return panelTab1;
254 225
	 }
......
294 265
			c.gridx = 0;
295 266
			c.gridy = 1; 
296 267
				
297
			panelTab2.add(getOutputOptionsPanel(), c);
298
					
268
			panelTab2.add(getOutputOptionsPanel(), c);			
299 269
		}
300 270
		return panelTab2; 
301 271
	 }
......
305 275
	 * @return panel con las opciones de salida.
306 276
	 */
307 277
	public JPanel getOutputOptionsPanel() {
308
			if (nombreCapa==null){ 
309
				nombreCapa=new JPanel();
310
				nombreCapa.setPreferredSize(new Dimension(400,130));
311
				TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this, "salida"));
312
				topBorder.setTitlePosition(TitledBorder.TOP);
313
				nombreCapa.setBorder(topBorder);
314
				GridBagConstraints gridBagConstraints;
315
				JPanel radioPanel = new JPanel();
316
				radioPanel.setLayout(new GridBagLayout());
317
				radioPanel.setBorder(BorderFactory.createTitledBorder(""));
318
				ButtonGroup buttonGroup = new ButtonGroup();
319
				buttonGroup.add(getRadioMemory());
320
				gridBagConstraints = new java.awt.GridBagConstraints();
321
				gridBagConstraints.gridx = 0;
322
				gridBagConstraints.gridy = 1;
323
				gridBagConstraints.anchor = GridBagConstraints.WEST;
324
				gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
325
				radioPanel.add(getRadioMemory(),gridBagConstraints);
326
				buttonGroup.add(getRadioFile());
327
				gridBagConstraints = new java.awt.GridBagConstraints();
328
				gridBagConstraints.gridx = 0;
329
				gridBagConstraints.gridy = 2;
330
				gridBagConstraints.anchor = GridBagConstraints.WEST;
331
				gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
332
				radioPanel.add(getRadioFile(),gridBagConstraints);
333
				//Establece la separacion entre los elementos
334
				nombreCapa.setLayout(new GridBagLayout());
335
				gridBagConstraints = new java.awt.GridBagConstraints();
336
				gridBagConstraints.gridx = 0;
337
				gridBagConstraints.gridy = 0;
338
				gridBagConstraints.anchor = GridBagConstraints.WEST;
339
				gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
340
				nombreCapa.add(new JLabel(("Nombre:"),SwingConstants.RIGHT ),gridBagConstraints);
341
					
342
				gridBagConstraints = new java.awt.GridBagConstraints();
343
				gridBagConstraints.gridx = 1;
344
				gridBagConstraints.gridy = 0;
345
				gridBagConstraints.anchor = GridBagConstraints.WEST;
346
				gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
347
				nombreCapa.add(getJTextNombreCapa(),gridBagConstraints);
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);
348 312
				
349
				gridBagConstraints = new java.awt.GridBagConstraints();
350
				gridBagConstraints.gridx = 2;
351
				gridBagConstraints.gridy = 0;
352
				gridBagConstraints.anchor = GridBagConstraints.WEST;
353
				gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
354
				nombreCapa.add(radioPanel,gridBagConstraints);	
355
			}
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
		}
356 327
			return nombreCapa;
357 328
		}
358 329
		
......
390 361
			jTextNombreCapa=new JTextField(10);
391 362
			jTextNombreCapa.setText(RasterLibrary.getOnlyLayerName());
392 363
			jTextNombreCapa.addFocusListener(this);
393
	//		RasterLibrary.addOnlyLayerNameListener(this);
394 364
		}
395 365
			return jTextNombreCapa;	
396 366
	}
397 367
		 
398
		 	
399 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
	
400 575
	public void focusGained(FocusEvent arg0) {
401 576
	}
402 577

  
......
410 585

  
411 586

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

  
591

  
592
	public void interrupted() {
413 593
		// TODO Auto-generated method stub
594
		
414 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
	
415 632
}

Also available in: Unified diff