svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / RasterModule.java @ 18014
History | View | Annotate | Download (19 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 | 17804 | nbrodin | import java.util.ArrayList; |
22 | 11893 | nacho | import java.util.prefs.Preferences; |
23 | |||
24 | 13761 | nacho | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
25 | import org.gvsig.fmap.raster.layers.StatusLayerRaster; |
||
26 | 18014 | bsanchez | import org.gvsig.raster.Configuration; |
27 | import org.gvsig.raster.ConfigurationEvent; |
||
28 | import org.gvsig.raster.ConfigurationListener; |
||
29 | 17349 | nbrodin | import org.gvsig.raster.RasterLibrary; |
30 | 17161 | bsanchez | import org.gvsig.raster.gui.preferences.RasterPreferences; |
31 | 12425 | nacho | import org.gvsig.raster.gui.properties.dialog.RasterPropertiesTocMenuEntry; |
32 | 13543 | bsanchez | import org.gvsig.raster.gui.wizards.FileOpenRaster; |
33 | 12182 | nacho | import org.gvsig.rastertools.analysisview.ViewRasterAnalysisTocMenuEntry; |
34 | 14842 | bsanchez | import org.gvsig.rastertools.clipping.ClippingTocMenuEntry; |
35 | 12344 | bsanchez | import org.gvsig.rastertools.colortable.ColorTableTocMenuEntry; |
36 | 11500 | bsanchez | import org.gvsig.rastertools.filter.FilterTocMenuEntry; |
37 | 14135 | nbrodin | import org.gvsig.rastertools.geolocation.GeoLocationTocMenuEntry; |
38 | 11268 | nacho | import org.gvsig.rastertools.histogram.HistogramTocMenuEntry; |
39 | 17219 | nbrodin | import org.gvsig.rastertools.overviews.OverviewsTocMenuEntry; |
40 | 11268 | nacho | import org.gvsig.rastertools.properties.panels.BandSetupPanel; |
41 | import org.gvsig.rastertools.properties.panels.EnhancedPanel; |
||
42 | import org.gvsig.rastertools.properties.panels.InfoPanel; |
||
43 | 12617 | amunoz | import org.gvsig.rastertools.properties.panels.PanSharpeningPanel; |
44 | 14467 | bsanchez | import org.gvsig.rastertools.properties.panels.ScalePanel; |
45 | 17699 | nbrodin | import org.gvsig.rastertools.properties.panels.StatisticsPanel; |
46 | 11268 | nacho | import org.gvsig.rastertools.properties.panels.TransparencyPanel; |
47 | 11662 | nacho | import org.gvsig.rastertools.rasterresolution.ZoomPixelCursorTocMenuEntry; |
48 | 14218 | bsanchez | import org.gvsig.rastertools.roi.ui.ROIManagerTocMenuEntry; |
49 | 11900 | nacho | import org.gvsig.rastertools.saveas.SaveAsTocMenuEntry; |
50 | 11686 | nacho | import org.gvsig.rastertools.selectrasterlayer.SelectImageListener; |
51 | 12610 | nacho | |
52 | 11268 | nacho | import com.iver.andami.PluginServices; |
53 | import com.iver.andami.plugins.Extension; |
||
54 | import com.iver.cit.gvsig.fmap.MapContext; |
||
55 | import com.iver.cit.gvsig.fmap.MapControl; |
||
56 | 15671 | nbrodin | import com.iver.cit.gvsig.fmap.layers.FLayers; |
57 | 13761 | nacho | import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
58 | 11268 | nacho | import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
59 | import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
||
60 | 11686 | nacho | import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
61 | 11268 | nacho | import com.iver.cit.gvsig.project.documents.view.IProjectView; |
62 | import com.iver.cit.gvsig.project.documents.view.gui.View; |
||
63 | import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
||
64 | import com.iver.utiles.extensionPoints.ExtensionPoint; |
||
65 | import com.iver.utiles.extensionPoints.ExtensionPoints; |
||
66 | import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
||
67 | /**
|
||
68 | 11715 | bsanchez | * Extensi?n que adapta a FMap y gvSIG la nueva implementaci?n de raster. Para
|
69 | * el cuadro de Propiedades de visualizaci?n de raster contiene el contenedor
|
||
70 | * base se registran la entrada del men? del TOC y los paneles en el cuadro.
|
||
71 | * Para la parte de FMap contiene una nueva capa raster y los drivers
|
||
72 | * necesarios.
|
||
73 | 12344 | bsanchez | *
|
74 | 11268 | nacho | * @author Nacho Brodin (nachobrodin@gmail.com)
|
75 | */
|
||
76 | 17491 | bsanchez | public class RasterModule extends Extension implements ConfigurationListener { |
77 | 11894 | nacho | /**
|
78 | 11902 | bsanchez | * Contador global de las capas generadas para raster
|
79 | */
|
||
80 | 17804 | nbrodin | private static int layerCount = 1; |
81 | private static ArrayList propetiesListeners = new ArrayList(); |
||
82 | 11902 | bsanchez | |
83 | 17491 | bsanchez | /**
|
84 | * Indica si en el panel de preferencias se refresca automaticamente la vista
|
||
85 | * para mostrar los cambios
|
||
86 | */
|
||
87 | public static boolean autoRefreshView = true; |
||
88 | |||
89 | /**
|
||
90 | * Indica si se debe preguntar las coordenadas al cargar una capa que no las
|
||
91 | * tenga
|
||
92 | */
|
||
93 | public static boolean askCoordinates = false; |
||
94 | |||
95 | 17804 | nbrodin | /**
|
96 | * La gesti?n de nombres ?nicos en la generaci?n de capas se lleva de forma
|
||
97 | * autom?tica. Cuando alguien crea una capa nueva, si esta no tiene nombre especifico,
|
||
98 | * obtiene su nombre mediante este m?todo. La siguiente vez que se llame dar? un nombre
|
||
99 | * distinto. El nombre de la capa ser? NewLayer_ seguido de un contador de actualizaci?n
|
||
100 | * autom?tica cada vez que se usa.
|
||
101 | * @return Nombre ?nico para la capa.
|
||
102 | */
|
||
103 | public static String usesOnlyLayerName() { |
||
104 | String oldValue = getOnlyLayerName();
|
||
105 | String newValue = "NewLayer_" + (++RasterModule.layerCount); |
||
106 | for (int i = 0; i < propetiesListeners.size(); i++) { |
||
107 | if(propetiesListeners.get(i) instanceof PropertyListener) |
||
108 | ((PropertyListener)propetiesListeners.get(i)).actionValueChanged(new PropertyEvent(oldValue, "NewLayer", newValue, oldValue)); |
||
109 | } |
||
110 | return newValue;
|
||
111 | } |
||
112 | |||
113 | /**
|
||
114 | * Obtiene el nombre ?nico de la siguiente capa sin actualizar el contador. Es
|
||
115 | * solo para consulta. La siguiente vez que se llama a getOnlyLayerName o usesOnlyLayerName
|
||
116 | * devolver? el mismo nomnbre.
|
||
117 | * @return Nombre ?nico para la capa.
|
||
118 | */
|
||
119 | public static String getOnlyLayerName() { |
||
120 | return "NewLayer_" + RasterModule.layerCount; |
||
121 | } |
||
122 | |||
123 | /**
|
||
124 | * A?adir un listener a la lista de eventos
|
||
125 | * @param listener
|
||
126 | */
|
||
127 | public static void addOnlyLayerNameListener(PropertyListener listener) { |
||
128 | if (!propetiesListeners.contains(listener))
|
||
129 | propetiesListeners.add(listener); |
||
130 | } |
||
131 | |||
132 | /**
|
||
133 | * Elimina un listener de la lista de eventos
|
||
134 | * @param listener
|
||
135 | */
|
||
136 | public static void removeOnlyLayerNameListener(PropertyListener listener) { |
||
137 | for (int i = 0; i < propetiesListeners.size(); i++) |
||
138 | if(propetiesListeners.get(i) == listener)
|
||
139 | propetiesListeners.remove(i); |
||
140 | } |
||
141 | |||
142 | 11894 | nacho | /*
|
143 | * (non-Javadoc)
|
||
144 | * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
||
145 | */
|
||
146 | 11902 | bsanchez | public void execute(String actionCommand) { |
147 | 11686 | nacho | View theView = (View) PluginServices.getMDIManager().getActiveWindow(); |
148 | 11902 | bsanchez | MapControl mapCtrl = theView.getMapControl(); |
149 | |||
150 | // Listener de eventos de movimiento que pone las coordenadas del rat?n en
|
||
151 | // la barra de estado
|
||
152 | StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
||
153 | |||
154 | 11686 | nacho | if (actionCommand.equals("SELECTIMAGE")) { |
155 | loadSelectRasterListener(mapCtrl, sbl); |
||
156 | mapCtrl.setTool("selectRasterLayer");
|
||
157 | 16414 | bsanchez | } |
158 | 11902 | bsanchez | } |
159 | |||
160 | 11686 | nacho | /**
|
161 | 11902 | bsanchez | * Carga el listener de selecci?n de raster en el MapControl.
|
162 | */
|
||
163 | private void loadSelectRasterListener(MapControl mapCtrl, StatusBarListener sbl) { |
||
164 | if (mapCtrl.getNamesMapTools().get("selectRasterLayer") == null) { |
||
165 | 11686 | nacho | SelectImageListener sil = new SelectImageListener(mapCtrl);
|
166 | 11902 | bsanchez | mapCtrl.addMapTool("selectRasterLayer", new Behavior[] { new PointBehavior(sil), new MouseMovementBehavior(sbl) }); |
167 | 11686 | nacho | mapCtrl.setTool("selectRasterLayer");
|
168 | } |
||
169 | 11902 | bsanchez | } |
170 | 16414 | bsanchez | |
171 | 11268 | nacho | /*
|
172 | * (non-Javadoc)
|
||
173 | * @see com.iver.andami.plugins.IExtension#initialize()
|
||
174 | */
|
||
175 | public void initialize() { |
||
176 | 17491 | bsanchez | Configuration.addValueChangedListener(this); |
177 | loadConfigurationValues(); |
||
178 | |||
179 | 16414 | bsanchez | registerIcons(); |
180 | 17349 | nbrodin | RasterLibrary.wakeUp(); |
181 | 16414 | bsanchez | |
182 | 11268 | nacho | // DiagSignalHandler.install("ALRM");
|
183 | |||
184 | 11902 | bsanchez | Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
185 | 11900 | nacho | prefs.put("DataFolder", System.getProperty("user.home")); |
186 | 11902 | bsanchez | |
187 | 11268 | nacho | ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
188 | 11902 | bsanchez | |
189 | // Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades.
|
||
190 | 13277 | nacho | if (!extensionPoints.containsKey("RasterSEPropertiesDialog")) { |
191 | 11902 | bsanchez | extensionPoints.put(new ExtensionPoint("RasterSEPropertiesDialog", "Raster Properties registrable panels (register instances of javax.swing.JPanel)")); |
192 | 11268 | nacho | } |
193 | 13599 | bsanchez | |
194 | 17161 | bsanchez | // A?adimos la configuracion de Raster a gvSIG
|
195 | extensionPoints.add("AplicationPreferences","RasterPreferences", new RasterPreferences()); |
||
196 | |||
197 | 11902 | bsanchez | // A?adimos paneles al cuadro de propiedades.
|
198 | 13599 | bsanchez | extensionPoints.add("RasterSEPropertiesDialog", "info", InfoPanel.class); |
199 | extensionPoints.add("RasterSEPropertiesDialog", "bands_panel", BandSetupPanel.class); |
||
200 | extensionPoints.add("RasterSEPropertiesDialog", "transparencia", TransparencyPanel.class); |
||
201 | extensionPoints.add("RasterSEPropertiesDialog", "realce", EnhancedPanel.class); |
||
202 | extensionPoints.add("RasterSEPropertiesDialog", "pansharp", PanSharpeningPanel.class); |
||
203 | 14467 | bsanchez | extensionPoints.add("RasterSEPropertiesDialog", "scale_panel", ScalePanel.class); |
204 | 17699 | nbrodin | extensionPoints.add("RasterSEPropertiesDialog", "stats_panel", StatisticsPanel.class); |
205 | 13599 | bsanchez | |
206 | 17219 | nbrodin | // A?adimos las entradas del men? del toc de raster
|
207 | 11902 | bsanchez | extensionPoints.add("View_TocActions", "HistogramPanel", new HistogramTocMenuEntry()); |
208 | 14846 | bsanchez | extensionPoints.add("View_TocActions", "ClippingPanel", new ClippingTocMenuEntry()); |
209 | 11902 | bsanchez | extensionPoints.add("View_TocActions", "FilterPanel", new FilterTocMenuEntry()); |
210 | extensionPoints.add("View_TocActions", "RasterSEProperties", new RasterPropertiesTocMenuEntry()); |
||
211 | extensionPoints.add("View_TocActions", "ZoomPixelCursor", new ZoomPixelCursorTocMenuEntry()); |
||
212 | extensionPoints.add("View_TocActions", "SaveAs", new SaveAsTocMenuEntry()); |
||
213 | 12182 | nacho | extensionPoints.add("View_TocActions", "ViewRasterAnalysis", new ViewRasterAnalysisTocMenuEntry()); |
214 | 12344 | bsanchez | extensionPoints.add("View_TocActions", "ViewColorTable", new ColorTableTocMenuEntry()); |
215 | 14135 | nbrodin | extensionPoints.add("View_TocActions", "GeoLocation", new GeoLocationTocMenuEntry()); |
216 | 14120 | gsdiego | extensionPoints.add("View_TocActions", "RoisManager", new ROIManagerTocMenuEntry()); |
217 | 17219 | nbrodin | extensionPoints.add("View_TocActions", "Overviews", new OverviewsTocMenuEntry()); |
218 | 16414 | bsanchez | |
219 | 13543 | bsanchez | // A?adimos nuestra extension para el tratamiento de la apertura de ficheros
|
220 | // dentro de gvSIG
|
||
221 | 14218 | bsanchez | extensionPoints.add("FileExtendingOpenDialog", "FileOpenRaster", FileOpenRaster.class); |
222 | 16414 | bsanchez | |
223 | 13761 | nacho | //Alias
|
224 | LayerFactory.registerLayerClassForName("com.iver.cit.gvsig.fmap.layers.FLyrRaster", FLyrRasterSE.class);
|
||
225 | LayerFactory.registerLayerClassForName("com.iver.cit.gvsig.fmap.layers.StatusLayerRaster", StatusLayerRaster.class);
|
||
226 | 11268 | nacho | } |
227 | 11902 | bsanchez | |
228 | 15774 | nbrodin | /**
|
229 | * Registra los iconos a utilizar en andami.
|
||
230 | */
|
||
231 | 15765 | nbrodin | private void registerIcons(){ |
232 | PluginServices.getIconTheme().registerDefault( |
||
233 | 16414 | bsanchez | "forward-icon",
|
234 | this.getClass().getClassLoader().getResource("images/forward.png") |
||
235 | ); |
||
236 | PluginServices.getIconTheme().registerDefault( |
||
237 | "backward-icon",
|
||
238 | this.getClass().getClassLoader().getResource("images/backward.png") |
||
239 | ); |
||
240 | PluginServices.getIconTheme().registerDefault( |
||
241 | 15765 | nbrodin | "map-ok-ico",
|
242 | MapControl.class.getResource("images/map_ico_ok.gif")
|
||
243 | ); |
||
244 | PluginServices.getIconTheme().registerDefault( |
||
245 | "crux-cursor",
|
||
246 | MapControl.class.getResource("images/CruxCursor.png")
|
||
247 | ); |
||
248 | PluginServices.getIconTheme().registerDefault( |
||
249 | "addlayer-icon",
|
||
250 | this.getClass().getClassLoader().getResource("images/addlayer.png") |
||
251 | ); |
||
252 | PluginServices.getIconTheme().registerDefault( |
||
253 | "delall-icon",
|
||
254 | this.getClass().getClassLoader().getResource("images/delall.png") |
||
255 | ); |
||
256 | PluginServices.getIconTheme().registerDefault( |
||
257 | "rotar-icon",
|
||
258 | this.getClass().getClassLoader().getResource("images/Rotar.gif") |
||
259 | ); |
||
260 | PluginServices.getIconTheme().registerDefault( |
||
261 | "hor-arrow-icon",
|
||
262 | this.getClass().getClassLoader().getResource("images/FlechaHorizCursor.gif") |
||
263 | ); |
||
264 | PluginServices.getIconTheme().registerDefault( |
||
265 | "ver-arrow-icon",
|
||
266 | this.getClass().getClassLoader().getResource("images/FlechaVertCursor.gif") |
||
267 | ); |
||
268 | PluginServices.getIconTheme().registerDefault( |
||
269 | "inclder-arrow-icon",
|
||
270 | this.getClass().getClassLoader().getResource("images/FlechaInclDerCursor.gif") |
||
271 | ); |
||
272 | PluginServices.getIconTheme().registerDefault( |
||
273 | "inclizq-arrow-icon",
|
||
274 | this.getClass().getClassLoader().getResource("images/FlechaInclIzqCursor.gif") |
||
275 | ); |
||
276 | PluginServices.getIconTheme().registerDefault( |
||
277 | "shear-y-icon",
|
||
278 | this.getClass().getClassLoader().getResource("images/y.gif") |
||
279 | ); |
||
280 | PluginServices.getIconTheme().registerDefault( |
||
281 | "shear-x-icon",
|
||
282 | this.getClass().getClassLoader().getResource("images/x.gif") |
||
283 | ); |
||
284 | PluginServices.getIconTheme().registerDefault( |
||
285 | "hand-icon",
|
||
286 | this.getClass().getClassLoader().getResource("images/Hand.gif") |
||
287 | ); |
||
288 | PluginServices.getIconTheme().registerDefault( |
||
289 | "back-icon",
|
||
290 | this.getClass().getClassLoader().getResource("images/back.png") |
||
291 | ); |
||
292 | PluginServices.getIconTheme().registerDefault( |
||
293 | "next-icon",
|
||
294 | this.getClass().getClassLoader().getResource("images/next.png") |
||
295 | ); |
||
296 | PluginServices.getIconTheme().registerDefault( |
||
297 | "undo-icon",
|
||
298 | this.getClass().getClassLoader().getResource("images/undo.png") |
||
299 | ); |
||
300 | PluginServices.getIconTheme().registerDefault( |
||
301 | "zoom-pixel-cursor",
|
||
302 | this.getClass().getClassLoader().getResource("images/ZoomPixelCursor.gif") |
||
303 | ); |
||
304 | PluginServices.getIconTheme().registerDefault( |
||
305 | "save-raster",
|
||
306 | this.getClass().getClassLoader().getResource("images/Rectangle.png") |
||
307 | ); |
||
308 | PluginServices.getIconTheme().registerDefault( |
||
309 | "pixel-increase",
|
||
310 | this.getClass().getClassLoader().getResource("images/increase.png") |
||
311 | ); |
||
312 | PluginServices.getIconTheme().registerDefault( |
||
313 | "select-raster",
|
||
314 | this.getClass().getClassLoader().getResource("images/stock_toggle-info.png") |
||
315 | ); |
||
316 | PluginServices.getIconTheme().registerDefault( |
||
317 | "select-raster",
|
||
318 | this.getClass().getClassLoader().getResource("images/stock_toggle-info.png") |
||
319 | ); |
||
320 | PluginServices.getIconTheme().registerDefault( |
||
321 | 16555 | bsanchez | "export-icon",
|
322 | this.getClass().getClassLoader().getResource("images/export.png") |
||
323 | 15765 | nbrodin | ); |
324 | PluginServices.getIconTheme().registerDefault( |
||
325 | 17199 | bsanchez | "pref-raster-icon",
|
326 | this.getClass().getClassLoader().getResource("images/raster-pref.png") |
||
327 | ); |
||
328 | PluginServices.getIconTheme().registerDefault( |
||
329 | 16555 | bsanchez | "import-icon",
|
330 | this.getClass().getClassLoader().getResource("images/import.png") |
||
331 | ); |
||
332 | PluginServices.getIconTheme().registerDefault( |
||
333 | 15765 | nbrodin | "save-icon",
|
334 | this.getClass().getClassLoader().getResource("images/save.png") |
||
335 | ); |
||
336 | PluginServices.getIconTheme().registerDefault( |
||
337 | "reset-icon",
|
||
338 | this.getClass().getClassLoader().getResource("images/reset.png") |
||
339 | ); |
||
340 | 16326 | nbrodin | PluginServices.getIconTheme().registerDefault( |
341 | "tfwload-icon",
|
||
342 | this.getClass().getClassLoader().getResource("images/load.png") |
||
343 | ); |
||
344 | PluginServices.getIconTheme().registerDefault( |
||
345 | "centerraster-icon",
|
||
346 | this.getClass().getClassLoader().getResource("images/center_image.png") |
||
347 | ); |
||
348 | 17727 | nbrodin | PluginServices.getIconTheme().registerDefault( |
349 | "increase-icon",
|
||
350 | this.getClass().getClassLoader().getResource("images/aumentar.png") |
||
351 | ); |
||
352 | PluginServices.getIconTheme().registerDefault( |
||
353 | "decrease-icon",
|
||
354 | this.getClass().getClassLoader().getResource("images/disminuir.png") |
||
355 | ); |
||
356 | 17909 | nbrodin | PluginServices.getIconTheme().registerDefault( |
357 | "selectzoomarea-icon",
|
||
358 | this.getClass().getClassLoader().getResource("images/view-zoom-to-seleccion.png") |
||
359 | ); |
||
360 | PluginServices.getIconTheme().registerDefault( |
||
361 | "prevzoom-icon",
|
||
362 | this.getClass().getClassLoader().getResource("images/view-zoom-back.png") |
||
363 | ); |
||
364 | PluginServices.getIconTheme().registerDefault( |
||
365 | "fullview-icon",
|
||
366 | this.getClass().getClassLoader().getResource("images/view-zoom-map-contents.png") |
||
367 | ); |
||
368 | 17727 | nbrodin | PluginServices.getIconTheme().register( |
369 | "georeferencing-icon",
|
||
370 | this.getClass().getClassLoader().getResource("images/georef.png") |
||
371 | ); |
||
372 | PluginServices.getIconTheme().register( |
||
373 | "geolocalization-icon",
|
||
374 | this.getClass().getClassLoader().getResource("images/geoloc.gif") |
||
375 | ); |
||
376 | PluginServices.getIconTheme().register( |
||
377 | "exporttoascii-icon",
|
||
378 | this.getClass().getClassLoader().getResource("images/exportToAscii.png") |
||
379 | ); |
||
380 | PluginServices.getIconTheme().register( |
||
381 | "exporttocsv-icon",
|
||
382 | this.getClass().getClassLoader().getResource("images/exportToCSV.png") |
||
383 | ); |
||
384 | PluginServices.getIconTheme().register( |
||
385 | "importfromcsv-icon",
|
||
386 | this.getClass().getClassLoader().getResource("images/importFromCSV.png") |
||
387 | ); |
||
388 | 15765 | nbrodin | } |
389 | 11268 | nacho | /*
|
390 | * (non-Javadoc)
|
||
391 | * @see com.iver.andami.plugins.IExtension#isEnabled()
|
||
392 | */
|
||
393 | public boolean isEnabled() { |
||
394 | 15671 | nbrodin | com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
395 | if (f == null) { |
||
396 | return false; |
||
397 | } |
||
398 | if (f.getClass() == View.class) { |
||
399 | View vista = (View) f; |
||
400 | IProjectView model = vista.getModel(); |
||
401 | MapContext mapa = model.getMapContext(); |
||
402 | FLayers layers = mapa.getLayers(); |
||
403 | 16414 | bsanchez | for (int i = 0; i < layers.getLayersCount(); i++) |
404 | if (layers.getLayer(i) instanceof FLyrRasterSE) |
||
405 | 15671 | nbrodin | return true; |
406 | } |
||
407 | return false; |
||
408 | 11268 | nacho | } |
409 | |||
410 | /**
|
||
411 | * Mostramos el control si hay alguna capa cargada.
|
||
412 | */
|
||
413 | public boolean isVisible() { |
||
414 | 11902 | bsanchez | com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
415 | if (f == null) |
||
416 | return false; |
||
417 | 11268 | nacho | |
418 | 11902 | bsanchez | if (f instanceof View) { |
419 | View vista = (View) f; |
||
420 | IProjectView model = vista.getModel(); |
||
421 | MapContext mapa = model.getMapContext(); |
||
422 | 16414 | bsanchez | if (mapa.getLayers().getLayersCount() > 0) |
423 | 11902 | bsanchez | return true; |
424 | } |
||
425 | 11268 | nacho | |
426 | 11902 | bsanchez | return false; |
427 | 11268 | nacho | } |
428 | 17491 | bsanchez | |
429 | /**
|
||
430 | * Carga los valores de configuracion iniciales
|
||
431 | */
|
||
432 | private void loadConfigurationValues() { |
||
433 | autoRefreshView = Configuration.getValue("general_auto_preview", Boolean.TRUE).booleanValue(); |
||
434 | askCoordinates = Configuration.getValue("general_ask_coordinates", Boolean.FALSE).booleanValue(); |
||
435 | RasterLibrary.defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)).intValue(); |
||
436 | RasterLibrary.cacheSize = Configuration.getValue("cache_size", Long.valueOf(RasterLibrary.cacheSize)).longValue(); |
||
437 | RasterLibrary.pageSize = Configuration.getValue("cache_pagesize", Double.valueOf(RasterLibrary.pageSize)).doubleValue(); |
||
438 | RasterLibrary.pagsPerGroup = Configuration.getValue("cache_pagspergroup", Integer.valueOf(RasterLibrary.pagsPerGroup)).intValue(); |
||
439 | RasterLibrary.blockHeight = Configuration.getValue("cache_blockheight", Integer.valueOf(RasterLibrary.blockHeight)).intValue(); |
||
440 | 17669 | bsanchez | RasterLibrary.defaultNoDataValue = Configuration.getValue("nodata_value", Double.valueOf(RasterLibrary.defaultNoDataValue)).doubleValue(); |
441 | 17491 | bsanchez | } |
442 | |||
443 | /*
|
||
444 | * (non-Javadoc)
|
||
445 | * @see org.gvsig.raster.util.ConfigurationListener#actionConfigurationChanged(org.gvsig.raster.util.ConfigurationEvent)
|
||
446 | */
|
||
447 | public void actionConfigurationChanged(ConfigurationEvent e) { |
||
448 | if (e.getKey().equals("general_auto_preview")) { |
||
449 | autoRefreshView = ((Boolean) e.getValue()).booleanValue();
|
||
450 | return;
|
||
451 | } |
||
452 | |||
453 | if (e.getKey().equals("general_ask_coordinates")) { |
||
454 | askCoordinates = ((Boolean) e.getValue()).booleanValue();
|
||
455 | return;
|
||
456 | } |
||
457 | |||
458 | if (e.getKey().equals("general_defaultNumberOfClasses")) { |
||
459 | RasterLibrary.defaultNumberOfClasses = ((Integer) e.getValue()).intValue();
|
||
460 | return;
|
||
461 | } |
||
462 | |||
463 | if (e.getKey().equals("cache_size")) { |
||
464 | RasterLibrary.cacheSize = ((Long) e.getValue()).longValue();
|
||
465 | return;
|
||
466 | } |
||
467 | |||
468 | if (e.getKey().equals("cache_pagesize")) { |
||
469 | RasterLibrary.pageSize = ((Double) e.getValue()).doubleValue();
|
||
470 | return;
|
||
471 | } |
||
472 | |||
473 | if (e.getKey().equals("cache_pagspergroup")) { |
||
474 | RasterLibrary.pagsPerGroup = ((Integer) e.getValue()).intValue();
|
||
475 | return;
|
||
476 | } |
||
477 | |||
478 | if (e.getKey().equals("cache_blockheight")) { |
||
479 | RasterLibrary.blockHeight = ((Integer) e.getValue()).intValue();
|
||
480 | return;
|
||
481 | } |
||
482 | |||
483 | if (e.getKey().equals("nodata_value")) { |
||
484 | 17669 | bsanchez | RasterLibrary.defaultNoDataValue = ((Double) e.getValue()).doubleValue();
|
485 | 17491 | bsanchez | return;
|
486 | } |
||
487 | } |
||
488 | 11902 | bsanchez | } |