Statistics
| Revision:

root / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / wizard / GeoProcessingExtension.java @ 15641

History | View | Annotate | Download (7.51 KB)

1
/*
2
 * Created on 22-jun-2005
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
package com.iver.cit.gvsig.geoprocess.wizard;
45

    
46
import com.iver.andami.PluginServices;
47
import com.iver.andami.plugins.Extension;
48
import com.iver.cit.gvsig.fmap.layers.FLayer;
49
import com.iver.cit.gvsig.fmap.layers.FLayers;
50
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
51
import com.iver.cit.gvsig.geoprocess.impl.buffer.BufferGeoprocessPlugin;
52
import com.iver.cit.gvsig.geoprocess.impl.clip.ClipGeoprocessPlugin;
53
import com.iver.cit.gvsig.geoprocess.impl.difference.DifferenceGeoprocessPlugin;
54
import com.iver.cit.gvsig.geoprocess.impl.dissolve.DissolveGeoprocessPlugin;
55
import com.iver.cit.gvsig.geoprocess.impl.intersection.IntersectionGeoprocessPlugin;
56
import com.iver.cit.gvsig.geoprocess.impl.merge.MergeGeoprocessPlugin;
57
import com.iver.cit.gvsig.geoprocess.impl.spatialjoin.SpatialJoinGeoprocessPlugin;
58
import com.iver.cit.gvsig.geoprocess.impl.union.UnionGeoprocessPlugin;
59
import com.iver.cit.gvsig.project.documents.view.IProjectView;
60
import com.iver.cit.gvsig.project.documents.view.gui.View;
61

    
62
/**
63
 * GeoProcessingExtension class
64
 *
65
 * @author jmorell
66
 */
67
public class GeoProcessingExtension extends Extension {
68

    
69
    /* (non-Javadoc)
70
     * @see com.iver.andami.plugins.Extension#inicializar()
71
     */
72
    public void initialize() {
73
        // TODO Auto-generated method stub
74
            
75
            
76
            PluginServices.getIconTheme().registerDefault(
77
                                "geo-process",
78
                                this.getClass().getClassLoader().getResource("images/geoprocessicon.png")
79
                        );
80
            
81
            
82
            PluginServices.getIconTheme().registerDefault(
83
                                "buffered-desc",
84
                                this.getClass().getClassLoader().getResource("images/bufferdesc.png")
85
                        );
86

    
87
            PluginServices.getIconTheme().registerDefault(
88
                                "dissolved-desc",
89
                                this.getClass().getClassLoader().getResource("images/dissolvedesc.png")
90
                        );
91

    
92
            PluginServices.getIconTheme().registerDefault(
93
                                "merge-desc",
94
                                this.getClass().getClassLoader().getResource("images/mergedesc.png")
95
                        );
96

    
97
            PluginServices.getIconTheme().registerDefault(
98
                                "intersect-desc",
99
                                this.getClass().getClassLoader().getResource("images/intersectdesc.png")
100
                        );
101

    
102
            PluginServices.getIconTheme().registerDefault(
103
                                "union-desc",
104
                                this.getClass().getClassLoader().getResource("images/uniondesc.png")
105
                        );
106

    
107
            PluginServices.getIconTheme().registerDefault(
108
                                "spatialjoin-desc",
109
                                this.getClass().getClassLoader().getResource("images/spatialjoindesc.png")
110
                        );
111

    
112
            PluginServices.getIconTheme().registerDefault(
113
                                "clip-desc",
114
                                this.getClass().getClassLoader().getResource("images/clipdesc.png")
115
                        );
116

    
117
            PluginServices.getIconTheme().registerDefault(
118
                                "convexhull-desc",
119
                                this.getClass().getClassLoader().getResource("images/convexhulldesc.png")
120
                        );
121
            
122
            PluginServices.getIconTheme().registerDefault(
123
                                "difference-desc",
124
                                this.getClass().getClassLoader().getResource("images/differencedesc.png")
125
                        );
126
            PluginServices.getIconTheme().registerDefault(
127
                                "bufferdesc-resource",
128
                                BufferGeoprocessPlugin.class.getResource("resources/bufferdesc.png")
129
                        );
130
                PluginServices.getIconTheme().registerDefault(
131
                                "clipdesc-resource",
132
                                ClipGeoprocessPlugin.class.getResource("resources/clipdesc.png")
133
                        );
134
                PluginServices.getIconTheme().registerDefault(
135
                                "differencedesc-resource",
136
                                DifferenceGeoprocessPlugin.class.getResource("resources/differencedesc.png")
137
                        ); 
138
                PluginServices.getIconTheme().registerDefault(
139
                                "dissolvedesc-resource",
140
                                DissolveGeoprocessPlugin.class.getResource("resources/dissolvedesc.png")
141
                        );
142
                PluginServices.getIconTheme().registerDefault(
143
                                "intersectdesc-resource",
144
                                IntersectionGeoprocessPlugin.class.getResource("resources/intersectdesc.png")
145
                        );
146
                PluginServices.getIconTheme().registerDefault(
147
                                "mergedesc-resource",
148
                                MergeGeoprocessPlugin.class.getResource("resources/mergedesc.png")
149
                        );
150
                PluginServices.getIconTheme().registerDefault(
151
                                "spatialjoindesc-resource",
152
                                SpatialJoinGeoprocessPlugin.class.getResource("resources/spatialjoindesc.png")
153
                        );
154
                PluginServices.getIconTheme().registerDefault(
155
                                "uniondesc-resource",
156
                                UnionGeoprocessPlugin.class.getResource("resources/uniondesc.png")
157
                        );
158
                
159

    
160
    }
161
    
162
    /* (non-Javadoc)
163
     * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
164
     */
165
    public void execute(String actionCommand) {
166
            AndamiCmd cmd = null;
167
            if(actionCommand.equalsIgnoreCase("GEOPROCESSING")){
168
                    cmd = new GeoProcessingWizardCmd();
169
            }else if(actionCommand.equalsIgnoreCase("BUFFER")){
170
                    cmd = new BufferCmd();
171
            }else if(actionCommand.equalsIgnoreCase("CLIP")){
172
                    cmd = new ClipCmd();
173
            }else if(actionCommand.equalsIgnoreCase("DISSOLVE")){
174
                    cmd = new DissolveCmd();
175
            }else if(actionCommand.equalsIgnoreCase("INTERSECT")){
176
                    cmd = new IntersectionCmd();
177
            }else if(actionCommand.equalsIgnoreCase("DIFFERENCE")){
178
                    cmd = new DifferenceCmd();
179
            }else if(actionCommand.equalsIgnoreCase("UNION")){
180
                    cmd = new UnionCmd();
181
            }else if(actionCommand.equalsIgnoreCase("CONVEXHULL")){
182
                    cmd = new ConvexHullCmd();
183
            }else if(actionCommand.equalsIgnoreCase("MERGE")){
184
                    cmd = new MergeCmd();
185
            }else if(actionCommand.equalsIgnoreCase("SPATIAL_JOIN")){
186
                    cmd = new SpatialJoinCmd();
187
            }
188
            cmd.execute();
189
    }
190

    
191
    public boolean isEnabled() {
192
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
193
                 .getActiveWindow();
194
                if (f == null) {
195
                    return false;
196
                }
197
                if (f instanceof View) {
198
                    View vista = (View) f;
199
                    IProjectView model = vista.getModel();
200
                    FLayers layers =  model.getMapContext().getLayers();
201
                    int numLayers = layers.getLayersCount();
202
                    for(int i = 0; i < numLayers; i++){
203
                            FLayer layer = layers.getLayer(i);
204
                            if(layer instanceof FLyrVect && layer.isAvailable())
205
                                    return true;
206
                    }
207
                }
208
                return false;
209
    }
210

    
211
    public boolean isVisible() {
212
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
213
                 .getActiveWindow();
214
                if (f == null) {
215
                    return false;
216
                }
217
                if (f instanceof View) {
218
                    View vista = (View) f;
219
                    IProjectView model = vista.getModel();
220
                    FLayers layers =  model.getMapContext().getLayers();
221
                    int numLayers = layers.getLayersCount();
222
                    for(int i = 0; i < numLayers; i++){
223
                            FLayer layer = layers.getLayer(i);
224
                            if(layer instanceof FLyrVect)
225
                                    return true;
226
                    }
227
                    return false;
228
                }
229
                return false;
230
    }
231

    
232
}