svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / GeneralToolsModule.java @ 19292
History | View | Annotate | Download (6.1 KB)
1 | 15671 | nbrodin | /* 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 | 18826 | bsanchez | import javax.swing.Icon; |
22 | |||
23 | import org.gvsig.raster.gui.IGenericToolBarMenuItem; |
||
24 | import org.gvsig.raster.util.RasterToolsUtil; |
||
25 | 15671 | nbrodin | import org.gvsig.rastertools.pixelincrease.PixelncreaseDialog; |
26 | import org.gvsig.rastertools.saveraster.map.SaveRasterListener; |
||
27 | |||
28 | import com.iver.andami.PluginServices; |
||
29 | import com.iver.andami.plugins.Extension; |
||
30 | import com.iver.andami.ui.mdiManager.IWindow; |
||
31 | import com.iver.cit.gvsig.fmap.MapContext; |
||
32 | import com.iver.cit.gvsig.fmap.MapControl; |
||
33 | 18826 | bsanchez | import com.iver.cit.gvsig.fmap.layers.FLayer; |
34 | 15671 | nbrodin | import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
35 | import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
||
36 | import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
||
37 | import com.iver.cit.gvsig.project.documents.view.IProjectView; |
||
38 | import com.iver.cit.gvsig.project.documents.view.gui.View; |
||
39 | 18826 | bsanchez | import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
40 | 15671 | nbrodin | import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
41 | 18826 | bsanchez | import com.iver.utiles.extensionPoints.ExtensionPoints; |
42 | import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
||
43 | 15671 | nbrodin | /**
|
44 | * Extensi?n que contiene herramientas generales para gvSIG y que no son
|
||
45 | * especificas de raster. Para este otro tipo es mejor utilizar RasterModule.
|
||
46 | *
|
||
47 | * @author Nacho Brodin (nachobrodin@gmail.com)
|
||
48 | */
|
||
49 | 18826 | bsanchez | public class GeneralToolsModule extends Extension implements IGenericToolBarMenuItem { |
50 | 15671 | nbrodin | /*
|
51 | * (non-Javadoc)
|
||
52 | * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
||
53 | */
|
||
54 | public void execute(String actionCommand) { |
||
55 | View theView = (View) PluginServices.getMDIManager().getActiveWindow(); |
||
56 | MapControl mapCtrl = theView.getMapControl(); |
||
57 | |||
58 | // Listener de eventos de movimiento que pone las coordenadas del rat?n en
|
||
59 | // la barra de estado
|
||
60 | StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
||
61 | |||
62 | if (actionCommand.equals("SAVERASTER")) { |
||
63 | 18982 | nbrodin | RasterToolsUtil.messageBoxInfo("start_save", null); |
64 | 15671 | nbrodin | loadSaveRasterListener(mapCtrl, sbl); |
65 | mapCtrl.setTool("saveRaster");
|
||
66 | } |
||
67 | |||
68 | if (actionCommand.equals("PIXELINCREASE")) { |
||
69 | IWindow[] win = PluginServices.getMDIManager().getAllWindows();
|
||
70 | for (int i = 0; i < win.length; i++) { |
||
71 | if (win[i] instanceof PixelncreaseDialog) { |
||
72 | PluginServices.getMDIManager().closeWindow(win[i]); |
||
73 | return;
|
||
74 | } |
||
75 | } |
||
76 | PixelncreaseDialog pIncrease = new PixelncreaseDialog();
|
||
77 | PluginServices.getMDIManager().addWindow(pIncrease); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | /**
|
||
82 | * Carga el listener de salvar a raster en el MapControl.
|
||
83 | */
|
||
84 | private void loadSaveRasterListener(MapControl m_MapControl, StatusBarListener sbl) { |
||
85 | // Si no se ha cargado el listener a?n lo cargamos.
|
||
86 | if (m_MapControl.getNamesMapTools().get("saveRaster") == null) { |
||
87 | SaveRasterListener srl = new SaveRasterListener(m_MapControl);
|
||
88 | m_MapControl.addMapTool("saveRaster", new Behavior[] { new RectangleBehavior(srl), new MouseMovementBehavior(sbl) }); |
||
89 | } |
||
90 | } |
||
91 | |||
92 | /*
|
||
93 | * (non-Javadoc)
|
||
94 | * @see com.iver.andami.plugins.IExtension#initialize()
|
||
95 | */
|
||
96 | public void initialize() { |
||
97 | 18826 | bsanchez | ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
98 | extensionPoints.add("GenericToolBarMenu", "SaveRaster", this); |
||
99 | 15671 | nbrodin | } |
100 | |||
101 | /*
|
||
102 | * (non-Javadoc)
|
||
103 | * @see com.iver.andami.plugins.IExtension#isEnabled()
|
||
104 | */
|
||
105 | public boolean isEnabled() { |
||
106 | return true; |
||
107 | } |
||
108 | |||
109 | /**
|
||
110 | * Mostramos el control si hay alguna capa cargada.
|
||
111 | */
|
||
112 | public boolean isVisible() { |
||
113 | com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
||
114 | if (f == null) |
||
115 | return false; |
||
116 | |||
117 | if (f instanceof View) { |
||
118 | View vista = (View) f; |
||
119 | IProjectView model = vista.getModel(); |
||
120 | MapContext mapa = model.getMapContext(); |
||
121 | if (mapa.getLayers().getLayersCount() > 0) |
||
122 | return true; |
||
123 | } |
||
124 | |||
125 | return false; |
||
126 | } |
||
127 | 18826 | bsanchez | |
128 | /*
|
||
129 | * (non-Javadoc)
|
||
130 | * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
||
131 | */
|
||
132 | public void execute(ITocItem item, FLayer[] selectedItems) { |
||
133 | this.execute("SAVERASTER"); |
||
134 | } |
||
135 | |||
136 | /*
|
||
137 | * (non-Javadoc)
|
||
138 | * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroup()
|
||
139 | */
|
||
140 | public String getGroup() { |
||
141 | return "RasterExport"; |
||
142 | } |
||
143 | |||
144 | /*
|
||
145 | * (non-Javadoc)
|
||
146 | * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getIcon()
|
||
147 | */
|
||
148 | public Icon getIcon() { |
||
149 | 18972 | bsanchez | return PluginServices.getIconTheme().get("save-raster"); |
150 | 18826 | bsanchez | } |
151 | |||
152 | /*
|
||
153 | * (non-Javadoc)
|
||
154 | * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getOrder()
|
||
155 | */
|
||
156 | public int getOrder() { |
||
157 | return 0; |
||
158 | } |
||
159 | |||
160 | /*
|
||
161 | * (non-Javadoc)
|
||
162 | * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getText()
|
||
163 | */
|
||
164 | public String getText() { |
||
165 | 18846 | bsanchez | return RasterToolsUtil.getText(this, "salvar_raster_geo"); |
166 | 18826 | bsanchez | } |
167 | |||
168 | /*
|
||
169 | * (non-Javadoc)
|
||
170 | * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
||
171 | */
|
||
172 | public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
||
173 | return this.isEnabled(); |
||
174 | } |
||
175 | |||
176 | /*
|
||
177 | * (non-Javadoc)
|
||
178 | * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
||
179 | */
|
||
180 | public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
||
181 | return this.isVisible(); |
||
182 | } |
||
183 | 18846 | bsanchez | |
184 | /*
|
||
185 | * (non-Javadoc)
|
||
186 | * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroupOrder()
|
||
187 | */
|
||
188 | public int getGroupOrder() { |
||
189 | return 50; |
||
190 | } |
||
191 | 15671 | nbrodin | } |