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