svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / RasterModule.java @ 18836
History | View | Annotate | Download (21.9 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.fmap.raster.layers.FLyrRasterSE; |
25 |
import org.gvsig.fmap.raster.layers.StatusLayerRaster; |
26 |
import org.gvsig.raster.Configuration; |
27 |
import org.gvsig.raster.ConfigurationEvent; |
28 |
import org.gvsig.raster.ConfigurationListener; |
29 |
import org.gvsig.raster.RasterLibrary; |
30 |
import org.gvsig.raster.gui.preferences.RasterPreferences; |
31 |
import org.gvsig.raster.gui.properties.dialog.RasterPropertiesTocMenuEntry; |
32 |
import org.gvsig.raster.gui.wizards.FileOpenRaster; |
33 |
import org.gvsig.raster.regionalpha.filter.RegionAlphaListManager; |
34 |
import org.gvsig.rastertools.analysisview.ViewRasterAnalysisTocMenuEntry; |
35 |
import org.gvsig.rastertools.clipping.ClippingTocMenuEntry; |
36 |
import org.gvsig.rastertools.colortable.ColorTableTocMenuEntry; |
37 |
import org.gvsig.rastertools.filter.FilterTocMenuEntry; |
38 |
import org.gvsig.rastertools.geolocation.GeoLocationTocMenuEntry; |
39 |
import org.gvsig.rastertools.histogram.HistogramTocMenuEntry; |
40 |
import org.gvsig.rastertools.overviews.OverviewsTocMenuEntry; |
41 |
import org.gvsig.rastertools.properties.panels.BandSelectorPanel; |
42 |
import org.gvsig.rastertools.properties.panels.EnhancedPanel; |
43 |
import org.gvsig.rastertools.properties.panels.InfoPanel; |
44 |
import org.gvsig.rastertools.properties.panels.PanSharpeningPanel; |
45 |
import org.gvsig.rastertools.properties.panels.ScalePanel; |
46 |
import org.gvsig.rastertools.properties.panels.StatisticsPanel; |
47 |
import org.gvsig.rastertools.properties.panels.TransparencyPanel; |
48 |
import org.gvsig.rastertools.rasterresolution.ZoomPixelCursorTocMenuEntry; |
49 |
import org.gvsig.rastertools.roi.ui.ROIManagerTocMenuEntry; |
50 |
import org.gvsig.rastertools.saveas.SaveAsTocMenuEntry; |
51 |
import org.gvsig.rastertools.selectrasterlayer.SelectImageListener; |
52 |
|
53 |
import com.iver.andami.PluginServices; |
54 |
import com.iver.andami.plugins.Extension; |
55 |
import com.iver.andami.ui.mdiManager.IWindow; |
56 |
import com.iver.cit.gvsig.fmap.MapContext; |
57 |
import com.iver.cit.gvsig.fmap.MapControl; |
58 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
59 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
60 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
61 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
62 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
63 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
64 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
65 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
66 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
67 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
68 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
69 |
/**
|
70 |
* Extensi?n que adapta a FMap y gvSIG la nueva implementaci?n de raster. Para
|
71 |
* el cuadro de Propiedades de visualizaci?n de raster contiene el contenedor
|
72 |
* base se registran la entrada del men? del TOC y los paneles en el cuadro.
|
73 |
* Para la parte de FMap contiene una nueva capa raster y los drivers
|
74 |
* necesarios.
|
75 |
*
|
76 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
77 |
*/
|
78 |
public class RasterModule extends Extension implements ConfigurationListener { |
79 |
/**
|
80 |
* Contador global de las capas generadas para raster
|
81 |
*/
|
82 |
private static int layerCount = 1; |
83 |
private static ArrayList propetiesListeners = new ArrayList(); |
84 |
|
85 |
/**
|
86 |
* Indica si en el panel de preferencias se refresca automaticamente la vista
|
87 |
* para mostrar los cambios
|
88 |
*/
|
89 |
public static boolean autoRefreshView = true; |
90 |
|
91 |
/**
|
92 |
* Indica si se debe preguntar las coordenadas al cargar una capa que no las
|
93 |
* tenga
|
94 |
*/
|
95 |
public static boolean askCoordinates = false; |
96 |
|
97 |
/**
|
98 |
* La gesti?n de nombres ?nicos en la generaci?n de capas se lleva de forma
|
99 |
* autom?tica. Cuando alguien crea una capa nueva, si esta no tiene nombre especifico,
|
100 |
* obtiene su nombre mediante este m?todo. La siguiente vez que se llame dar? un nombre
|
101 |
* distinto. El nombre de la capa ser? NewLayer_ seguido de un contador de actualizaci?n
|
102 |
* autom?tica cada vez que se usa.
|
103 |
* @return Nombre ?nico para la capa.
|
104 |
*/
|
105 |
public static String usesOnlyLayerName() { |
106 |
String oldValue = getOnlyLayerName();
|
107 |
String newValue = "NewLayer_" + (++RasterModule.layerCount); |
108 |
for (int i = 0; i < propetiesListeners.size(); i++) { |
109 |
if(propetiesListeners.get(i) instanceof PropertyListener) |
110 |
((PropertyListener)propetiesListeners.get(i)).actionValueChanged(new PropertyEvent(oldValue, "NewLayer", newValue, oldValue)); |
111 |
} |
112 |
return newValue;
|
113 |
} |
114 |
|
115 |
/**
|
116 |
* Obtiene el nombre ?nico de la siguiente capa sin actualizar el contador. Es
|
117 |
* solo para consulta. La siguiente vez que se llama a getOnlyLayerName o usesOnlyLayerName
|
118 |
* devolver? el mismo nomnbre.
|
119 |
* @return Nombre ?nico para la capa.
|
120 |
*/
|
121 |
public static String getOnlyLayerName() { |
122 |
return "NewLayer_" + RasterModule.layerCount; |
123 |
} |
124 |
|
125 |
/**
|
126 |
* A?adir un listener a la lista de eventos
|
127 |
* @param listener
|
128 |
*/
|
129 |
public static void addOnlyLayerNameListener(PropertyListener listener) { |
130 |
if (!propetiesListeners.contains(listener))
|
131 |
propetiesListeners.add(listener); |
132 |
} |
133 |
|
134 |
/**
|
135 |
* Elimina un listener de la lista de eventos
|
136 |
* @param listener
|
137 |
*/
|
138 |
public static void removeOnlyLayerNameListener(PropertyListener listener) { |
139 |
for (int i = 0; i < propetiesListeners.size(); i++) |
140 |
if(propetiesListeners.get(i) == listener)
|
141 |
propetiesListeners.remove(i); |
142 |
} |
143 |
|
144 |
/*
|
145 |
* (non-Javadoc)
|
146 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
147 |
*/
|
148 |
public void execute(String actionCommand) { |
149 |
View theView = (View) PluginServices.getMDIManager().getActiveWindow(); |
150 |
MapControl mapCtrl = theView.getMapControl(); |
151 |
|
152 |
// Listener de eventos de movimiento que pone las coordenadas del rat?n en
|
153 |
// la barra de estado
|
154 |
StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
155 |
|
156 |
if (actionCommand.equals("SELECTIMAGE")) { |
157 |
loadSelectRasterListener(mapCtrl, sbl); |
158 |
mapCtrl.setTool("selectRasterLayer");
|
159 |
} |
160 |
} |
161 |
|
162 |
/**
|
163 |
* Carga el listener de selecci?n de raster en el MapControl.
|
164 |
*/
|
165 |
private void loadSelectRasterListener(MapControl mapCtrl, StatusBarListener sbl) { |
166 |
if (mapCtrl.getNamesMapTools().get("selectRasterLayer") == null) { |
167 |
SelectImageListener sil = new SelectImageListener(mapCtrl);
|
168 |
mapCtrl.addMapTool("selectRasterLayer", new Behavior[] { new PointBehavior(sil), new MouseMovementBehavior(sbl) }); |
169 |
mapCtrl.setTool("selectRasterLayer");
|
170 |
} |
171 |
} |
172 |
|
173 |
/*
|
174 |
* (non-Javadoc)
|
175 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
176 |
*/
|
177 |
public void initialize() { |
178 |
// Asignamos la configuracion global a FlyrRasterSE
|
179 |
FLyrRasterSE.setConfiguration(Configuration.getSingleton());
|
180 |
|
181 |
Configuration.addValueChangedListener(this); |
182 |
loadConfigurationValues(); |
183 |
|
184 |
registerIcons(); |
185 |
RasterLibrary.wakeUp(); |
186 |
|
187 |
// DiagSignalHandler.install("ALRM");
|
188 |
|
189 |
Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
190 |
prefs.put("DataFolder", System.getProperty("user.home")); |
191 |
|
192 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
193 |
|
194 |
// Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades.
|
195 |
if (!extensionPoints.containsKey("RasterSEPropertiesDialog")) { |
196 |
extensionPoints.put(new ExtensionPoint("RasterSEPropertiesDialog", "Raster Properties registrable panels (register instances of javax.swing.JPanel)")); |
197 |
} |
198 |
|
199 |
// A?adimos la configuracion de Raster a gvSIG
|
200 |
extensionPoints.add("AplicationPreferences","RasterPreferences", new RasterPreferences()); |
201 |
|
202 |
// A?adimos paneles al cuadro de propiedades.
|
203 |
extensionPoints.add("RasterSEPropertiesDialog", "info", InfoPanel.class); |
204 |
extensionPoints.add("RasterSEPropertiesDialog", "bands_panel", BandSelectorPanel.class); |
205 |
extensionPoints.add("RasterSEPropertiesDialog", "transparencia", TransparencyPanel.class); |
206 |
extensionPoints.add("RasterSEPropertiesDialog", "realce", EnhancedPanel.class); |
207 |
extensionPoints.add("RasterSEPropertiesDialog", "pansharp", PanSharpeningPanel.class); |
208 |
extensionPoints.add("RasterSEPropertiesDialog", "scale_panel", ScalePanel.class); |
209 |
extensionPoints.add("RasterSEPropertiesDialog", "stats_panel", StatisticsPanel.class); |
210 |
|
211 |
// A?adimos las entradas del men? del toc de raster
|
212 |
extensionPoints.add("View_TocActions", "RasterSEProperties", RasterPropertiesTocMenuEntry.getSingleton()); |
213 |
extensionPoints.add("View_TocActions", "HistogramPanel", HistogramTocMenuEntry.getSingleton()); |
214 |
extensionPoints.add("View_TocActions", "ViewColorTable", ColorTableTocMenuEntry.getSingleton()); |
215 |
extensionPoints.add("View_TocActions", "Overviews", OverviewsTocMenuEntry.getSingleton()); |
216 |
extensionPoints.add("View_TocActions", "RoisManager", ROIManagerTocMenuEntry.getSingleton()); |
217 |
extensionPoints.add("View_TocActions", "ViewRasterAnalysis", ViewRasterAnalysisTocMenuEntry.getSingleton()); |
218 |
|
219 |
extensionPoints.add("View_TocActions", "SaveAs", SaveAsTocMenuEntry.getSingleton()); |
220 |
extensionPoints.add("View_TocActions", "ClippingPanel", ClippingTocMenuEntry.getSingleton()); |
221 |
|
222 |
extensionPoints.add("View_TocActions", "FilterPanel", FilterTocMenuEntry.getSingleton()); |
223 |
|
224 |
extensionPoints.add("View_TocActions", "GeoLocation", GeoLocationTocMenuEntry.getSingleton()); |
225 |
|
226 |
extensionPoints.add("View_TocActions", "ZoomPixelCursor", new ZoomPixelCursorTocMenuEntry()); |
227 |
|
228 |
// A?adimos nuestra extension para el tratamiento de la apertura de ficheros
|
229 |
// dentro de gvSIG
|
230 |
extensionPoints.add("FileExtendingOpenDialog", "FileOpenRaster", FileOpenRaster.class); |
231 |
|
232 |
//Alias
|
233 |
LayerFactory.registerLayerClassForName("com.iver.cit.gvsig.fmap.layers.FLyrRaster", FLyrRasterSE.class);
|
234 |
LayerFactory.registerLayerClassForName("com.iver.cit.gvsig.fmap.layers.StatusLayerRaster", StatusLayerRaster.class);
|
235 |
|
236 |
// Registrar el filtro RegionAlpha
|
237 |
RegionAlphaListManager.register(); |
238 |
} |
239 |
|
240 |
/**
|
241 |
* Registra los iconos a utilizar en andami.
|
242 |
*/
|
243 |
private void registerIcons(){ |
244 |
PluginServices.getIconTheme().registerDefault( |
245 |
"forward-icon",
|
246 |
this.getClass().getClassLoader().getResource("images/forward.png") |
247 |
); |
248 |
PluginServices.getIconTheme().registerDefault( |
249 |
"backward-icon",
|
250 |
this.getClass().getClassLoader().getResource("images/backward.png") |
251 |
); |
252 |
PluginServices.getIconTheme().registerDefault( |
253 |
"map-ok-ico",
|
254 |
MapControl.class.getResource("images/map_ico_ok.gif")
|
255 |
); |
256 |
PluginServices.getIconTheme().registerDefault( |
257 |
"crux-cursor",
|
258 |
MapControl.class.getResource("images/CruxCursor.png")
|
259 |
); |
260 |
PluginServices.getIconTheme().registerDefault( |
261 |
"blank-icon",
|
262 |
getClass().getClassLoader().getResource("images/blank.png")
|
263 |
); |
264 |
PluginServices.getIconTheme().registerDefault( |
265 |
"addlayer-icon",
|
266 |
this.getClass().getClassLoader().getResource("images/addlayer.png") |
267 |
); |
268 |
PluginServices.getIconTheme().registerDefault( |
269 |
"delall-icon",
|
270 |
this.getClass().getClassLoader().getResource("images/delall.png") |
271 |
); |
272 |
PluginServices.getIconTheme().registerDefault( |
273 |
"rotar-icon",
|
274 |
this.getClass().getClassLoader().getResource("images/Rotar.gif") |
275 |
); |
276 |
PluginServices.getIconTheme().registerDefault( |
277 |
"hor-arrow-icon",
|
278 |
this.getClass().getClassLoader().getResource("images/FlechaHorizCursor.gif") |
279 |
); |
280 |
PluginServices.getIconTheme().registerDefault( |
281 |
"ver-arrow-icon",
|
282 |
this.getClass().getClassLoader().getResource("images/FlechaVertCursor.gif") |
283 |
); |
284 |
PluginServices.getIconTheme().registerDefault( |
285 |
"inclder-arrow-icon",
|
286 |
this.getClass().getClassLoader().getResource("images/FlechaInclDerCursor.gif") |
287 |
); |
288 |
PluginServices.getIconTheme().registerDefault( |
289 |
"inclizq-arrow-icon",
|
290 |
this.getClass().getClassLoader().getResource("images/FlechaInclIzqCursor.gif") |
291 |
); |
292 |
PluginServices.getIconTheme().registerDefault( |
293 |
"shear-y-icon",
|
294 |
this.getClass().getClassLoader().getResource("images/y.gif") |
295 |
); |
296 |
PluginServices.getIconTheme().registerDefault( |
297 |
"shear-x-icon",
|
298 |
this.getClass().getClassLoader().getResource("images/x.gif") |
299 |
); |
300 |
PluginServices.getIconTheme().registerDefault( |
301 |
"hand-icon",
|
302 |
this.getClass().getClassLoader().getResource("images/Hand.gif") |
303 |
); |
304 |
PluginServices.getIconTheme().registerDefault( |
305 |
"back-icon",
|
306 |
this.getClass().getClassLoader().getResource("images/back.png") |
307 |
); |
308 |
PluginServices.getIconTheme().registerDefault( |
309 |
"next-icon",
|
310 |
this.getClass().getClassLoader().getResource("images/next.png") |
311 |
); |
312 |
PluginServices.getIconTheme().registerDefault( |
313 |
"undo-icon",
|
314 |
this.getClass().getClassLoader().getResource("images/undo.png") |
315 |
); |
316 |
PluginServices.getIconTheme().registerDefault( |
317 |
"zoom-pixel-cursor",
|
318 |
this.getClass().getClassLoader().getResource("images/ZoomPixelCursor.gif") |
319 |
); |
320 |
PluginServices.getIconTheme().registerDefault( |
321 |
"save-raster",
|
322 |
this.getClass().getClassLoader().getResource("images/Rectangle.png") |
323 |
); |
324 |
PluginServices.getIconTheme().registerDefault( |
325 |
"pixel-increase",
|
326 |
this.getClass().getClassLoader().getResource("images/increase.png") |
327 |
); |
328 |
PluginServices.getIconTheme().registerDefault( |
329 |
"select-raster",
|
330 |
this.getClass().getClassLoader().getResource("images/stock_toggle-info.png") |
331 |
); |
332 |
PluginServices.getIconTheme().registerDefault( |
333 |
"select-raster",
|
334 |
this.getClass().getClassLoader().getResource("images/stock_toggle-info.png") |
335 |
); |
336 |
PluginServices.getIconTheme().registerDefault( |
337 |
"export-icon",
|
338 |
this.getClass().getClassLoader().getResource("images/export.png") |
339 |
); |
340 |
PluginServices.getIconTheme().registerDefault( |
341 |
"pref-raster-icon",
|
342 |
this.getClass().getClassLoader().getResource("images/raster-pref.png") |
343 |
); |
344 |
PluginServices.getIconTheme().registerDefault( |
345 |
"import-icon",
|
346 |
this.getClass().getClassLoader().getResource("images/import.png") |
347 |
); |
348 |
PluginServices.getIconTheme().registerDefault( |
349 |
"save-icon",
|
350 |
this.getClass().getClassLoader().getResource("images/save.png") |
351 |
); |
352 |
PluginServices.getIconTheme().registerDefault( |
353 |
"reset-icon",
|
354 |
this.getClass().getClassLoader().getResource("images/reset.png") |
355 |
); |
356 |
PluginServices.getIconTheme().registerDefault( |
357 |
"tfwload-icon",
|
358 |
this.getClass().getClassLoader().getResource("images/load.png") |
359 |
); |
360 |
PluginServices.getIconTheme().registerDefault( |
361 |
"centerraster-icon",
|
362 |
this.getClass().getClassLoader().getResource("images/center_image.png") |
363 |
); |
364 |
PluginServices.getIconTheme().registerDefault( |
365 |
"increase-icon",
|
366 |
this.getClass().getClassLoader().getResource("images/aumentar.png") |
367 |
); |
368 |
PluginServices.getIconTheme().registerDefault( |
369 |
"decrease-icon",
|
370 |
this.getClass().getClassLoader().getResource("images/disminuir.png") |
371 |
); |
372 |
PluginServices.getIconTheme().registerDefault( |
373 |
"selectzoomarea-icon",
|
374 |
this.getClass().getClassLoader().getResource("images/view-zoom-to-seleccion.png") |
375 |
); |
376 |
PluginServices.getIconTheme().registerDefault( |
377 |
"prevzoom-icon",
|
378 |
this.getClass().getClassLoader().getResource("images/view-zoom-back.png") |
379 |
); |
380 |
PluginServices.getIconTheme().registerDefault( |
381 |
"fullview-icon",
|
382 |
this.getClass().getClassLoader().getResource("images/view-zoom-map-contents.png") |
383 |
); |
384 |
PluginServices.getIconTheme().register( |
385 |
"geolocalization-icon",
|
386 |
this.getClass().getClassLoader().getResource("images/georef.png") |
387 |
); |
388 |
PluginServices.getIconTheme().register( |
389 |
"exporttoascii-icon",
|
390 |
this.getClass().getClassLoader().getResource("images/exportToAscii.png") |
391 |
); |
392 |
PluginServices.getIconTheme().register( |
393 |
"exporttocsv-icon",
|
394 |
this.getClass().getClassLoader().getResource("images/exportToCSV.png") |
395 |
); |
396 |
PluginServices.getIconTheme().register( |
397 |
"importfromcsv-icon",
|
398 |
this.getClass().getClassLoader().getResource("images/importFromCSV.png") |
399 |
); |
400 |
PluginServices.getIconTheme().register( |
401 |
"exit-icon",
|
402 |
this.getClass().getClassLoader().getResource("images/ico_exit.gif") |
403 |
); |
404 |
PluginServices.getIconTheme().register( |
405 |
"process-icon",
|
406 |
this.getClass().getClassLoader().getResource("images/icon_process.gif") |
407 |
); |
408 |
PluginServices.getIconTheme().register( |
409 |
"options-icon",
|
410 |
this.getClass().getClassLoader().getResource("images/ico_options.gif") |
411 |
); |
412 |
PluginServices.getIconTheme().register( |
413 |
"add-icon",
|
414 |
this.getClass().getClassLoader().getResource("images/add-ico.gif") |
415 |
); |
416 |
PluginServices.getIconTheme().register( |
417 |
"centerpoint-icon",
|
418 |
this.getClass().getClassLoader().getResource("images/icon_centerpoint.gif") |
419 |
); |
420 |
PluginServices.getIconTheme().register( |
421 |
"hand-icon",
|
422 |
this.getClass().getClassLoader().getResource("images/Hand.gif") |
423 |
); |
424 |
PluginServices.getIconTheme().registerDefault( |
425 |
"clipping-icon",
|
426 |
getClass().getClassLoader().getResource("images/clipping.gif")
|
427 |
); |
428 |
PluginServices.getIconTheme().registerDefault( |
429 |
"filter-icon",
|
430 |
getClass().getClassLoader().getResource("images/filter.gif")
|
431 |
); |
432 |
PluginServices.getIconTheme().registerDefault( |
433 |
"histogram-icon",
|
434 |
getClass().getClassLoader().getResource("images/histogram.png")
|
435 |
); |
436 |
PluginServices.getIconTheme().registerDefault( |
437 |
"overviews-icon",
|
438 |
getClass().getClassLoader().getResource("images/overviews.gif")
|
439 |
); |
440 |
PluginServices.getIconTheme().registerDefault( |
441 |
"properties-icon",
|
442 |
getClass().getClassLoader().getResource("images/properties.gif")
|
443 |
); |
444 |
PluginServices.getIconTheme().registerDefault( |
445 |
"colortable-icon",
|
446 |
getClass().getClassLoader().getResource("images/colortable.png")
|
447 |
); |
448 |
PluginServices.getIconTheme().registerDefault( |
449 |
"rois-icon",
|
450 |
getClass().getClassLoader().getResource("images/rois.png")
|
451 |
); |
452 |
} |
453 |
/*
|
454 |
* (non-Javadoc)
|
455 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
456 |
*/
|
457 |
public boolean isEnabled() { |
458 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
459 |
if (f == null) { |
460 |
return false; |
461 |
} |
462 |
if (f.getClass() == View.class) { |
463 |
View vista = (View) f; |
464 |
IProjectView model = vista.getModel(); |
465 |
MapContext mapa = model.getMapContext(); |
466 |
FLayers layers = mapa.getLayers(); |
467 |
for (int i = 0; i < layers.getLayersCount(); i++) |
468 |
if (layers.getLayer(i) instanceof FLyrRasterSE) |
469 |
return true; |
470 |
} |
471 |
return false; |
472 |
} |
473 |
|
474 |
/**
|
475 |
* Mostramos el control si hay alguna capa cargada.
|
476 |
*/
|
477 |
public boolean isVisible() { |
478 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
479 |
if (f == null) |
480 |
return false; |
481 |
|
482 |
if (f instanceof View) { |
483 |
View vista = (View) f; |
484 |
IProjectView model = vista.getModel(); |
485 |
MapContext mapa = model.getMapContext(); |
486 |
if (mapa.getLayers().getLayersCount() > 0) |
487 |
return true; |
488 |
} |
489 |
|
490 |
return false; |
491 |
} |
492 |
|
493 |
/**
|
494 |
* Carga los valores de configuracion iniciales
|
495 |
*/
|
496 |
private void loadConfigurationValues() { |
497 |
autoRefreshView = Configuration.getValue("general_auto_preview", Boolean.TRUE).booleanValue(); |
498 |
askCoordinates = Configuration.getValue("general_ask_coordinates", Boolean.FALSE).booleanValue(); |
499 |
RasterLibrary.defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)).intValue(); |
500 |
RasterLibrary.cacheSize = Configuration.getValue("cache_size", Long.valueOf(RasterLibrary.cacheSize)).longValue(); |
501 |
RasterLibrary.pageSize = Configuration.getValue("cache_pagesize", Double.valueOf(RasterLibrary.pageSize)).doubleValue(); |
502 |
RasterLibrary.pagsPerGroup = Configuration.getValue("cache_pagspergroup", Integer.valueOf(RasterLibrary.pagsPerGroup)).intValue(); |
503 |
RasterLibrary.blockHeight = Configuration.getValue("cache_blockheight", Integer.valueOf(RasterLibrary.blockHeight)).intValue(); |
504 |
RasterLibrary.defaultNoDataValue = Configuration.getValue("nodata_value", Double.valueOf(RasterLibrary.defaultNoDataValue)).doubleValue(); |
505 |
} |
506 |
|
507 |
/*
|
508 |
* (non-Javadoc)
|
509 |
* @see org.gvsig.raster.util.ConfigurationListener#actionConfigurationChanged(org.gvsig.raster.util.ConfigurationEvent)
|
510 |
*/
|
511 |
public void actionConfigurationChanged(ConfigurationEvent e) { |
512 |
if (e.getKey().equals("nodata_transparency_enabled")) { |
513 |
boolean noDataTransparent = ((Boolean) e.getValue()).booleanValue(); |
514 |
IWindow[] f = PluginServices.getMDIManager().getAllWindows();
|
515 |
if (f == null) |
516 |
return;
|
517 |
for (int i = 0; i < f.length; i++) { |
518 |
if (f[i] instanceof View) { |
519 |
View vista = (View) f[i]; |
520 |
IProjectView model = vista.getModel(); |
521 |
MapContext map = model.getMapContext(); |
522 |
FLayers lyrs = map.getLayers(); |
523 |
for (int j = 0; j < lyrs.getLayersCount(); j++) { |
524 |
if(lyrs.getLayer(j) instanceof FLyrRasterSE) |
525 |
((FLyrRasterSE)lyrs.getLayer(j)).getDataSource().getTransparencyFilesStatus().activeNoData(noDataTransparent); |
526 |
} |
527 |
} |
528 |
} |
529 |
|
530 |
return;
|
531 |
} |
532 |
|
533 |
if (e.getKey().equals("general_auto_preview")) { |
534 |
autoRefreshView = ((Boolean) e.getValue()).booleanValue();
|
535 |
return;
|
536 |
} |
537 |
|
538 |
if (e.getKey().equals("general_ask_coordinates")) { |
539 |
askCoordinates = ((Boolean) e.getValue()).booleanValue();
|
540 |
return;
|
541 |
} |
542 |
|
543 |
if (e.getKey().equals("general_defaultNumberOfClasses")) { |
544 |
RasterLibrary.defaultNumberOfClasses = ((Integer) e.getValue()).intValue();
|
545 |
return;
|
546 |
} |
547 |
|
548 |
if (e.getKey().equals("cache_size")) { |
549 |
RasterLibrary.cacheSize = ((Long) e.getValue()).longValue();
|
550 |
return;
|
551 |
} |
552 |
|
553 |
if (e.getKey().equals("cache_pagesize")) { |
554 |
RasterLibrary.pageSize = ((Double) e.getValue()).doubleValue();
|
555 |
return;
|
556 |
} |
557 |
|
558 |
if (e.getKey().equals("cache_pagspergroup")) { |
559 |
RasterLibrary.pagsPerGroup = ((Integer) e.getValue()).intValue();
|
560 |
return;
|
561 |
} |
562 |
|
563 |
if (e.getKey().equals("cache_blockheight")) { |
564 |
RasterLibrary.blockHeight = ((Integer) e.getValue()).intValue();
|
565 |
return;
|
566 |
} |
567 |
|
568 |
if (e.getKey().equals("nodata_value")) { |
569 |
RasterLibrary.defaultNoDataValue = ((Double) e.getValue()).doubleValue();
|
570 |
return;
|
571 |
} |
572 |
} |
573 |
} |