Statistics
| Revision:

root / branches / v10 / applications / appgvSIG / src / com / iver / cit / gvsig / MeasureExtension.java @ 20910

History | View | Annotate | Download (3.85 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
    }
66

    
67
    /* (non-Javadoc)
68
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
69
     */
70
    public void execute(String s) {
71
        com.iver.andami.ui.mdiManager.IWindow view = PluginServices.getMDIManager()
72
                                                                   .getActiveWindow();
73

    
74
        if (!(view instanceof View)) {
75
            return;
76
        }
77

    
78
        View vista = (View) view;
79
        MapControl mapCtrl = vista.getMapControl();
80

    
81
        if (s.equals("MEDICION")) {
82
            mapCtrl.setTool("medicion");
83
        } else if (s.equals("AREA")) {
84
            mapCtrl.setTool("area");
85
        }
86
    }
87

    
88
    /* (non-Javadoc)
89
     * @see com.iver.andami.plugins.IExtension#isEnabled()
90
     */
91
    public boolean isEnabled() {
92
        com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
93
                                                                .getActiveWindow();
94

    
95
        if (f == null) {
96
            return false;
97
        }
98

    
99
        if (f instanceof View) {
100
            View vista = (View) f;
101
            IProjectView model = vista.getModel();
102
            MapContext mapa = model.getMapContext();
103

    
104
            FLayers layers = mapa.getLayers();
105

    
106
            for (int i = 0; i < layers.getLayersCount(); i++) {
107
                if (layers.getLayer(i).isAvailable()) {
108
                    return true;
109
                }
110
            }
111
        }
112

    
113
        return false;
114
    }
115

    
116
    /* (non-Javadoc)
117
     * @see com.iver.andami.plugins.IExtension#isVisible()
118
     */
119
    public boolean isVisible() {
120
        com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
121
                                                                .getActiveWindow();
122

    
123
        if (f == null) {
124
            return false;
125
        }
126

    
127
        if (f instanceof View) {
128
            View vista = (View) f;
129
            IProjectView model = vista.getModel();
130
            MapContext mapa = model.getMapContext();
131

    
132
            return mapa.getLayers().getLayersCount() > 0;
133
        }
134

    
135
        return false;
136
    }
137
}