Statistics
| Revision:

root / trunk / extensions / extTopology / src / org / gvsig / topology / ReferencingExtension.java @ 22892

History | View | Annotate | Download (3.96 KB)

1
/*
2
 * Created on 10-abr-2006
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
 *
46
 * $Id: 
47
 * $Log: 
48
 */
49
package org.gvsig.topology;
50

    
51
import com.iver.andami.PluginServices;
52
import com.iver.andami.plugins.Extension;
53
import com.iver.cit.gvsig.fmap.MapContext;
54
import com.iver.cit.gvsig.fmap.MapControl;
55
import com.iver.cit.gvsig.fmap.layers.FLayer;
56
import com.iver.cit.gvsig.fmap.layers.FLayers;
57
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
58
import com.iver.cit.gvsig.project.documents.view.IProjectView;
59
import com.iver.cit.gvsig.project.documents.view.gui.View;
60
import com.iver.cit.gvsig.referencing.VectorialReferencingPanel;
61

    
62
/**
63
 * Extension to reference vectorial layers.
64
 * 
65
 * @author Alvaro Zabala
66
 * 
67
 */
68
public class ReferencingExtension extends Extension {
69

    
70
        public void execute(String actionCommand) {
71
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices
72
                                .getMDIManager().getActiveWindow();
73
                View vista = (View) f;
74
                if (f != null) {
75
                        MapControl mapControl = vista.getMapControl();
76
                        if(mapControl != null){
77
                                VectorialReferencingPanel refPanel = new VectorialReferencingPanel(mapControl.getMapContext().getLayers());
78
                                PluginServices.getMDIManager().addWindow(refPanel);
79
                        }// if
80
                }
81
        }
82

    
83
        public void initialize() {
84
                PluginServices.getIconTheme().registerDefault(
85
                                "vectorial-adjust",
86
                                this.getClass().getClassLoader().getResource(
87
                                                "images/vectorial-adjust.gif"));
88

    
89
                PluginServices.getIconTheme().registerDefault(
90
                                "vectorial-adjust",
91
                                this.getClass().getClassLoader().getResource(
92
                                                "images/vectorial-adjust.gif"));
93
        }
94

    
95
        public boolean isEnabled() {
96
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices
97
                                .getMDIManager().getActiveWindow();
98
                if (f == null) {
99
                        return false;
100
                }
101
                if (f instanceof View) {
102
                        View vista = (View) f;
103
                        MapContext mapContext = vista.getModel().getMapContext();
104
                        FLayers layers = mapContext.getLayers();
105
                        int numLayers = layers.getLayersCount();
106
                        for (int i = 0; i < numLayers; i++) {
107
                                FLayer layer = layers.getLayer(i);
108
                                if (layer instanceof FLyrVect && layer.isAvailable()
109
                                                && layer.isActive()) {
110
                                        return true;
111

    
112
                                }// if
113
                        }// for
114
                }// if
115
                return false;
116
        }
117

    
118
        public boolean isVisible() {
119
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices
120
                                .getMDIManager().getActiveWindow();
121
                if (f == null) {
122
                        return false;
123
                }
124
                if (f instanceof View) {
125
                        View vista = (View) f;
126
                        IProjectView model = vista.getModel();
127
                        FLayers layers = model.getMapContext().getLayers();
128
                        int numLayers = layers.getLayersCount();
129
                        for (int i = 0; i < numLayers; i++) {
130
                                FLayer layer = layers.getLayer(i);
131
                                if (layer instanceof FLyrVect)
132
                                        return true;
133
                        }
134
                        return false;
135
                }
136
                return false;
137
        }
138

    
139
}