Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extRemoteSensing / src / org / gvsig / remotesensing / MultiespectralTransformationsExtension.java @ 31496

History | View | Annotate | Download (6.46 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 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 Ibez, 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.andami.PluginServices;
45
import org.gvsig.andami.plugins.Extension;
46
import org.gvsig.app.project.documents.view.ViewDocument;
47
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
48
import org.gvsig.app.project.documents.view.toc.ITocItem;
49
import org.gvsig.fmap.mapcontext.MapContext;
50
import org.gvsig.fmap.mapcontext.layers.FLayer;
51
import org.gvsig.fmap.mapcontext.layers.FLayers;
52
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
53
import org.gvsig.fmap.raster.layers.ILayerState;
54
import org.gvsig.raster.gui.IGenericToolBarMenuItem;
55
import org.gvsig.remotesensing.tasseledcap.TransformationPanel;
56
import org.gvsig.tools.ToolsLocator;
57
import org.gvsig.tools.extensionpoint.ExtensionPoint;
58
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
59

    
60
/**
61
 * Extensi?n para el c?lculo de  transformaciones multiespectrales.
62
 *
63
 * @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)
64
 */
65
public class MultiespectralTransformationsExtension extends Extension implements IGenericToolBarMenuItem {
66

    
67
        static private MultiespectralTransformationsExtension singleton  = null;
68

    
69

    
70
        static public MultiespectralTransformationsExtension getSingleton() {
71
                if (singleton == null)
72
                        singleton = new MultiespectralTransformationsExtension();
73
                return singleton;
74
        }
75

    
76
        /*
77
         * (non-Javadoc)
78
         * @see com.iver.andami.plugins.IExtension#initialize()
79
         */
80
        public void initialize() {
81
                ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager();
82
                ExtensionPoint point=extensionPoints.add("GenericToolBarMenu");
83
                point.append("Transformations", "", this.getClass());
84
        }
85

    
86
        /*
87
         * (non-Javadoc)
88
         * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
89
         */
90
        public void execute(String actionCommand) {
91
                if (actionCommand.equals("transformations")) {
92
                        org.gvsig.andami.ui.mdiManager.IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow();
93

    
94
                        // si la ventana activa es de tipo Vista
95
                        if (activeWindow instanceof DefaultViewPanel) {
96
                                TransformationPanel pcPanel = new TransformationPanel ((DefaultViewPanel)activeWindow);
97
                                PluginServices.getMDIManager().addWindow(pcPanel);
98
                        }
99
                }
100
        }
101

    
102
        /*
103
         * (non-Javadoc)
104
         * @see com.iver.andami.plugins.IExtension#isEnabled()
105
         */
106
        public boolean isEnabled() {
107
                org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
108
                if (f == null) {
109
                        return false;
110
                }
111
                if (f.getClass() == DefaultViewPanel.class) {
112
                        DefaultViewPanel vista = (DefaultViewPanel) f;
113
                        ViewDocument model = vista.getModel();
114
                        MapContext mapa = model.getMapContext();
115
                        FLayers layers = mapa.getLayers();
116
                        for (int i = 0; i < layers.getLayersCount(); i++)
117
                                if (layers.getLayer(i) instanceof FLyrRasterSE)
118
                                        return true;
119
                }
120
                return false;
121
        }
122

    
123
        /*
124
         * (non-Javadoc)
125
         * @see com.iver.andami.plugins.IExtension#isVisible()
126
         */
127
        public boolean isVisible() {
128
                org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
129
                if (f == null) {
130
                        return false;
131
                }
132
                if (f instanceof DefaultViewPanel) {
133
                        DefaultViewPanel vista = (DefaultViewPanel) f;
134
                        ViewDocument model = vista.getModel();
135
                        MapContext mapa = model.getMapContext();
136
                        return mapa.getLayers().getLayersCount() > 0;
137
                } else {
138
                        return false;
139
                }
140
        }
141

    
142
        /*
143
         * (non-Javadoc)
144
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
145
         */
146
        public void execute(ITocItem item, FLayer[] selectedItems) {
147
                this.execute("transformations");
148
        }
149

    
150
        /*
151
         * (non-Javadoc)
152
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroup()
153
         */
154
        public String getGroup() {
155
                return "RasterProcess";
156
        }
157

    
158
        /*
159
         * (non-Javadoc)
160
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getIcon()
161
         */
162
        public Icon getIcon() {
163
                return PluginServices.getIconTheme().get("transform-icon");
164
        }
165

    
166
        /*
167
         * (non-Javadoc)
168
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getOrder()
169
         */
170
        public int getOrder() {
171
                return 0;
172
        }
173

    
174
        /*
175
         * (non-Javadoc)
176
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getText()
177
         */
178
        public String getText() {
179
                return PluginServices.getText(this, "transformations");
180
        }
181

    
182
        /*
183
         * (non-Javadoc)
184
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
185
         */
186
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
187
                if ((selectedItems == null) || (selectedItems.length != 1))
188
                        return false;
189

    
190
                if (!(selectedItems[0] instanceof ILayerState))
191
                        return false;
192

    
193
                if (!((ILayerState) selectedItems[0]).isOpen())
194
                        return false;
195

    
196
                return true;
197
        }
198

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

    
207
                if (!(selectedItems[0] instanceof FLyrRasterSE))
208
                        return false;
209

    
210
                return true;
211
        }
212

    
213
        /*
214
         * (non-Javadoc)
215
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroupOrder()
216
         */
217
        public int getGroupOrder() {
218
                return 0;
219
        }
220
}