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 @ 940
History | View | Annotate | Download (25.1 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.toc.ITocItem; |
38 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
39 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
40 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
41 |
import org.gvsig.fmap.dal.raster.CoverageStore; |
42 |
import org.gvsig.fmap.mapcontext.MapContext; |
43 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
44 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
45 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
46 |
import org.gvsig.fmap.mapcontrol.MapControl; |
47 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
48 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
49 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
50 |
import org.gvsig.raster.fmap.FmapRasterLibrary; |
51 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
52 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
53 |
import org.gvsig.raster.tools.app.basic.config.Configuration; |
54 |
import org.gvsig.raster.tools.app.basic.config.ConfigurationEvent; |
55 |
import org.gvsig.raster.tools.app.basic.config.ConfigurationListener; |
56 |
import org.gvsig.raster.tools.app.basic.raster.gui.preference.RasterPreferences; |
57 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareDataStoreParametersRaw; |
58 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareDataStoreParametersVTR; |
59 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareLayerAskCoordinates; |
60 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareLayerAskProjection; |
61 |
import org.gvsig.raster.tools.app.basic.tool.filter.grayscale.GrayScaleManager; |
62 |
import org.gvsig.raster.tools.app.basic.tool.filter.mask.MaskListManager; |
63 |
import org.gvsig.raster.tools.app.basic.tool.filter.regionalpha.RegionAlphaListManager; |
64 |
import org.gvsig.raster.tools.app.basic.tool.multiresolution.ResolutionLevelListener; |
65 |
import org.gvsig.raster.tools.app.basic.tool.properties.RasterPropertiesTocMenuEntry; |
66 |
import org.gvsig.raster.tools.app.basic.tool.properties.panel.EnhancedPanel; |
67 |
import org.gvsig.raster.tools.app.basic.tool.properties.panel.GeneralPanel; |
68 |
import org.gvsig.raster.tools.app.basic.tool.properties.panel.InfoPanel; |
69 |
import org.gvsig.raster.tools.app.basic.tool.properties.panel.TransparencyPanel; |
70 |
import org.gvsig.raster.tools.app.basic.tool.rasterresolution.ZoomPixelCursorTocMenuEntry; |
71 |
import org.gvsig.raster.tools.app.basic.tool.saveas.SaveAsTocMenuEntry; |
72 |
import org.gvsig.tools.ToolsLocator; |
73 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
74 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
75 |
|
76 |
|
77 |
/**
|
78 |
* Extensi?n que adapta a FMap y gvSIG la nueva implementaci?n de raster. Para
|
79 |
* el cuadro de Propiedades de visualizaci?n de raster contiene el contenedor
|
80 |
* base se registran la entrada del men? del TOC y los paneles en el cuadro.
|
81 |
* Para la parte de FMap contiene una nueva capa raster y los drivers
|
82 |
* necesarios.
|
83 |
*
|
84 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
85 |
*/
|
86 |
public class RasterExtension extends Extension implements ConfigurationListener { |
87 |
|
88 |
/**
|
89 |
* Indica si en el panel de preferencias se refresca automaticamente la vista
|
90 |
* para mostrar los cambios
|
91 |
*/
|
92 |
public static boolean autoRefreshView = true; |
93 |
|
94 |
/**
|
95 |
* Indica si se debe preguntar las coordenadas al cargar una capa que no las
|
96 |
* tenga
|
97 |
*/
|
98 |
public static boolean askCoordinates = false; |
99 |
|
100 |
/*
|
101 |
* (non-Javadoc)
|
102 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
103 |
*/
|
104 |
public void execute(String actionCommand) { |
105 |
if(actionCommand.compareTo("ZOOM_RES_LEVEL") == 0) { |
106 |
IWindow theView = PluginServices.getMDIManager().getActiveWindow(); |
107 |
if(!(theView instanceof AbstractViewPanel)) { |
108 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this.getClass(), "window_not_valid")); |
109 |
return;
|
110 |
} |
111 |
|
112 |
MapControl mapCtrl = ((AbstractViewPanel)theView).getMapControl(); |
113 |
StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
114 |
ResolutionLevelListener rll = new ResolutionLevelListener();
|
115 |
mapCtrl.addBehavior("zoomResolutionLevel", new Behavior[]{new PointBehavior(rll), |
116 |
new MouseMovementBehavior(sbl)});
|
117 |
mapCtrl.setTool("zoomResolutionLevel");
|
118 |
} |
119 |
} |
120 |
|
121 |
/*
|
122 |
* (non-Javadoc)
|
123 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
124 |
*/
|
125 |
public void initialize() { |
126 |
// Asignamos la configuracion global a FlyrRasterSE
|
127 |
DefaultFLyrRaster.setConfiguration(Configuration.getSingleton());
|
128 |
|
129 |
Configuration.addValueChangedListener(this); |
130 |
loadConfigurationValues(); |
131 |
|
132 |
registerIcons(); |
133 |
|
134 |
FmapRasterLibrary fmapRaster = new FmapRasterLibrary();
|
135 |
fmapRaster.initialize(); |
136 |
|
137 |
Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
138 |
prefs.put("DataFolder", System.getProperty("user.home")); |
139 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
140 |
|
141 |
// Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades.
|
142 |
if (!extensionPoints.has("RasterSEPropertiesDialog")) { |
143 |
ExtensionPoint point = extensionPoints.add("RasterSEPropertiesDialog");
|
144 |
point.setDescription("Raster Properties registrable panels (register instances of javax.swing.JPanel)");
|
145 |
} |
146 |
|
147 |
// A?adimos la configuracion de Raster a gvSIG
|
148 |
|
149 |
ExtensionPoint point = extensionPoints.add("AplicationPreferences");
|
150 |
point.append("RasterPreferences", "", RasterPreferences.class); |
151 |
|
152 |
// A?adimos paneles al cuadro de propiedades.
|
153 |
point = extensionPoints.add("RasterSEPropertiesDialog");
|
154 |
point.append("info", "", InfoPanel.class); |
155 |
point.append("transparencia", "", TransparencyPanel.class); |
156 |
point.append("realce", "", EnhancedPanel.class); |
157 |
point.append("general_panel", "", GeneralPanel.class); |
158 |
|
159 |
// A?adimos las entradas del men? del toc de raster
|
160 |
point = extensionPoints.add("View_TocActions");
|
161 |
point.append("RasterSEProperties", "", RasterPropertiesTocMenuEntry.getSingleton()); |
162 |
point.append("View_TocActions", "SaveAs", SaveAsTocMenuEntry.getSingleton()); |
163 |
point.append("View_TocActions", "ZoomPixelCursor", new ZoomPixelCursorTocMenuEntry()); |
164 |
|
165 |
// A?adimos nuestra extension para el tratamiento de la apertura de ficheros mdentro de gvSIG
|
166 |
// AddLayer.addWizard(FileOpenWizard.class);
|
167 |
// ToolsLocator.getExtensionPointManager().add("FileExtendingOpenDialog",
|
168 |
// "").append("FileOpenRaster", "", FileOpenRaster.class);
|
169 |
|
170 |
ApplicationManager appGvSigMan = ApplicationLocator.getManager(); |
171 |
|
172 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersRaw());
|
173 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersVTR());
|
174 |
|
175 |
appGvSigMan.registerPrepareOpenLayer(new PrepareLayerAskCoordinates());
|
176 |
appGvSigMan.registerPrepareOpenLayer(new PrepareLayerAskProjection());
|
177 |
appGvSigMan.registerPrepareOpenDataStoreParameters(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 |
PluginServices.getIconTheme().registerDefault( |
454 |
"export-icon",
|
455 |
getClass().getClassLoader().getResource("images/export.png")
|
456 |
); |
457 |
PluginServices.getIconTheme().registerDefault( |
458 |
"import-icon",
|
459 |
getClass().getClassLoader().getResource("images/import.png")
|
460 |
); |
461 |
PluginServices.getIconTheme().registerDefault( |
462 |
"round-icon",
|
463 |
getClass().getClassLoader().getResource("images/round.png")
|
464 |
); |
465 |
PluginServices.getIconTheme().registerDefault( |
466 |
"rois-icon",
|
467 |
getClass().getClassLoader().getResource("images/rois.png")
|
468 |
); |
469 |
PluginServices.getIconTheme().registerDefault( |
470 |
"fullextent-icon",
|
471 |
getClass().getClassLoader().getResource("images/fullExtent.png")
|
472 |
); |
473 |
PluginServices.getIconTheme().registerDefault( |
474 |
"selecttool-icon",
|
475 |
getClass().getClassLoader().getResource("images/selectTool.png")
|
476 |
); |
477 |
} |
478 |
/*
|
479 |
* (non-Javadoc)
|
480 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
481 |
*/
|
482 |
@SuppressWarnings("deprecation") |
483 |
public boolean isEnabled() { |
484 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
485 |
if (f == null) |
486 |
return false; |
487 |
if (f instanceof AbstractViewPanel) { |
488 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
489 |
ViewDocument model = vista.getModel(); |
490 |
MapContext mapa = model.getMapContext(); |
491 |
FLayers layers = mapa.getLayers(); |
492 |
for (int i = 0; i < layers.getLayersCount(); i++) |
493 |
if (layers.getLayer(i) instanceof FLyrRaster) |
494 |
return true; |
495 |
} |
496 |
return false; |
497 |
} |
498 |
|
499 |
/**
|
500 |
* Mostramos el control si hay alguna capa cargada.
|
501 |
*/
|
502 |
@SuppressWarnings("deprecation") |
503 |
public boolean isVisible() { |
504 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
505 |
if (f == null) |
506 |
return false; |
507 |
|
508 |
if (f instanceof AbstractViewPanel) { |
509 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
510 |
ViewDocument model = vista.getModel(); |
511 |
MapContext mapa = model.getMapContext(); |
512 |
if (mapa.getLayers().getLayersCount() > 0) |
513 |
return true; |
514 |
} |
515 |
|
516 |
return false; |
517 |
} |
518 |
|
519 |
/**
|
520 |
* Carga los valores de configuracion iniciales
|
521 |
*/
|
522 |
private void loadConfigurationValues() { |
523 |
autoRefreshView = Configuration.getValue("general_auto_preview", Boolean.TRUE).booleanValue(); |
524 |
askCoordinates = Configuration.getValue("general_ask_coordinates", Boolean.FALSE).booleanValue(); |
525 |
RasterLibrary.defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)).intValue(); |
526 |
RasterLibrary.cacheSize = Configuration.getValue("cache_size", Long.valueOf(RasterLibrary.cacheSize)).longValue(); |
527 |
RasterLibrary.pageSize = Configuration.getValue("cache_pagesize", Double.valueOf(RasterLibrary.pageSize)).doubleValue(); |
528 |
RasterLibrary.pagsPerGroup = Configuration.getValue("cache_pagspergroup", Integer.valueOf(RasterLibrary.pagsPerGroup)).intValue(); |
529 |
RasterLibrary.blockHeight = Configuration.getValue("cache_blockheight", Integer.valueOf(RasterLibrary.blockHeight)).intValue(); |
530 |
//RasterLibrary.defaultNoDataValue = Configuration.getValue("nodata_value", Double.valueOf(RasterLibrary.defaultNoDataValue)).doubleValue();
|
531 |
} |
532 |
|
533 |
/*
|
534 |
* (non-Javadoc)
|
535 |
* @see org.gvsig.raster.util.ConfigurationListener#actionConfigurationChanged(org.gvsig.raster.util.ConfigurationEvent)
|
536 |
*/
|
537 |
@SuppressWarnings("deprecation") |
538 |
public void actionConfigurationChanged(ConfigurationEvent e) { |
539 |
if (e.getKey().equals("nodata_transparency_enabled")) { |
540 |
boolean noDataTransparent = ((Boolean) e.getValue()).booleanValue(); |
541 |
IWindow[] f = PluginServices.getMDIManager().getAllWindows();
|
542 |
if (f == null) |
543 |
return;
|
544 |
for (int i = 0; i < f.length; i++) |
545 |
if (f[i] instanceof AbstractViewPanel) { |
546 |
AbstractViewPanel vista = (AbstractViewPanel) f[i]; |
547 |
ViewDocument model = vista.getModel(); |
548 |
MapContext map = model.getMapContext(); |
549 |
FLayers lyrs = map.getLayers(); |
550 |
|
551 |
ArrayList<FLayer> list = RasterToolsUtil.getRasterLayerList(lyrs, null); |
552 |
for (int j = 0; j < list.size(); j++) |
553 |
if(list.get(j) instanceof FLyrRaster) |
554 |
((RasterDataStore)((FLyrRaster)list.get(j)).getDataStore()).getTransparency().activeNoData(noDataTransparent); |
555 |
} |
556 |
|
557 |
return;
|
558 |
} |
559 |
|
560 |
if (e.getKey().equals("general_auto_preview")) { |
561 |
if(e.getValue() instanceof String) |
562 |
autoRefreshView = new Boolean((String) e.getValue()).booleanValue(); |
563 |
if(e.getValue() instanceof Boolean) |
564 |
autoRefreshView = ((Boolean) e.getValue()).booleanValue();
|
565 |
return;
|
566 |
} |
567 |
|
568 |
if (e.getKey().equals("general_ask_coordinates")) { |
569 |
if(e.getValue() instanceof String) |
570 |
askCoordinates = new Boolean((String) e.getValue()).booleanValue(); |
571 |
if(e.getValue() instanceof Boolean) |
572 |
askCoordinates = ((Boolean) e.getValue()).booleanValue();
|
573 |
return;
|
574 |
} |
575 |
|
576 |
if (e.getKey().equals("general_defaultNumberOfClasses")) { |
577 |
if(e.getValue() instanceof String) |
578 |
try {
|
579 |
RasterLibrary.defaultNumberOfClasses = new Integer( |
580 |
(String) e.getValue()).intValue();
|
581 |
} catch (NumberFormatException exc) { |
582 |
//Valor por defecto en el n?mero de clases
|
583 |
} |
584 |
|
585 |
if(e.getValue() instanceof Integer) |
586 |
RasterLibrary.defaultNumberOfClasses = ((Integer) e.getValue()).intValue();
|
587 |
return;
|
588 |
} |
589 |
|
590 |
if (e.getKey().equals("cache_size")) { |
591 |
if(e.getValue() instanceof String) |
592 |
try {
|
593 |
RasterLibrary.cacheSize = new Long((String) e.getValue()).longValue(); |
594 |
} catch (NumberFormatException exc) { |
595 |
//Valor por defecto en la cache
|
596 |
} |
597 |
if(e.getValue() instanceof Long) |
598 |
RasterLibrary.cacheSize = ((Long) e.getValue()).longValue();
|
599 |
return;
|
600 |
} |
601 |
|
602 |
if (e.getKey().equals("cache_pagesize")) { |
603 |
if(e.getValue() instanceof String) |
604 |
try {
|
605 |
RasterLibrary.pageSize = new Double((String) e.getValue()) |
606 |
.doubleValue(); |
607 |
} catch (NumberFormatException exc) { |
608 |
//Valor por defecto en la cache
|
609 |
} |
610 |
|
611 |
if(e.getValue() instanceof Double) |
612 |
RasterLibrary.pageSize = ((Double) e.getValue()).doubleValue();
|
613 |
return;
|
614 |
} |
615 |
|
616 |
if (e.getKey().equals("cache_pagspergroup")) { |
617 |
if(e.getValue() instanceof String) |
618 |
try {
|
619 |
RasterLibrary.pagsPerGroup = new Integer((String) e |
620 |
.getValue()).intValue(); |
621 |
} catch (NumberFormatException exc) { |
622 |
//Valor por defecto en la cache
|
623 |
} |
624 |
|
625 |
if(e.getValue() instanceof Integer) |
626 |
RasterLibrary.pagsPerGroup = ((Integer) e.getValue()).intValue();
|
627 |
return;
|
628 |
} |
629 |
|
630 |
if (e.getKey().equals("cache_blockheight")) { |
631 |
if(e.getValue() instanceof String) |
632 |
try {
|
633 |
RasterLibrary.blockHeight = new Integer((String) e |
634 |
.getValue()).intValue(); |
635 |
} catch (NumberFormatException exc) { |
636 |
//Valor por defecto en la cache
|
637 |
} |
638 |
if(e.getValue() instanceof Integer) |
639 |
RasterLibrary.blockHeight = ((Integer) e.getValue()).intValue();
|
640 |
return;
|
641 |
} |
642 |
|
643 |
/*if (e.getKey().equals("nodata_value")) {
|
644 |
if(e.getValue() instanceof String)
|
645 |
try {
|
646 |
RasterLibrary.defaultNoDataValue = new Double((String) e
|
647 |
.getValue()).doubleValue();
|
648 |
} catch (NumberFormatException exc) {
|
649 |
//Valor por defecto en valor nodata
|
650 |
}
|
651 |
|
652 |
if(e.getValue() instanceof Double)
|
653 |
RasterLibrary.defaultNoDataValue = ((Double) e.getValue()).doubleValue();
|
654 |
return;
|
655 |
}*/
|
656 |
|
657 |
} |
658 |
|
659 |
/*
|
660 |
* (non-Javadoc)
|
661 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
662 |
*/
|
663 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
664 |
this.execute("SELECTIMAGE"); |
665 |
} |
666 |
|
667 |
public void postInitialize() { |
668 |
super.postInitialize();
|
669 |
// storeLibrary.postInitialize();
|
670 |
} |
671 |
} |