svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / RasterModule.java @ 16326
History | View | Annotate | Download (12.3 KB)
1 | 11268 | nacho | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007 IVER T.I. 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 | package org.gvsig.rastertools; |
||
20 | |||
21 | 11893 | nacho | import java.util.prefs.Preferences; |
22 | |||
23 | 13761 | nacho | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
24 | import org.gvsig.fmap.raster.layers.StatusLayerRaster; |
||
25 | 12425 | nacho | import org.gvsig.raster.gui.properties.dialog.RasterPropertiesTocMenuEntry; |
26 | 13543 | bsanchez | import org.gvsig.raster.gui.wizards.FileOpenRaster; |
27 | 12182 | nacho | import org.gvsig.rastertools.analysisview.ViewRasterAnalysisTocMenuEntry; |
28 | 14842 | bsanchez | import org.gvsig.rastertools.clipping.ClippingTocMenuEntry; |
29 | 12344 | bsanchez | import org.gvsig.rastertools.colortable.ColorTableTocMenuEntry; |
30 | 11500 | bsanchez | import org.gvsig.rastertools.filter.FilterTocMenuEntry; |
31 | 14135 | nbrodin | import org.gvsig.rastertools.geolocation.GeoLocationTocMenuEntry; |
32 | 11268 | nacho | import org.gvsig.rastertools.histogram.HistogramTocMenuEntry; |
33 | import org.gvsig.rastertools.properties.panels.BandSetupPanel; |
||
34 | import org.gvsig.rastertools.properties.panels.EnhancedPanel; |
||
35 | import org.gvsig.rastertools.properties.panels.InfoPanel; |
||
36 | 12617 | amunoz | import org.gvsig.rastertools.properties.panels.PanSharpeningPanel; |
37 | 14467 | bsanchez | import org.gvsig.rastertools.properties.panels.ScalePanel; |
38 | 11268 | nacho | import org.gvsig.rastertools.properties.panels.TransparencyPanel; |
39 | 11662 | nacho | import org.gvsig.rastertools.rasterresolution.ZoomPixelCursorTocMenuEntry; |
40 | 14218 | bsanchez | import org.gvsig.rastertools.roi.ui.ROIManagerTocMenuEntry; |
41 | 11900 | nacho | import org.gvsig.rastertools.saveas.SaveAsTocMenuEntry; |
42 | 11686 | nacho | import org.gvsig.rastertools.selectrasterlayer.SelectImageListener; |
43 | 12610 | nacho | |
44 | 11268 | nacho | import com.iver.andami.PluginServices; |
45 | import com.iver.andami.plugins.Extension; |
||
46 | import com.iver.cit.gvsig.fmap.MapContext; |
||
47 | import com.iver.cit.gvsig.fmap.MapControl; |
||
48 | 15671 | nbrodin | import com.iver.cit.gvsig.fmap.layers.FLayers; |
49 | 13761 | nacho | import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
50 | 11268 | nacho | import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
51 | import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
||
52 | 11686 | nacho | import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
53 | 11268 | nacho | import com.iver.cit.gvsig.project.documents.view.IProjectView; |
54 | import com.iver.cit.gvsig.project.documents.view.gui.View; |
||
55 | import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
||
56 | import com.iver.utiles.extensionPoints.ExtensionPoint; |
||
57 | import com.iver.utiles.extensionPoints.ExtensionPoints; |
||
58 | import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
||
59 | /**
|
||
60 | 11715 | bsanchez | * Extensi?n que adapta a FMap y gvSIG la nueva implementaci?n de raster. Para
|
61 | * el cuadro de Propiedades de visualizaci?n de raster contiene el contenedor
|
||
62 | * base se registran la entrada del men? del TOC y los paneles en el cuadro.
|
||
63 | * Para la parte de FMap contiene una nueva capa raster y los drivers
|
||
64 | * necesarios.
|
||
65 | 12344 | bsanchez | *
|
66 | 11268 | nacho | * @author Nacho Brodin (nachobrodin@gmail.com)
|
67 | */
|
||
68 | public class RasterModule extends Extension{ |
||
69 | 11894 | nacho | /**
|
70 | 11902 | bsanchez | * Contador global de las capas generadas para raster
|
71 | */
|
||
72 | 13975 | nacho | public static int layerCount = 1; |
73 | 11902 | bsanchez | |
74 | 11894 | nacho | /*
|
75 | * (non-Javadoc)
|
||
76 | * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
||
77 | */
|
||
78 | 11902 | bsanchez | public void execute(String actionCommand) { |
79 | 11686 | nacho | View theView = (View) PluginServices.getMDIManager().getActiveWindow(); |
80 | 11902 | bsanchez | MapControl mapCtrl = theView.getMapControl(); |
81 | |||
82 | // Listener de eventos de movimiento que pone las coordenadas del rat?n en
|
||
83 | // la barra de estado
|
||
84 | StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
||
85 | |||
86 | 11686 | nacho | if (actionCommand.equals("SELECTIMAGE")) { |
87 | loadSelectRasterListener(mapCtrl, sbl); |
||
88 | mapCtrl.setTool("selectRasterLayer");
|
||
89 | 13761 | nacho | } |
90 | 11902 | bsanchez | } |
91 | |||
92 | 11686 | nacho | /**
|
93 | 11902 | bsanchez | * Carga el listener de selecci?n de raster en el MapControl.
|
94 | */
|
||
95 | private void loadSelectRasterListener(MapControl mapCtrl, StatusBarListener sbl) { |
||
96 | if (mapCtrl.getNamesMapTools().get("selectRasterLayer") == null) { |
||
97 | 11686 | nacho | SelectImageListener sil = new SelectImageListener(mapCtrl);
|
98 | 11902 | bsanchez | mapCtrl.addMapTool("selectRasterLayer", new Behavior[] { new PointBehavior(sil), new MouseMovementBehavior(sbl) }); |
99 | 11686 | nacho | mapCtrl.setTool("selectRasterLayer");
|
100 | } |
||
101 | 11902 | bsanchez | } |
102 | 12569 | nacho | |
103 | 11268 | nacho | /*
|
104 | * (non-Javadoc)
|
||
105 | * @see com.iver.andami.plugins.IExtension#initialize()
|
||
106 | */
|
||
107 | public void initialize() { |
||
108 | // DiagSignalHandler.install("ALRM");
|
||
109 | |||
110 | 11902 | bsanchez | Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
111 | 11900 | nacho | prefs.put("DataFolder", System.getProperty("user.home")); |
112 | 11902 | bsanchez | |
113 | 11268 | nacho | ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
114 | 11902 | bsanchez | |
115 | // Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades.
|
||
116 | 13277 | nacho | if (!extensionPoints.containsKey("RasterSEPropertiesDialog")) { |
117 | 11902 | bsanchez | extensionPoints.put(new ExtensionPoint("RasterSEPropertiesDialog", "Raster Properties registrable panels (register instances of javax.swing.JPanel)")); |
118 | 11268 | nacho | } |
119 | 13599 | bsanchez | |
120 | 11902 | bsanchez | // A?adimos paneles al cuadro de propiedades.
|
121 | 13599 | bsanchez | extensionPoints.add("RasterSEPropertiesDialog", "info", InfoPanel.class); |
122 | extensionPoints.add("RasterSEPropertiesDialog", "bands_panel", BandSetupPanel.class); |
||
123 | extensionPoints.add("RasterSEPropertiesDialog", "transparencia", TransparencyPanel.class); |
||
124 | extensionPoints.add("RasterSEPropertiesDialog", "realce", EnhancedPanel.class); |
||
125 | extensionPoints.add("RasterSEPropertiesDialog", "pansharp", PanSharpeningPanel.class); |
||
126 | 14467 | bsanchez | extensionPoints.add("RasterSEPropertiesDialog", "scale_panel", ScalePanel.class); |
127 | 13599 | bsanchez | |
128 | 11902 | bsanchez | // A?adimos la entrada del toc de la ventana de Histograma.
|
129 | extensionPoints.add("View_TocActions", "HistogramPanel", new HistogramTocMenuEntry()); |
||
130 | 11352 | bsanchez | |
131 | 11902 | bsanchez | // A?adimos la entrada del toc de la ventana de Recorte.
|
132 | 14846 | bsanchez | extensionPoints.add("View_TocActions", "ClippingPanel", new ClippingTocMenuEntry()); |
133 | 11500 | bsanchez | |
134 | 11902 | bsanchez | // A?adimos la entrada del toc de la ventana de Filtros.
|
135 | extensionPoints.add("View_TocActions", "FilterPanel", new FilterTocMenuEntry()); |
||
136 | |||
137 | // A?adimos la entrada del toc del cuadro de Propiedades. Como se llama igual sustituye a la vieja.
|
||
138 | extensionPoints.add("View_TocActions", "RasterSEProperties", new RasterPropertiesTocMenuEntry()); |
||
139 | |||
140 | // A?adimos la entrada del toc de zoom a la resoluci?n del raster.
|
||
141 | extensionPoints.add("View_TocActions", "ZoomPixelCursor", new ZoomPixelCursorTocMenuEntry()); |
||
142 | |||
143 | // A?adimos la entrada del toc de zoom Salvar Como.
|
||
144 | extensionPoints.add("View_TocActions", "SaveAs", new SaveAsTocMenuEntry()); |
||
145 | 12344 | bsanchez | |
146 | 12182 | nacho | // A?adimos la entrada del toc de la vista de analisis.
|
147 | extensionPoints.add("View_TocActions", "ViewRasterAnalysis", new ViewRasterAnalysisTocMenuEntry()); |
||
148 | 11902 | bsanchez | |
149 | 12344 | bsanchez | // A?adimos la entrada del toc de la vista de analisis.
|
150 | extensionPoints.add("View_TocActions", "ViewColorTable", new ColorTableTocMenuEntry()); |
||
151 | 14120 | gsdiego | |
152 | // A?adimos la entrada del toc de la vista de analisis.
|
||
153 | 14135 | nbrodin | extensionPoints.add("View_TocActions", "GeoLocation", new GeoLocationTocMenuEntry()); |
154 | |||
155 | // A?adimos la entrada del toc de la vista de analisis.
|
||
156 | 14120 | gsdiego | extensionPoints.add("View_TocActions", "RoisManager", new ROIManagerTocMenuEntry()); |
157 | 14135 | nbrodin | |
158 | 13543 | bsanchez | // A?adimos nuestra extension para el tratamiento de la apertura de ficheros
|
159 | // dentro de gvSIG
|
||
160 | 14218 | bsanchez | extensionPoints.add("FileExtendingOpenDialog", "FileOpenRaster", FileOpenRaster.class); |
161 | 13761 | nacho | |
162 | //Alias
|
||
163 | LayerFactory.registerLayerClassForName("com.iver.cit.gvsig.fmap.layers.FLyrRaster", FLyrRasterSE.class);
|
||
164 | LayerFactory.registerLayerClassForName("com.iver.cit.gvsig.fmap.layers.StatusLayerRaster", StatusLayerRaster.class);
|
||
165 | 15765 | nbrodin | registerIcons(); |
166 | 11268 | nacho | } |
167 | 11902 | bsanchez | |
168 | 15774 | nbrodin | /**
|
169 | * Registra los iconos a utilizar en andami.
|
||
170 | */
|
||
171 | 15765 | nbrodin | private void registerIcons(){ |
172 | PluginServices.getIconTheme().registerDefault( |
||
173 | "map-ok-ico",
|
||
174 | MapControl.class.getResource("images/map_ico_ok.gif")
|
||
175 | ); |
||
176 | PluginServices.getIconTheme().registerDefault( |
||
177 | "crux-cursor",
|
||
178 | MapControl.class.getResource("images/CruxCursor.png")
|
||
179 | ); |
||
180 | PluginServices.getIconTheme().registerDefault( |
||
181 | "addlayer-icon",
|
||
182 | this.getClass().getClassLoader().getResource("images/addlayer.png") |
||
183 | ); |
||
184 | PluginServices.getIconTheme().registerDefault( |
||
185 | "delall-icon",
|
||
186 | this.getClass().getClassLoader().getResource("images/delall.png") |
||
187 | ); |
||
188 | PluginServices.getIconTheme().registerDefault( |
||
189 | "rotar-icon",
|
||
190 | this.getClass().getClassLoader().getResource("images/Rotar.gif") |
||
191 | ); |
||
192 | PluginServices.getIconTheme().registerDefault( |
||
193 | "hor-arrow-icon",
|
||
194 | this.getClass().getClassLoader().getResource("images/FlechaHorizCursor.gif") |
||
195 | ); |
||
196 | PluginServices.getIconTheme().registerDefault( |
||
197 | "ver-arrow-icon",
|
||
198 | this.getClass().getClassLoader().getResource("images/FlechaVertCursor.gif") |
||
199 | ); |
||
200 | PluginServices.getIconTheme().registerDefault( |
||
201 | "inclder-arrow-icon",
|
||
202 | this.getClass().getClassLoader().getResource("images/FlechaInclDerCursor.gif") |
||
203 | ); |
||
204 | PluginServices.getIconTheme().registerDefault( |
||
205 | "inclizq-arrow-icon",
|
||
206 | this.getClass().getClassLoader().getResource("images/FlechaInclIzqCursor.gif") |
||
207 | ); |
||
208 | PluginServices.getIconTheme().registerDefault( |
||
209 | "shear-y-icon",
|
||
210 | this.getClass().getClassLoader().getResource("images/y.gif") |
||
211 | ); |
||
212 | PluginServices.getIconTheme().registerDefault( |
||
213 | "shear-x-icon",
|
||
214 | this.getClass().getClassLoader().getResource("images/x.gif") |
||
215 | ); |
||
216 | PluginServices.getIconTheme().registerDefault( |
||
217 | "hand-icon",
|
||
218 | this.getClass().getClassLoader().getResource("images/Hand.gif") |
||
219 | ); |
||
220 | |||
221 | PluginServices.getIconTheme().registerDefault( |
||
222 | "back-icon",
|
||
223 | this.getClass().getClassLoader().getResource("images/back.png") |
||
224 | ); |
||
225 | PluginServices.getIconTheme().registerDefault( |
||
226 | "next-icon",
|
||
227 | this.getClass().getClassLoader().getResource("images/next.png") |
||
228 | ); |
||
229 | PluginServices.getIconTheme().registerDefault( |
||
230 | "undo-icon",
|
||
231 | this.getClass().getClassLoader().getResource("images/undo.png") |
||
232 | ); |
||
233 | PluginServices.getIconTheme().registerDefault( |
||
234 | "zoom-pixel-cursor",
|
||
235 | this.getClass().getClassLoader().getResource("images/ZoomPixelCursor.gif") |
||
236 | ); |
||
237 | |||
238 | PluginServices.getIconTheme().registerDefault( |
||
239 | "save-raster",
|
||
240 | this.getClass().getClassLoader().getResource("images/Rectangle.png") |
||
241 | ); |
||
242 | |||
243 | PluginServices.getIconTheme().registerDefault( |
||
244 | "pixel-increase",
|
||
245 | this.getClass().getClassLoader().getResource("images/increase.png") |
||
246 | ); |
||
247 | |||
248 | PluginServices.getIconTheme().registerDefault( |
||
249 | "select-raster",
|
||
250 | this.getClass().getClassLoader().getResource("images/stock_toggle-info.png") |
||
251 | ); |
||
252 | PluginServices.getIconTheme().registerDefault( |
||
253 | "select-raster",
|
||
254 | this.getClass().getClassLoader().getResource("images/stock_toggle-info.png") |
||
255 | ); |
||
256 | PluginServices.getIconTheme().registerDefault( |
||
257 | "duplicate-icon",
|
||
258 | this.getClass().getClassLoader().getResource("images/duplicate_icon.png") |
||
259 | ); |
||
260 | PluginServices.getIconTheme().registerDefault( |
||
261 | "save-icon",
|
||
262 | this.getClass().getClassLoader().getResource("images/save.png") |
||
263 | ); |
||
264 | PluginServices.getIconTheme().registerDefault( |
||
265 | "reset-icon",
|
||
266 | this.getClass().getClassLoader().getResource("images/reset.png") |
||
267 | ); |
||
268 | 16326 | nbrodin | PluginServices.getIconTheme().registerDefault( |
269 | "tfwload-icon",
|
||
270 | this.getClass().getClassLoader().getResource("images/load.png") |
||
271 | ); |
||
272 | PluginServices.getIconTheme().registerDefault( |
||
273 | "centerraster-icon",
|
||
274 | this.getClass().getClassLoader().getResource("images/center_image.png") |
||
275 | ); |
||
276 | 15765 | nbrodin | } |
277 | 11268 | nacho | /*
|
278 | * (non-Javadoc)
|
||
279 | * @see com.iver.andami.plugins.IExtension#isEnabled()
|
||
280 | */
|
||
281 | public boolean isEnabled() { |
||
282 | 15671 | nbrodin | com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
283 | if (f == null) { |
||
284 | return false; |
||
285 | } |
||
286 | if (f.getClass() == View.class) { |
||
287 | View vista = (View) f; |
||
288 | IProjectView model = vista.getModel(); |
||
289 | MapContext mapa = model.getMapContext(); |
||
290 | FLayers layers = mapa.getLayers(); |
||
291 | for (int i = 0; i < layers.getLayersCount(); i++) |
||
292 | if (layers.getLayer(i) instanceof FLyrRasterSE) |
||
293 | return true; |
||
294 | } |
||
295 | return false; |
||
296 | 11268 | nacho | } |
297 | |||
298 | /**
|
||
299 | * Mostramos el control si hay alguna capa cargada.
|
||
300 | */
|
||
301 | public boolean isVisible() { |
||
302 | 11902 | bsanchez | com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
303 | if (f == null) |
||
304 | return false; |
||
305 | 11268 | nacho | |
306 | 11902 | bsanchez | if (f instanceof View) { |
307 | View vista = (View) f; |
||
308 | IProjectView model = vista.getModel(); |
||
309 | MapContext mapa = model.getMapContext(); |
||
310 | 13311 | nacho | if (mapa.getLayers().getLayersCount() > 0) |
311 | 11902 | bsanchez | return true; |
312 | } |
||
313 | 11268 | nacho | |
314 | 11902 | bsanchez | return false; |
315 | 11268 | nacho | } |
316 | 11902 | bsanchez | } |