root / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / classification / gui / ClassificationPanel.java @ 24986
History | View | Annotate | Download (24.3 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 |
package org.gvsig.remotesensing.classification.gui; |
41 |
|
42 |
import java.awt.BorderLayout; |
43 |
import java.awt.Dimension; |
44 |
import java.awt.GridBagConstraints; |
45 |
import java.awt.GridBagLayout; |
46 |
import java.awt.Insets; |
47 |
import java.awt.event.ActionEvent; |
48 |
import java.awt.event.ActionListener; |
49 |
import java.awt.event.FocusEvent; |
50 |
import java.awt.event.FocusListener; |
51 |
import java.io.File; |
52 |
|
53 |
import javax.swing.BorderFactory; |
54 |
import javax.swing.ButtonGroup; |
55 |
import javax.swing.ComboBoxModel; |
56 |
import javax.swing.DefaultComboBoxModel; |
57 |
import javax.swing.JFileChooser; |
58 |
import javax.swing.JLabel; |
59 |
import javax.swing.JOptionPane; |
60 |
import javax.swing.JPanel; |
61 |
import javax.swing.JRadioButton; |
62 |
import javax.swing.JScrollPane; |
63 |
import javax.swing.JTabbedPane; |
64 |
import javax.swing.JTable; |
65 |
import javax.swing.JTextField; |
66 |
import javax.swing.SwingConstants; |
67 |
import javax.swing.border.CompoundBorder; |
68 |
import javax.swing.border.EmptyBorder; |
69 |
import javax.swing.border.TitledBorder; |
70 |
|
71 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
72 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
73 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
74 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
75 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
76 |
import org.gvsig.raster.RasterLibrary; |
77 |
import org.gvsig.raster.dataset.GeoRasterWriter; |
78 |
import org.gvsig.raster.grid.GridException; |
79 |
import org.gvsig.raster.util.ExtendedFileFilter; |
80 |
import org.gvsig.raster.util.PropertyEvent; |
81 |
import org.gvsig.raster.util.PropertyListener; |
82 |
import org.gvsig.raster.util.RasterToolsUtil; |
83 |
import org.gvsig.rastertools.roi.ui.ROIsTablePanel; |
84 |
import org.gvsig.remotesensing.classification.ClassificationGeneralProcess; |
85 |
import org.gvsig.remotesensing.classification.ClassificationMaximumLikelihoodProcess; |
86 |
import org.gvsig.remotesensing.classification.ClassificationMinimumDistanceProcess; |
87 |
import org.gvsig.remotesensing.classification.ClassificationParallelepipedProcess; |
88 |
import org.gvsig.remotesensing.classification.NoSupervisedClassificationProcess; |
89 |
import org.gvsig.remotesensing.principalcomponents.gui.BandTableFormat; |
90 |
|
91 |
import com.iver.andami.PluginServices; |
92 |
import com.iver.andami.Utilities; |
93 |
import com.iver.andami.ui.mdiManager.IWindow; |
94 |
import com.iver.andami.ui.mdiManager.IWindowListener; |
95 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
96 |
import com.iver.cit.gvsig.addlayer.fileopen.FileOpenWizard; |
97 |
import com.iver.cit.gvsig.fmap.MapContext; |
98 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
99 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
100 |
import com.iver.utiles.swing.JComboBox; |
101 |
|
102 |
/**
|
103 |
* Clase que define la interfaz del proceso de clasificacion de una imagen. Recoge la
|
104 |
* imagen a clasificar con la selecci?n de bandas correspondiente. Posibilita la elecci?n del
|
105 |
* m?todo empleado y da la posibilidad de manejar la lista de clases que intervienen en el proceso.
|
106 |
* Permite ajustar algunos parametros del proceso y configurar las opciones de salida.
|
107 |
*
|
108 |
* @author Alejandro Mu?oz Sanchez (alejandro.munoz@uclm.es)
|
109 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)
|
110 |
* @version 19/10/2007
|
111 |
*/
|
112 |
public class ClassificationPanel extends DefaultButtonsPanel implements PropertyListener, IWindow, IWindowListener, |
113 |
ButtonsPanelListener,ActionListener,FocusListener{ |
114 |
|
115 |
private static final long serialVersionUID = 1L; |
116 |
private View view = null; |
117 |
private int width=400; |
118 |
private int height=555; |
119 |
private MapContext m_MapContext=null; |
120 |
private FLayers layers=null; |
121 |
private int nMethods = 4; |
122 |
private JRadioButton rButtonFile=null; |
123 |
private JRadioButton rButtonMemory =null; |
124 |
private JTextField jTextNombreCapa=null; |
125 |
private JPanel panelTab1=null; |
126 |
private JPanel panelTab2=null; |
127 |
private JScrollPane scrollBandas=null; |
128 |
private JScrollPane scrollTable=null; |
129 |
private JComboBox comboLayers= null; |
130 |
private JComboBox comboMethods= null; |
131 |
private ROIsTablePanel roisTablePanel= null; |
132 |
private BandTableFormat mModeloTabla=null; |
133 |
private JTable jTableBandas=null; |
134 |
private JPanel nombreCapa=null; |
135 |
private int[] bands= null; |
136 |
private JPanel panelParametros=null; |
137 |
private JTextField stevField = null; |
138 |
private JPanel panelParametros2=null; |
139 |
private JTextField numClases = null; |
140 |
/**
|
141 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
142 |
*/
|
143 |
public WindowInfo getWindowInfo(){
|
144 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
|
145 |
m_viewinfo.setWidth(width); |
146 |
m_viewinfo.setHeight(height); |
147 |
m_viewinfo.setTitle(PluginServices.getText(this,"classification")); |
148 |
m_viewinfo.setX(300);
|
149 |
return m_viewinfo;
|
150 |
} |
151 |
|
152 |
/**
|
153 |
* @param view vista de la aplicacion
|
154 |
*/
|
155 |
public ClassificationPanel(View view) { |
156 |
this.view = view;
|
157 |
m_MapContext = view.getModel().getMapContext(); |
158 |
layers = m_MapContext.getLayers(); |
159 |
this.setPreferredSize(new Dimension(width, height)); |
160 |
this.setSize(width, height);
|
161 |
this.setLayout(new BorderLayout(1, 1)); |
162 |
this.addButtonPressedListener(this); |
163 |
initialize(); |
164 |
} |
165 |
|
166 |
|
167 |
/**
|
168 |
* Inicializaci?n del cuadro de dialogo
|
169 |
*/
|
170 |
private void initialize(){ |
171 |
BorderLayout bd=new BorderLayout(); |
172 |
this.setLayout(bd);
|
173 |
TitledBorder topBorder = BorderFactory.createTitledBorder(" "); |
174 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
175 |
this.setBorder(new CompoundBorder(topBorder,new EmptyBorder(0,5,5,5))); |
176 |
JTabbedPane tabbedPane = new JTabbedPane(); |
177 |
tabbedPane.addTab(PluginServices.getText(this, "operacion"), getPanelTab1()); |
178 |
tabbedPane.addTab(PluginServices.getText(this, "opciones"), getPanelTab2()); |
179 |
this.setLayout(new BorderLayout()); |
180 |
this.add(tabbedPane, BorderLayout.CENTER); |
181 |
getBandas(); |
182 |
} |
183 |
|
184 |
/**
|
185 |
* @return panel para el tab operacion.
|
186 |
*/
|
187 |
private JPanel getPanelTab1(){ |
188 |
if (panelTab1==null){ |
189 |
panelTab1 = new JPanel(); |
190 |
panelTab1.setLayout(new GridBagLayout()); |
191 |
|
192 |
// Panel superior opcion Selecion de imagen y bandas
|
193 |
JPanel selectionImagenPanel= new JPanel(); |
194 |
TitledBorder topBorder = BorderFactory.createTitledBorder(" Imagen"); |
195 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
196 |
JPanel aux= new JPanel(); |
197 |
aux.setPreferredSize(new Dimension(300,110)); |
198 |
|
199 |
BorderLayout bd=new BorderLayout(); |
200 |
aux.setLayout(bd); |
201 |
|
202 |
aux.add(getComboCapas(),BorderLayout.NORTH);
|
203 |
aux.add(getScrollBands(),BorderLayout.SOUTH);
|
204 |
selectionImagenPanel.add(aux); |
205 |
|
206 |
selectionImagenPanel.setBorder(topBorder); |
207 |
GridBagConstraints c = new GridBagConstraints(); |
208 |
c.fill = GridBagConstraints.BOTH;
|
209 |
c.insets=new Insets(2,2,2,2); |
210 |
c.weightx = 1;
|
211 |
c.weighty = 0.5;
|
212 |
c.gridx = 0;
|
213 |
c.gridy = 0;
|
214 |
panelTab1.add(selectionImagenPanel, c); |
215 |
|
216 |
|
217 |
// Panel seleccion metodo
|
218 |
JPanel methodPanel= new JPanel(); |
219 |
TitledBorder topBorderMethod = BorderFactory.createTitledBorder("Metodo"); |
220 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
221 |
methodPanel.setBorder(topBorderMethod); |
222 |
methodPanel.add(new JLabel(PluginServices.getText(this, "metodo"))); |
223 |
methodPanel.add(getComboMethods()); |
224 |
c.fill = GridBagConstraints.BOTH;
|
225 |
c.insets=new Insets(2,2,2,2); |
226 |
c.weightx = 1;
|
227 |
c.weighty = 0.1;
|
228 |
c.gridx = 0;
|
229 |
c.gridy = 1;
|
230 |
panelTab1.add(methodPanel, c); |
231 |
|
232 |
// Insercion del panel de las clases
|
233 |
c.fill = GridBagConstraints.BOTH;
|
234 |
c.insets=new Insets(2,2,2,2); |
235 |
c.weightx = 1;
|
236 |
c.weighty = 1;
|
237 |
c.gridx = 0;
|
238 |
c.gridy = 2;
|
239 |
panelTab1.add(getRoisTablePanel(), c); |
240 |
} |
241 |
return panelTab1;
|
242 |
} |
243 |
|
244 |
/**
|
245 |
* @return Panel para el tab de opciones.
|
246 |
*/
|
247 |
private JPanel getPanelTab2(){ |
248 |
if (panelTab2==null){ |
249 |
panelTab2 = new JPanel(); |
250 |
panelTab2.setLayout(new GridBagLayout()); |
251 |
|
252 |
JPanel parameterPanel= new JPanel(); |
253 |
TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this, "parametros")); |
254 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
255 |
JPanel aux= new JPanel(); |
256 |
aux.setPreferredSize(new Dimension(300,110)); |
257 |
|
258 |
BorderLayout bd=new BorderLayout(); |
259 |
aux.setLayout(bd); |
260 |
|
261 |
//aux.add(new JButton(),BorderLayout.NORTH);
|
262 |
parameterPanel.add(aux); |
263 |
|
264 |
parameterPanel.setBorder(topBorder); |
265 |
BorderLayout bordlayout= new BorderLayout(); |
266 |
parameterPanel.setLayout(bordlayout); |
267 |
parameterPanel.add(getPanelParametros(),BorderLayout.NORTH);
|
268 |
parameterPanel.add(getPanelParametros2(),BorderLayout.CENTER);
|
269 |
GridBagConstraints c = new GridBagConstraints(); |
270 |
c.fill = GridBagConstraints.BOTH;
|
271 |
c.insets=new Insets(2,2,2,2); |
272 |
c.weightx = 1;
|
273 |
c.weighty = 1;
|
274 |
c.gridx = 0;
|
275 |
c.gridy = 0;
|
276 |
panelTab2.add(parameterPanel, c); |
277 |
|
278 |
// Insercion del panel de las clases
|
279 |
c.fill = GridBagConstraints.BOTH;
|
280 |
c.insets=new Insets(2,2,2,2); |
281 |
c.weightx = 0.05;
|
282 |
c.weighty = 0.05;
|
283 |
c.gridx = 0;
|
284 |
c.gridy = 1;
|
285 |
|
286 |
panelTab2.add(getOutputOptionsPanel(), c); |
287 |
|
288 |
} |
289 |
return panelTab2;
|
290 |
} |
291 |
|
292 |
|
293 |
// Paneel de parametros
|
294 |
|
295 |
JPanel getPanelParametros(){
|
296 |
if (panelParametros==null){ |
297 |
|
298 |
panelParametros= new JPanel(); |
299 |
panelParametros.add(new JLabel(PluginServices.getText(this,"max_stev_interval_multiplo"))); |
300 |
panelParametros.add(getStevField()); |
301 |
panelParametros.setVisible(false);
|
302 |
|
303 |
} |
304 |
return panelParametros;
|
305 |
} |
306 |
|
307 |
|
308 |
JPanel getPanelParametros2(){
|
309 |
if (panelParametros2==null){ |
310 |
BorderLayout bd= new BorderLayout(); |
311 |
panelParametros2= new JPanel(); |
312 |
panelParametros2.add(new JLabel(PluginServices.getText(this,"numClases")),BorderLayout.NORTH); |
313 |
panelParametros2.add(getNumClases()); |
314 |
panelParametros2.setVisible(false);
|
315 |
} |
316 |
return panelParametros2;
|
317 |
} |
318 |
|
319 |
|
320 |
/**
|
321 |
* @return Scroll con la tabla de clases intervienen en el proceso de clasificaci?n.
|
322 |
*/
|
323 |
public JScrollPane getScrollTable() { |
324 |
|
325 |
if(scrollTable==null){ |
326 |
scrollTable=new JScrollPane(); |
327 |
TitledBorder topBorder = BorderFactory.createTitledBorder((PluginServices.getText(this,"clases"))); |
328 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
329 |
scrollTable.setBorder(new CompoundBorder(topBorder,new EmptyBorder(2,2,2,2))); |
330 |
scrollTable.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
331 |
scrollTable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
332 |
} |
333 |
return scrollTable;
|
334 |
} |
335 |
|
336 |
/**
|
337 |
* @return javax.swing.JTextField
|
338 |
*/
|
339 |
public JTextField getJTextNombreCapa() { |
340 |
if (jTextNombreCapa==null) { |
341 |
jTextNombreCapa=new JTextField(10); |
342 |
jTextNombreCapa.setText(RasterLibrary.getOnlyLayerName()); |
343 |
jTextNombreCapa.addFocusListener(this);
|
344 |
RasterLibrary.addOnlyLayerNameListener(this);
|
345 |
} |
346 |
return jTextNombreCapa;
|
347 |
} |
348 |
|
349 |
|
350 |
/**
|
351 |
* Especificar el nombre de la nueva capa para el recuadro de texto asign?ndo
|
352 |
* en cada llamada un nombre consecutivo.
|
353 |
*/
|
354 |
public void updateNewLayerText() { |
355 |
getJTextNombreCapa().setText(RasterLibrary.getOnlyLayerName()); |
356 |
} |
357 |
|
358 |
/**
|
359 |
* @return JRadioButton de generar fichero
|
360 |
*/
|
361 |
public JRadioButton getRadioFile(){ |
362 |
if (rButtonFile == null){ |
363 |
rButtonFile = new JRadioButton(PluginServices.getText(this,"a_fichero")); |
364 |
rButtonFile.addActionListener(this);
|
365 |
} |
366 |
return rButtonFile;
|
367 |
} |
368 |
|
369 |
/**
|
370 |
* @return JRadioButton de generar en memoria
|
371 |
*/
|
372 |
public JRadioButton getRadioMemory(){ |
373 |
if (rButtonMemory == null){ |
374 |
rButtonMemory = new JRadioButton(PluginServices.getText(this,"a_memoria"),true); |
375 |
rButtonMemory.addActionListener(this);
|
376 |
} |
377 |
return rButtonMemory;
|
378 |
} |
379 |
|
380 |
|
381 |
/**
|
382 |
* @return JComboBox con los r?ster cargados en la vista.
|
383 |
*/
|
384 |
public JComboBox getComboCapas() { |
385 |
if (comboLayers==null){ |
386 |
ComboBoxModel jComboBoxLayersModel = new |
387 |
DefaultComboBoxModel(getLayerNames());
|
388 |
comboLayers = new JComboBox(); |
389 |
comboLayers.setModel(jComboBoxLayersModel); |
390 |
comboLayers.setEnabled(true);
|
391 |
comboLayers.addActionListener(this);
|
392 |
comboLayers.setSelectedIndex(0);
|
393 |
} |
394 |
return comboLayers;
|
395 |
} |
396 |
|
397 |
|
398 |
/**
|
399 |
* Acciones a ejecuar al cerrar el di?logo.
|
400 |
*/
|
401 |
public void close(){ |
402 |
try {
|
403 |
RasterLibrary.removeOnlyLayerNameListener(this);
|
404 |
PluginServices.getMDIManager().closeWindow(this);
|
405 |
} catch (ArrayIndexOutOfBoundsException ex) { |
406 |
// Si la ventana no se puede eliminar no hacemos nada
|
407 |
} |
408 |
} |
409 |
|
410 |
|
411 |
/**
|
412 |
* @return array de string con los nombre de las capas raster
|
413 |
*/
|
414 |
private String[] getLayerNames() { |
415 |
|
416 |
int i, capasraster=0; |
417 |
for (i = 0; i < layers.getLayersCount(); i++) { |
418 |
if (layers.getLayer(i)instanceof FLyrRasterSE) |
419 |
capasraster++; |
420 |
} |
421 |
// Solo se toman las capas raster.
|
422 |
String[] sNames = new String[capasraster]; |
423 |
capasraster=0;
|
424 |
|
425 |
for (i = 0; i < layers.getLayersCount(); i++) { |
426 |
if (layers.getLayer(i)instanceof FLyrRasterSE){ |
427 |
sNames[capasraster] =layers.getLayer(i).getName(); |
428 |
capasraster++; |
429 |
} |
430 |
} |
431 |
return sNames;
|
432 |
} |
433 |
|
434 |
|
435 |
/**
|
436 |
* Devuelve la ruta del fichero donde se va a guardar, en caso de guardarse
|
437 |
* en memoria, calcula el nombre sin preguntar y devuelve la ruta.
|
438 |
* @return string con la ruta de salida
|
439 |
*/
|
440 |
public String getFileSelected() { |
441 |
String path = ""; |
442 |
if (getRadioFile().isSelected()) {
|
443 |
JFileChooser chooser = new JFileChooser(FileOpenWizard.getLastPath()); |
444 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
445 |
//A?adimos las extensiones que hayan sido registradas en el driver
|
446 |
String[] extList = GeoRasterWriter.getDriversExtensions(); |
447 |
for(int i=0;i<extList.length;i++) |
448 |
chooser.addChoosableFileFilter(new ExtendedFileFilter(extList[i]));
|
449 |
|
450 |
if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) |
451 |
return null; |
452 |
|
453 |
FileOpenWizard.setLastPath(chooser.getSelectedFile().getPath().substring(0, chooser.getSelectedFile().getPath().lastIndexOf(File.separator))); |
454 |
ExtendedFileFilter fileFilter = (ExtendedFileFilter) chooser.getFileFilter(); |
455 |
path = fileFilter.getNormalizedFilename(chooser.getSelectedFile()); |
456 |
} else {
|
457 |
String file = getJTextNombreCapa().getText();
|
458 |
path = Utilities.createTempDirectory() + File.separator + getJTextNombreCapa().getText() + ".tif"; |
459 |
if(file.compareTo(RasterLibrary.getOnlyLayerName()) == 0) |
460 |
RasterLibrary.usesOnlyLayerName(); |
461 |
updateNewLayerText(); |
462 |
} |
463 |
return path;
|
464 |
} |
465 |
|
466 |
/**
|
467 |
* Acciones al aceptar
|
468 |
*/
|
469 |
public void accept(){ |
470 |
|
471 |
// Imagen que va a ser clasificada
|
472 |
FLyrRasterSE rasterLayer= ((FLyrRasterSE)layers.getLayer((String) getComboCapas().getSelectedItem()));
|
473 |
/*
|
474 |
* Bandas que intervienen en la clasificaci?n.
|
475 |
*/
|
476 |
boolean bandsSelected[] = getModeloTabla().getSeleccionadas(); |
477 |
int bandCount = 0; |
478 |
for (int i= 0; i<bandsSelected.length;i++) |
479 |
if(bandsSelected[i]==true) |
480 |
bandCount++; |
481 |
int bandList[] = new int[bandCount]; |
482 |
int index = 0; |
483 |
for (int i = 0; i < bandsSelected.length; i++){ |
484 |
if (bandsSelected[i])
|
485 |
{ bandList[index]=i; |
486 |
index++; |
487 |
} |
488 |
} |
489 |
|
490 |
ClassificationGeneralProcess process=null;
|
491 |
if(getComboMethods().getSelectedIndex()==0) |
492 |
process = new ClassificationMaximumLikelihoodProcess();
|
493 |
if(getComboMethods().getSelectedIndex()==1) |
494 |
process = new ClassificationMinimumDistanceProcess();
|
495 |
if(getComboMethods().getSelectedIndex()==2){ |
496 |
process= new ClassificationParallelepipedProcess();
|
497 |
process.addParam("dev", new Double(Double.parseDouble(getStevField().getText()))); |
498 |
} |
499 |
if(getComboMethods().getSelectedIndex()==3){ |
500 |
process= new NoSupervisedClassificationProcess();
|
501 |
process.addParam("numClases",new Integer(Integer.parseInt(getNumClases().getText()))); |
502 |
} |
503 |
process.addParam("layer",rasterLayer);
|
504 |
process.addParam("rois",getRoisTablePanel().getROIs());
|
505 |
process.addParam("bandList",bandList);
|
506 |
process.addParam("filename",getFileSelected());
|
507 |
process.addParam("view", view);
|
508 |
process.start(); |
509 |
} |
510 |
|
511 |
/*
|
512 |
* (non-Javadoc)
|
513 |
* @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
|
514 |
*/
|
515 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
516 |
// Bot?n de Aceptar
|
517 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
518 |
if(!(getRoisTablePanel().getROIs().isEmpty() && getComboMethods().getSelectedIndex()!=3)) |
519 |
{accept(); close();} |
520 |
else
|
521 |
JOptionPane.showMessageDialog(null, PluginServices.getText(this,"no_clases"), PluginServices.getText(this,"no_clases"),JOptionPane.WARNING_MESSAGE); |
522 |
} |
523 |
|
524 |
// Bot?n de Aplicar
|
525 |
if (e.getButton() == ButtonsPanel.BUTTON_APPLY) {
|
526 |
if(!(getRoisTablePanel().getROIs().isEmpty()&& getComboMethods().getSelectedIndex()!=3)) |
527 |
accept(); |
528 |
else
|
529 |
JOptionPane.showMessageDialog(null, PluginServices.getText(this,"no_clases"), PluginServices.getText(this,"clasificacion"),JOptionPane.WARNING_MESSAGE); |
530 |
} |
531 |
|
532 |
// Bot?n de Cerrar
|
533 |
if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
|
534 |
close(); |
535 |
} |
536 |
} |
537 |
|
538 |
/**
|
539 |
*Actualizaci?n de las bandas cuando cambia la imagen seleccionada
|
540 |
*/
|
541 |
public void actionPerformed(ActionEvent arg0) { |
542 |
if(arg0.getSource()==getComboCapas()){
|
543 |
getBandas(); |
544 |
} |
545 |
if(arg0.getSource()==getComboMethods()){
|
546 |
if(getComboMethods().getSelectedIndex()==2){ |
547 |
getPanelParametros().setVisible(true);
|
548 |
getPanelParametros2().setVisible(false);
|
549 |
getScrollTable().setEnabled(true);
|
550 |
} |
551 |
else if(getComboMethods().getSelectedIndex()==3){ |
552 |
getPanelParametros().setVisible(false);
|
553 |
getPanelParametros2().setVisible(true);
|
554 |
getScrollTable().setEnabled(false);
|
555 |
} |
556 |
else{
|
557 |
getPanelParametros().setVisible(false);
|
558 |
getPanelParametros2().setVisible(false);
|
559 |
getScrollTable().setEnabled(true);
|
560 |
} |
561 |
updateUI(); |
562 |
} |
563 |
} |
564 |
|
565 |
|
566 |
/**
|
567 |
* @return tabla conlas bandas de la imagen
|
568 |
*/
|
569 |
private JTable getTableBands(){ |
570 |
if (jTableBandas==null){ |
571 |
jTableBandas=new JTable(getModeloTabla()); |
572 |
} |
573 |
return jTableBandas;
|
574 |
} |
575 |
|
576 |
|
577 |
/**
|
578 |
* @return modelo de tabla
|
579 |
* @see BandTableFormat
|
580 |
*/
|
581 |
public BandTableFormat getModeloTabla() {
|
582 |
if(mModeloTabla==null){ |
583 |
mModeloTabla=new BandTableFormat();
|
584 |
} |
585 |
return mModeloTabla;
|
586 |
} |
587 |
|
588 |
/**
|
589 |
* @return
|
590 |
* */
|
591 |
public JTextField getStevField(){ |
592 |
if (stevField==null){ |
593 |
stevField= new JTextField(5); |
594 |
stevField.setText("3.0");
|
595 |
} |
596 |
return stevField;
|
597 |
} |
598 |
|
599 |
/**
|
600 |
* @return scroll con bandas del r?ster
|
601 |
*/
|
602 |
public JScrollPane getScrollBands() { |
603 |
if (scrollBandas==null){ |
604 |
scrollBandas=new JScrollPane(); |
605 |
} |
606 |
getTableBands().getColumn("").setPreferredWidth(30); |
607 |
scrollBandas.setPreferredSize(new Dimension(250,80)); |
608 |
scrollBandas.setViewportView(getTableBands()); |
609 |
scrollBandas.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
610 |
return scrollBandas;
|
611 |
} |
612 |
|
613 |
|
614 |
/**
|
615 |
* @return panel de gesti?n de ROIs
|
616 |
*/
|
617 |
public ROIsTablePanel getRoisTablePanel() {
|
618 |
if (roisTablePanel==null){ |
619 |
roisTablePanel= new ROIsTablePanel();
|
620 |
} |
621 |
return roisTablePanel;
|
622 |
} |
623 |
|
624 |
|
625 |
/**
|
626 |
* @return JComboBox con los m?todos de clasificaci?n
|
627 |
*/
|
628 |
public JComboBox getComboMethods() { |
629 |
if (comboMethods==null){ |
630 |
comboMethods= new JComboBox(); |
631 |
String[] sNames = new String[nMethods]; |
632 |
sNames[0]= new String(PluginServices.getText(this, "metodo_maxima_probabilidad")); |
633 |
sNames[1]= new String(PluginServices.getText(this, "metodo_minima_diatancia")); |
634 |
sNames[2]= new String(PluginServices.getText(this, "metodo_paralelepipedos")); |
635 |
sNames[3]= new String(PluginServices.getText(this, "metodo_noSupervisado")); |
636 |
ComboBoxModel jComboBoxLayersModel = new DefaultComboBoxModel(sNames); |
637 |
comboMethods.setModel(jComboBoxLayersModel); |
638 |
comboMethods.setEnabled(true);
|
639 |
comboMethods.addActionListener(this);
|
640 |
} |
641 |
return comboMethods;
|
642 |
} |
643 |
|
644 |
/**
|
645 |
* Toma las Bandas de la imagen seleccionada en el combo Imagen
|
646 |
*/
|
647 |
public void getBandas(){ |
648 |
|
649 |
// Antes de insertar se borra lo anterior
|
650 |
getModeloTabla().LimpiarLista(); |
651 |
|
652 |
FLyrRasterSE rasterLayer= (FLyrRasterSE)layers.getLayer((String)getComboCapas().getSelectedItem());
|
653 |
String bandas[]=new String[rasterLayer.getBandCount()]; |
654 |
bands= new int[rasterLayer.getBandCount()]; |
655 |
if (layers.getLayer((String)getComboCapas().getSelectedItem()) instanceof FLyrRasterSE ){ |
656 |
for (int j=0; j<rasterLayer.getBandCount(); j++){ |
657 |
String s=(PluginServices.getText(this,"banda"))+(j+1); |
658 |
bandas[j]=s; |
659 |
bands[j]=j; |
660 |
} |
661 |
for (int i=0;i<bandas.length;i++) |
662 |
getModeloTabla().addRow(bandas[i],true);
|
663 |
getTableBands().updateUI(); |
664 |
try {
|
665 |
getRoisTablePanel().setFLayer((FLyrRasterSE)layers.getLayer((String)getComboCapas().getSelectedItem()));
|
666 |
} catch (GridException e) {
|
667 |
RasterToolsUtil.messageBoxError(PluginServices.getText(this, "grid_error"), this, e); |
668 |
} |
669 |
} |
670 |
} |
671 |
|
672 |
|
673 |
/**
|
674 |
* @return panel con las opciones de salida.
|
675 |
*/
|
676 |
public JPanel getOutputOptionsPanel() { |
677 |
if (nombreCapa==null){ |
678 |
nombreCapa=new JPanel(); |
679 |
nombreCapa.setPreferredSize(new Dimension(400,130)); |
680 |
TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this, "salida")); |
681 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
682 |
nombreCapa.setBorder(topBorder); |
683 |
GridBagConstraints gridBagConstraints;
|
684 |
JPanel radioPanel = new JPanel(); |
685 |
radioPanel.setLayout(new GridBagLayout()); |
686 |
radioPanel.setBorder(BorderFactory.createTitledBorder("")); |
687 |
ButtonGroup buttonGroup = new ButtonGroup(); |
688 |
buttonGroup.add(getRadioMemory()); |
689 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
690 |
gridBagConstraints.gridx = 0;
|
691 |
gridBagConstraints.gridy = 1;
|
692 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
693 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
694 |
radioPanel.add(getRadioMemory(),gridBagConstraints); |
695 |
buttonGroup.add(getRadioFile()); |
696 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
697 |
gridBagConstraints.gridx = 0;
|
698 |
gridBagConstraints.gridy = 2;
|
699 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
700 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
701 |
radioPanel.add(getRadioFile(),gridBagConstraints); |
702 |
//Establece la separacion entre los elementos
|
703 |
nombreCapa.setLayout(new GridBagLayout()); |
704 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
705 |
gridBagConstraints.gridx = 0;
|
706 |
gridBagConstraints.gridy = 0;
|
707 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
708 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
709 |
nombreCapa.add(new JLabel(("Nombre:"),SwingConstants.RIGHT ),gridBagConstraints); |
710 |
|
711 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
712 |
gridBagConstraints.gridx = 1;
|
713 |
gridBagConstraints.gridy = 0;
|
714 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
715 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
716 |
nombreCapa.add(getJTextNombreCapa(),gridBagConstraints); |
717 |
|
718 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
719 |
gridBagConstraints.gridx = 2;
|
720 |
gridBagConstraints.gridy = 0;
|
721 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
722 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
723 |
nombreCapa.add(radioPanel,gridBagConstraints); |
724 |
} |
725 |
return nombreCapa;
|
726 |
} |
727 |
|
728 |
|
729 |
/**
|
730 |
* Acciones al cerrar.
|
731 |
*/
|
732 |
public void windowClosed() { |
733 |
/*
|
734 |
* Limpiar los gr?ficos de la vista:
|
735 |
*/
|
736 |
getRoisTablePanel().clearRoiGraphics(); |
737 |
getRoisTablePanel().getMapControl().rePaintDirtyLayers(); |
738 |
getRoisTablePanel().setPreviousTool(); |
739 |
} |
740 |
|
741 |
public void focusGained(FocusEvent arg0) { |
742 |
|
743 |
} |
744 |
|
745 |
public void focusLost(FocusEvent arg0) { |
746 |
// TODO Auto-generated method stub
|
747 |
|
748 |
} |
749 |
|
750 |
public void windowActivated() {} |
751 |
|
752 |
public void actionValueChanged(PropertyEvent e) { |
753 |
updateNewLayerText(); |
754 |
} |
755 |
|
756 |
public JTextField getNumClases() { |
757 |
if (numClases==null){ |
758 |
numClases= new JTextField(5); |
759 |
numClases.setText("5");
|
760 |
} |
761 |
return numClases;
|
762 |
} |
763 |
|
764 |
public Object getWindowProfile() { |
765 |
return WindowInfo.PROPERTIES_PROFILE;
|
766 |
} |
767 |
} |
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|