svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / ViewSelectionControls.java @ 7011
History | View | Annotate | Download (4.86 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 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 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
/* CVS MESSAGES:
|
43 |
*
|
44 |
* $Id: ViewSelectionControls.java 7011 2006-09-04 16:26:54Z fjp $
|
45 |
* $Log$
|
46 |
* Revision 1.7 2006-09-04 16:26:54 fjp
|
47 |
* Seleccionar por pol?gono
|
48 |
*
|
49 |
* Revision 1.6 2006/08/29 07:56:27 cesar
|
50 |
* Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
|
51 |
*
|
52 |
* Revision 1.5 2006/08/29 07:21:08 cesar
|
53 |
* Rename com.iver.cit.gvsig.fmap.Fmap class to com.iver.cit.gvsig.fmap.MapContext
|
54 |
*
|
55 |
* Revision 1.4 2006/08/29 07:13:53 cesar
|
56 |
* Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow
|
57 |
*
|
58 |
* Revision 1.3 2006/08/18 08:40:04 jmvivo
|
59 |
* Actualizado para que el isEnabled tenga en cuenta que las capas esten 'avialable'
|
60 |
*
|
61 |
* Revision 1.2 2006/07/27 06:20:28 jaume
|
62 |
* *** empty log message ***
|
63 |
*
|
64 |
* Revision 1.1 2006/07/26 09:53:05 jaume
|
65 |
* separadas las herramientas de selecci?n del viewControls al ViewSelectionControls
|
66 |
*
|
67 |
*
|
68 |
*/
|
69 |
package com.iver.cit.gvsig; |
70 |
|
71 |
import org.apache.log4j.Logger; |
72 |
|
73 |
import com.iver.andami.PluginServices; |
74 |
import com.iver.andami.plugins.Extension; |
75 |
import com.iver.cit.gvsig.fmap.MapContext; |
76 |
import com.iver.cit.gvsig.fmap.MapControl; |
77 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
78 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
79 |
import com.iver.cit.gvsig.gui.View; |
80 |
import com.iver.cit.gvsig.gui.selectionByTheme.DefaultSelectionByThemeModel; |
81 |
import com.iver.cit.gvsig.gui.selectionByTheme.MySelectionByThemeListener; |
82 |
import com.iver.cit.gvsig.gui.selectionByTheme.SelectionByTheme; |
83 |
import com.iver.cit.gvsig.project.ProjectView; |
84 |
|
85 |
/**
|
86 |
* Extension that handles the selection tools, selection tools have sense on vectorial
|
87 |
* layers only.
|
88 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
89 |
*
|
90 |
*/
|
91 |
public class ViewSelectionControls extends Extension { |
92 |
private static Logger logger = Logger.getLogger(ViewControls.class.getName()); |
93 |
|
94 |
public void initialize() { |
95 |
// TODO Auto-generated method stub
|
96 |
|
97 |
} |
98 |
|
99 |
public void execute(String actionCommand) { |
100 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
101 |
ProjectView model = vista.getModel(); |
102 |
MapContext mapa = model.getMapContext(); |
103 |
MapControl mapCtrl = vista.getMapControl(); |
104 |
logger.debug("Comand : " + actionCommand);
|
105 |
if (actionCommand.equals("SELRECT") ) { |
106 |
mapCtrl.setTool("rectSelection");
|
107 |
} else if (actionCommand.equals("SELPOINT") ) { |
108 |
mapCtrl.setTool("pointSelection");
|
109 |
} else if (actionCommand.equals("SELPOL") ) { |
110 |
mapCtrl.setTool("polSelection");
|
111 |
} else if (actionCommand.equals("SELECTIONBYSHAPE") ) { |
112 |
SelectionByTheme dlg = new SelectionByTheme();
|
113 |
//FLayer[] layers = mapa.getLayers().getActives();
|
114 |
//int count = 0;
|
115 |
dlg.setModel(new DefaultSelectionByThemeModel());
|
116 |
dlg.addSelectionListener(new MySelectionByThemeListener());
|
117 |
PluginServices.getMDIManager().addWindow(dlg); |
118 |
} |
119 |
} |
120 |
|
121 |
public boolean isEnabled() { |
122 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
123 |
.getActiveWindow(); |
124 |
if (f instanceof View) { |
125 |
|
126 |
View vista = (View) f; |
127 |
ProjectView model = vista.getModel(); |
128 |
MapContext mapa = model.getMapContext(); |
129 |
|
130 |
for (int i = 0; i < mapa.getLayers().getActives().length; i++) { |
131 |
FLayer lyr = mapa.getLayers().getActives()[i]; |
132 |
if (lyr.isAvailable() && lyr instanceof FLyrVect) { |
133 |
return true; |
134 |
} |
135 |
} |
136 |
return false; |
137 |
} |
138 |
return true; |
139 |
} |
140 |
|
141 |
public boolean isVisible() { |
142 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
143 |
.getActiveWindow(); |
144 |
|
145 |
if (f != null && f instanceof View) { |
146 |
View vista = (View) f; |
147 |
ProjectView model = vista.getModel(); |
148 |
MapContext mapa = model.getMapContext(); |
149 |
|
150 |
for (int i = 0; i < mapa.getLayers().getLayersCount(); i++) { |
151 |
FLayer lyr = mapa.getLayers().getLayer(i); |
152 |
if (lyr instanceof FLyrVect) { |
153 |
return true; |
154 |
} |
155 |
} |
156 |
} |
157 |
return false; |
158 |
} |
159 |
} |