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