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