svn-gvsig-desktop / branches / gvSIG_CAD_Layout_version / applications / appgvSIG / src / com / iver / cit / gvsig / ViewControls.java @ 1649
History | View | Annotate | Download (6.85 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 | 596 | fernando | import com.iver.andami.PluginServices; |
50 | import com.iver.andami.messages.NotificationManager; |
||
51 | import com.iver.andami.plugins.Extension; |
||
52 | 1086 | vcaballero | |
53 | 652 | fernando | import com.iver.cit.gvsig.fmap.DriverException; |
54 | 312 | fernando | import com.iver.cit.gvsig.fmap.FMap; |
55 | 1223 | fernando | import com.iver.cit.gvsig.fmap.MapControl; |
56 | 637 | fjp | import com.iver.cit.gvsig.fmap.layers.FLayer; |
57 | import com.iver.cit.gvsig.gui.Encuadrator; |
||
58 | import com.iver.cit.gvsig.gui.ExtentListSelectorModel; |
||
59 | import com.iver.cit.gvsig.gui.FPanelExtentSelector; |
||
60 | import com.iver.cit.gvsig.gui.FPanelLocConfig; |
||
61 | 312 | fernando | import com.iver.cit.gvsig.gui.View; |
62 | 1221 | fernando | import com.iver.cit.gvsig.gui.project.ViewProperties; |
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.ProjectExtent; |
||
68 | import com.iver.cit.gvsig.project.ProjectView; |
||
69 | 1086 | vcaballero | |
70 | import org.apache.log4j.Logger; |
||
71 | |||
72 | |||
73 | 312 | fernando | //import com.iver.utiles.FPanelExtentSelector;
|
74 | |||
75 | /**
|
||
76 | 1219 | vcaballero | * Extensi?n que controla las operaciones basicas realizadas sobre la vista.
|
77 | 312 | fernando | *
|
78 | * @author vcn
|
||
79 | */
|
||
80 | 596 | fernando | public class ViewControls implements Extension { |
81 | 1086 | vcaballero | private static Logger logger = Logger.getLogger(ViewControls.class.getName()); |
82 | 312 | fernando | |
83 | 1086 | vcaballero | /**
|
84 | 1219 | vcaballero | * @see com.iver.mdiApp.plugins.Extension#updateUI(java.lang.String)
|
85 | 1086 | vcaballero | */
|
86 | public void execute(String s) { |
||
87 | View vista = (View) PluginServices.getMDIManager().getActiveView(); |
||
88 | ProjectView model = vista.getModel(); |
||
89 | FMap mapa = model.getMapContext(); |
||
90 | 1349 | fernando | MapControl mapCtrl = vista.getMapControl().getMapControl(); |
91 | 1086 | vcaballero | logger.debug("Comand : " + s);
|
92 | 312 | fernando | |
93 | 1086 | vcaballero | if (s.compareTo("FULL") == 0) { |
94 | try {
|
||
95 | 1327 | fjp | // mapa.beginAtomicEvent();
|
96 | 312 | fernando | mapa.getViewPort().setExtent(mapa.getLayers().getFullExtent()); |
97 | 1327 | fjp | vista.repaintMap(); |
98 | // mapa.endAtomicEvent();
|
||
99 | 652 | fernando | } catch (DriverException e) {
|
100 | 1086 | vcaballero | NotificationManager.addError("Error obteniendo el full extent",
|
101 | e); |
||
102 | 312 | fernando | } |
103 | 1086 | vcaballero | } else if (s.compareTo("SELECTIONBYSHAPE") == 0) { |
104 | SelectionByTheme dlg = new SelectionByTheme();
|
||
105 | FLayer[] layers = mapa.getLayers().getActives();
|
||
106 | int count = 0; |
||
107 | dlg.setModel(new DefaultSelectionByThemeModel());
|
||
108 | dlg.addSelectionListener(new MySelectionByThemeListener());
|
||
109 | PluginServices.getMDIManager().addView(dlg); |
||
110 | } else if (s.compareTo("ENCUADRE") == 0) { |
||
111 | FPanelExtentSelector l = new FPanelExtentSelector();
|
||
112 | 312 | fernando | |
113 | 1086 | vcaballero | ProjectExtension p = (ProjectExtension) PluginServices.getExtension(com.iver.cit.gvsig.ProjectExtension.class); |
114 | Project project = p.getProject(); |
||
115 | ExtentListSelectorModel modelo = new ExtentListSelectorModel(project);
|
||
116 | ProjectExtent[] extents = project.getExtents();
|
||
117 | project.addPropertyChangeListener(modelo); |
||
118 | l.setModel(modelo); |
||
119 | l.addSelectionListener(new Encuadrator(project, mapa, vista));
|
||
120 | PluginServices.getMDIManager().addView(l); |
||
121 | } else if (s.compareTo("INFO") == 0) { |
||
122 | mapCtrl.setTool("info");
|
||
123 | } else if (s.compareTo("CONFIG_LOCATOR") == 0) { |
||
124 | 312 | fernando | //Set up the map overview
|
125 | 643 | fjp | FPanelLocConfig m_panelLoc = new FPanelLocConfig(vista.getMapOverview());
|
126 | 637 | fjp | PluginServices.getMDIManager().addView(m_panelLoc); |
127 | 1086 | vcaballero | m_panelLoc.setPreferredSize(m_panelLoc.getSize()); |
128 | } else if (s.compareTo("PAN") == 0) { |
||
129 | mapCtrl.setTool("pan");
|
||
130 | } else if (s.compareTo("ZOOM_IN") == 0) { |
||
131 | mapCtrl.setTool("zoomIn");
|
||
132 | } else if (s.compareTo("ZOOM_OUT") == 0) { |
||
133 | mapCtrl.setTool("zoomOut");
|
||
134 | 1219 | vcaballero | } else if (s.compareTo("MEDICION") == 0) { |
135 | 375 | fjp | mapCtrl.setTool("medicion");
|
136 | 312 | fernando | } else if (s.compareTo("AREA") == 0) { |
137 | 375 | fjp | mapCtrl.setTool("area");
|
138 | 312 | fernando | } else if (s.compareTo("SELRECT") == 0) { |
139 | 457 | fernando | mapCtrl.setTool("rectSelection");
|
140 | 312 | fernando | } else if (s.compareTo("SELPOINT") == 0) { |
141 | 457 | fernando | mapCtrl.setTool("pointSelection");
|
142 | 1086 | vcaballero | } else if (s.compareTo("PROPERTIES") == 0) { |
143 | 357 | fjp | ViewProperties viewProperties = new ViewProperties(model);
|
144 | 596 | fernando | PluginServices.getMDIManager().addView(viewProperties); |
145 | 1219 | vcaballero | } else if (s.compareTo("TEMAS_VISIBLES") == 0) { |
146 | setVisibles(true, mapa);
|
||
147 | } else if (s.compareTo("TEMAS_NOVISIBLES") == 0) { |
||
148 | setVisibles(false, mapa);
|
||
149 | } else if (s.compareTo("TEMAS_ACTIVOS") == 0) { |
||
150 | setActives(true, mapa);
|
||
151 | } else if (s.compareTo("TEMAS_NOACTIVOS") == 0) { |
||
152 | setActives(false, mapa);
|
||
153 | 1086 | vcaballero | } |
154 | } |
||
155 | 1219 | vcaballero | |
156 | /**
|
||
157 | * Pone todas las capas visibles o no visibles.
|
||
158 | *
|
||
159 | * @param visible true si que quieren poner a visibles.
|
||
160 | * @param mapa FMap sobre el que actuar.
|
||
161 | */
|
||
162 | private void setVisibles(boolean visible, FMap mapa) { |
||
163 | for (int i = 0; i < mapa.getLayers().getLayersCount(); i++) { |
||
164 | FLayer layer = mapa.getLayers().getLayer(i); |
||
165 | 1185 | vcaballero | layer.setVisible(visible); |
166 | } |
||
167 | } |
||
168 | 1219 | vcaballero | |
169 | /**
|
||
170 | * Pone todas las capas activas o no activas.
|
||
171 | *
|
||
172 | * @param active true si que quieren poner a activas.
|
||
173 | * @param mapa FMap sobre el que actuar.
|
||
174 | */
|
||
175 | private void setActives(boolean active, FMap mapa) { |
||
176 | for (int i = 0; i < mapa.getLayers().getLayersCount(); i++) { |
||
177 | FLayer layer = mapa.getLayers().getLayer(i); |
||
178 | 1185 | vcaballero | layer.setActive(active); |
179 | } |
||
180 | } |
||
181 | 1219 | vcaballero | |
182 | 1086 | vcaballero | /**
|
183 | * @see com.iver.mdiApp.plugins.Extension#isVisible()
|
||
184 | */
|
||
185 | public boolean isVisible() { |
||
186 | com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
||
187 | .getActiveView(); |
||
188 | 312 | fernando | |
189 | 1086 | vcaballero | if (f == null) { |
190 | return false; |
||
191 | } |
||
192 | 312 | fernando | |
193 | 1086 | vcaballero | if (f.getClass() == View.class) { |
194 | View vista = (View) f; |
||
195 | ProjectView model = vista.getModel(); |
||
196 | FMap mapa = model.getMapContext(); |
||
197 | 1219 | vcaballero | |
198 | 1086 | vcaballero | return mapa.getLayers().getLayersCount() > 0; |
199 | } else {
|
||
200 | return false; |
||
201 | } |
||
202 | } |
||
203 | 596 | fernando | |
204 | /**
|
||
205 | * @see com.iver.andami.plugins.Extension#inicializar()
|
||
206 | */
|
||
207 | public void inicializar() { |
||
208 | } |
||
209 | |||
210 | /**
|
||
211 | * @see com.iver.andami.plugins.Extension#isEnabled()
|
||
212 | */
|
||
213 | public boolean isEnabled() { |
||
214 | return true; |
||
215 | } |
||
216 | 312 | fernando | } |