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 @ 979
History | View | Annotate | Download (25.3 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.raster.gui.wizard.PrepareLayerAskUsingTiles; |
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 PrepareLayerAskUsingTiles());
|
178 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareLayerAskUsingTiles());
|
179 |
appGvSigMan.registerPrepareOpenLayer(new PrepareLayerAskProjection());
|
180 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareLayerAskProjection());
|
181 |
|
182 |
//Alias
|
183 |
LayerFactory lFactory = LayerFactory.getInstance(); |
184 |
// lFactory.registerLayerToUseForStore("com.iver.cit.gvsig.fmap.layers.FLyrRaster", FLyrRasterSE.class);
|
185 |
// lFactory.registerLayerToUseForStore("com.iver.cit.gvsig.fmap.layers.StatusLayerRaster", StatusLayerRaster.class);
|
186 |
lFactory.registerLayerToUseForStore(CoverageStore.class, |
187 |
DefaultFLyrRaster.class); |
188 |
|
189 |
// Registrar filtros
|
190 |
RegionAlphaListManager.register(); |
191 |
MaskListManager.register(); |
192 |
GrayScaleManager.register(); |
193 |
} |
194 |
|
195 |
/**
|
196 |
* Registra los iconos a utilizar en andami.
|
197 |
*/
|
198 |
private void registerIcons(){ |
199 |
PluginServices.getIconTheme().registerDefault( |
200 |
"zoom-res-level",
|
201 |
getClass().getClassLoader().getResource("images/raton02.png")
|
202 |
); |
203 |
PluginServices.getIconTheme().registerDefault( |
204 |
"forward-icon",
|
205 |
this.getClass().getClassLoader().getResource("images/forward.png") |
206 |
); |
207 |
PluginServices.getIconTheme().registerDefault( |
208 |
"backward-icon",
|
209 |
this.getClass().getClassLoader().getResource("images/backward.png") |
210 |
); |
211 |
PluginServices.getIconTheme().registerDefault( |
212 |
"map-ok-ico",
|
213 |
this.getClass().getClassLoader().getResource("images/map_ico_ok.gif") |
214 |
); |
215 |
// PluginServices.getIconTheme().registerDefault(
|
216 |
// "crux-cursor",
|
217 |
// MapControl.class.getResource("images/CruxCursor.png")
|
218 |
// );
|
219 |
PluginServices.getIconTheme().registerDefault( |
220 |
"blank-icon",
|
221 |
getClass().getClassLoader().getResource("images/blank.png")
|
222 |
); |
223 |
PluginServices.getIconTheme().registerDefault( |
224 |
"addlayer-icon",
|
225 |
this.getClass().getClassLoader().getResource("images/addlayer.png") |
226 |
); |
227 |
PluginServices.getIconTheme().registerDefault( |
228 |
"delall-icon",
|
229 |
this.getClass().getClassLoader().getResource("images/delall.png") |
230 |
); |
231 |
PluginServices.getIconTheme().registerDefault( |
232 |
"rotar-icon",
|
233 |
this.getClass().getClassLoader().getResource("images/Rotar.gif") |
234 |
); |
235 |
PluginServices.getIconTheme().registerDefault( |
236 |
"hor-arrow-icon",
|
237 |
this.getClass().getClassLoader().getResource("images/FlechaHorizCursor.gif") |
238 |
); |
239 |
PluginServices.getIconTheme().registerDefault( |
240 |
"ver-arrow-icon",
|
241 |
this.getClass().getClassLoader().getResource("images/FlechaVertCursor.gif") |
242 |
); |
243 |
PluginServices.getIconTheme().registerDefault( |
244 |
"inclder-arrow-icon",
|
245 |
this.getClass().getClassLoader().getResource("images/FlechaInclDerCursor.gif") |
246 |
); |
247 |
PluginServices.getIconTheme().registerDefault( |
248 |
"inclizq-arrow-icon",
|
249 |
this.getClass().getClassLoader().getResource("images/FlechaInclIzqCursor.gif") |
250 |
); |
251 |
PluginServices.getIconTheme().registerDefault( |
252 |
"shear-y-icon",
|
253 |
this.getClass().getClassLoader().getResource("images/y.gif") |
254 |
); |
255 |
PluginServices.getIconTheme().registerDefault( |
256 |
"shear-x-icon",
|
257 |
this.getClass().getClassLoader().getResource("images/x.gif") |
258 |
); |
259 |
PluginServices.getIconTheme().registerDefault( |
260 |
"hand-icon",
|
261 |
this.getClass().getClassLoader().getResource("images/Hand.gif") |
262 |
); |
263 |
PluginServices.getIconTheme().registerDefault( |
264 |
"back-icon",
|
265 |
this.getClass().getClassLoader().getResource("images/back.png") |
266 |
); |
267 |
PluginServices.getIconTheme().registerDefault( |
268 |
"next-icon",
|
269 |
this.getClass().getClassLoader().getResource("images/next.png") |
270 |
); |
271 |
PluginServices.getIconTheme().registerDefault( |
272 |
"undo-icon",
|
273 |
this.getClass().getClassLoader().getResource("images/undo.png") |
274 |
); |
275 |
PluginServices.getIconTheme().registerDefault( |
276 |
"zoom-pixel-cursor",
|
277 |
this.getClass().getClassLoader().getResource("images/ZoomPixelCursor.gif") |
278 |
); |
279 |
PluginServices.getIconTheme().registerDefault( |
280 |
"save-raster",
|
281 |
this.getClass().getClassLoader().getResource("images/Rectangle.png") |
282 |
); |
283 |
PluginServices.getIconTheme().registerDefault( |
284 |
"pixel-increase",
|
285 |
this.getClass().getClassLoader().getResource("images/increase.png") |
286 |
); |
287 |
PluginServices.getIconTheme().registerDefault( |
288 |
"select-raster",
|
289 |
this.getClass().getClassLoader().getResource("images/stock_toggle-info.png") |
290 |
); |
291 |
PluginServices.getIconTheme().registerDefault( |
292 |
"select-raster",
|
293 |
this.getClass().getClassLoader().getResource("images/stock_toggle-info.png") |
294 |
); |
295 |
PluginServices.getIconTheme().registerDefault( |
296 |
"export-icon",
|
297 |
this.getClass().getClassLoader().getResource("images/export.png") |
298 |
); |
299 |
PluginServices.getIconTheme().registerDefault( |
300 |
"pref-raster-icon",
|
301 |
this.getClass().getClassLoader().getResource("images/raster-pref.png") |
302 |
); |
303 |
PluginServices.getIconTheme().registerDefault( |
304 |
"import-icon",
|
305 |
this.getClass().getClassLoader().getResource("images/import.png") |
306 |
); |
307 |
PluginServices.getIconTheme().registerDefault( |
308 |
"save-icon",
|
309 |
this.getClass().getClassLoader().getResource("images/savefile.png") |
310 |
); |
311 |
PluginServices.getIconTheme().registerDefault( |
312 |
"reset-icon",
|
313 |
this.getClass().getClassLoader().getResource("images/reset.png") |
314 |
); |
315 |
PluginServices.getIconTheme().registerDefault( |
316 |
"tfwload-icon",
|
317 |
this.getClass().getClassLoader().getResource("images/load.png") |
318 |
); |
319 |
PluginServices.getIconTheme().registerDefault( |
320 |
"centerraster-icon",
|
321 |
this.getClass().getClassLoader().getResource("images/center_image.png") |
322 |
); |
323 |
PluginServices.getIconTheme().registerDefault( |
324 |
"increase-icon",
|
325 |
this.getClass().getClassLoader().getResource("images/aumentar.png") |
326 |
); |
327 |
PluginServices.getIconTheme().registerDefault( |
328 |
"decrease-icon",
|
329 |
this.getClass().getClassLoader().getResource("images/disminuir.png") |
330 |
); |
331 |
PluginServices.getIconTheme().registerDefault( |
332 |
"selectzoomarea-icon",
|
333 |
this.getClass().getClassLoader().getResource("images/view-zoom-to-seleccion.png") |
334 |
); |
335 |
PluginServices.getIconTheme().registerDefault( |
336 |
"prevzoom-icon",
|
337 |
this.getClass().getClassLoader().getResource("images/view-zoom-back.png") |
338 |
); |
339 |
PluginServices.getIconTheme().registerDefault( |
340 |
"fullview-icon",
|
341 |
this.getClass().getClassLoader().getResource("images/view-zoom-map-contents.png") |
342 |
); |
343 |
PluginServices.getIconTheme().register( |
344 |
"geolocalization-icon",
|
345 |
this.getClass().getClassLoader().getResource("images/georef.png") |
346 |
); |
347 |
PluginServices.getIconTheme().register( |
348 |
"exporttoascii-icon",
|
349 |
this.getClass().getClassLoader().getResource("images/exportToAscii.png") |
350 |
); |
351 |
PluginServices.getIconTheme().register( |
352 |
"exporttocsv-icon",
|
353 |
this.getClass().getClassLoader().getResource("images/exportToCSV.png") |
354 |
); |
355 |
PluginServices.getIconTheme().register( |
356 |
"importfromcsv-icon",
|
357 |
this.getClass().getClassLoader().getResource("images/importFromCSV.png") |
358 |
); |
359 |
PluginServices.getIconTheme().register( |
360 |
"exit-icon",
|
361 |
this.getClass().getClassLoader().getResource("images/ico_exit.gif") |
362 |
); |
363 |
PluginServices.getIconTheme().register( |
364 |
"options-icon",
|
365 |
this.getClass().getClassLoader().getResource("images/ico_options.gif") |
366 |
); |
367 |
PluginServices.getIconTheme().register( |
368 |
"add-icon",
|
369 |
this.getClass().getClassLoader().getResource("images/add-ico.gif") |
370 |
); |
371 |
PluginServices.getIconTheme().register( |
372 |
"centerpoint-icon",
|
373 |
this.getClass().getClassLoader().getResource("images/icon_centerpoint.gif") |
374 |
); |
375 |
PluginServices.getIconTheme().register( |
376 |
"hand-icon",
|
377 |
this.getClass().getClassLoader().getResource("images/Hand.gif") |
378 |
); |
379 |
PluginServices.getIconTheme().register( |
380 |
"analisis-icon",
|
381 |
this.getClass().getClassLoader().getResource("images/prismaticos.gif") |
382 |
); |
383 |
PluginServices.getIconTheme().registerDefault( |
384 |
"clipping-icon",
|
385 |
getClass().getClassLoader().getResource("images/clipping.gif")
|
386 |
); |
387 |
PluginServices.getIconTheme().registerDefault( |
388 |
"filter-icon",
|
389 |
getClass().getClassLoader().getResource("images/raster-filter.png")
|
390 |
); |
391 |
PluginServices.getIconTheme().registerDefault( |
392 |
"histogram-icon",
|
393 |
getClass().getClassLoader().getResource("images/histogram.png")
|
394 |
); |
395 |
PluginServices.getIconTheme().registerDefault( |
396 |
"overviews-icon",
|
397 |
getClass().getClassLoader().getResource("images/overviews.gif")
|
398 |
); |
399 |
PluginServices.getIconTheme().registerDefault( |
400 |
"properties-icon",
|
401 |
getClass().getClassLoader().getResource("images/properties.gif")
|
402 |
); |
403 |
PluginServices.getIconTheme().registerDefault( |
404 |
"colortable-icon",
|
405 |
getClass().getClassLoader().getResource("images/colortable.png")
|
406 |
); |
407 |
PluginServices.getIconTheme().registerDefault( |
408 |
"rois-icon",
|
409 |
getClass().getClassLoader().getResource("images/rois.png")
|
410 |
); |
411 |
PluginServices.getIconTheme().registerDefault( |
412 |
"brush-icon",
|
413 |
getClass().getClassLoader().getResource("images/brush.png")
|
414 |
); |
415 |
PluginServices.getIconTheme().registerDefault( |
416 |
"selectrgb-icon",
|
417 |
getClass().getClassLoader().getResource("images/select_rgb.gif")
|
418 |
); |
419 |
PluginServices.getIconTheme().registerDefault( |
420 |
"reproj-icon",
|
421 |
getClass().getClassLoader().getResource("images/reproject.png")
|
422 |
); |
423 |
PluginServices.getIconTheme().registerDefault( |
424 |
"vectorization-icon",
|
425 |
getClass().getClassLoader().getResource("images/vectorT.png")
|
426 |
); |
427 |
PluginServices.getIconTheme().registerDefault( |
428 |
"focus-icon",
|
429 |
getClass().getClassLoader().getResource("images/focus.png")
|
430 |
); |
431 |
|
432 |
PluginServices.getIconTheme().registerDefault( |
433 |
"point-icon",
|
434 |
getClass().getClassLoader().getResource("images/Point.png")
|
435 |
); |
436 |
PluginServices.getIconTheme().registerDefault( |
437 |
"pointcursor-icon",
|
438 |
getClass().getClassLoader().getResource("images/PointCursor.gif")
|
439 |
); |
440 |
PluginServices.getIconTheme().registerDefault( |
441 |
"poligon-icon",
|
442 |
getClass().getClassLoader().getResource("images/Poligon.png")
|
443 |
); |
444 |
PluginServices.getIconTheme().registerDefault( |
445 |
"poligoncursor-icon",
|
446 |
getClass().getClassLoader().getResource("images/PoligonCursor.png")
|
447 |
); |
448 |
PluginServices.getIconTheme().registerDefault( |
449 |
"line-icon",
|
450 |
getClass().getClassLoader().getResource("images/Line.png")
|
451 |
); |
452 |
PluginServices.getIconTheme().registerDefault( |
453 |
"linecursor-icon",
|
454 |
getClass().getClassLoader().getResource("images/LineCursor.png")
|
455 |
); |
456 |
PluginServices.getIconTheme().registerDefault( |
457 |
"export-icon",
|
458 |
getClass().getClassLoader().getResource("images/export.png")
|
459 |
); |
460 |
PluginServices.getIconTheme().registerDefault( |
461 |
"import-icon",
|
462 |
getClass().getClassLoader().getResource("images/import.png")
|
463 |
); |
464 |
PluginServices.getIconTheme().registerDefault( |
465 |
"round-icon",
|
466 |
getClass().getClassLoader().getResource("images/round.png")
|
467 |
); |
468 |
PluginServices.getIconTheme().registerDefault( |
469 |
"rois-icon",
|
470 |
getClass().getClassLoader().getResource("images/rois.png")
|
471 |
); |
472 |
PluginServices.getIconTheme().registerDefault( |
473 |
"fullextent-icon",
|
474 |
getClass().getClassLoader().getResource("images/fullExtent.png")
|
475 |
); |
476 |
PluginServices.getIconTheme().registerDefault( |
477 |
"selecttool-icon",
|
478 |
getClass().getClassLoader().getResource("images/selectTool.png")
|
479 |
); |
480 |
} |
481 |
/*
|
482 |
* (non-Javadoc)
|
483 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
484 |
*/
|
485 |
@SuppressWarnings("deprecation") |
486 |
public boolean isEnabled() { |
487 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
488 |
if (f == null) |
489 |
return false; |
490 |
if (f instanceof AbstractViewPanel) { |
491 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
492 |
ViewDocument model = vista.getModel(); |
493 |
MapContext mapa = model.getMapContext(); |
494 |
FLayers layers = mapa.getLayers(); |
495 |
for (int i = 0; i < layers.getLayersCount(); i++) |
496 |
if (layers.getLayer(i) instanceof FLyrRaster) |
497 |
return true; |
498 |
} |
499 |
return false; |
500 |
} |
501 |
|
502 |
/**
|
503 |
* Mostramos el control si hay alguna capa cargada.
|
504 |
*/
|
505 |
@SuppressWarnings("deprecation") |
506 |
public boolean isVisible() { |
507 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
508 |
if (f == null) |
509 |
return false; |
510 |
|
511 |
if (f instanceof AbstractViewPanel) { |
512 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
513 |
ViewDocument model = vista.getModel(); |
514 |
MapContext mapa = model.getMapContext(); |
515 |
if (mapa.getLayers().getLayersCount() > 0) |
516 |
return true; |
517 |
} |
518 |
|
519 |
return false; |
520 |
} |
521 |
|
522 |
/**
|
523 |
* Carga los valores de configuracion iniciales
|
524 |
*/
|
525 |
private void loadConfigurationValues() { |
526 |
autoRefreshView = Configuration.getValue("general_auto_preview", Boolean.TRUE).booleanValue(); |
527 |
askCoordinates = Configuration.getValue("general_ask_coordinates", Boolean.FALSE).booleanValue(); |
528 |
RasterLibrary.defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)).intValue(); |
529 |
RasterLibrary.cacheSize = Configuration.getValue("cache_size", Long.valueOf(RasterLibrary.cacheSize)).longValue(); |
530 |
RasterLibrary.pageSize = Configuration.getValue("cache_pagesize", Double.valueOf(RasterLibrary.pageSize)).doubleValue(); |
531 |
RasterLibrary.pagsPerGroup = Configuration.getValue("cache_pagspergroup", Integer.valueOf(RasterLibrary.pagsPerGroup)).intValue(); |
532 |
RasterLibrary.blockHeight = Configuration.getValue("cache_blockheight", Integer.valueOf(RasterLibrary.blockHeight)).intValue(); |
533 |
//RasterLibrary.defaultNoDataValue = Configuration.getValue("nodata_value", Double.valueOf(RasterLibrary.defaultNoDataValue)).doubleValue();
|
534 |
} |
535 |
|
536 |
/*
|
537 |
* (non-Javadoc)
|
538 |
* @see org.gvsig.raster.util.ConfigurationListener#actionConfigurationChanged(org.gvsig.raster.util.ConfigurationEvent)
|
539 |
*/
|
540 |
@SuppressWarnings("deprecation") |
541 |
public void actionConfigurationChanged(ConfigurationEvent e) { |
542 |
if (e.getKey().equals("nodata_transparency_enabled")) { |
543 |
boolean noDataTransparent = ((Boolean) e.getValue()).booleanValue(); |
544 |
IWindow[] f = PluginServices.getMDIManager().getAllWindows();
|
545 |
if (f == null) |
546 |
return;
|
547 |
for (int i = 0; i < f.length; i++) |
548 |
if (f[i] instanceof AbstractViewPanel) { |
549 |
AbstractViewPanel vista = (AbstractViewPanel) f[i]; |
550 |
ViewDocument model = vista.getModel(); |
551 |
MapContext map = model.getMapContext(); |
552 |
FLayers lyrs = map.getLayers(); |
553 |
|
554 |
ArrayList<FLayer> list = RasterToolsUtil.getRasterLayerList(lyrs, null); |
555 |
for (int j = 0; j < list.size(); j++) |
556 |
if(list.get(j) instanceof FLyrRaster) |
557 |
((RasterDataStore)((FLyrRaster)list.get(j)).getDataStore()).getNoDataValue().setNoDataTransparent(noDataTransparent); |
558 |
} |
559 |
|
560 |
return;
|
561 |
} |
562 |
|
563 |
if (e.getKey().equals("general_auto_preview")) { |
564 |
if(e.getValue() instanceof String) |
565 |
autoRefreshView = new Boolean((String) e.getValue()).booleanValue(); |
566 |
if(e.getValue() instanceof Boolean) |
567 |
autoRefreshView = ((Boolean) e.getValue()).booleanValue();
|
568 |
return;
|
569 |
} |
570 |
|
571 |
if (e.getKey().equals("general_ask_coordinates")) { |
572 |
if(e.getValue() instanceof String) |
573 |
askCoordinates = new Boolean((String) e.getValue()).booleanValue(); |
574 |
if(e.getValue() instanceof Boolean) |
575 |
askCoordinates = ((Boolean) e.getValue()).booleanValue();
|
576 |
return;
|
577 |
} |
578 |
|
579 |
if (e.getKey().equals("general_defaultNumberOfClasses")) { |
580 |
if(e.getValue() instanceof String) |
581 |
try {
|
582 |
RasterLibrary.defaultNumberOfClasses = new Integer( |
583 |
(String) e.getValue()).intValue();
|
584 |
} catch (NumberFormatException exc) { |
585 |
//Valor por defecto en el n?mero de clases
|
586 |
} |
587 |
|
588 |
if(e.getValue() instanceof Integer) |
589 |
RasterLibrary.defaultNumberOfClasses = ((Integer) e.getValue()).intValue();
|
590 |
return;
|
591 |
} |
592 |
|
593 |
if (e.getKey().equals("cache_size")) { |
594 |
if(e.getValue() instanceof String) |
595 |
try {
|
596 |
RasterLibrary.cacheSize = new Long((String) e.getValue()).longValue(); |
597 |
} catch (NumberFormatException exc) { |
598 |
//Valor por defecto en la cache
|
599 |
} |
600 |
if(e.getValue() instanceof Long) |
601 |
RasterLibrary.cacheSize = ((Long) e.getValue()).longValue();
|
602 |
return;
|
603 |
} |
604 |
|
605 |
if (e.getKey().equals("cache_pagesize")) { |
606 |
if(e.getValue() instanceof String) |
607 |
try {
|
608 |
RasterLibrary.pageSize = new Double((String) e.getValue()) |
609 |
.doubleValue(); |
610 |
} catch (NumberFormatException exc) { |
611 |
//Valor por defecto en la cache
|
612 |
} |
613 |
|
614 |
if(e.getValue() instanceof Double) |
615 |
RasterLibrary.pageSize = ((Double) e.getValue()).doubleValue();
|
616 |
return;
|
617 |
} |
618 |
|
619 |
if (e.getKey().equals("cache_pagspergroup")) { |
620 |
if(e.getValue() instanceof String) |
621 |
try {
|
622 |
RasterLibrary.pagsPerGroup = new Integer((String) e |
623 |
.getValue()).intValue(); |
624 |
} catch (NumberFormatException exc) { |
625 |
//Valor por defecto en la cache
|
626 |
} |
627 |
|
628 |
if(e.getValue() instanceof Integer) |
629 |
RasterLibrary.pagsPerGroup = ((Integer) e.getValue()).intValue();
|
630 |
return;
|
631 |
} |
632 |
|
633 |
if (e.getKey().equals("cache_blockheight")) { |
634 |
if(e.getValue() instanceof String) |
635 |
try {
|
636 |
RasterLibrary.blockHeight = new Integer((String) e |
637 |
.getValue()).intValue(); |
638 |
} catch (NumberFormatException exc) { |
639 |
//Valor por defecto en la cache
|
640 |
} |
641 |
if(e.getValue() instanceof Integer) |
642 |
RasterLibrary.blockHeight = ((Integer) e.getValue()).intValue();
|
643 |
return;
|
644 |
} |
645 |
|
646 |
/*if (e.getKey().equals("nodata_value")) {
|
647 |
if(e.getValue() instanceof String)
|
648 |
try {
|
649 |
RasterLibrary.defaultNoDataValue = new Double((String) e
|
650 |
.getValue()).doubleValue();
|
651 |
} catch (NumberFormatException exc) {
|
652 |
//Valor por defecto en valor nodata
|
653 |
}
|
654 |
|
655 |
if(e.getValue() instanceof Double)
|
656 |
RasterLibrary.defaultNoDataValue = ((Double) e.getValue()).doubleValue();
|
657 |
return;
|
658 |
}*/
|
659 |
|
660 |
} |
661 |
|
662 |
/*
|
663 |
* (non-Javadoc)
|
664 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
665 |
*/
|
666 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
667 |
this.execute("SELECTIMAGE"); |
668 |
} |
669 |
|
670 |
public void postInitialize() { |
671 |
super.postInitialize();
|
672 |
// storeLibrary.postInitialize();
|
673 |
} |
674 |
} |