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