root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / MeasureExtension.java @ 14821
History | View | Annotate | Download (4.15 KB)
1 |
|
---|---|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
3 |
*
|
4 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* Generalitat Valenciana
|
23 |
* Conselleria d'Infraestructures i Transport
|
24 |
* Av. Blasco Ib??ez, 50
|
25 |
* 46010 VALENCIA
|
26 |
* SPAIN
|
27 |
*
|
28 |
* +34 963862235
|
29 |
* gvsig@gva.es
|
30 |
* www.gvsig.gva.es
|
31 |
*
|
32 |
* or
|
33 |
*
|
34 |
* IVER T.I. S.A
|
35 |
* Salamanca 50
|
36 |
* 46005 Valencia
|
37 |
* Spain
|
38 |
*
|
39 |
* +34 963163400
|
40 |
* dac@iver.es
|
41 |
*/
|
42 |
|
43 |
package com.iver.cit.gvsig; |
44 |
|
45 |
import com.iver.andami.PluginServices; |
46 |
import com.iver.andami.plugins.Extension; |
47 |
|
48 |
import com.iver.cit.gvsig.fmap.MapContext; |
49 |
import com.iver.cit.gvsig.fmap.MapControl; |
50 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
51 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
52 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
53 |
|
54 |
|
55 |
/**
|
56 |
* Extensi?n que controla las operaciones de medida realizadas sobre la vista.
|
57 |
*
|
58 |
* @author Vicente Caballero Navarro
|
59 |
*/
|
60 |
public class MeasureExtension extends Extension { |
61 |
/* (non-Javadoc)
|
62 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
63 |
*/
|
64 |
public void initialize() { |
65 |
PluginServices.getIconTheme().register( |
66 |
"view-query-distance",
|
67 |
this.getClass().getClassLoader().getResource("images/Distancia.png") |
68 |
); |
69 |
|
70 |
PluginServices.getIconTheme().register( |
71 |
"view-query-area",
|
72 |
this.getClass().getClassLoader().getResource("images/Poligono16.png") |
73 |
); |
74 |
} |
75 |
|
76 |
/* (non-Javadoc)
|
77 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
78 |
*/
|
79 |
public void execute(String s) { |
80 |
com.iver.andami.ui.mdiManager.IWindow view = PluginServices.getMDIManager() |
81 |
.getActiveWindow(); |
82 |
|
83 |
if (!(view instanceof View)) { |
84 |
return;
|
85 |
} |
86 |
|
87 |
View vista = (View) view; |
88 |
MapControl mapCtrl = vista.getMapControl(); |
89 |
|
90 |
if (s.equals("MEDICION")) { |
91 |
mapCtrl.setTool("medicion");
|
92 |
} else if (s.equals("AREA")) { |
93 |
mapCtrl.setTool("area");
|
94 |
} |
95 |
} |
96 |
|
97 |
/* (non-Javadoc)
|
98 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
99 |
*/
|
100 |
public boolean isEnabled() { |
101 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
102 |
.getActiveWindow(); |
103 |
|
104 |
if (f == null) { |
105 |
return false; |
106 |
} |
107 |
|
108 |
if (f instanceof View) { |
109 |
View vista = (View) f; |
110 |
IProjectView model = vista.getModel(); |
111 |
MapContext mapa = model.getMapContext(); |
112 |
|
113 |
FLayers layers = mapa.getLayers(); |
114 |
|
115 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
116 |
if (layers.getLayer(i).isAvailable()) {
|
117 |
return true; |
118 |
} |
119 |
} |
120 |
} |
121 |
|
122 |
return false; |
123 |
} |
124 |
|
125 |
/* (non-Javadoc)
|
126 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
127 |
*/
|
128 |
public boolean isVisible() { |
129 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
130 |
.getActiveWindow(); |
131 |
|
132 |
if (f == null) { |
133 |
return false; |
134 |
} |
135 |
|
136 |
if (f instanceof View) { |
137 |
View vista = (View) f; |
138 |
IProjectView model = vista.getModel(); |
139 |
MapContext mapa = model.getMapContext(); |
140 |
|
141 |
return mapa.getLayers().getLayersCount() > 0; |
142 |
} |
143 |
|
144 |
return false; |
145 |
} |
146 |
} |