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