Revision 21378
trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/MultiespectralTransformationsExtension.java | ||
---|---|---|
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 Ibez, 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; |
|
41 |
|
|
42 |
import javax.swing.Icon; |
|
43 |
|
|
44 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
|
45 |
import org.gvsig.fmap.raster.layers.ILayerState; |
|
46 |
import org.gvsig.raster.gui.IGenericToolBarMenuItem; |
|
47 |
import org.gvsig.remotesensing.tasseledcap.TransformationPanel; |
|
48 |
|
|
49 |
import com.iver.andami.PluginServices; |
|
50 |
import com.iver.andami.plugins.Extension; |
|
51 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
52 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
53 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
54 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
|
55 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
|
56 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
|
57 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
|
58 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
59 |
/** |
|
60 |
* Extensi?n para el c?lculo de transformaciones multiespectrales. |
|
61 |
* |
|
62 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
|
63 |
*/ |
|
64 |
public class MultiespectralTransformationsExtension extends Extension implements IGenericToolBarMenuItem { |
|
65 |
|
|
66 |
static private MultiespectralTransformationsExtension singleton = null; |
|
67 |
|
|
68 |
|
|
69 |
static public MultiespectralTransformationsExtension getSingleton() { |
|
70 |
if (singleton == null) |
|
71 |
singleton = new MultiespectralTransformationsExtension(); |
|
72 |
return singleton; |
|
73 |
} |
|
74 |
|
|
75 |
/* |
|
76 |
* (non-Javadoc) |
|
77 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
78 |
*/ |
|
79 |
public void initialize() { |
|
80 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
81 |
extensionPoints.add("GenericToolBarMenu", "Transformations", this); |
|
82 |
} |
|
83 |
|
|
84 |
/* |
|
85 |
* (non-Javadoc) |
|
86 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
87 |
*/ |
|
88 |
public void execute(String actionCommand) { |
|
89 |
if (actionCommand.equals("transformations")) { |
|
90 |
com.iver.andami.ui.mdiManager.IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
|
91 |
|
|
92 |
// si la ventana activa es de tipo Vista |
|
93 |
if (activeWindow instanceof View) { |
|
94 |
TransformationPanel pcPanel = new TransformationPanel ((View)activeWindow); |
|
95 |
PluginServices.getMDIManager().addWindow(pcPanel); |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
/* |
|
101 |
* (non-Javadoc) |
|
102 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
103 |
*/ |
|
104 |
public boolean isEnabled() { |
|
105 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
106 |
if (f == null) { |
|
107 |
return false; |
|
108 |
} |
|
109 |
if (f.getClass() == View.class) { |
|
110 |
View vista = (View) f; |
|
111 |
IProjectView model = vista.getModel(); |
|
112 |
MapContext mapa = model.getMapContext(); |
|
113 |
FLayers layers = mapa.getLayers(); |
|
114 |
for (int i = 0; i < layers.getLayersCount(); i++) |
|
115 |
if (layers.getLayer(i) instanceof FLyrRasterSE) |
|
116 |
return true; |
|
117 |
} |
|
118 |
return false; |
|
119 |
} |
|
120 |
|
|
121 |
/* |
|
122 |
* (non-Javadoc) |
|
123 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
124 |
*/ |
|
125 |
public boolean isVisible() { |
|
126 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
127 |
if (f == null) { |
|
128 |
return false; |
|
129 |
} |
|
130 |
if (f instanceof View) { |
|
131 |
View vista = (View) f; |
|
132 |
IProjectView model = vista.getModel(); |
|
133 |
MapContext mapa = model.getMapContext(); |
|
134 |
return mapa.getLayers().getLayersCount() > 0; |
|
135 |
} else { |
|
136 |
return false; |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
/* |
|
141 |
* (non-Javadoc) |
|
142 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[]) |
|
143 |
*/ |
|
144 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
|
145 |
this.execute("transformations"); |
|
146 |
} |
|
147 |
|
|
148 |
/* |
|
149 |
* (non-Javadoc) |
|
150 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroup() |
|
151 |
*/ |
|
152 |
public String getGroup() { |
|
153 |
return "RasterProcess"; |
|
154 |
} |
|
155 |
|
|
156 |
/* |
|
157 |
* (non-Javadoc) |
|
158 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getIcon() |
|
159 |
*/ |
|
160 |
public Icon getIcon() { |
|
161 |
return PluginServices.getIconTheme().get("transform-icon"); |
|
162 |
} |
|
163 |
|
|
164 |
/* |
|
165 |
* (non-Javadoc) |
|
166 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getOrder() |
|
167 |
*/ |
|
168 |
public int getOrder() { |
|
169 |
return 0; |
|
170 |
} |
|
171 |
|
|
172 |
/* |
|
173 |
* (non-Javadoc) |
|
174 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getText() |
|
175 |
*/ |
|
176 |
public String getText() { |
|
177 |
return PluginServices.getText(this, "transformations"); |
|
178 |
} |
|
179 |
|
|
180 |
/* |
|
181 |
* (non-Javadoc) |
|
182 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[]) |
|
183 |
*/ |
|
184 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
|
185 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
|
186 |
return false; |
|
187 |
|
|
188 |
if (!(selectedItems[0] instanceof ILayerState)) |
|
189 |
return false; |
|
190 |
|
|
191 |
if (!((ILayerState) selectedItems[0]).isOpen()) |
|
192 |
return false; |
|
193 |
|
|
194 |
return true; |
|
195 |
} |
|
196 |
|
|
197 |
/* |
|
198 |
* (non-Javadoc) |
|
199 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[]) |
|
200 |
*/ |
|
201 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
|
202 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
|
203 |
return false; |
|
204 |
|
|
205 |
if (!(selectedItems[0] instanceof FLyrRasterSE)) |
|
206 |
return false; |
|
207 |
|
|
208 |
return true; |
|
209 |
} |
|
210 |
|
|
211 |
/* |
|
212 |
* (non-Javadoc) |
|
213 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroupOrder() |
|
214 |
*/ |
|
215 |
public int getGroupOrder() { |
|
216 |
return 0; |
|
217 |
} |
|
218 |
} |
Also available in: Unified diff