Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extRemoteSensing / src / org / gvsig / remotesensing / RemoteSensingModule.java @ 26879

History | View | Annotate | Download (7.4 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2007 Instituto de Desarrollo Regional 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
*   Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
34
*   Campus Universitario s/n
35
*   02071 Alabacete
36
*   Spain
37
*
38
*   +34 967 599 200
39
*/
40
package org.gvsig.remotesensing;
41

    
42
import javax.swing.Icon;
43

    
44
import org.gvsig.fmap.mapcontext.MapContext;
45
import org.gvsig.fmap.mapcontext.layers.FLayer;
46
import org.gvsig.fmap.mapcontext.layers.FLayers;
47
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
48
import org.gvsig.fmap.raster.layers.ILayerState;
49
import org.gvsig.raster.grid.filter.histogramMatching.HistogramMatchingListManager;
50
import org.gvsig.raster.gui.IGenericToolBarMenuItem;
51
import org.gvsig.remotesensing.decisiontrees.gui.DecisionTreeDialog;
52
import org.gvsig.remotesensing.scatterplot.gui.ScatterPlotTocMenuEntry;
53
import org.gvsig.tools.ToolsLocator;
54
import org.gvsig.tools.extensionpoint.ExtensionPoint;
55
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
56

    
57
import com.iver.andami.PluginServices;
58
import com.iver.andami.plugins.Extension;
59
import com.iver.cit.gvsig.project.documents.view.IProjectView;
60
import com.iver.cit.gvsig.project.documents.view.gui.View;
61
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
62

    
63
public class RemoteSensingModule extends Extension implements IGenericToolBarMenuItem {
64

    
65
        /*
66
         * (non-Javadoc)
67
         * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
68
         */
69
        public void execute(String actionCommand) {
70
                if (actionCommand.equals("decision_trees")){
71
                        com.iver.andami.ui.mdiManager.IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow();
72

    
73
                        //si la ventana activa es de tipo Vista
74
                        if (activeWindow instanceof View) {
75
                                DecisionTreeDialog decisionTreeDialog =new DecisionTreeDialog(600,500,(View)activeWindow);
76
                                PluginServices.getMDIManager().addWindow(decisionTreeDialog);
77
                        }
78
                }
79
        }
80

    
81
        /*
82
         * (non-Javadoc)
83
         * @see com.iver.andami.plugins.IExtension#initialize()
84
         */
85
        public void initialize() {
86
                HistogramMatchingListManager.register();
87
                ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager();
88
                ExtensionPoint point=extensionPoints.add("GenericToolBarMenu");
89

    
90
                //A?adimos la entrada del toc de diagramas de dispersion.
91
                point.append("ScatterPlot", "", ScatterPlotTocMenuEntry.getSingleton());
92
                point.append("DecisionTree", "", this.getClass());
93
                point.append("ImageFusion", "", ImageFusionExtension.getSingleton());
94
                point.append("Profile", "", ProfileImageExtension.getSingleton());
95
                point.append("Mosaic", "", MosaicExtension.class);//getSingleton());
96
                point.append("Transformations", "", MultiespectralTransformationsExtension.class);//getSingleton());
97

    
98
                PluginServices.getIconTheme().register(
99
                                "tree-icon",
100
                                this.getClass().getClassLoader().getResource("images/tree.gif")
101
                        );
102

    
103
                PluginServices.getIconTheme().register(
104
                                "fusion-icon",
105
                                this.getClass().getClassLoader().getResource("images/fusion.png")
106
                        );
107

    
108
                PluginServices.getIconTheme().register(
109
                                "scatter-icon",
110
                                this.getClass().getClassLoader().getResource("images/scatterplot.png")
111
                        );
112

    
113
                PluginServices.getIconTheme().register(
114
                                "profile-icon",
115
                                this.getClass().getClassLoader().getResource("images/profile.png")
116
                        );
117

    
118
                PluginServices.getIconTheme().register(
119
                                "mosaic-icon",
120
                                this.getClass().getClassLoader().getResource("images/mosaic.png")
121
                        );
122
                PluginServices.getIconTheme().register(
123
                                "transform-icon",
124
                                this.getClass().getClassLoader().getResource("images/transformationIcon.png")
125
                        );
126
        }
127

    
128
        /*
129
         * (non-Javadoc)
130
         * @see com.iver.andami.plugins.IExtension#isEnabled()
131
         */
132
        public boolean isEnabled() {
133
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
134
                if (f == null) {
135
                        return false;
136
                }
137
                if (f.getClass() == View.class) {
138
                        View vista = (View) f;
139
                        IProjectView model = vista.getModel();
140
                        MapContext mapa = model.getMapContext();
141
                        FLayers layers = mapa.getLayers();
142
                        for (int i = 0; i < layers.getLayersCount(); i++)
143
                                if (layers.getLayer(i) instanceof FLyrRasterSE)
144
                                        return true;
145
                }
146
                return false;
147
        }
148

    
149
        /*
150
         * (non-Javadoc)
151
         * @see com.iver.andami.plugins.IExtension#isVisible()
152
         */
153
        public boolean isVisible() {
154
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
155
                if (f == null) {
156
                        return false;
157
                }
158
                if (f instanceof View) {
159
                        View vista = (View) f;
160
                        IProjectView model = vista.getModel();
161
                        MapContext mapa = model.getMapContext();
162
                        return mapa.getLayers().getLayersCount() > 0;
163
                } else {
164
                        return false;
165
                }
166
        }
167

    
168
        /*
169
         * (non-Javadoc)
170
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroup()
171
         */
172
        public String getGroup() {
173
                return "RasterProcess";
174
        }
175

    
176
        /*
177
         * (non-Javadoc)
178
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getIcon()
179
         */
180
        public Icon getIcon() {
181
                return PluginServices.getIconTheme().get("tree-icon");
182
        }
183

    
184
        /*
185
         * (non-Javadoc)
186
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getOrder()
187
         */
188
        public int getOrder() {
189
                return 0;
190
        }
191

    
192
        /*
193
         * (non-Javadoc)
194
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getText()
195
         */
196
        public String getText() {
197
                return PluginServices.getText(this, "decision_trees");
198
        }
199

    
200
        /*
201
         * (non-Javadoc)
202
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
203
         */
204
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
205
                if ((selectedItems == null) || (selectedItems.length != 1))
206
                        return false;
207

    
208
                if (!(selectedItems[0] instanceof ILayerState))
209
                        return false;
210

    
211
                if (!((ILayerState) selectedItems[0]).isOpen())
212
                        return false;
213

    
214
                return true;
215
        }
216

    
217
        /*
218
         * (non-Javadoc)
219
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
220
         */
221
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
222
                if ((selectedItems == null) || (selectedItems.length != 1))
223
                        return false;
224

    
225
                if (!(selectedItems[0] instanceof FLyrRasterSE))
226
                        return false;
227

    
228
                return true;
229
        }
230

    
231
        /*
232
         * (non-Javadoc)
233
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
234
         */
235
        public void execute(ITocItem item, FLayer[] selectedItems) {
236
                execute("decision_trees");
237
        }
238

    
239
        /*
240
         * (non-Javadoc)
241
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroupOrder()
242
         */
243
        public int getGroupOrder() {
244
                return 0;
245
        }
246
}