root / branches / v2_0_0_prep / extensions / extRemoteSensing / src / org / gvsig / remotesensing / mosaic / gui / MosaicDialog.java @ 31496
History | View | Annotate | Download (20 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.JLabel; |
68 |
import javax.swing.JPanel; |
69 |
import javax.swing.JRadioButton; |
70 |
import javax.swing.JTabbedPane; |
71 |
import javax.swing.JTextField; |
72 |
import javax.swing.SwingConstants; |
73 |
import javax.swing.border.TitledBorder; |
74 |
|
75 |
import org.gvsig.andami.PluginServices; |
76 |
import org.gvsig.andami.Utilities; |
77 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
78 |
import org.gvsig.andami.ui.mdiManager.IWindowListener; |
79 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
80 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
81 |
import org.gvsig.fmap.mapcontrol.MapControl; |
82 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
83 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
84 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
85 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
86 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
87 |
import org.gvsig.gui.beans.swing.JFileChooser; |
88 |
import org.gvsig.raster.IProcessActions; |
89 |
import org.gvsig.raster.RasterLibrary; |
90 |
import org.gvsig.raster.buffer.BufferFactory; |
91 |
import org.gvsig.raster.buffer.RasterBuffer; |
92 |
import org.gvsig.raster.dataset.GeoRasterWriter; |
93 |
import org.gvsig.raster.dataset.IRasterDataSource; |
94 |
import org.gvsig.raster.datastruct.Histogram; |
95 |
import org.gvsig.raster.hierarchy.IHistogramable; |
96 |
import org.gvsig.raster.util.ExtendedFileFilter; |
97 |
import org.gvsig.raster.util.PropertyEvent; |
98 |
import org.gvsig.raster.util.PropertyListener; |
99 |
import org.gvsig.raster.util.RasterNotLoadException; |
100 |
import org.gvsig.raster.util.RasterToolsUtil; |
101 |
import org.gvsig.rastertools.histogram.HistogramProcess; |
102 |
import org.gvsig.remotesensing.mosaic.process.FeatherProcessBuff; |
103 |
import org.gvsig.remotesensing.mosaic.process.HistogramMatchProcess; |
104 |
import org.gvsig.remotesensing.mosaic.process.MosaicProcess; |
105 |
|
106 |
|
107 |
public class MosaicDialog extends DefaultButtonsPanel implements PropertyListener, IWindow, IWindowListener, |
108 |
ButtonsPanelListener,ActionListener,FocusListener,PropertyChangeListener,IProcessActions{ |
109 |
|
110 |
private static final long serialVersionUID = 2847035927527203595L; |
111 |
private SelectLayersFromViewPanel northPanel = null; |
112 |
private MethodMosaicPanel southPanel = null; |
113 |
private MapControl mapControl = null; |
114 |
private DefaultViewPanel view=null; |
115 |
private JPanel panelTab1=null; |
116 |
private JPanel panelTab2=null; |
117 |
private JPanel nombreCapa=null; |
118 |
private JRadioButton rButtonMemory=null; |
119 |
private JRadioButton rButtonFile=null; |
120 |
private JTextField jTextNombreCapa=null; |
121 |
|
122 |
private final int HM = 0; |
123 |
private final int PREMOSAICING = 1; |
124 |
private final int MOSAICING = 2; |
125 |
private final int LOADING = 3; |
126 |
private int currentProcess = this.HM; |
127 |
|
128 |
private FLyrRasterSE hmMasterRaster = null; |
129 |
private int masterRasterPosition = 0 ; |
130 |
private FLyrRasterSE inputRasterLayers[]; |
131 |
private FLyrRasterSE resultLayer = null; |
132 |
private boolean applyHistogramM = false; |
133 |
|
134 |
/**
|
135 |
* Constructor
|
136 |
* @param width Ancho del panel
|
137 |
* @param height Alto del panel
|
138 |
*/
|
139 |
public MosaicDialog(int width, int height, DefaultViewPanel view) { |
140 |
super();
|
141 |
this.view= view;
|
142 |
this.setSize(width, height);
|
143 |
this.setLayout(new BorderLayout()); |
144 |
JTabbedPane tabbedPane = new JTabbedPane(); |
145 |
tabbedPane.addTab(PluginServices.getText(this, "operacion"), getPanelTab1()); |
146 |
tabbedPane.addTab(PluginServices.getText(this, "opciones"), getPanelTab2()); |
147 |
this.add(tabbedPane, BorderLayout.CENTER); |
148 |
this.addButtonPressedListener(this); |
149 |
} |
150 |
|
151 |
|
152 |
public WindowInfo getWindowInfo() {
|
153 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.RESIZABLE);
|
154 |
m_viewinfo.setTitle(PluginServices.getText(this, "mosaicos")); |
155 |
m_viewinfo.setHeight(this.getHeight());
|
156 |
m_viewinfo.setWidth(this.getWidth());
|
157 |
return m_viewinfo;
|
158 |
} |
159 |
|
160 |
|
161 |
/**
|
162 |
* Acciones a ejecutar cuando se cancela
|
163 |
*/
|
164 |
public void close(){ |
165 |
try {
|
166 |
PluginServices.getMDIManager().closeWindow(this);
|
167 |
} catch (ArrayIndexOutOfBoundsException ex) { |
168 |
// Si la ventana no se puede eliminar no hacemos nada
|
169 |
} |
170 |
} |
171 |
|
172 |
/**
|
173 |
* @return northPanel. Panel principal
|
174 |
* */
|
175 |
public SelectLayersFromViewPanel getPanelNorth() {
|
176 |
if (northPanel == null){ |
177 |
northPanel = new SelectLayersFromViewPanel(view);
|
178 |
northPanel.getTableImages().addPropertyChangeListener(this);
|
179 |
} |
180 |
return northPanel;
|
181 |
} |
182 |
|
183 |
/**
|
184 |
* @return northPanel. Panel principal
|
185 |
* */
|
186 |
public MethodMosaicPanel getPanelSouth() {
|
187 |
if (southPanel == null){ |
188 |
southPanel = new MethodMosaicPanel(northPanel.getSelectedLayers(),view);
|
189 |
} |
190 |
return southPanel;
|
191 |
} |
192 |
|
193 |
|
194 |
|
195 |
public MapControl getMapControl() {
|
196 |
return mapControl;
|
197 |
} |
198 |
|
199 |
|
200 |
/**
|
201 |
* @return panel para el tab operacion.
|
202 |
*/
|
203 |
private JPanel getPanelTab1(){ |
204 |
if (panelTab1==null){ |
205 |
panelTab1 = new JPanel(); |
206 |
panelTab1.setLayout(new GridBagLayout()); |
207 |
JPanel selectionImagenPanel= new JPanel(); |
208 |
JPanel aux= new JPanel(); |
209 |
BorderLayout bd=new BorderLayout(); |
210 |
aux.setLayout(bd); |
211 |
aux.add(getPanelNorth(),BorderLayout.NORTH);
|
212 |
aux.add(getPanelSouth(),BorderLayout.SOUTH);
|
213 |
selectionImagenPanel.add(aux); |
214 |
GridBagConstraints c = new GridBagConstraints(); |
215 |
c.fill = GridBagConstraints.BOTH;
|
216 |
c.insets=new Insets(2,2,2,2); |
217 |
c.weightx = 1;
|
218 |
c.weighty = 0.1;
|
219 |
c.gridx = 0;
|
220 |
c.gridy = 0;
|
221 |
panelTab1.add(selectionImagenPanel, c); |
222 |
} |
223 |
return panelTab1;
|
224 |
} |
225 |
|
226 |
|
227 |
/**
|
228 |
* @return Panel para el tab de opciones.
|
229 |
*/
|
230 |
private JPanel getPanelTab2(){ |
231 |
if (panelTab2==null){ |
232 |
panelTab2 = new JPanel(); |
233 |
panelTab2.setLayout(new GridBagLayout()); |
234 |
|
235 |
JPanel parameterPanel= new JPanel(); |
236 |
TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this, "parametros")); |
237 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
238 |
JPanel aux= new JPanel(); |
239 |
aux.setPreferredSize(new Dimension(300,110)); |
240 |
|
241 |
BorderLayout bd=new BorderLayout(); |
242 |
aux.setLayout(bd); |
243 |
parameterPanel.add(aux); |
244 |
|
245 |
parameterPanel.setBorder(topBorder); |
246 |
BorderLayout bordlayout= new BorderLayout(); |
247 |
parameterPanel.setLayout(bordlayout); |
248 |
parameterPanel.add(new JPanel(),BorderLayout.NORTH); |
249 |
GridBagConstraints c = new GridBagConstraints(); |
250 |
c.fill = GridBagConstraints.BOTH;
|
251 |
c.insets=new Insets(2,2,2,2); |
252 |
c.weightx = 1;
|
253 |
c.weighty = 1;
|
254 |
c.gridx = 0;
|
255 |
c.gridy = 0;
|
256 |
panelTab2.add(parameterPanel, c); |
257 |
|
258 |
|
259 |
// Insercion del panel de las clases
|
260 |
c.fill = GridBagConstraints.BOTH;
|
261 |
c.insets=new Insets(2,2,2,2); |
262 |
c.weightx = 0.05;
|
263 |
c.weighty = 0.05;
|
264 |
c.gridx = 0;
|
265 |
c.gridy = 1;
|
266 |
|
267 |
panelTab2.add(getOutputOptionsPanel(), c); |
268 |
} |
269 |
return panelTab2;
|
270 |
} |
271 |
|
272 |
|
273 |
/**
|
274 |
* @return panel con las opciones de salida.
|
275 |
*/
|
276 |
public JPanel getOutputOptionsPanel() { |
277 |
|
278 |
if (nombreCapa==null){ |
279 |
nombreCapa=new JPanel(); |
280 |
nombreCapa.setPreferredSize(new Dimension(400,130)); |
281 |
TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this, "salida")); |
282 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
283 |
nombreCapa.setBorder(topBorder); |
284 |
GridBagConstraints gridBagConstraints;
|
285 |
JPanel radioPanel = new JPanel(); |
286 |
radioPanel.setLayout(new GridBagLayout()); |
287 |
radioPanel.setBorder(BorderFactory.createTitledBorder("")); |
288 |
ButtonGroup buttonGroup = new ButtonGroup(); |
289 |
buttonGroup.add(getRadioMemory()); |
290 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
291 |
gridBagConstraints.gridx = 0;
|
292 |
gridBagConstraints.gridy = 1;
|
293 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
294 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
295 |
radioPanel.add(getRadioMemory(),gridBagConstraints); |
296 |
buttonGroup.add(getRadioFile()); |
297 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
298 |
gridBagConstraints.gridx = 0;
|
299 |
gridBagConstraints.gridy = 2;
|
300 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
301 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
302 |
radioPanel.add(getRadioFile(),gridBagConstraints); |
303 |
//Establece la separacion entre los elementos
|
304 |
nombreCapa.setLayout(new GridBagLayout()); |
305 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
306 |
gridBagConstraints.gridx = 0;
|
307 |
gridBagConstraints.gridy = 0;
|
308 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
309 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
310 |
nombreCapa.add(new JLabel(("Nombre:"),SwingConstants.RIGHT ),gridBagConstraints); |
311 |
|
312 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
313 |
gridBagConstraints.gridx = 1;
|
314 |
gridBagConstraints.gridy = 0;
|
315 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
316 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
317 |
nombreCapa.add(getJTextNombreCapa(),gridBagConstraints); |
318 |
|
319 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
320 |
gridBagConstraints.gridx = 2;
|
321 |
gridBagConstraints.gridy = 0;
|
322 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
323 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
324 |
nombreCapa.add(radioPanel,gridBagConstraints); |
325 |
} |
326 |
return nombreCapa;
|
327 |
} |
328 |
|
329 |
|
330 |
|
331 |
/**
|
332 |
* @return JRadioButton de generar en memoria
|
333 |
*/
|
334 |
public JRadioButton getRadioMemory(){ |
335 |
if (rButtonMemory == null){ |
336 |
rButtonMemory = new JRadioButton(PluginServices.getText(this,"a_memoria"),true); |
337 |
rButtonMemory.addActionListener(this);
|
338 |
} |
339 |
return rButtonMemory;
|
340 |
} |
341 |
|
342 |
|
343 |
|
344 |
/**
|
345 |
* @return JRadioButton de generar fichero
|
346 |
*/
|
347 |
public JRadioButton getRadioFile(){ |
348 |
if (rButtonFile == null){ |
349 |
rButtonFile = new JRadioButton(PluginServices.getText(this,"a_fichero")); |
350 |
rButtonFile.addActionListener(this);
|
351 |
} |
352 |
return rButtonFile;
|
353 |
} |
354 |
|
355 |
/**
|
356 |
* @return javax.swing.JTextField
|
357 |
*/
|
358 |
public JTextField getJTextNombreCapa() { |
359 |
if (jTextNombreCapa==null) { |
360 |
jTextNombreCapa=new JTextField(10); |
361 |
jTextNombreCapa.setText(RasterLibrary.getOnlyLayerName()); |
362 |
jTextNombreCapa.addFocusListener(this);
|
363 |
} |
364 |
return jTextNombreCapa;
|
365 |
} |
366 |
|
367 |
|
368 |
/**
|
369 |
* Especificar el nombre de la nueva capa para el recuadro de texto asign?ndo
|
370 |
* en cada llamada un nombre consecutivo.
|
371 |
*/
|
372 |
public void updateNewLayerText() { |
373 |
getJTextNombreCapa().setText(RasterLibrary.getOnlyLayerName()); |
374 |
} |
375 |
|
376 |
|
377 |
|
378 |
/**
|
379 |
* Acciones ante la modificaci?n de las capas seleccionadas en panelNorth
|
380 |
* */
|
381 |
public void propertyChange(PropertyChangeEvent evt) { |
382 |
getPanelSouth().setNameLayers(getPanelNorth().getSelectedLayers()); |
383 |
getPanelSouth().updateCombo(); |
384 |
getPanelSouth().updateRoisTable(); |
385 |
} |
386 |
|
387 |
|
388 |
/**
|
389 |
* Devuelve la ruta del fichero donde se va a guardar, en caso de guardarse
|
390 |
* en memoria, calcula el nombre sin preguntar y devuelve la ruta.
|
391 |
* @return string con la ruta de salida
|
392 |
*/
|
393 |
public String getFileSelected() { |
394 |
String path = ""; |
395 |
if (getRadioFile().isSelected()) {
|
396 |
JFileChooser chooser = new JFileChooser("MOSAIC_DIALOG",JFileChooser.getLastPath("MOSAIC_DIALOG", null)); |
397 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
398 |
//A?adimos las extensiones que hayan sido registradas en el driver
|
399 |
String[] extList = GeoRasterWriter.getDriversExtensions(); |
400 |
for(int i=0;i<extList.length;i++) |
401 |
chooser.addChoosableFileFilter(new ExtendedFileFilter(extList[i]));
|
402 |
|
403 |
if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) |
404 |
return null; |
405 |
|
406 |
JFileChooser.setLastPath("MOSAIC_DIALOG", chooser.getSelectedFile()); |
407 |
ExtendedFileFilter fileFilter = (ExtendedFileFilter) chooser.getFileFilter(); |
408 |
path = fileFilter.getNormalizedFilename(chooser.getSelectedFile()); |
409 |
|
410 |
} else {
|
411 |
String file = getJTextNombreCapa().getText();
|
412 |
path = Utilities.createTempDirectory() + File.separator + getJTextNombreCapa().getText() + ".tif"; |
413 |
if(file.compareTo(RasterLibrary.getOnlyLayerName()) == 0) |
414 |
RasterLibrary.usesOnlyLayerName(); |
415 |
updateNewLayerText(); |
416 |
} |
417 |
return path;
|
418 |
} |
419 |
|
420 |
|
421 |
/**
|
422 |
* Acciones al presionar los botones aceptar, aplicar o cancelar
|
423 |
* Cancelar se cierra el dialogo
|
424 |
* Aceptar se comprueba las opciones seleccionadas. si la opcion de histogramMatching se encuentra seleccionada, si no se dispone del hostograma
|
425 |
* de referencia.Obtenido el histograma (con un proceso histogramProcess), se lanza el proceso de HistogramMatching para cada una de las capas seleccionadas.
|
426 |
* 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
|
427 |
* correspondientes.
|
428 |
* */
|
429 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
430 |
// Al pulsar Cancelar la ventana se cierra y se refresca la vista
|
431 |
if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
|
432 |
close(); |
433 |
} |
434 |
|
435 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
436 |
apply(); |
437 |
close(); |
438 |
} |
439 |
|
440 |
if (e.getButton() == ButtonsPanel.BUTTON_APPLY) {
|
441 |
apply(); |
442 |
} |
443 |
} |
444 |
|
445 |
|
446 |
/** M?todo que lanza la ejecuci?n del histogramMatchProcess */
|
447 |
private void applyHistogramMatchProcess(){ |
448 |
try{
|
449 |
FLyrRasterSE capas[]= new FLyrRasterSE[getPanelSouth().getLayers().getLayersCount()]; |
450 |
hmMasterRaster= (FLyrRasterSE) getPanelSouth().getLayers().getLayer((String)getPanelSouth().getMasterImageCombo().getSelectedItem());
|
451 |
|
452 |
IRasterDataSource dsetCopy = null;
|
453 |
dsetCopy = hmMasterRaster.getDataSource().newDataset(); |
454 |
BufferFactory bufferFactory = new BufferFactory(dsetCopy);
|
455 |
bufferFactory.setDrawableBands(hmMasterRaster.getRenderBands()); |
456 |
if (!RasterBuffer.loadInMemory(dsetCopy))
|
457 |
bufferFactory.setReadOnly(true);
|
458 |
bufferFactory.setAreaOfInterest(); |
459 |
Histogram histogramReference = bufferFactory.getRasterBuf().getHistogram(); |
460 |
|
461 |
//Histogram histogramReference=hmMasterRaster.getDataSource().getHistogram();
|
462 |
for(int i=0; i<getPanelSouth().getLayers().getLayersCount();i++) |
463 |
if(!hmMasterRaster.getName().equals(getPanelSouth().getLayers().getLayer(i).getName())){
|
464 |
capas[i]= (FLyrRasterSE) getPanelSouth().getLayers().getLayer(i).cloneLayer(); |
465 |
} |
466 |
else
|
467 |
masterRasterPosition = i; |
468 |
|
469 |
File tempHMDir = new File(Utilities.createTempDirectory()+File.separator+"HMResults"); |
470 |
tempHMDir.mkdir(); |
471 |
|
472 |
HistogramMatchProcess proceso = new HistogramMatchProcess();
|
473 |
proceso.addParam("masterHistogram",histogramReference);
|
474 |
proceso.addParam("numbands",new Integer(3)); //********************************* |
475 |
proceso.addParam("inputRasterLayers",capas);
|
476 |
proceso.addParam("outputPath",tempHMDir.getAbsolutePath());
|
477 |
proceso.setActions(this);
|
478 |
proceso.start(); |
479 |
|
480 |
}catch (Exception e2) { |
481 |
RasterToolsUtil.messageBoxError(PluginServices.getText(this, "apply_histogramMatching_filter_error"), this, e2); |
482 |
} |
483 |
} |
484 |
|
485 |
|
486 |
|
487 |
/**
|
488 |
* Acciones que se realizan al finalizar de crear los recortes de imagen.
|
489 |
* Este m?todo es llamado por el thread TailRasterProcess al finalizar.
|
490 |
*/
|
491 |
public void loadLayerInToc(String fileName) { |
492 |
if(!new File(fileName).exists()) |
493 |
return;
|
494 |
try {
|
495 |
RasterToolsUtil.loadLayer(PluginServices.getMDIManager().getWindowInfo(view).getTitle(), fileName, null);
|
496 |
} catch (RasterNotLoadException e) {
|
497 |
RasterToolsUtil.messageBoxError("error_cargar_capa", this, e); |
498 |
} |
499 |
} |
500 |
|
501 |
/*
|
502 |
* (non-Javadoc)
|
503 |
* @see org.gvsig.rastertools.IProcessActions#end(java.lang.Object)
|
504 |
*/
|
505 |
public void end(Object param) { |
506 |
switch (currentProcess){
|
507 |
case 0: //HM |
508 |
currentProcess = this.PREMOSAICING;
|
509 |
applyHistogramMatchProcess(); |
510 |
break;
|
511 |
case 1: //HMS |
512 |
currentProcess = this.MOSAICING;
|
513 |
FLyrRasterSE inputRasterLayers[] = (FLyrRasterSE[]) param; |
514 |
if (applyHistogramM)
|
515 |
inputRasterLayers[masterRasterPosition] = hmMasterRaster; |
516 |
if(getPanelSouth().getRButtomEdge().isSelected())
|
517 |
applyFeatherPorcess((FLyrRasterSE[]) inputRasterLayers);
|
518 |
else
|
519 |
applyBasicProcess((FLyrRasterSE[] )inputRasterLayers);
|
520 |
break;
|
521 |
case 2: //MOSAICING |
522 |
currentProcess = this.LOADING;
|
523 |
resultLayer = (FLyrRasterSE)param; |
524 |
loadLayer(); |
525 |
//Borrar las ficheros intermedios (el resultado del H.M.)
|
526 |
File tempDir = new File(Utilities.createTempDirectory()+File.separator+"HMResults"); |
527 |
File filesToDelete[] = tempDir.listFiles(); |
528 |
if (filesToDelete!=null) |
529 |
for (int i = 0; i<filesToDelete.length; i++) |
530 |
filesToDelete[i].delete(); |
531 |
tempDir.delete(); |
532 |
break;
|
533 |
} |
534 |
} |
535 |
|
536 |
private void applyFeatherPorcess(FLyrRasterSE inputRasterLayers[]) { |
537 |
FeatherProcessBuff featherProcess= new FeatherProcessBuff();
|
538 |
|
539 |
featherProcess.addParam("inputRasterLayers",inputRasterLayers);
|
540 |
featherProcess.addParam("outputPath", getFileSelected());
|
541 |
featherProcess.setActions(this);
|
542 |
featherProcess.start(); |
543 |
} |
544 |
|
545 |
|
546 |
private void applyBasicProcess(FLyrRasterSE inputRasterLayers[]) { |
547 |
MosaicProcess proceso= new MosaicProcess ();
|
548 |
try {
|
549 |
proceso.addParam("inputRasterLayers",inputRasterLayers);
|
550 |
//proceso.addParam("layers",getPanelSouth().getLayers().cloneLayer());
|
551 |
} catch (Exception e1) { |
552 |
e1.printStackTrace(); |
553 |
} |
554 |
proceso.addParam("methodCode",new Integer(getPanelSouth().getComboOverlapFunction().getSelectedIndex())); |
555 |
proceso.addParam("outputPath",getFileSelected());
|
556 |
proceso.setActions(this);
|
557 |
proceso.start(); |
558 |
} |
559 |
|
560 |
|
561 |
private void loadLayer() { |
562 |
view.getMapControl().getMapContext().getLayers().addLayer(resultLayer); |
563 |
view.getMapControl().getMapContext().endAtomicEvent(); |
564 |
view.getMapControl().getMapContext().invalidate(); |
565 |
} |
566 |
|
567 |
|
568 |
public void windowActivated() { |
569 |
} |
570 |
|
571 |
public void windowClosed() { |
572 |
} |
573 |
|
574 |
public void focusGained(FocusEvent arg0) { |
575 |
} |
576 |
|
577 |
public void focusLost(FocusEvent arg0) { |
578 |
// TODO Auto-generated method stub
|
579 |
} |
580 |
|
581 |
public void actionPerformed(ActionEvent e) { |
582 |
// TODO Auto-generated method stub
|
583 |
} |
584 |
|
585 |
|
586 |
public void actionValueChanged(PropertyEvent e) { |
587 |
updateNewLayerText(); |
588 |
} |
589 |
|
590 |
|
591 |
public void interrupted() { |
592 |
// TODO Auto-generated method stub
|
593 |
|
594 |
} |
595 |
|
596 |
|
597 |
/** Acciones al aplicar */
|
598 |
void apply(){
|
599 |
applyHistogramM = getPanelSouth().getCheckHistogramMatching().isSelected(); |
600 |
|
601 |
if(applyHistogramM){
|
602 |
currentProcess = this.HM;
|
603 |
try{
|
604 |
FLyrRasterSE rasterReferencia= (FLyrRasterSE) getPanelSouth().getLayers().getLayer((String)getPanelSouth().getMasterImageCombo().getSelectedItem());
|
605 |
// Si el histograma no esta calculado se calcula
|
606 |
HistogramProcess histoCalculus= new HistogramProcess();
|
607 |
histoCalculus.addParam("histogramable", (IHistogramable)rasterReferencia.getDataSource());
|
608 |
histoCalculus.setActions(this);
|
609 |
histoCalculus.start(); |
610 |
|
611 |
// cuando el proceso termina se lanzara e HistogramMatching;
|
612 |
|
613 |
}catch (Exception e2) { |
614 |
RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_getting_referenceHistogram"), this, e2); |
615 |
} |
616 |
} |
617 |
else{
|
618 |
currentProcess = this.PREMOSAICING;
|
619 |
inputRasterLayers= new FLyrRasterSE[getPanelSouth().getLayers().getLayersCount()];
|
620 |
for(int i=0; i<inputRasterLayers.length;i++) |
621 |
inputRasterLayers[i]=(FLyrRasterSE) getPanelSouth().getLayers().getLayer(i); |
622 |
this.end(inputRasterLayers);
|
623 |
} |
624 |
} |
625 |
|
626 |
|
627 |
public Object getWindowProfile() { |
628 |
return WindowInfo.PROPERTIES_PROFILE;
|
629 |
} |
630 |
|
631 |
} |