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