svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / ViewControls.java @ 5379
History | View | Annotate | Download (6.74 KB)
1 | 312 | fernando | /*
|
---|---|---|---|
2 | * Created on 20-feb-2004
|
||
3 | *
|
||
4 | * To change the template for this generated file go to
|
||
5 | * Window>Preferences>Java>Code Generation>Code and Comments
|
||
6 | */
|
||
7 | 1103 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 | *
|
||
9 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
10 | *
|
||
11 | * This program is free software; you can redistribute it and/or
|
||
12 | * modify it under the terms of the GNU General Public License
|
||
13 | * as published by the Free Software Foundation; either version 2
|
||
14 | * of the License, or (at your option) any later version.
|
||
15 | *
|
||
16 | * This program is distributed in the hope that it will be useful,
|
||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
19 | * GNU General Public License for more details.
|
||
20 | *
|
||
21 | * You should have received a copy of the GNU General Public License
|
||
22 | * along with this program; if not, write to the Free Software
|
||
23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
24 | *
|
||
25 | * For more information, contact:
|
||
26 | *
|
||
27 | * Generalitat Valenciana
|
||
28 | * Conselleria d'Infraestructures i Transport
|
||
29 | * Av. Blasco Ib??ez, 50
|
||
30 | * 46010 VALENCIA
|
||
31 | * SPAIN
|
||
32 | *
|
||
33 | * +34 963862235
|
||
34 | * gvsig@gva.es
|
||
35 | * www.gvsig.gva.es
|
||
36 | *
|
||
37 | * or
|
||
38 | *
|
||
39 | * IVER T.I. S.A
|
||
40 | * Salamanca 50
|
||
41 | * 46005 Valencia
|
||
42 | * Spain
|
||
43 | *
|
||
44 | * +34 963163400
|
||
45 | * dac@iver.es
|
||
46 | */
|
||
47 | 312 | fernando | package com.iver.cit.gvsig; |
48 | |||
49 | 2522 | caballero | import org.apache.log4j.Logger; |
50 | |||
51 | 596 | fernando | import com.iver.andami.PluginServices; |
52 | import com.iver.andami.messages.NotificationManager; |
||
53 | import com.iver.andami.plugins.Extension; |
||
54 | 652 | fernando | import com.iver.cit.gvsig.fmap.DriverException; |
55 | 312 | fernando | import com.iver.cit.gvsig.fmap.FMap; |
56 | 1223 | fernando | import com.iver.cit.gvsig.fmap.MapControl; |
57 | 637 | fjp | import com.iver.cit.gvsig.fmap.layers.FLayer; |
58 | import com.iver.cit.gvsig.gui.Encuadrator; |
||
59 | import com.iver.cit.gvsig.gui.ExtentListSelectorModel; |
||
60 | import com.iver.cit.gvsig.gui.FPanelExtentSelector; |
||
61 | import com.iver.cit.gvsig.gui.FPanelLocConfig; |
||
62 | 312 | fernando | import com.iver.cit.gvsig.gui.View; |
63 | 950 | fernando | import com.iver.cit.gvsig.gui.selectionByTheme.DefaultSelectionByThemeModel; |
64 | 935 | fernando | import com.iver.cit.gvsig.gui.selectionByTheme.MySelectionByThemeListener; |
65 | import com.iver.cit.gvsig.gui.selectionByTheme.SelectionByTheme; |
||
66 | 1221 | fernando | import com.iver.cit.gvsig.project.Project; |
67 | import com.iver.cit.gvsig.project.ProjectView; |
||
68 | 1086 | vcaballero | |
69 | |||
70 | 312 | fernando | //import com.iver.utiles.FPanelExtentSelector;
|
71 | |||
72 | /**
|
||
73 | 1219 | vcaballero | * Extensi?n que controla las operaciones basicas realizadas sobre la vista.
|
74 | 312 | fernando | *
|
75 | * @author vcn
|
||
76 | */
|
||
77 | 5005 | jorpiell | public class ViewControls extends Extension { |
78 | 1086 | vcaballero | private static Logger logger = Logger.getLogger(ViewControls.class.getName()); |
79 | 312 | fernando | |
80 | 1086 | vcaballero | /**
|
81 | 5005 | jorpiell | * @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String)
|
82 | 1086 | vcaballero | */
|
83 | public void execute(String s) { |
||
84 | View vista = (View) PluginServices.getMDIManager().getActiveView(); |
||
85 | ProjectView model = vista.getModel(); |
||
86 | FMap mapa = model.getMapContext(); |
||
87 | 1223 | fernando | MapControl mapCtrl = vista.getMapControl(); |
88 | 1086 | vcaballero | logger.debug("Comand : " + s);
|
89 | 312 | fernando | |
90 | 1086 | vcaballero | if (s.compareTo("FULL") == 0) { |
91 | try {
|
||
92 | 1327 | fjp | // mapa.beginAtomicEvent();
|
93 | 312 | fernando | mapa.getViewPort().setExtent(mapa.getLayers().getFullExtent()); |
94 | 1327 | fjp | vista.repaintMap(); |
95 | // mapa.endAtomicEvent();
|
||
96 | 652 | fernando | } catch (DriverException e) {
|
97 | 1086 | vcaballero | NotificationManager.addError("Error obteniendo el full extent",
|
98 | e); |
||
99 | 312 | fernando | } |
100 | 1086 | vcaballero | } else if (s.compareTo("SELECTIONBYSHAPE") == 0) { |
101 | SelectionByTheme dlg = new SelectionByTheme();
|
||
102 | 2522 | caballero | //FLayer[] layers = mapa.getLayers().getActives();
|
103 | //int count = 0;
|
||
104 | 1086 | vcaballero | dlg.setModel(new DefaultSelectionByThemeModel());
|
105 | dlg.addSelectionListener(new MySelectionByThemeListener());
|
||
106 | PluginServices.getMDIManager().addView(dlg); |
||
107 | } else if (s.compareTo("ENCUADRE") == 0) { |
||
108 | FPanelExtentSelector l = new FPanelExtentSelector();
|
||
109 | 312 | fernando | |
110 | 1086 | vcaballero | ProjectExtension p = (ProjectExtension) PluginServices.getExtension(com.iver.cit.gvsig.ProjectExtension.class); |
111 | Project project = p.getProject(); |
||
112 | ExtentListSelectorModel modelo = new ExtentListSelectorModel(project);
|
||
113 | 2522 | caballero | //ProjectExtent[] extents = project.getExtents();
|
114 | 1086 | vcaballero | project.addPropertyChangeListener(modelo); |
115 | l.setModel(modelo); |
||
116 | l.addSelectionListener(new Encuadrator(project, mapa, vista));
|
||
117 | PluginServices.getMDIManager().addView(l); |
||
118 | } else if (s.compareTo("INFO") == 0) { |
||
119 | mapCtrl.setTool("info");
|
||
120 | } else if (s.compareTo("CONFIG_LOCATOR") == 0) { |
||
121 | 312 | fernando | //Set up the map overview
|
122 | 643 | fjp | FPanelLocConfig m_panelLoc = new FPanelLocConfig(vista.getMapOverview());
|
123 | 637 | fjp | PluginServices.getMDIManager().addView(m_panelLoc); |
124 | 1086 | vcaballero | m_panelLoc.setPreferredSize(m_panelLoc.getSize()); |
125 | } else if (s.compareTo("PAN") == 0) { |
||
126 | mapCtrl.setTool("pan");
|
||
127 | } else if (s.compareTo("ZOOM_IN") == 0) { |
||
128 | mapCtrl.setTool("zoomIn");
|
||
129 | } else if (s.compareTo("ZOOM_OUT") == 0) { |
||
130 | mapCtrl.setTool("zoomOut");
|
||
131 | 1219 | vcaballero | } else if (s.compareTo("MEDICION") == 0) { |
132 | 375 | fjp | mapCtrl.setTool("medicion");
|
133 | 312 | fernando | } else if (s.compareTo("AREA") == 0) { |
134 | 375 | fjp | mapCtrl.setTool("area");
|
135 | 312 | fernando | } else if (s.compareTo("SELRECT") == 0) { |
136 | 457 | fernando | mapCtrl.setTool("rectSelection");
|
137 | 312 | fernando | } else if (s.compareTo("SELPOINT") == 0) { |
138 | 457 | fernando | mapCtrl.setTool("pointSelection");
|
139 | 5258 | jmvivo | } else if (s.compareTo("CAPAS_VISIBLES") == 0) { |
140 | 1219 | vcaballero | setVisibles(true, mapa);
|
141 | 5258 | jmvivo | } else if (s.compareTo("CAPAS_NOVISIBLES") == 0) { |
142 | 1219 | vcaballero | setVisibles(false, mapa);
|
143 | 5258 | jmvivo | } else if (s.compareTo("CAPAS_ACTIVAS") == 0) { |
144 | 1219 | vcaballero | setActives(true, mapa);
|
145 | 5258 | jmvivo | } else if (s.compareTo("CAPAS_NOACTIVAS") == 0) { |
146 | 1219 | vcaballero | setActives(false, mapa);
|
147 | 2183 | fernando | }else if (s.compareTo("SAVERASTER") == 0) { |
148 | mapCtrl.setTool("saveRaster");
|
||
149 | }else if (s.compareTo("SELECTIMAGE") == 0) { |
||
150 | mapCtrl.setTool("selectImage");
|
||
151 | 1086 | vcaballero | } |
152 | } |
||
153 | 1219 | vcaballero | |
154 | /**
|
||
155 | * Pone todas las capas visibles o no visibles.
|
||
156 | *
|
||
157 | * @param visible true si que quieren poner a visibles.
|
||
158 | * @param mapa FMap sobre el que actuar.
|
||
159 | */
|
||
160 | private void setVisibles(boolean visible, FMap mapa) { |
||
161 | for (int i = 0; i < mapa.getLayers().getLayersCount(); i++) { |
||
162 | FLayer layer = mapa.getLayers().getLayer(i); |
||
163 | 1185 | vcaballero | layer.setVisible(visible); |
164 | } |
||
165 | } |
||
166 | 1219 | vcaballero | |
167 | /**
|
||
168 | * Pone todas las capas activas o no activas.
|
||
169 | *
|
||
170 | * @param active true si que quieren poner a activas.
|
||
171 | * @param mapa FMap sobre el que actuar.
|
||
172 | */
|
||
173 | private void setActives(boolean active, FMap mapa) { |
||
174 | for (int i = 0; i < mapa.getLayers().getLayersCount(); i++) { |
||
175 | FLayer layer = mapa.getLayers().getLayer(i); |
||
176 | 1185 | vcaballero | layer.setActive(active); |
177 | } |
||
178 | } |
||
179 | 1219 | vcaballero | |
180 | 1086 | vcaballero | /**
|
181 | 5005 | jorpiell | * @see com.iver.mdiApp.plugins.IExtension#isVisible()
|
182 | 1086 | vcaballero | */
|
183 | public boolean isVisible() { |
||
184 | com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
||
185 | .getActiveView(); |
||
186 | 312 | fernando | |
187 | 1086 | vcaballero | if (f == null) { |
188 | return false; |
||
189 | } |
||
190 | 312 | fernando | |
191 | 1086 | vcaballero | if (f.getClass() == View.class) { |
192 | View vista = (View) f; |
||
193 | ProjectView model = vista.getModel(); |
||
194 | FMap mapa = model.getMapContext(); |
||
195 | 1219 | vcaballero | |
196 | 1086 | vcaballero | return mapa.getLayers().getLayersCount() > 0; |
197 | } else {
|
||
198 | return false; |
||
199 | } |
||
200 | } |
||
201 | 596 | fernando | |
202 | /**
|
||
203 | 5005 | jorpiell | * @see com.iver.andami.plugins.IExtension#initialize()
|
204 | 596 | fernando | */
|
205 | 5005 | jorpiell | public void initialize() { |
206 | 596 | fernando | } |
207 | |||
208 | /**
|
||
209 | 5005 | jorpiell | * @see com.iver.andami.plugins.IExtension#isEnabled()
|
210 | 596 | fernando | */
|
211 | public boolean isEnabled() { |
||
212 | return true; |
||
213 | } |
||
214 | 312 | fernando | } |