svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extRasterTools-SE / src / org / gvsig / rastertools / RasterModule.java @ 34300
History | View | Annotate | Download (22.3 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.ApplicationLocator; |
28 |
import org.gvsig.app.ApplicationManager; |
29 |
import org.gvsig.app.project.documents.view.ViewDocument; |
30 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
31 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
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.fmap.raster.tools.ColorTablesFactory; |
40 |
import org.gvsig.raster.Configuration; |
41 |
import org.gvsig.raster.ConfigurationEvent; |
42 |
import org.gvsig.raster.ConfigurationListener; |
43 |
import org.gvsig.raster.RasterLibrary; |
44 |
import org.gvsig.raster.filter.grayscale.GrayScaleManager; |
45 |
import org.gvsig.raster.filter.mask.MaskListManager; |
46 |
import org.gvsig.raster.filter.regionalpha.RegionAlphaListManager; |
47 |
import org.gvsig.raster.gui.preferences.RasterPreferences; |
48 |
import org.gvsig.raster.gui.wizards.PrepareDataStoreParametersRaw; |
49 |
import org.gvsig.raster.gui.wizards.PrepareDataStoreParametersVTR; |
50 |
import org.gvsig.raster.gui.wizards.PrepareLayerAskCoordinates; |
51 |
import org.gvsig.raster.gui.wizards.PrepareLayerAskProjection; |
52 |
import org.gvsig.raster.util.RasterToolsUtil; |
53 |
import org.gvsig.rastertools.properties.RasterPropertiesTocMenuEntry; |
54 |
import org.gvsig.rastertools.properties.panels.BandSelectorPanel; |
55 |
import org.gvsig.rastertools.properties.panels.EnhancedPanel; |
56 |
import org.gvsig.rastertools.properties.panels.GeneralPanel; |
57 |
import org.gvsig.rastertools.properties.panels.InfoPanel; |
58 |
import org.gvsig.rastertools.properties.panels.TransparencyPanel; |
59 |
import org.gvsig.rastertools.rasterresolution.ZoomPixelCursorTocMenuEntry; |
60 |
import org.gvsig.rastertools.saveas.SaveAsTocMenuEntry; |
61 |
import org.gvsig.tools.ToolsLocator; |
62 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
63 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
64 |
|
65 |
|
66 |
/**
|
67 |
* Extensi?n que adapta a FMap y gvSIG la nueva implementaci?n de raster. Para
|
68 |
* el cuadro de Propiedades de visualizaci?n de raster contiene el contenedor
|
69 |
* base se registran la entrada del men? del TOC y los paneles en el cuadro.
|
70 |
* Para la parte de FMap contiene una nueva capa raster y los drivers
|
71 |
* necesarios.
|
72 |
*
|
73 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
74 |
*/
|
75 |
public class RasterModule extends Extension implements ConfigurationListener { |
76 |
|
77 |
/**
|
78 |
* Indica si en el panel de preferencias se refresca automaticamente la vista
|
79 |
* para mostrar los cambios
|
80 |
*/
|
81 |
public static boolean autoRefreshView = true; |
82 |
|
83 |
/**
|
84 |
* Indica si se debe preguntar las coordenadas al cargar una capa que no las
|
85 |
* tenga
|
86 |
*/
|
87 |
public static boolean askCoordinates = false; |
88 |
|
89 |
// private RasterStoreLibrary storeLibrary;
|
90 |
|
91 |
/*
|
92 |
* (non-Javadoc)
|
93 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
94 |
*/
|
95 |
public void execute(String actionCommand) { |
96 |
|
97 |
} |
98 |
|
99 |
/*
|
100 |
* (non-Javadoc)
|
101 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
102 |
*/
|
103 |
public void initialize() { |
104 |
// Asignamos la configuracion global a FlyrRasterSE
|
105 |
FLyrRasterSE.setConfiguration(Configuration.getSingleton());
|
106 |
|
107 |
Configuration.addValueChangedListener(this); |
108 |
loadConfigurationValues(); |
109 |
|
110 |
registerIcons(); |
111 |
RasterLibrary.wakeUp(); |
112 |
// DefaultRasterIOLibrary drivers = null;
|
113 |
// try {
|
114 |
// drivers = new DefaultRasterIOLibrary();
|
115 |
// drivers.initialize();
|
116 |
// } catch (NoClassDefFoundError e) {
|
117 |
// RasterToolsUtil.debug("There was not possible to load drivers", e, null);
|
118 |
// }
|
119 |
|
120 |
// DiagSignalHandler.install("ALRM");
|
121 |
|
122 |
Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
123 |
prefs.put("DataFolder", System.getProperty("user.home")); |
124 |
ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager(); |
125 |
|
126 |
// Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades.
|
127 |
if (!extensionPoints.has("RasterSEPropertiesDialog")) { |
128 |
ExtensionPoint point=extensionPoints.add("RasterSEPropertiesDialog");
|
129 |
|
130 |
point.setDescription("Raster Properties registrable panels (register instances of javax.swing.JPanel)");
|
131 |
//extensionPoints.put(new ExtensionPoint("RasterSEPropertiesDialog", "Raster Properties registrable panels (register instances of javax.swing.JPanel)"));
|
132 |
} |
133 |
|
134 |
// A?adimos la configuracion de Raster a gvSIG
|
135 |
|
136 |
ExtensionPoint point=extensionPoints.add("AplicationPreferences");
|
137 |
point.append("RasterPreferences", "", RasterPreferences.class); |
138 |
|
139 |
// A?adimos paneles al cuadro de propiedades.
|
140 |
point = extensionPoints.add("RasterSEPropertiesDialog");
|
141 |
point.append("info", "", InfoPanel.class); |
142 |
point.append("bands_panel", "", BandSelectorPanel.class); |
143 |
point.append("transparencia", "", TransparencyPanel.class); |
144 |
point.append("realce", "", EnhancedPanel.class); |
145 |
//extensionPoints.add("RasterSEPropertiesDialog", "pansharp", PanSharpeningPanel.class);
|
146 |
point.append("general_panel", "", GeneralPanel.class); |
147 |
|
148 |
// A?adimos las entradas del men? del toc de raster
|
149 |
point = extensionPoints.add("View_TocActions");
|
150 |
point.append("RasterSEProperties", "", RasterPropertiesTocMenuEntry.getSingleton()); |
151 |
point.append("View_TocActions", "SaveAs", SaveAsTocMenuEntry.getSingleton()); |
152 |
point.append("View_TocActions", "ZoomPixelCursor", new ZoomPixelCursorTocMenuEntry()); |
153 |
|
154 |
// A?adimos nuestra extension para el tratamiento de la apertura de ficheros mdentro de gvSIG
|
155 |
// AddLayer.addWizard(FileOpenWizard.class);
|
156 |
// ToolsLocator.getExtensionPointManager().add("FileExtendingOpenDialog",
|
157 |
// "").append("FileOpenRaster", "", FileOpenRaster.class);
|
158 |
|
159 |
ApplicationManager appGvSigMan = ApplicationLocator.getManager(); |
160 |
|
161 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersRaw());
|
162 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersVTR());
|
163 |
|
164 |
appGvSigMan.registerPrepareOpenLayer(new PrepareLayerAskCoordinates());
|
165 |
appGvSigMan.registerPrepareOpenLayer(new PrepareLayerAskProjection());
|
166 |
|
167 |
//Alias
|
168 |
LayerFactory lFactory=LayerFactory.getInstance(); |
169 |
// lFactory.registerLayerToUseForStore("com.iver.cit.gvsig.fmap.layers.FLyrRaster", FLyrRasterSE.class);
|
170 |
// lFactory.registerLayerToUseForStore("com.iver.cit.gvsig.fmap.layers.StatusLayerRaster", StatusLayerRaster.class);
|
171 |
lFactory.registerLayerToUseForStore(CoverageStore.class, |
172 |
FLyrRasterSE.class); |
173 |
|
174 |
// storeLibrary = new RasterStoreLibrary();
|
175 |
// storeLibrary.initialize();
|
176 |
|
177 |
// Registrar filtros
|
178 |
RegionAlphaListManager.register(); |
179 |
MaskListManager.register(); |
180 |
GrayScaleManager.register(); |
181 |
|
182 |
ApplicationLocator.getManager().registerColorTablesFactory(new ColorTablesFactory());
|
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/savefile.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 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
424 |
if (f == null) |
425 |
return false; |
426 |
if (f.getClass() == DefaultViewPanel.class) {
|
427 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
428 |
ViewDocument 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 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
443 |
if (f == null) |
444 |
return false; |
445 |
|
446 |
if (f instanceof DefaultViewPanel) { |
447 |
DefaultViewPanel vista = (DefaultViewPanel) f; |
448 |
ViewDocument 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 DefaultViewPanel) { |
483 |
DefaultViewPanel vista = (DefaultViewPanel) f[i]; |
484 |
ViewDocument 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 |
} |