svn-gvsig-desktop / branches / v10 / extensions / extRasterTools / src / org / gvsig / rasterTools / pansharpening / ui / PanSharpeningPanel.java @ 9056
History | View | Annotate | Download (27.4 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.gvsig.rasterTools.pansharpening.ui; |
25 |
|
26 |
import java.awt.Component; |
27 |
import java.awt.Dimension; |
28 |
import java.awt.FlowLayout; |
29 |
import java.awt.GridBagConstraints; |
30 |
import java.awt.GridBagLayout; |
31 |
import java.awt.event.ActionEvent; |
32 |
import java.awt.event.ActionListener; |
33 |
import java.awt.event.KeyEvent; |
34 |
import java.awt.event.KeyListener; |
35 |
import java.awt.image.DataBuffer; |
36 |
import java.io.File; |
37 |
import java.util.Vector; |
38 |
|
39 |
import javax.swing.AbstractCellEditor; |
40 |
import javax.swing.ButtonGroup; |
41 |
import javax.swing.JCheckBox; |
42 |
import javax.swing.JPanel; |
43 |
import javax.swing.JRadioButton; |
44 |
import javax.swing.JScrollPane; |
45 |
import javax.swing.JSlider; |
46 |
import javax.swing.JTable; |
47 |
import javax.swing.JTextField; |
48 |
import javax.swing.SwingConstants; |
49 |
import javax.swing.SwingUtilities; |
50 |
import javax.swing.event.ChangeEvent; |
51 |
import javax.swing.event.ChangeListener; |
52 |
import javax.swing.event.TableModelEvent; |
53 |
import javax.swing.event.TableModelListener; |
54 |
import javax.swing.table.DefaultTableModel; |
55 |
import javax.swing.table.TableCellEditor; |
56 |
import javax.swing.table.TableCellRenderer; |
57 |
import javax.swing.table.TableColumn; |
58 |
|
59 |
import org.cresques.filter.IRasterOperationsRegistrablePanels; |
60 |
import org.cresques.filter.IStackManager; |
61 |
import org.cresques.filter.RasterFilterStackManager; |
62 |
import org.cresques.io.GeoRasterFile; |
63 |
import org.cresques.ui.filter.FilterRasterDialogPanel; |
64 |
import org.cresques.ui.filter.RasterTransparencyPanel; |
65 |
import org.cresques.ui.raster.IResize; |
66 |
import org.gvsig.rasterTools.pansharpening.filter.PanSharpeningStackManager; |
67 |
|
68 |
import com.iver.andami.PluginServices; |
69 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
70 |
import com.iver.cit.gvsig.gui.panels.IRasterPropertiesRegistrable; |
71 |
import com.iver.cit.gvsig.gui.panels.PropertiesRasterDialog; |
72 |
import com.iver.cit.gvsig.project.documents.view.toc.gui.FLyrRasterAdjustPropertiesTocMenuEntry; |
73 |
|
74 |
/**
|
75 |
* Selecciona las bandas visibles en un raster. Contiene una tabla con una fila por cada
|
76 |
* banda de la imagen. Por medio de checkbox se selecciona para cada RGB que banda de la
|
77 |
* imagen ser? visualizada.
|
78 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
79 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
80 |
*/
|
81 |
public class PanSharpeningPanel extends JPanel implements TableModelListener, |
82 |
KeyListener, ChangeListener, |
83 |
ActionListener,
|
84 |
IRasterPropertiesRegistrable, |
85 |
IRasterOperationsRegistrablePanels, |
86 |
IResize{ |
87 |
final private static long serialVersionUID = -3370601314380922368L; |
88 |
|
89 |
private final static String[] columnNames = { " ", "Band" }; |
90 |
|
91 |
|
92 |
private int wComp = 445, hComp = 239; |
93 |
private int wNorth = wComp - 5, hNorth = hComp -14; |
94 |
private int wCheck = wNorth - 100, hCheck = 30; |
95 |
private int wSouth = wNorth - 30, hSouth = 62; |
96 |
private int wPSliders = wSouth - 10, hPSliders = 30; |
97 |
private int wTable = wNorth - 40, hTable = hNorth - 165; |
98 |
private int wSlider = wPSliders - 220, hSlider = 16; |
99 |
|
100 |
/**
|
101 |
* Nombre del panel
|
102 |
*/
|
103 |
private String nom = "Pansharp"; |
104 |
private JTable rgbTable = null; |
105 |
private JScrollPane rgbBandAssignPane = null; |
106 |
RGBBandAsignTableModel tableModel = null;
|
107 |
private int sizeX = 445; |
108 |
private int sizeY = 174; |
109 |
private JPanel activationPanel = null; |
110 |
private JCheckBox cbActiveSharpening = null; |
111 |
private JPanel pSharpNorth = null; |
112 |
private JPanel pSharpSouth = null; |
113 |
private JRadioButton rbBrovey = null; |
114 |
private JRadioButton rbHSL = null; |
115 |
private JPanel pHSL = null; |
116 |
private JSlider jSlider = null; |
117 |
private JTextField jTextField = null; |
118 |
private JPanel pBrovey = null; |
119 |
private JSlider slBrovey = null; |
120 |
private JTextField jTextField1 = null; |
121 |
private PanSharpeningStackManager pStackManager = null; |
122 |
|
123 |
/**
|
124 |
* This method initializes
|
125 |
*
|
126 |
*/
|
127 |
public PanSharpeningPanel() {
|
128 |
super();
|
129 |
initialize(); |
130 |
this.setTranslation();
|
131 |
} |
132 |
|
133 |
/**
|
134 |
* This method initializes this
|
135 |
*
|
136 |
* @return void
|
137 |
*/
|
138 |
void initialize() {
|
139 |
this.setPreferredSize(new Dimension(sizeX, sizeY)); |
140 |
this.setLayout(new FlowLayout()); |
141 |
this.setLocation(0, 0); |
142 |
this.setSize(wComp, hComp);
|
143 |
this.add(getPSharpNorth(), null); |
144 |
this.setTableEnabled(false); |
145 |
} |
146 |
|
147 |
/**
|
148 |
* Obtiene el nombre del panel
|
149 |
* @return Cadena con el nombre del panel
|
150 |
*/
|
151 |
public String getName(){ |
152 |
return this.nom; |
153 |
} |
154 |
|
155 |
/**
|
156 |
* Activa o desactiva la tabla de selecci?n de banda de refinado
|
157 |
* @param enable
|
158 |
*/
|
159 |
public void setTableEnabled(boolean enabled){ |
160 |
this.getRGBBandAssignPane().setEnabled(enabled);
|
161 |
this.getRGBTable().setEnabled(enabled);
|
162 |
this.getJSlider().setEnabled(enabled);
|
163 |
this.getJSlider1().setEnabled(enabled);
|
164 |
this.getJTextField().setEnabled(enabled);
|
165 |
this.getJTextField1().setEnabled(enabled);
|
166 |
this.getRbBrovey().setEnabled(enabled);
|
167 |
this.getRbHSL().setEnabled(enabled);
|
168 |
} |
169 |
|
170 |
/**
|
171 |
* Traducciones del panel
|
172 |
*/
|
173 |
public void setTranslation(){ |
174 |
this.getCbActiveSharpening().setText(PluginServices.getText(this,"onSharpening")); |
175 |
this.getPSharpNorth().setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"selectBandaRefinado"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
176 |
} |
177 |
|
178 |
/**
|
179 |
* This method initializes jTable
|
180 |
*
|
181 |
* @return javax.swing.JTable
|
182 |
*/
|
183 |
private JScrollPane getRGBBandAssignPane() { |
184 |
if (rgbBandAssignPane == null) { |
185 |
rgbBandAssignPane = new JScrollPane(getRGBTable()); |
186 |
rgbBandAssignPane.setPreferredSize(new java.awt.Dimension(wTable,hTable));
|
187 |
rgbBandAssignPane.setEnabled(true);
|
188 |
TableColumn column = null; |
189 |
|
190 |
for (int i = 0; i < 1; i++) { |
191 |
column = rgbTable.getColumnModel().getColumn(i); |
192 |
column.setCellRenderer(new RadioColumnRenderer());
|
193 |
column.setCellEditor(new RadioColumnEditor());
|
194 |
column.setMaxWidth(22);
|
195 |
column.setMinWidth(22);
|
196 |
} |
197 |
} |
198 |
return rgbBandAssignPane;
|
199 |
} |
200 |
|
201 |
/**
|
202 |
* Obtiene la Tabla
|
203 |
* @return Tabla de bandas de la imagen
|
204 |
*/
|
205 |
public JTable getRGBTable() { |
206 |
if (rgbTable == null) { |
207 |
tableModel = new RGBBandAsignTableModel();
|
208 |
tableModel.addTableModelListener(this);
|
209 |
rgbTable = new JTable(tableModel); |
210 |
rgbTable.setPreferredScrollableViewportSize(new Dimension(300, 60)); |
211 |
} |
212 |
return rgbTable;
|
213 |
} |
214 |
|
215 |
|
216 |
/**
|
217 |
* A?ade una banda a la tabla bandas de la imagen asignandole un
|
218 |
* nombre y valor a los checkbox
|
219 |
* @param bandName Nombre de la banda
|
220 |
*/
|
221 |
private void addBand(String bandName) { |
222 |
Vector v = new Vector(); |
223 |
v.add(new Boolean(false)); |
224 |
v.add(bandName); |
225 |
((DefaultTableModel) rgbTable.getModel()).addRow(v);
|
226 |
} |
227 |
|
228 |
/**
|
229 |
* Obtiene el n?mero de bandas de la lista
|
230 |
* @return
|
231 |
*/
|
232 |
public int getNBands() { |
233 |
return ((DefaultTableModel) rgbTable.getModel()).getRowCount(); |
234 |
} |
235 |
|
236 |
/**
|
237 |
* Obtiene el nombre de la banda de la posici?n i de la tabla
|
238 |
* @param i
|
239 |
* @return
|
240 |
*/
|
241 |
public String getBandName(int i) { |
242 |
String s = (String) ((DefaultTableModel) rgbTable.getModel()).getValueAt(i, 1); |
243 |
return s.substring(s.lastIndexOf("[8U]") + 5, s.length()); |
244 |
} |
245 |
|
246 |
/**
|
247 |
* Selecciona una banda de la tabla.
|
248 |
* @param i
|
249 |
*/
|
250 |
public void selectRow(int i){ |
251 |
((DefaultTableModel) rgbTable.getModel()).setValueAt(new Boolean(true),i,0); |
252 |
} |
253 |
|
254 |
/**
|
255 |
* Elimina todas las filas seleccionadas
|
256 |
*/
|
257 |
public void removeSelections(){ |
258 |
for(int i=0;i<((DefaultTableModel) rgbTable.getModel()).getRowCount();i++){ |
259 |
((DefaultTableModel) rgbTable.getModel()).setValueAt(new Boolean(false),i,0); |
260 |
} |
261 |
} |
262 |
|
263 |
/* (non-Javadoc)
|
264 |
* @see javax.swing.event.TableModelListener#tableChanged(javax.swing.event.TableModelEvent)
|
265 |
*/
|
266 |
public void tableChanged(TableModelEvent e) { |
267 |
rgbTable.revalidate(); |
268 |
rgbBandAssignPane.revalidate(); |
269 |
revalidate(); |
270 |
} |
271 |
|
272 |
/* (non-Javadoc)
|
273 |
* @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
|
274 |
*/
|
275 |
public void keyPressed(KeyEvent arg0) { |
276 |
// TODO Auto-generated method stub
|
277 |
} |
278 |
|
279 |
/* (non-Javadoc)
|
280 |
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
|
281 |
*/
|
282 |
public void keyReleased(KeyEvent arg0) { |
283 |
// TODO Auto-generated method stub
|
284 |
} |
285 |
|
286 |
/* (non-Javadoc)
|
287 |
* @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
|
288 |
*/
|
289 |
public void keyTyped(KeyEvent arg0) { |
290 |
// TODO Auto-generated method stub
|
291 |
} |
292 |
|
293 |
/**
|
294 |
*
|
295 |
*/
|
296 |
public void actionPerformed(ActionEvent e) { |
297 |
if(e.getSource() == this.cbActiveSharpening){ |
298 |
if(this.cbActiveSharpening.isSelected()){ |
299 |
this.setTableEnabled(true); |
300 |
}else{
|
301 |
this.setTableEnabled(false); |
302 |
} |
303 |
} |
304 |
} |
305 |
|
306 |
class RadioColumnEditor extends AbstractCellEditor |
307 |
implements TableCellEditor { |
308 |
final private static long serialVersionUID = -3370601314380922368L; |
309 |
public JRadioButton theRadioButton; |
310 |
|
311 |
public RadioColumnEditor() {
|
312 |
super();
|
313 |
theRadioButton = new JRadioButton(); |
314 |
theRadioButton.addActionListener(new ActionListener() { |
315 |
public void actionPerformed(ActionEvent event) { |
316 |
fireEditingStopped(); |
317 |
} |
318 |
}); |
319 |
} |
320 |
|
321 |
public Component getTableCellEditorComponent(JTable table, Object obj, |
322 |
boolean isSelected,
|
323 |
int row, int col) { |
324 |
theRadioButton.setHorizontalAlignment(SwingUtilities.CENTER);
|
325 |
|
326 |
Boolean lValueAsBoolean = (Boolean) obj; |
327 |
theRadioButton.setSelected(lValueAsBoolean.booleanValue()); |
328 |
|
329 |
return theRadioButton;
|
330 |
} |
331 |
|
332 |
public Object getCellEditorValue() { |
333 |
return new Boolean(theRadioButton.isSelected()); |
334 |
} |
335 |
} |
336 |
|
337 |
class RadioColumnRenderer extends JRadioButton implements TableCellRenderer { |
338 |
final private static long serialVersionUID = -3370601314380922368L; |
339 |
|
340 |
public Component getTableCellRendererComponent(JTable table, |
341 |
Object value,
|
342 |
boolean isSelected,
|
343 |
boolean hasFocus,
|
344 |
int row, int column) { |
345 |
if (value == null) { |
346 |
this.setSelected(false); |
347 |
} |
348 |
|
349 |
Boolean ValueAsBoolean = (Boolean) value; |
350 |
this.setSelected(ValueAsBoolean.booleanValue());
|
351 |
this.setHorizontalAlignment(SwingConstants.CENTER); |
352 |
|
353 |
return this; |
354 |
} |
355 |
} |
356 |
|
357 |
class RGBBandAsignTableModel extends DefaultTableModel { |
358 |
final private static long serialVersionUID = -3370601314380922368L; |
359 |
|
360 |
public RGBBandAsignTableModel() {
|
361 |
super(new Object[0][2], columnNames); |
362 |
} |
363 |
|
364 |
public Class getColumnClass(int c) { |
365 |
if (c < 1) { |
366 |
return Boolean.class; |
367 |
} |
368 |
|
369 |
return String.class; |
370 |
} |
371 |
|
372 |
public void setValueAt(Object value, int row, int col) { |
373 |
if ((col < 1) && ((Boolean) value).booleanValue()) { |
374 |
for (int i = 0; i < getRowCount(); i++) { |
375 |
if (i != row) {
|
376 |
setValueAt(new Boolean(false), i, col); |
377 |
} |
378 |
} |
379 |
} |
380 |
|
381 |
super.setValueAt(value, row, col);
|
382 |
} |
383 |
|
384 |
public void addNew() { |
385 |
super.addRow(new Object[] { |
386 |
new Boolean(false), "" |
387 |
}); |
388 |
} |
389 |
} |
390 |
|
391 |
/**
|
392 |
* This method initializes jPanel
|
393 |
*
|
394 |
* @return javax.swing.JPanel
|
395 |
*/
|
396 |
private JPanel getActivationPanel() { |
397 |
if (activationPanel == null) { |
398 |
FlowLayout flowLayout = new FlowLayout(); |
399 |
flowLayout.setAlignment(java.awt.FlowLayout.LEFT); |
400 |
flowLayout.setVgap(0);
|
401 |
flowLayout.setHgap(0);
|
402 |
activationPanel = new JPanel(); |
403 |
activationPanel.setLayout(flowLayout); |
404 |
activationPanel.setPreferredSize(new java.awt.Dimension(wCheck,hCheck));
|
405 |
activationPanel.add(getCbActiveSharpening(), null);
|
406 |
} |
407 |
return activationPanel;
|
408 |
} |
409 |
/**
|
410 |
* This method initializes jCheckBox
|
411 |
*
|
412 |
* @return javax.swing.JCheckBox
|
413 |
*/
|
414 |
public JCheckBox getCbActiveSharpening() { |
415 |
if (cbActiveSharpening == null) { |
416 |
cbActiveSharpening = new JCheckBox(); |
417 |
cbActiveSharpening.setText("Activar Pansharpening");
|
418 |
cbActiveSharpening.setPreferredSize(new java.awt.Dimension(150,23)); |
419 |
cbActiveSharpening.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); |
420 |
cbActiveSharpening.addActionListener(this);
|
421 |
} |
422 |
return cbActiveSharpening;
|
423 |
} |
424 |
/**
|
425 |
* This method initializes jPanel
|
426 |
*
|
427 |
* @return javax.swing.JPanel
|
428 |
*/
|
429 |
public JPanel getPSharpNorth() { |
430 |
if (pSharpNorth == null) { |
431 |
GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); |
432 |
gridBagConstraints10.gridx = 0;
|
433 |
gridBagConstraints10.gridy = 1;
|
434 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
435 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
436 |
pSharpNorth = new JPanel(); |
437 |
pSharpNorth.setLayout(new GridBagLayout()); |
438 |
pSharpNorth.setPreferredSize(new java.awt.Dimension(wNorth,hNorth));
|
439 |
pSharpNorth.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Selector de banda de refinado", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
440 |
gridBagConstraints2.gridx = 0;
|
441 |
gridBagConstraints2.gridy = 0;
|
442 |
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; |
443 |
gridBagConstraints2.gridwidth = 0;
|
444 |
gridBagConstraints2.gridheight = 1;
|
445 |
gridBagConstraints3.gridx = 0;
|
446 |
gridBagConstraints3.gridy = 2;
|
447 |
gridBagConstraints3.weightx = 0.0D;
|
448 |
gridBagConstraints3.weighty = 0.0D;
|
449 |
gridBagConstraints3.fill = java.awt.GridBagConstraints.NONE; |
450 |
gridBagConstraints3.ipadx = 0;
|
451 |
gridBagConstraints3.ipady = 0;
|
452 |
gridBagConstraints3.insets = new java.awt.Insets(0,0,0,0); |
453 |
gridBagConstraints3.gridheight = 0;
|
454 |
gridBagConstraints3.gridwidth = 0;
|
455 |
pSharpNorth.add(getActivationPanel(), gridBagConstraints2); |
456 |
pSharpNorth.add(getRGBBandAssignPane(), gridBagConstraints3); |
457 |
pSharpNorth.add(getPSharpSouth(), gridBagConstraints10); |
458 |
} |
459 |
return pSharpNorth;
|
460 |
} |
461 |
|
462 |
private JPanel getPSharpSouth() { |
463 |
if (pSharpSouth == null) { |
464 |
GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); |
465 |
GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); |
466 |
pSharpSouth = new JPanel(); |
467 |
pSharpSouth.setLayout(new GridBagLayout()); |
468 |
pSharpSouth.setPreferredSize(new java.awt.Dimension(wSouth,hSouth));
|
469 |
gridBagConstraints9.gridy = 1;
|
470 |
gridBagConstraints8.gridy = 0;
|
471 |
pSharpSouth.add(getJPanel(), gridBagConstraints8); |
472 |
ButtonGroup group = new ButtonGroup(); |
473 |
group.add(getRbBrovey()); |
474 |
group.add(getRbHSL()); |
475 |
gridBagConstraints9.ipadx = 0;
|
476 |
pSharpSouth.add(getPKernel(), gridBagConstraints9); |
477 |
} |
478 |
return pSharpSouth;
|
479 |
} |
480 |
/**
|
481 |
* This method initializes jRadioButton
|
482 |
*
|
483 |
* @return javax.swing.JRadioButton
|
484 |
*/
|
485 |
public JRadioButton getRbBrovey() { |
486 |
if (rbBrovey == null) { |
487 |
rbBrovey = new JRadioButton(); |
488 |
rbBrovey.setText("Brovey");
|
489 |
rbBrovey.setPreferredSize(new java.awt.Dimension(70,23)); |
490 |
rbBrovey.setSelected(true);
|
491 |
} |
492 |
return rbBrovey;
|
493 |
} |
494 |
/**
|
495 |
* This method initializes jRadioButton
|
496 |
*
|
497 |
* @return javax.swing.JRadioButton
|
498 |
*/
|
499 |
public JRadioButton getRbHSL() { |
500 |
if (rbHSL == null) { |
501 |
rbHSL = new JRadioButton(); |
502 |
rbHSL.setText("HSL");
|
503 |
rbHSL.setPreferredSize(new java.awt.Dimension(70,23)); |
504 |
} |
505 |
return rbHSL;
|
506 |
} |
507 |
/**
|
508 |
* This method initializes jPanel
|
509 |
*
|
510 |
* @return javax.swing.JPanel
|
511 |
*/
|
512 |
private JPanel getPKernel() { |
513 |
if (pHSL == null) { |
514 |
GridBagConstraints gridBagConstraints7 = new GridBagConstraints(); |
515 |
GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); |
516 |
GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); |
517 |
pHSL = new JPanel(); |
518 |
pHSL.setLayout(new GridBagLayout()); |
519 |
pHSL.setPreferredSize(new java.awt.Dimension(wPSliders,hPSliders));
|
520 |
gridBagConstraints5.gridx = 0;
|
521 |
gridBagConstraints5.gridy = 0;
|
522 |
gridBagConstraints5.insets = new java.awt.Insets(0,0,0,0); |
523 |
gridBagConstraints5.gridheight = 0;
|
524 |
gridBagConstraints6.gridx = 1;
|
525 |
gridBagConstraints6.gridwidth = 1;
|
526 |
gridBagConstraints6.gridy = 0;
|
527 |
gridBagConstraints6.weightx = 1.0;
|
528 |
gridBagConstraints6.fill = java.awt.GridBagConstraints.HORIZONTAL; |
529 |
gridBagConstraints6.insets = new java.awt.Insets(0,0,0,0); |
530 |
gridBagConstraints6.gridheight = 0;
|
531 |
gridBagConstraints7.weightx = 1.0D;
|
532 |
gridBagConstraints7.weighty = 1.0D;
|
533 |
gridBagConstraints7.gridwidth = 1;
|
534 |
gridBagConstraints7.fill = java.awt.GridBagConstraints.HORIZONTAL; |
535 |
gridBagConstraints7.gridheight = 1;
|
536 |
gridBagConstraints7.gridy = 0;
|
537 |
gridBagConstraints7.gridx = 2;
|
538 |
pHSL.add(getJTextField(), gridBagConstraints7); |
539 |
pHSL.add(getRbHSL(), gridBagConstraints5); |
540 |
pHSL.add(getJSlider(), gridBagConstraints6); |
541 |
this.getJSlider().setValue(0); |
542 |
} |
543 |
return pHSL;
|
544 |
} |
545 |
/**
|
546 |
* This method initializes jSlider
|
547 |
*
|
548 |
* @return javax.swing.JSlider
|
549 |
*/
|
550 |
public JSlider getJSlider() { |
551 |
if (jSlider == null) { |
552 |
jSlider = new JSlider(); |
553 |
jSlider.setMinimum(0);
|
554 |
jSlider.setPreferredSize(new java.awt.Dimension(wSlider,hSlider));
|
555 |
jSlider.setMaximum(100);
|
556 |
jSlider.addChangeListener(this);
|
557 |
} |
558 |
return jSlider;
|
559 |
} |
560 |
/**
|
561 |
* This method initializes jTextField
|
562 |
*
|
563 |
* @return javax.swing.JTextField
|
564 |
*/
|
565 |
public JTextField getJTextField() { |
566 |
if (jTextField == null) { |
567 |
jTextField = new JTextField(); |
568 |
jTextField.setPreferredSize(new java.awt.Dimension(20,19)); |
569 |
jTextField.setText("0.0");
|
570 |
} |
571 |
return jTextField;
|
572 |
} |
573 |
|
574 |
public void stateChanged(ChangeEvent e) { |
575 |
//Ponemos el valor del texto del coeficiente
|
576 |
if (e.getSource().equals(this.getJSlider())) { |
577 |
this.getJTextField().setText(String.valueOf((getJSlider().getValue()/200.0))); |
578 |
} |
579 |
|
580 |
if (e.getSource().equals(this.getJSlider1())) { |
581 |
this.getJTextField1().setText(String.valueOf((getJSlider1().getValue()/2))); |
582 |
} |
583 |
|
584 |
} |
585 |
|
586 |
/**
|
587 |
* This method initializes jPanel
|
588 |
*
|
589 |
* @return javax.swing.JPanel
|
590 |
*/
|
591 |
private JPanel getJPanel() { |
592 |
if (pBrovey == null) { |
593 |
GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
594 |
gridBagConstraints11.fill = java.awt.GridBagConstraints.HORIZONTAL; |
595 |
gridBagConstraints11.gridx = 2;
|
596 |
gridBagConstraints11.gridy = 0;
|
597 |
gridBagConstraints11.weighty = 1.0D;
|
598 |
gridBagConstraints11.weightx = 1.0;
|
599 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
600 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
601 |
gridBagConstraints1.gridheight = 0;
|
602 |
gridBagConstraints1.gridx = 1;
|
603 |
gridBagConstraints1.gridy = 0;
|
604 |
gridBagConstraints1.weightx = 1.0;
|
605 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
606 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER; |
607 |
gridBagConstraints.gridy = 0;
|
608 |
gridBagConstraints.gridheight = 0;
|
609 |
gridBagConstraints.gridx = 0;
|
610 |
pBrovey = new JPanel(); |
611 |
pBrovey.setLayout(new GridBagLayout()); |
612 |
pBrovey.setPreferredSize(new java.awt.Dimension(wPSliders,hPSliders));
|
613 |
pBrovey.add(getRbBrovey(), gridBagConstraints); |
614 |
pBrovey.add(getJSlider1(), gridBagConstraints1); |
615 |
this.getJSlider1().setValue(0); |
616 |
pBrovey.add(getJTextField1(), gridBagConstraints11); |
617 |
} |
618 |
return pBrovey;
|
619 |
} |
620 |
|
621 |
/**
|
622 |
* This method initializes jSlider1
|
623 |
*
|
624 |
* @return javax.swing.JSlider
|
625 |
*/
|
626 |
public JSlider getJSlider1() { |
627 |
if (slBrovey == null) { |
628 |
slBrovey = new JSlider(); |
629 |
slBrovey.setMaximum(100);
|
630 |
slBrovey.setPreferredSize(new java.awt.Dimension(wSlider,hSlider));
|
631 |
slBrovey.addChangeListener(this);
|
632 |
} |
633 |
return slBrovey;
|
634 |
} |
635 |
|
636 |
/**
|
637 |
* This method initializes jTextField1
|
638 |
*
|
639 |
* @return javax.swing.JTextField
|
640 |
*/
|
641 |
public JTextField getJTextField1() { |
642 |
if (jTextField1 == null) { |
643 |
jTextField1 = new JTextField(); |
644 |
jTextField1.setPreferredSize(new java.awt.Dimension(20,19)); |
645 |
jTextField1.setText("0");
|
646 |
} |
647 |
return jTextField1;
|
648 |
} |
649 |
|
650 |
/**
|
651 |
* Asigna el gestor del filtro de pansharpening
|
652 |
* @param p PanSharpeningStackManager
|
653 |
*/
|
654 |
public void setPanSharpeningStackManager(PanSharpeningStackManager p){ |
655 |
pStackManager = p; |
656 |
} |
657 |
|
658 |
//--------------------------------------------------------------
|
659 |
//IRasterPropertiesRegistrable
|
660 |
|
661 |
/**
|
662 |
* M?todo que es ejecutado desde PropertiesRasterDialog cuando se pulsa "Aceptar"
|
663 |
* en todas los paneles que tiene a?adidos.
|
664 |
* @param fLayer FLyrRaster
|
665 |
* @param propsDialog PropertiesRasterDialog
|
666 |
*/
|
667 |
public void actionPerformed(RasterFilterStackManager stackManager, PropertiesRasterDialog propsDialog, FLyrRaster fLayer){ |
668 |
PanSharpeningPanel pSharp = (PanSharpeningPanel)((FilterRasterDialogPanel)propsDialog.getContentPane()).getPanelByClassName("PanSharpeningPanel");
|
669 |
if(pSharp.getCbActiveSharpening().isSelected()){
|
670 |
String pancr = null; |
671 |
|
672 |
//Obtenemos el nombre de la banda seleccionada
|
673 |
for(int i=0;i<(pSharp.getRGBTable()).getRowCount();i++){ |
674 |
if(((Boolean) (pSharp.getRGBTable()).getValueAt(i, 0)).booleanValue()) |
675 |
pancr = ((String) (pSharp.getRGBTable()).getValueAt(i, 1)); |
676 |
} |
677 |
|
678 |
//Buscamos el GeoRasterFile que corresponde a la capa y a?adimos el filtro con el
|
679 |
if(pancr!=null){ |
680 |
pancr = pancr.substring(pancr.lastIndexOf("] ") + 2, pancr.length()); |
681 |
for(int i=0; i<fLayer.getSource().getFiles().length;i++){ |
682 |
if(fLayer.getSource().getFiles()[i].getName().endsWith(File.separator+pancr)){ |
683 |
int[] order = { propsDialog.getAssignedBand(GeoRasterFile.RED_BAND), |
684 |
propsDialog.getAssignedBand(GeoRasterFile.GREEN_BAND), |
685 |
propsDialog.getAssignedBand(GeoRasterFile.BLUE_BAND)}; |
686 |
|
687 |
RasterTransparencyPanel tpan = (RasterTransparencyPanel)((FilterRasterDialogPanel)propsDialog.getContentPane()).getPanelByClassName("RasterTransparencyPanel");
|
688 |
int opac = Integer.parseInt(tpan.getOpacityText().getText()); |
689 |
opac = (int)((opac*255)/100); |
690 |
|
691 |
String method = "brovey"; |
692 |
if(pSharp.getRbHSL().isSelected())
|
693 |
method = "hsl";
|
694 |
|
695 |
double coef = 0D; |
696 |
if(pSharp.getRbHSL().isSelected())
|
697 |
coef = Double.parseDouble(pSharp.getJTextField().getText());
|
698 |
|
699 |
int coefBrovey = 0; |
700 |
if(pSharp.getRbBrovey().isSelected())
|
701 |
coefBrovey = Integer.parseInt(pSharp.getJTextField1().getText());
|
702 |
|
703 |
pStackManager.addSharpeningFilter(fLayer.getSource().getFiles(), i, order, opac, method, coef, coefBrovey); |
704 |
} |
705 |
} |
706 |
} |
707 |
}else{
|
708 |
stackManager.removeFilter(stackManager.getTypeFilter("sharpening"));
|
709 |
} |
710 |
fLayer.getMapContext().invalidate(); |
711 |
} |
712 |
|
713 |
public void addTabPanel(FLyrRasterAdjustPropertiesTocMenuEntry menu) { |
714 |
//Este m?todo no tiene funcionalidad para el panel
|
715 |
} |
716 |
|
717 |
public void setStackManager(RasterFilterStackManager stackManager) { |
718 |
//Este m?todo no tiene funcionalidad para el panel
|
719 |
} |
720 |
|
721 |
public IStackManager getStackManager() {
|
722 |
return pStackManager;
|
723 |
} |
724 |
|
725 |
//--------------------------------------------------------------
|
726 |
//IRasterOperationsRegistrablePanels
|
727 |
|
728 |
|
729 |
public void setComponentSize(int w, int h){ |
730 |
wComp = w; hComp = h; |
731 |
wNorth = wComp - 5; hNorth = hComp -14; |
732 |
wCheck = wNorth - 100; hCheck = 30; |
733 |
wSouth = wNorth - 30; hSouth = 62; |
734 |
wPSliders = wSouth - 10; hPSliders = 30; |
735 |
wTable = wNorth - 40; hTable = hNorth - 165; |
736 |
wSlider = wPSliders - 220; hSlider = 16; |
737 |
|
738 |
this.setSize(wComp, hComp);
|
739 |
pSharpNorth.setPreferredSize(new java.awt.Dimension(wNorth,hNorth));
|
740 |
activationPanel.setPreferredSize(new java.awt.Dimension(wCheck,hCheck));
|
741 |
rgbBandAssignPane.setPreferredSize(new java.awt.Dimension(wTable,hTable));
|
742 |
pSharpSouth.setPreferredSize(new java.awt.Dimension(wSouth,hSouth));
|
743 |
pBrovey.setPreferredSize(new java.awt.Dimension(wPSliders,hPSliders));
|
744 |
slBrovey.setPreferredSize(new java.awt.Dimension(wSlider,hSlider));
|
745 |
pHSL.setPreferredSize(new java.awt.Dimension(wPSliders,hPSliders));
|
746 |
jSlider.setPreferredSize(new java.awt.Dimension(wSlider,hSlider));
|
747 |
|
748 |
|
749 |
} |
750 |
|
751 |
|
752 |
/**
|
753 |
* M?todo del interfaz IRasterOperationsRegistrablePanels
|
754 |
* A?ade la lista de georasterfiles a la tabla
|
755 |
* @param files lista de ficheros a a?adir
|
756 |
*/
|
757 |
public void addFiles(GeoRasterFile[] files) { |
758 |
for (int i = 0; i < files.length; i++) { |
759 |
String fName = files[i].getName();
|
760 |
|
761 |
String bandName = new File(fName).getName(); |
762 |
String bandType = ""; |
763 |
|
764 |
switch (files[i].getDataType()) {
|
765 |
case DataBuffer.TYPE_BYTE: |
766 |
bandType = "8U";
|
767 |
break;
|
768 |
case DataBuffer.TYPE_INT: |
769 |
bandType = "32";
|
770 |
break;
|
771 |
case DataBuffer.TYPE_DOUBLE: |
772 |
bandType = "64";
|
773 |
break;
|
774 |
case DataBuffer.TYPE_FLOAT: |
775 |
bandType = "32";
|
776 |
break;
|
777 |
case DataBuffer.TYPE_SHORT: |
778 |
bandType = "16";
|
779 |
break;
|
780 |
case DataBuffer.TYPE_USHORT: |
781 |
bandType = "16U";
|
782 |
break;
|
783 |
case DataBuffer.TYPE_UNDEFINED: |
784 |
bandType = "??";
|
785 |
break;
|
786 |
} |
787 |
|
788 |
if (files[i].getBandCount() > 1) { |
789 |
for (int b = 0; b < files[i].getBandCount(); b++) |
790 |
addBand((b + 1) + " [" + bandType + "] " + bandName); |
791 |
} else {
|
792 |
addBand("1 [" + bandType + "] " + bandName); |
793 |
} |
794 |
} |
795 |
} |
796 |
|
797 |
/**
|
798 |
* M?todo del interfaz IRasterOperationsRegistrablePanels
|
799 |
* Elimina un fichero de la lista
|
800 |
* @param file Nombre del fichero a eliminar
|
801 |
*/
|
802 |
public void removeFile(String file) { |
803 |
for (int i = 0; i < ((DefaultTableModel) rgbTable.getModel()).getRowCount(); i++) { |
804 |
if (((String) ((DefaultTableModel) rgbTable.getModel()).getValueAt(i, 1)).endsWith(file)) { |
805 |
((DefaultTableModel) rgbTable.getModel()).removeRow(i);
|
806 |
i--; //Ojo! que hemos eliminado una fila
|
807 |
} |
808 |
} |
809 |
} |
810 |
|
811 |
} // @jve:decl-index=0:visual-constraint="10,10"
|