root / branches / v2_0_0_prep / extensions / extRemoteSensing / src / org / gvsig / remotesensing / ClassificationExtension.java @ 31496
History | View | Annotate | Download (6.39 KB)
1 |
/* gvSIG. Sistema de Informacin Geogrfica 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.andami.PluginServices; |
45 |
import org.gvsig.andami.plugins.Extension; |
46 |
import org.gvsig.app.project.documents.view.ViewDocument; |
47 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
48 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
49 |
import org.gvsig.fmap.mapcontext.MapContext; |
50 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
51 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
52 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
53 |
import org.gvsig.fmap.raster.layers.ILayerState; |
54 |
import org.gvsig.raster.gui.IGenericToolBarMenuItem; |
55 |
import org.gvsig.remotesensing.classification.gui.ClassificationPanel; |
56 |
import org.gvsig.tools.ToolsLocator; |
57 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
58 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
59 |
|
60 |
/**
|
61 |
* Extensi?n para el proceso de classificacion de una imagen
|
62 |
*
|
63 |
* @author Alejandro Mu?oz S?nchez (alejandro.munoz@uclm.es)
|
64 |
*/
|
65 |
public class ClassificationExtension extends Extension implements IGenericToolBarMenuItem { |
66 |
|
67 |
/*
|
68 |
* (non-Javadoc)
|
69 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
70 |
*/
|
71 |
public void initialize() { |
72 |
ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager(); |
73 |
ExtensionPoint point=extensionPoints.add("GenericToolBarMenu");
|
74 |
point.append("Classification", "", this.getClass()); |
75 |
PluginServices.getIconTheme().register( |
76 |
"clasificator-icon",
|
77 |
this.getClass().getClassLoader().getResource("images/color_class.png") |
78 |
); |
79 |
} |
80 |
|
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("classification")){ |
89 |
org.gvsig.andami.ui.mdiManager.IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
90 |
|
91 |
//si la ventana activa es de tipo Vista
|
92 |
if (activeWindow instanceof DefaultViewPanel) { |
93 |
ClassificationPanel clasificationDialog =new ClassificationPanel((DefaultViewPanel)activeWindow);
|
94 |
//Mostrar la calculadora.
|
95 |
PluginServices.getMDIManager().addWindow(clasificationDialog); |
96 |
} |
97 |
} |
98 |
} |
99 |
|
100 |
/*
|
101 |
* (non-Javadoc)
|
102 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
103 |
*/
|
104 |
public boolean isEnabled() { |
105 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
106 |
if (f == null) { |
107 |
return false; |
108 |
} |
109 |
if (f.getClass() == DefaultViewPanel.class) {
|
110 |
DefaultViewPanel vista = (DefaultViewPanel) f; |
111 |
ViewDocument 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 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
127 |
if (f == null) { |
128 |
return false; |
129 |
} |
130 |
if (f instanceof DefaultViewPanel) { |
131 |
DefaultViewPanel vista = (DefaultViewPanel) f; |
132 |
ViewDocument 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("classification"); |
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("clasificator-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, "classification"); |
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 |
} |