svn-gvsig-desktop / trunk / extensions / extRasterTools / src / org / gvsig / rasterTools / pansharpening / toc / PanSharpeningTocMenuEntry.java @ 7304
History | View | Annotate | Download (4.43 KB)
1 |
/*
|
---|---|
2 |
* Created on 23-mar-2006
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
*/
|
23 |
package org.gvsig.rasterTools.pansharpening.toc; |
24 |
|
25 |
import org.cresques.filter.IStackManager; |
26 |
import org.cresques.filter.RasterFilter; |
27 |
import org.cresques.filter.RasterFilterStackManager; |
28 |
import org.cresques.ui.raster.FilterRasterDialogPanel; |
29 |
import org.gvsig.rasterTools.pansharpening.filter.PanSharpeningStackManager; |
30 |
import org.gvsig.rasterTools.pansharpening.ui.PanSharpeningPanel; |
31 |
|
32 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
33 |
import com.iver.cit.gvsig.gui.panels.IRasterPropertiesRegistrable; |
34 |
import com.iver.cit.gvsig.gui.panels.PropertiesRasterDialog; |
35 |
import com.iver.cit.gvsig.project.documents.view.toc.gui.FLyrRasterAdjustPropertiesTocMenuEntry; |
36 |
|
37 |
/**
|
38 |
* Entrada del menu contextual del TOC que contiene la parte del listener que
|
39 |
* corresponde al PanSharpening. La funci?n actionPerformed de este objeto ser?
|
40 |
* llamada por la clase FLyrRasterAdjustPropertiesTocMenuEntry. Para esto debe
|
41 |
* registrarse en ella a trav?s del m?todo "register".
|
42 |
*
|
43 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
44 |
*/
|
45 |
public class PanSharpeningTocMenuEntry implements IRasterPropertiesRegistrable{ |
46 |
|
47 |
private PanSharpeningPanel panel = null; |
48 |
private PanSharpeningStackManager manager = null; |
49 |
|
50 |
/**
|
51 |
* Contructor.
|
52 |
* Se registra a si mismo en las propiedades de raster del TOC
|
53 |
* @param menu
|
54 |
*/
|
55 |
public PanSharpeningTocMenuEntry(FLyrRasterAdjustPropertiesTocMenuEntry menu){
|
56 |
menu.register(this);
|
57 |
} |
58 |
|
59 |
/**
|
60 |
* Asigna el gestor de pila de filtros generico al gestor de pila de pansharpening
|
61 |
* @param stackManager RasterFilterStackManager
|
62 |
*/
|
63 |
public void setStackManager(RasterFilterStackManager stackManager){ |
64 |
panel = new PanSharpeningPanel();
|
65 |
manager = (PanSharpeningStackManager)stackManager.getManagerByClass(PanSharpeningStackManager.class); |
66 |
panel.setPanSharpeningStackManager(manager); |
67 |
} |
68 |
|
69 |
/**
|
70 |
* Obtiene el stackManger para este filtro
|
71 |
* @return PanSharpeningStackManager
|
72 |
*/
|
73 |
public IStackManager getStackManager(){
|
74 |
return manager;
|
75 |
} |
76 |
|
77 |
/**
|
78 |
* A?ade el panel al cuadro de dialogo de propiedades de raster
|
79 |
* @param menu FLyrRasterAdjustPropertiesTocMenuEntry
|
80 |
*/
|
81 |
public void addTabPanel(FLyrRasterAdjustPropertiesTocMenuEntry menu){ |
82 |
if(panel == null) |
83 |
panel = new PanSharpeningPanel();
|
84 |
menu.getPropertiesDialog().addTab(panel.getName(), panel); |
85 |
} |
86 |
|
87 |
public void actionPerformed(RasterFilterStackManager stackManager, PropertiesRasterDialog propsDialog, FLyrRaster fLayer) { |
88 |
//Modificaci?n del estado de los controles del pansharpening
|
89 |
if(stackManager.isActive(stackManager.getTypeFilter("sharpening"))){ |
90 |
PanSharpeningPanel pSharp = (PanSharpeningPanel)((FilterRasterDialogPanel)propsDialog.getContentPane()).getPanelByClassName("PanSharpeningPanel");
|
91 |
pSharp.getCbActiveSharpening().setSelected(true);
|
92 |
pSharp.setTableEnabled(true);
|
93 |
|
94 |
RasterFilter sharp = stackManager.getFilter("sharpening");
|
95 |
String pancrName = (String)sharp.getParam("pancrName"); |
96 |
for(int i=0;i<pSharp.getNBands();i++){ |
97 |
if(pSharp.getBandName(i).endsWith(pancrName))
|
98 |
pSharp.selectRow(i); |
99 |
} |
100 |
if(((String)sharp.getParam("method")).equals("hsl")){ |
101 |
pSharp.getRbHSL().setSelected(true);
|
102 |
Double coef = ((Double)sharp.getParam("coef")); |
103 |
pSharp.getJTextField().setText(coef.toString()); |
104 |
pSharp.getJSlider().setValue((int)((coef.doubleValue() * 100)/0.5)); |
105 |
} |
106 |
|
107 |
if(((String)sharp.getParam("method")).equals("brovey")){ |
108 |
pSharp.getRbBrovey().setSelected(true);
|
109 |
Integer coefBrovey = ((Integer)sharp.getParam("coefBrovey")); |
110 |
pSharp.getJTextField1().setText(coefBrovey.toString()); |
111 |
pSharp.getJSlider1().setValue((int)((coefBrovey.intValue() * 100)/50)); |
112 |
} |
113 |
} |
114 |
} |
115 |
} |