svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / RasterModule.java @ 12825
History | View | Annotate | Download (10.1 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 org.gvsig.raster.gui.properties.dialog.RasterPropertiesTocMenuEntry; |
24 |
import org.gvsig.raster.gui.wizards.FileOpenRasterDialog; |
25 |
import org.gvsig.rastertools.analysisview.ViewRasterAnalysisTocMenuEntry; |
26 |
import org.gvsig.rastertools.colortable.ColorTableTocMenuEntry; |
27 |
import org.gvsig.rastertools.cutting.CuttingTocMenuEntry; |
28 |
import org.gvsig.rastertools.filter.FilterTocMenuEntry; |
29 |
import org.gvsig.rastertools.geolocation.behavior.GeoRasterBehavior; |
30 |
import org.gvsig.rastertools.geolocation.listener.GeorefPanListener; |
31 |
import org.gvsig.rastertools.geolocation.ui.GeoLocationDialog; |
32 |
import org.gvsig.rastertools.histogram.HistogramTocMenuEntry; |
33 |
import org.gvsig.rastertools.pixelincrease.PixelncreaseDialog; |
34 |
import org.gvsig.rastertools.properties.panels.BandSetupPanel; |
35 |
import org.gvsig.rastertools.properties.panels.EnhancedPanel; |
36 |
import org.gvsig.rastertools.properties.panels.InfoPanel; |
37 |
import org.gvsig.rastertools.properties.panels.PanSharpeningPanel; |
38 |
import org.gvsig.rastertools.properties.panels.TransparencyPanel; |
39 |
import org.gvsig.rastertools.rasterresolution.ZoomPixelCursorTocMenuEntry; |
40 |
import org.gvsig.rastertools.saveas.SaveAsTocMenuEntry; |
41 |
import org.gvsig.rastertools.saveraster.map.SaveRasterListener; |
42 |
import org.gvsig.rastertools.selectrasterlayer.SelectImageListener; |
43 |
|
44 |
import com.iver.andami.PluginServices; |
45 |
import com.iver.andami.plugins.Extension; |
46 |
import com.iver.andami.ui.mdiManager.IWindow; |
47 |
import com.iver.cit.gvsig.AddLayer; |
48 |
import com.iver.cit.gvsig.fmap.MapContext; |
49 |
import com.iver.cit.gvsig.fmap.MapControl; |
50 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
51 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
52 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
53 |
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
54 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
55 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
56 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
57 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
58 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
59 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
60 |
/**
|
61 |
* Extensi?n que adapta a FMap y gvSIG la nueva implementaci?n de raster. Para
|
62 |
* el cuadro de Propiedades de visualizaci?n de raster contiene el contenedor
|
63 |
* base se registran la entrada del men? del TOC y los paneles en el cuadro.
|
64 |
* Para la parte de FMap contiene una nueva capa raster y los drivers
|
65 |
* necesarios.
|
66 |
*
|
67 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
68 |
*/
|
69 |
public class RasterModule extends Extension{ |
70 |
/**
|
71 |
* Contador global de las capas generadas para raster
|
72 |
*/
|
73 |
public static int layerCount = 1; |
74 |
|
75 |
/**
|
76 |
* Asigna la ?ltima ruta seleccionada en cualquier JFileChooser de la
|
77 |
* extensi?n de raster.
|
78 |
* @param value Valor de la ruta
|
79 |
*/
|
80 |
public static void setPath(String value) { |
81 |
Preferences prefs = Preferences.userRoot().node( "gvsig.foldering" ); |
82 |
prefs.put("DataFolder", value);
|
83 |
} |
84 |
|
85 |
/**
|
86 |
* Obtiene la ?ltima ruta seleccionada en cualquier JFileChooser de la
|
87 |
* extensi?n de raster.
|
88 |
* @return Valor de la ruta
|
89 |
*/
|
90 |
public static String getPath() { |
91 |
Preferences prefs = Preferences.userRoot().node( "gvsig.foldering" ); |
92 |
return prefs.get("DataFolder", null); |
93 |
} |
94 |
|
95 |
/*
|
96 |
* (non-Javadoc)
|
97 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
98 |
*/
|
99 |
public void execute(String actionCommand) { |
100 |
View theView = (View) PluginServices.getMDIManager().getActiveWindow(); |
101 |
MapControl mapCtrl = theView.getMapControl(); |
102 |
|
103 |
// Listener de eventos de movimiento que pone las coordenadas del rat?n en
|
104 |
// la barra de estado
|
105 |
StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
106 |
|
107 |
if (actionCommand.equals("SAVERASTER")) { |
108 |
loadSaveRasterListener(mapCtrl, sbl); |
109 |
mapCtrl.setTool("saveRaster");
|
110 |
} |
111 |
|
112 |
if (actionCommand.equals("PIXELINCREASE")) { |
113 |
IWindow[] win = PluginServices.getMDIManager().getAllWindows();
|
114 |
for (int i = 0; i < win.length; i++) { |
115 |
if (win[i] instanceof PixelncreaseDialog) { |
116 |
PluginServices.getMDIManager().closeWindow(win[i]); |
117 |
return;
|
118 |
} |
119 |
} |
120 |
PixelncreaseDialog pIncrease = new PixelncreaseDialog();
|
121 |
PluginServices.getMDIManager().addWindow(pIncrease); |
122 |
} |
123 |
|
124 |
if (actionCommand.equals("SELECTIMAGE")) { |
125 |
loadSelectRasterListener(mapCtrl, sbl); |
126 |
mapCtrl.setTool("selectRasterLayer");
|
127 |
} |
128 |
|
129 |
if (actionCommand.equals("GEO_PAN")) { |
130 |
GeoLocationDialog gld = null;
|
131 |
if(!GeoLocationDialog.isOpen) {
|
132 |
gld = new GeoLocationDialog(mapCtrl);
|
133 |
PluginServices.getMDIManager().addWindow(gld); |
134 |
} |
135 |
loadGeoPanListener(mapCtrl, sbl, gld); |
136 |
mapCtrl.setTool("geoPan");
|
137 |
} |
138 |
|
139 |
} |
140 |
|
141 |
/**
|
142 |
* Carga el listener de salvar a raster en el MapControl.
|
143 |
*/
|
144 |
private void loadSaveRasterListener(MapControl m_MapControl, StatusBarListener sbl) { |
145 |
// Si no se ha cargado el listener a?n lo cargamos.
|
146 |
if (m_MapControl.getNamesMapTools().get("saveRaster") == null) { |
147 |
SaveRasterListener srl = new SaveRasterListener(m_MapControl);
|
148 |
m_MapControl.addMapTool("saveRaster", new Behavior[] { new RectangleBehavior(srl), new MouseMovementBehavior(sbl) }); |
149 |
} |
150 |
} |
151 |
|
152 |
/**
|
153 |
* Carga el listener de selecci?n de raster en el MapControl.
|
154 |
*/
|
155 |
private void loadSelectRasterListener(MapControl mapCtrl, StatusBarListener sbl) { |
156 |
if (mapCtrl.getNamesMapTools().get("selectRasterLayer") == null) { |
157 |
SelectImageListener sil = new SelectImageListener(mapCtrl);
|
158 |
mapCtrl.addMapTool("selectRasterLayer", new Behavior[] { new PointBehavior(sil), new MouseMovementBehavior(sbl) }); |
159 |
mapCtrl.setTool("selectRasterLayer");
|
160 |
} |
161 |
} |
162 |
|
163 |
/**
|
164 |
* Carga el listener de selecci?n de raster en el MapControl.
|
165 |
*/
|
166 |
private void loadGeoPanListener(MapControl mapCtrl, StatusBarListener sbl, GeoLocationDialog gld) { |
167 |
if (mapCtrl.getNamesMapTools().get("geoPan") == null) { |
168 |
GeorefPanListener pl = new GeorefPanListener(mapCtrl);
|
169 |
GeoRasterBehavior mb = new GeoRasterBehavior(pl, gld);
|
170 |
mapCtrl.addMapTool("geoPan", new Behavior[]{mb, new MouseMovementBehavior(sbl)}); |
171 |
|
172 |
} |
173 |
} |
174 |
|
175 |
/*
|
176 |
* (non-Javadoc)
|
177 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
178 |
*/
|
179 |
public void initialize() { |
180 |
// DiagSignalHandler.install("ALRM");
|
181 |
|
182 |
Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
183 |
prefs.put("DataFolder", System.getProperty("user.home")); |
184 |
|
185 |
InfoPanel info = new InfoPanel();
|
186 |
BandSetupPanel bandSetup = new BandSetupPanel();
|
187 |
TransparencyPanel transpPanel = new TransparencyPanel();
|
188 |
EnhancedPanel enhancedPanel = new EnhancedPanel();
|
189 |
PanSharpeningPanel pansharpeningPanel= new PanSharpeningPanel();
|
190 |
|
191 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
192 |
|
193 |
// Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades.
|
194 |
if (!extensionPoints.containsKey("RasterSEProperties")) { |
195 |
extensionPoints.put(new ExtensionPoint("RasterSEPropertiesDialog", "Raster Properties registrable panels (register instances of javax.swing.JPanel)")); |
196 |
} |
197 |
// A?adimos paneles al cuadro de propiedades.
|
198 |
extensionPoints.add("RasterSEPropertiesDialog", info.getID(), info);
|
199 |
extensionPoints.add("RasterSEPropertiesDialog", bandSetup.getID(), bandSetup);
|
200 |
extensionPoints.add("RasterSEPropertiesDialog", transpPanel.getID(), transpPanel);
|
201 |
extensionPoints.add("RasterSEPropertiesDialog", enhancedPanel.getID(), enhancedPanel);
|
202 |
extensionPoints.add("RasterSEPropertiesDialog", pansharpeningPanel.getID(), pansharpeningPanel);
|
203 |
// A?adimos la entrada del toc de la ventana de Histograma.
|
204 |
extensionPoints.add("View_TocActions", "HistogramPanel", new HistogramTocMenuEntry()); |
205 |
|
206 |
// A?adimos la entrada del toc de la ventana de Recorte.
|
207 |
extensionPoints.add("View_TocActions", "CuttingPanel", new CuttingTocMenuEntry()); |
208 |
|
209 |
// A?adimos la entrada del toc de la ventana de Filtros.
|
210 |
extensionPoints.add("View_TocActions", "FilterPanel", new FilterTocMenuEntry()); |
211 |
|
212 |
// A?adimos la entrada del toc del cuadro de Propiedades. Como se llama igual sustituye a la vieja.
|
213 |
extensionPoints.add("View_TocActions", "RasterSEProperties", new RasterPropertiesTocMenuEntry()); |
214 |
|
215 |
// A?adimos la entrada del toc de zoom a la resoluci?n del raster.
|
216 |
extensionPoints.add("View_TocActions", "ZoomPixelCursor", new ZoomPixelCursorTocMenuEntry()); |
217 |
|
218 |
// A?adimos la entrada del toc de zoom Salvar Como.
|
219 |
extensionPoints.add("View_TocActions", "SaveAs", new SaveAsTocMenuEntry()); |
220 |
|
221 |
// A?adimos la entrada del toc de la vista de analisis.
|
222 |
extensionPoints.add("View_TocActions", "ViewRasterAnalysis", new ViewRasterAnalysisTocMenuEntry()); |
223 |
|
224 |
// A?adimos la entrada del toc de la vista de analisis.
|
225 |
extensionPoints.add("View_TocActions", "ViewColorTable", new ColorTableTocMenuEntry()); |
226 |
|
227 |
// A?adimos el panel al winzard de cargar capa. (Esto es temporal hasta que el actual sea totalmente extensible)
|
228 |
AddLayer.addWizard(FileOpenRasterDialog.class); |
229 |
} |
230 |
|
231 |
/*
|
232 |
* (non-Javadoc)
|
233 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
234 |
*/
|
235 |
public boolean isEnabled() { |
236 |
return true; |
237 |
} |
238 |
|
239 |
/**
|
240 |
* Mostramos el control si hay alguna capa cargada.
|
241 |
*/
|
242 |
public boolean isVisible() { |
243 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
244 |
if (f == null) |
245 |
return false; |
246 |
|
247 |
if (f instanceof View) { |
248 |
View vista = (View) f; |
249 |
IProjectView model = vista.getModel(); |
250 |
MapContext mapa = model.getMapContext(); |
251 |
if (mapa.getLayers().getLayersCount() > 0) |
252 |
return true; |
253 |
} |
254 |
|
255 |
return false; |
256 |
} |
257 |
} |