svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extRasterTools-SE / src / org / gvsig / rastertools / RasterModule.java @ 29569
History | View | Annotate | Download (22.2 KB)
1 |
/* 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 |
import java.util.ArrayList; |
22 |
import java.util.prefs.Preferences; |
23 |
|
24 |
import org.gvsig.AppGvSigLocator; |
25 |
import org.gvsig.AppGvSigManager; |
26 |
import org.gvsig.fmap.dal.coverage.dataset.io.DefaultRasterIOLibrary; |
27 |
import org.gvsig.fmap.dal.raster.CoverageStore; |
28 |
import org.gvsig.fmap.dal.store.raster.RasterStoreLibrary; |
29 |
import org.gvsig.fmap.mapcontext.MapContext; |
30 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
31 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
32 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
33 |
import org.gvsig.fmap.mapcontrol.MapControl; |
34 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
35 |
import org.gvsig.raster.Configuration; |
36 |
import org.gvsig.raster.ConfigurationEvent; |
37 |
import org.gvsig.raster.ConfigurationListener; |
38 |
import org.gvsig.raster.RasterLibrary; |
39 |
import org.gvsig.raster.filter.grayscale.GrayScaleManager; |
40 |
import org.gvsig.raster.filter.mask.MaskListManager; |
41 |
import org.gvsig.raster.filter.regionalpha.RegionAlphaListManager; |
42 |
import org.gvsig.raster.gui.preferences.RasterPreferences; |
43 |
import org.gvsig.raster.gui.wizards.PrepareDataStoreParametersRaw; |
44 |
import org.gvsig.raster.gui.wizards.PrepareDataStoreParametersVTR; |
45 |
import org.gvsig.raster.gui.wizards.PrepareLayerAskCoordinates; |
46 |
import org.gvsig.raster.gui.wizards.PrepareLayerAskProjection; |
47 |
import org.gvsig.raster.util.RasterToolsUtil; |
48 |
import org.gvsig.rastertools.properties.RasterPropertiesTocMenuEntry; |
49 |
import org.gvsig.rastertools.properties.panels.BandSelectorPanel; |
50 |
import org.gvsig.rastertools.properties.panels.EnhancedPanel; |
51 |
import org.gvsig.rastertools.properties.panels.GeneralPanel; |
52 |
import org.gvsig.rastertools.properties.panels.InfoPanel; |
53 |
import org.gvsig.rastertools.properties.panels.TransparencyPanel; |
54 |
import org.gvsig.rastertools.rasterresolution.ZoomPixelCursorTocMenuEntry; |
55 |
import org.gvsig.rastertools.saveas.SaveAsTocMenuEntry; |
56 |
import org.gvsig.tools.ToolsLocator; |
57 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
58 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
59 |
|
60 |
import com.iver.andami.PluginServices; |
61 |
import com.iver.andami.plugins.Extension; |
62 |
import com.iver.andami.ui.mdiManager.IWindow; |
63 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
64 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
65 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
66 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
67 |
|
68 |
/**
|
69 |
* Extensi?n que adapta a FMap y gvSIG la nueva implementaci?n de raster. Para
|
70 |
* el cuadro de Propiedades de visualizaci?n de raster contiene el contenedor
|
71 |
* base se registran la entrada del men? del TOC y los paneles en el cuadro.
|
72 |
* Para la parte de FMap contiene una nueva capa raster y los drivers
|
73 |
* necesarios.
|
74 |
*
|
75 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
76 |
*/
|
77 |
public class RasterModule extends Extension implements ConfigurationListener { |
78 |
|
79 |
/**
|
80 |
* Indica si en el panel de preferencias se refresca automaticamente la vista
|
81 |
* para mostrar los cambios
|
82 |
*/
|
83 |
public static boolean autoRefreshView = true; |
84 |
|
85 |
/**
|
86 |
* Indica si se debe preguntar las coordenadas al cargar una capa que no las
|
87 |
* tenga
|
88 |
*/
|
89 |
public static boolean askCoordinates = false; |
90 |
|
91 |
private RasterStoreLibrary storeLibrary;
|
92 |
|
93 |
/*
|
94 |
* (non-Javadoc)
|
95 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
96 |
*/
|
97 |
public void execute(String actionCommand) { |
98 |
|
99 |
} |
100 |
|
101 |
/*
|
102 |
* (non-Javadoc)
|
103 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
104 |
*/
|
105 |
public void initialize() { |
106 |
// Asignamos la configuracion global a FlyrRasterSE
|
107 |
FLyrRasterSE.setConfiguration(Configuration.getSingleton());
|
108 |
|
109 |
Configuration.addValueChangedListener(this); |
110 |
loadConfigurationValues(); |
111 |
|
112 |
registerIcons(); |
113 |
RasterLibrary.wakeUp(); |
114 |
DefaultRasterIOLibrary drivers = null;
|
115 |
try {
|
116 |
drivers = new DefaultRasterIOLibrary();
|
117 |
drivers.initialize(); |
118 |
} catch (NoClassDefFoundError e) { |
119 |
RasterToolsUtil.debug("There was not possible to load drivers", e, null); |
120 |
} |
121 |
|
122 |
// DiagSignalHandler.install("ALRM");
|
123 |
|
124 |
Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
125 |
prefs.put("DataFolder", System.getProperty("user.home")); |
126 |
ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager(); |
127 |
|
128 |
// Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades.
|
129 |
if (!extensionPoints.has("RasterSEPropertiesDialog")) { |
130 |
ExtensionPoint point=extensionPoints.add("RasterSEPropertiesDialog");
|
131 |
|
132 |
point.setDescription("Raster Properties registrable panels (register instances of javax.swing.JPanel)");
|
133 |
//extensionPoints.put(new ExtensionPoint("RasterSEPropertiesDialog", "Raster Properties registrable panels (register instances of javax.swing.JPanel)"));
|
134 |
} |
135 |
|
136 |
// A?adimos la configuracion de Raster a gvSIG
|
137 |
|
138 |
ExtensionPoint point=extensionPoints.add("AplicationPreferences");
|
139 |
point.append("RasterPreferences", "", RasterPreferences.class); |
140 |
|
141 |
// A?adimos paneles al cuadro de propiedades.
|
142 |
point = extensionPoints.add("RasterSEPropertiesDialog");
|
143 |
point.append("info", "", InfoPanel.class); |
144 |
point.append("bands_panel", "", BandSelectorPanel.class); |
145 |
point.append("transparencia", "", TransparencyPanel.class); |
146 |
point.append("realce", "", EnhancedPanel.class); |
147 |
//extensionPoints.add("RasterSEPropertiesDialog", "pansharp", PanSharpeningPanel.class);
|
148 |
point.append("general_panel", "", GeneralPanel.class); |
149 |
|
150 |
// A?adimos las entradas del men? del toc de raster
|
151 |
point = extensionPoints.add("View_TocActions");
|
152 |
point.append("RasterSEProperties", "", RasterPropertiesTocMenuEntry.getSingleton()); |
153 |
point.append("View_TocActions", "SaveAs", SaveAsTocMenuEntry.getSingleton()); |
154 |
point.append("View_TocActions", "ZoomPixelCursor", new ZoomPixelCursorTocMenuEntry()); |
155 |
|
156 |
// A?adimos nuestra extension para el tratamiento de la apertura de ficheros mdentro de gvSIG
|
157 |
// AddLayer.addWizard(FileOpenWizard.class);
|
158 |
// ToolsLocator.getExtensionPointManager().add("FileExtendingOpenDialog",
|
159 |
// "").append("FileOpenRaster", "", FileOpenRaster.class);
|
160 |
|
161 |
AppGvSigManager appGvSigMan = AppGvSigLocator.getAppGvSigManager(); |
162 |
|
163 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersRaw());
|
164 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersVTR());
|
165 |
|
166 |
appGvSigMan.registerPrepareOpenLayer(new PrepareLayerAskCoordinates());
|
167 |
appGvSigMan.registerPrepareOpenLayer(new PrepareLayerAskProjection());
|
168 |
|
169 |
//Alias
|
170 |
LayerFactory lFactory=LayerFactory.getInstance(); |
171 |
// lFactory.registerLayerToUseForStore("com.iver.cit.gvsig.fmap.layers.FLyrRaster", FLyrRasterSE.class);
|
172 |
// lFactory.registerLayerToUseForStore("com.iver.cit.gvsig.fmap.layers.StatusLayerRaster", StatusLayerRaster.class);
|
173 |
lFactory.registerLayerToUseForStore(CoverageStore.class, |
174 |
FLyrRasterSE.class); |
175 |
|
176 |
storeLibrary = new RasterStoreLibrary();
|
177 |
storeLibrary.initialize(); |
178 |
|
179 |
// Registrar filtros
|
180 |
RegionAlphaListManager.register(); |
181 |
MaskListManager.register(); |
182 |
GrayScaleManager.register(); |
183 |
} |
184 |
|
185 |
/**
|
186 |
* Registra los iconos a utilizar en andami.
|
187 |
*/
|
188 |
private void registerIcons(){ |
189 |
PluginServices.getIconTheme().registerDefault( |
190 |
"forward-icon",
|
191 |
this.getClass().getClassLoader().getResource("images/forward.png") |
192 |
); |
193 |
PluginServices.getIconTheme().registerDefault( |
194 |
"backward-icon",
|
195 |
this.getClass().getClassLoader().getResource("images/backward.png") |
196 |
); |
197 |
PluginServices.getIconTheme().registerDefault( |
198 |
"map-ok-ico",
|
199 |
this.getClass().getClassLoader().getResource("images/map_ico_ok.gif") |
200 |
); |
201 |
// PluginServices.getIconTheme().registerDefault(
|
202 |
// "crux-cursor",
|
203 |
// MapControl.class.getResource("images/CruxCursor.png")
|
204 |
// );
|
205 |
PluginServices.getIconTheme().registerDefault( |
206 |
"blank-icon",
|
207 |
getClass().getClassLoader().getResource("images/blank.png")
|
208 |
); |
209 |
PluginServices.getIconTheme().registerDefault( |
210 |
"addlayer-icon",
|
211 |
this.getClass().getClassLoader().getResource("images/addlayer.png") |
212 |
); |
213 |
PluginServices.getIconTheme().registerDefault( |
214 |
"delall-icon",
|
215 |
this.getClass().getClassLoader().getResource("images/delall.png") |
216 |
); |
217 |
PluginServices.getIconTheme().registerDefault( |
218 |
"rotar-icon",
|
219 |
this.getClass().getClassLoader().getResource("images/Rotar.gif") |
220 |
); |
221 |
PluginServices.getIconTheme().registerDefault( |
222 |
"hor-arrow-icon",
|
223 |
this.getClass().getClassLoader().getResource("images/FlechaHorizCursor.gif") |
224 |
); |
225 |
PluginServices.getIconTheme().registerDefault( |
226 |
"ver-arrow-icon",
|
227 |
this.getClass().getClassLoader().getResource("images/FlechaVertCursor.gif") |
228 |
); |
229 |
PluginServices.getIconTheme().registerDefault( |
230 |
"inclder-arrow-icon",
|
231 |
this.getClass().getClassLoader().getResource("images/FlechaInclDerCursor.gif") |
232 |
); |
233 |
PluginServices.getIconTheme().registerDefault( |
234 |
"inclizq-arrow-icon",
|
235 |
this.getClass().getClassLoader().getResource("images/FlechaInclIzqCursor.gif") |
236 |
); |
237 |
PluginServices.getIconTheme().registerDefault( |
238 |
"shear-y-icon",
|
239 |
this.getClass().getClassLoader().getResource("images/y.gif") |
240 |
); |
241 |
PluginServices.getIconTheme().registerDefault( |
242 |
"shear-x-icon",
|
243 |
this.getClass().getClassLoader().getResource("images/x.gif") |
244 |
); |
245 |
PluginServices.getIconTheme().registerDefault( |
246 |
"hand-icon",
|
247 |
this.getClass().getClassLoader().getResource("images/Hand.gif") |
248 |
); |
249 |
PluginServices.getIconTheme().registerDefault( |
250 |
"back-icon",
|
251 |
this.getClass().getClassLoader().getResource("images/back.png") |
252 |
); |
253 |
PluginServices.getIconTheme().registerDefault( |
254 |
"next-icon",
|
255 |
this.getClass().getClassLoader().getResource("images/next.png") |
256 |
); |
257 |
PluginServices.getIconTheme().registerDefault( |
258 |
"undo-icon",
|
259 |
this.getClass().getClassLoader().getResource("images/undo.png") |
260 |
); |
261 |
PluginServices.getIconTheme().registerDefault( |
262 |
"zoom-pixel-cursor",
|
263 |
this.getClass().getClassLoader().getResource("images/ZoomPixelCursor.gif") |
264 |
); |
265 |
PluginServices.getIconTheme().registerDefault( |
266 |
"save-raster",
|
267 |
this.getClass().getClassLoader().getResource("images/Rectangle.png") |
268 |
); |
269 |
PluginServices.getIconTheme().registerDefault( |
270 |
"pixel-increase",
|
271 |
this.getClass().getClassLoader().getResource("images/increase.png") |
272 |
); |
273 |
PluginServices.getIconTheme().registerDefault( |
274 |
"select-raster",
|
275 |
this.getClass().getClassLoader().getResource("images/stock_toggle-info.png") |
276 |
); |
277 |
PluginServices.getIconTheme().registerDefault( |
278 |
"select-raster",
|
279 |
this.getClass().getClassLoader().getResource("images/stock_toggle-info.png") |
280 |
); |
281 |
PluginServices.getIconTheme().registerDefault( |
282 |
"export-icon",
|
283 |
this.getClass().getClassLoader().getResource("images/export.png") |
284 |
); |
285 |
PluginServices.getIconTheme().registerDefault( |
286 |
"pref-raster-icon",
|
287 |
this.getClass().getClassLoader().getResource("images/raster-pref.png") |
288 |
); |
289 |
PluginServices.getIconTheme().registerDefault( |
290 |
"import-icon",
|
291 |
this.getClass().getClassLoader().getResource("images/import.png") |
292 |
); |
293 |
PluginServices.getIconTheme().registerDefault( |
294 |
"save-icon",
|
295 |
this.getClass().getClassLoader().getResource("images/save.png") |
296 |
); |
297 |
PluginServices.getIconTheme().registerDefault( |
298 |
"reset-icon",
|
299 |
this.getClass().getClassLoader().getResource("images/reset.png") |
300 |
); |
301 |
PluginServices.getIconTheme().registerDefault( |
302 |
"tfwload-icon",
|
303 |
this.getClass().getClassLoader().getResource("images/load.png") |
304 |
); |
305 |
PluginServices.getIconTheme().registerDefault( |
306 |
"centerraster-icon",
|
307 |
this.getClass().getClassLoader().getResource("images/center_image.png") |
308 |
); |
309 |
PluginServices.getIconTheme().registerDefault( |
310 |
"increase-icon",
|
311 |
this.getClass().getClassLoader().getResource("images/aumentar.png") |
312 |
); |
313 |
PluginServices.getIconTheme().registerDefault( |
314 |
"decrease-icon",
|
315 |
this.getClass().getClassLoader().getResource("images/disminuir.png") |
316 |
); |
317 |
PluginServices.getIconTheme().registerDefault( |
318 |
"selectzoomarea-icon",
|
319 |
this.getClass().getClassLoader().getResource("images/view-zoom-to-seleccion.png") |
320 |
); |
321 |
PluginServices.getIconTheme().registerDefault( |
322 |
"prevzoom-icon",
|
323 |
this.getClass().getClassLoader().getResource("images/view-zoom-back.png") |
324 |
); |
325 |
PluginServices.getIconTheme().registerDefault( |
326 |
"fullview-icon",
|
327 |
this.getClass().getClassLoader().getResource("images/view-zoom-map-contents.png") |
328 |
); |
329 |
PluginServices.getIconTheme().register( |
330 |
"geolocalization-icon",
|
331 |
this.getClass().getClassLoader().getResource("images/georef.png") |
332 |
); |
333 |
PluginServices.getIconTheme().register( |
334 |
"exporttoascii-icon",
|
335 |
this.getClass().getClassLoader().getResource("images/exportToAscii.png") |
336 |
); |
337 |
PluginServices.getIconTheme().register( |
338 |
"exporttocsv-icon",
|
339 |
this.getClass().getClassLoader().getResource("images/exportToCSV.png") |
340 |
); |
341 |
PluginServices.getIconTheme().register( |
342 |
"importfromcsv-icon",
|
343 |
this.getClass().getClassLoader().getResource("images/importFromCSV.png") |
344 |
); |
345 |
PluginServices.getIconTheme().register( |
346 |
"exit-icon",
|
347 |
this.getClass().getClassLoader().getResource("images/ico_exit.gif") |
348 |
); |
349 |
PluginServices.getIconTheme().register( |
350 |
"options-icon",
|
351 |
this.getClass().getClassLoader().getResource("images/ico_options.gif") |
352 |
); |
353 |
PluginServices.getIconTheme().register( |
354 |
"add-icon",
|
355 |
this.getClass().getClassLoader().getResource("images/add-ico.gif") |
356 |
); |
357 |
PluginServices.getIconTheme().register( |
358 |
"centerpoint-icon",
|
359 |
this.getClass().getClassLoader().getResource("images/icon_centerpoint.gif") |
360 |
); |
361 |
PluginServices.getIconTheme().register( |
362 |
"hand-icon",
|
363 |
this.getClass().getClassLoader().getResource("images/Hand.gif") |
364 |
); |
365 |
PluginServices.getIconTheme().register( |
366 |
"analisis-icon",
|
367 |
this.getClass().getClassLoader().getResource("images/prismaticos.gif") |
368 |
); |
369 |
PluginServices.getIconTheme().registerDefault( |
370 |
"clipping-icon",
|
371 |
getClass().getClassLoader().getResource("images/clipping.gif")
|
372 |
); |
373 |
PluginServices.getIconTheme().registerDefault( |
374 |
"filter-icon",
|
375 |
getClass().getClassLoader().getResource("images/raster-filter.png")
|
376 |
); |
377 |
PluginServices.getIconTheme().registerDefault( |
378 |
"histogram-icon",
|
379 |
getClass().getClassLoader().getResource("images/histogram.png")
|
380 |
); |
381 |
PluginServices.getIconTheme().registerDefault( |
382 |
"overviews-icon",
|
383 |
getClass().getClassLoader().getResource("images/overviews.gif")
|
384 |
); |
385 |
PluginServices.getIconTheme().registerDefault( |
386 |
"properties-icon",
|
387 |
getClass().getClassLoader().getResource("images/properties.gif")
|
388 |
); |
389 |
PluginServices.getIconTheme().registerDefault( |
390 |
"colortable-icon",
|
391 |
getClass().getClassLoader().getResource("images/colortable.png")
|
392 |
); |
393 |
PluginServices.getIconTheme().registerDefault( |
394 |
"rois-icon",
|
395 |
getClass().getClassLoader().getResource("images/rois.png")
|
396 |
); |
397 |
PluginServices.getIconTheme().registerDefault( |
398 |
"brush-icon",
|
399 |
getClass().getClassLoader().getResource("images/brush.png")
|
400 |
); |
401 |
PluginServices.getIconTheme().registerDefault( |
402 |
"selectrgb-icon",
|
403 |
getClass().getClassLoader().getResource("images/select_rgb.gif")
|
404 |
); |
405 |
PluginServices.getIconTheme().registerDefault( |
406 |
"reproj-icon",
|
407 |
getClass().getClassLoader().getResource("images/reproject.png")
|
408 |
); |
409 |
PluginServices.getIconTheme().registerDefault( |
410 |
"vectorization-icon",
|
411 |
getClass().getClassLoader().getResource("images/vectorT.png")
|
412 |
); |
413 |
PluginServices.getIconTheme().registerDefault( |
414 |
"focus-icon",
|
415 |
getClass().getClassLoader().getResource("images/focus.png")
|
416 |
); |
417 |
} |
418 |
/*
|
419 |
* (non-Javadoc)
|
420 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
421 |
*/
|
422 |
public boolean isEnabled() { |
423 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
424 |
if (f == null) |
425 |
return false; |
426 |
if (f.getClass() == View.class) { |
427 |
BaseView vista = (BaseView) f; |
428 |
IProjectView model = vista.getModel(); |
429 |
MapContext mapa = model.getMapContext(); |
430 |
FLayers layers = mapa.getLayers(); |
431 |
for (int i = 0; i < layers.getLayersCount(); i++) |
432 |
if (layers.getLayer(i) instanceof FLyrRasterSE) |
433 |
return true; |
434 |
} |
435 |
return false; |
436 |
} |
437 |
|
438 |
/**
|
439 |
* Mostramos el control si hay alguna capa cargada.
|
440 |
*/
|
441 |
public boolean isVisible() { |
442 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
443 |
if (f == null) |
444 |
return false; |
445 |
|
446 |
if (f instanceof View) { |
447 |
View vista = (View) f; |
448 |
IProjectView model = vista.getModel(); |
449 |
MapContext mapa = model.getMapContext(); |
450 |
if (mapa.getLayers().getLayersCount() > 0) |
451 |
return true; |
452 |
} |
453 |
|
454 |
return false; |
455 |
} |
456 |
|
457 |
/**
|
458 |
* Carga los valores de configuracion iniciales
|
459 |
*/
|
460 |
private void loadConfigurationValues() { |
461 |
autoRefreshView = Configuration.getValue("general_auto_preview", Boolean.TRUE).booleanValue(); |
462 |
askCoordinates = Configuration.getValue("general_ask_coordinates", Boolean.FALSE).booleanValue(); |
463 |
RasterLibrary.defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)).intValue(); |
464 |
RasterLibrary.cacheSize = Configuration.getValue("cache_size", Long.valueOf(RasterLibrary.cacheSize)).longValue(); |
465 |
RasterLibrary.pageSize = Configuration.getValue("cache_pagesize", Double.valueOf(RasterLibrary.pageSize)).doubleValue(); |
466 |
RasterLibrary.pagsPerGroup = Configuration.getValue("cache_pagspergroup", Integer.valueOf(RasterLibrary.pagsPerGroup)).intValue(); |
467 |
RasterLibrary.blockHeight = Configuration.getValue("cache_blockheight", Integer.valueOf(RasterLibrary.blockHeight)).intValue(); |
468 |
RasterLibrary.defaultNoDataValue = Configuration.getValue("nodata_value", Double.valueOf(RasterLibrary.defaultNoDataValue)).doubleValue(); |
469 |
} |
470 |
|
471 |
/*
|
472 |
* (non-Javadoc)
|
473 |
* @see org.gvsig.raster.util.ConfigurationListener#actionConfigurationChanged(org.gvsig.raster.util.ConfigurationEvent)
|
474 |
*/
|
475 |
public void actionConfigurationChanged(ConfigurationEvent e) { |
476 |
if (e.getKey().equals("nodata_transparency_enabled")) { |
477 |
boolean noDataTransparent = ((Boolean) e.getValue()).booleanValue(); |
478 |
IWindow[] f = PluginServices.getMDIManager().getAllWindows();
|
479 |
if (f == null) |
480 |
return;
|
481 |
for (int i = 0; i < f.length; i++) |
482 |
if (f[i] instanceof View) { |
483 |
View vista = (View) f[i]; |
484 |
IProjectView model = vista.getModel(); |
485 |
MapContext map = model.getMapContext(); |
486 |
FLayers lyrs = map.getLayers(); |
487 |
|
488 |
ArrayList list = RasterToolsUtil.getRasterLayerList(lyrs, null); |
489 |
for (int j = 0; j < list.size(); j++) |
490 |
if(list.get(j) instanceof FLyrRasterSE) |
491 |
((FLyrRasterSE)list.get(j)).getDataSource().getTransparencyFilesStatus().activeNoData(noDataTransparent); |
492 |
} |
493 |
|
494 |
return;
|
495 |
} |
496 |
|
497 |
if (e.getKey().equals("general_auto_preview")) { |
498 |
if(e.getValue() instanceof String) |
499 |
autoRefreshView = new Boolean((String) e.getValue()).booleanValue(); |
500 |
if(e.getValue() instanceof Boolean) |
501 |
autoRefreshView = ((Boolean) e.getValue()).booleanValue();
|
502 |
return;
|
503 |
} |
504 |
|
505 |
if (e.getKey().equals("general_ask_coordinates")) { |
506 |
if(e.getValue() instanceof String) |
507 |
askCoordinates = new Boolean((String) e.getValue()).booleanValue(); |
508 |
if(e.getValue() instanceof Boolean) |
509 |
askCoordinates = ((Boolean) e.getValue()).booleanValue();
|
510 |
return;
|
511 |
} |
512 |
|
513 |
if (e.getKey().equals("general_defaultNumberOfClasses")) { |
514 |
if(e.getValue() instanceof String) |
515 |
try {
|
516 |
RasterLibrary.defaultNumberOfClasses = new Integer( |
517 |
(String) e.getValue()).intValue();
|
518 |
} catch (NumberFormatException exc) { |
519 |
//Valor por defecto en el n?mero de clases
|
520 |
} |
521 |
|
522 |
if(e.getValue() instanceof Integer) |
523 |
RasterLibrary.defaultNumberOfClasses = ((Integer) e.getValue()).intValue();
|
524 |
return;
|
525 |
} |
526 |
|
527 |
if (e.getKey().equals("cache_size")) { |
528 |
if(e.getValue() instanceof String) |
529 |
try {
|
530 |
RasterLibrary.cacheSize = new Long((String) e.getValue()).longValue(); |
531 |
} catch (NumberFormatException exc) { |
532 |
//Valor por defecto en la cache
|
533 |
} |
534 |
if(e.getValue() instanceof Long) |
535 |
RasterLibrary.cacheSize = ((Long) e.getValue()).longValue();
|
536 |
return;
|
537 |
} |
538 |
|
539 |
if (e.getKey().equals("cache_pagesize")) { |
540 |
if(e.getValue() instanceof String) |
541 |
try {
|
542 |
RasterLibrary.pageSize = new Double((String) e.getValue()) |
543 |
.doubleValue(); |
544 |
} catch (NumberFormatException exc) { |
545 |
//Valor por defecto en la cache
|
546 |
} |
547 |
|
548 |
if(e.getValue() instanceof Double) |
549 |
RasterLibrary.pageSize = ((Double) e.getValue()).doubleValue();
|
550 |
return;
|
551 |
} |
552 |
|
553 |
if (e.getKey().equals("cache_pagspergroup")) { |
554 |
if(e.getValue() instanceof String) |
555 |
try {
|
556 |
RasterLibrary.pagsPerGroup = new Integer((String) e |
557 |
.getValue()).intValue(); |
558 |
} catch (NumberFormatException exc) { |
559 |
//Valor por defecto en la cache
|
560 |
} |
561 |
|
562 |
if(e.getValue() instanceof Integer) |
563 |
RasterLibrary.pagsPerGroup = ((Integer) e.getValue()).intValue();
|
564 |
return;
|
565 |
} |
566 |
|
567 |
if (e.getKey().equals("cache_blockheight")) { |
568 |
if(e.getValue() instanceof String) |
569 |
try {
|
570 |
RasterLibrary.blockHeight = new Integer((String) e |
571 |
.getValue()).intValue(); |
572 |
} catch (NumberFormatException exc) { |
573 |
//Valor por defecto en la cache
|
574 |
} |
575 |
if(e.getValue() instanceof Integer) |
576 |
RasterLibrary.blockHeight = ((Integer) e.getValue()).intValue();
|
577 |
return;
|
578 |
} |
579 |
|
580 |
if (e.getKey().equals("nodata_value")) { |
581 |
if(e.getValue() instanceof String) |
582 |
try {
|
583 |
RasterLibrary.defaultNoDataValue = new Double((String) e |
584 |
.getValue()).doubleValue(); |
585 |
} catch (NumberFormatException exc) { |
586 |
//Valor por defecto en valor nodata
|
587 |
} |
588 |
|
589 |
if(e.getValue() instanceof Double) |
590 |
RasterLibrary.defaultNoDataValue = ((Double) e.getValue()).doubleValue();
|
591 |
return;
|
592 |
} |
593 |
} |
594 |
|
595 |
/*
|
596 |
* (non-Javadoc)
|
597 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
598 |
*/
|
599 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
600 |
this.execute("SELECTIMAGE"); |
601 |
} |
602 |
|
603 |
public void postInitialize() { |
604 |
super.postInitialize();
|
605 |
storeLibrary.postInitialize(); |
606 |
} |
607 |
} |