Statistics
| Revision:

root / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / GridCalculatorExtension.java @ 18830

History | View | Annotate | Download (5.48 KB)

1
/* gvSIG. Sistema de Informacin Geogrfica 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.fmap.raster.layers.FLyrRasterSE;
45
import org.gvsig.raster.gui.IGenericToolBarMenuItem;
46
import org.gvsig.remotesensing.gridmath.gui.GridMathDialog;
47

    
48
import com.iver.andami.PluginServices;
49
import com.iver.andami.plugins.Extension;
50
import com.iver.cit.gvsig.fmap.MapContext;
51
import com.iver.cit.gvsig.fmap.layers.FLayer;
52
import com.iver.cit.gvsig.fmap.layers.FLayers;
53
import com.iver.cit.gvsig.project.documents.view.IProjectView;
54
import com.iver.cit.gvsig.project.documents.view.gui.View;
55
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
56
import com.iver.utiles.extensionPoints.ExtensionPoints;
57
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
58
/**
59
 * Extensi?n para el C?lculo de Raster (Band Math)
60
 * 
61
 * @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)
62
 */
63
public class GridCalculatorExtension extends Extension implements IGenericToolBarMenuItem {
64

    
65
        /*
66
         * (non-Javadoc)
67
         * @see com.iver.andami.plugins.IExtension#initialize()
68
         */
69
        public void initialize() {
70
                ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
71
                extensionPoints.add("GenericToolBarMenu", "GridCalculator", this);
72
        }
73

    
74
        /*
75
         * (non-Javadoc)
76
         * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
77
         */
78
        public void execute(String actionCommand) {
79
                if (actionCommand.equals("band_math")) {
80
                        com.iver.andami.ui.mdiManager.IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow();
81

    
82
                        // si la ventana activa es de tipo Vista
83
                        if (activeWindow instanceof View) {
84
                                GridMathDialog calculatorDialog = new GridMathDialog((View) activeWindow);
85
                                // Mostrar la calculadora.
86
                                PluginServices.getMDIManager().addWindow(calculatorDialog);
87
                        }
88
                }
89
        }
90

    
91
        /*
92
         * (non-Javadoc)
93
         * @see com.iver.andami.plugins.IExtension#isEnabled()
94
         */
95
        public boolean isEnabled() {
96
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
97
                if (f == null) {
98
                        return false;
99
                }
100
                if (f.getClass() == View.class) {
101
                        View vista = (View) f;
102
                        IProjectView model = vista.getModel();
103
                        MapContext mapa = model.getMapContext();
104
                        FLayers layers = mapa.getLayers();
105
                        for (int i = 0; i < layers.getLayersCount(); i++)
106
                                if (layers.getLayer(i) instanceof FLyrRasterSE)
107
                                        return true;
108
                }
109
                return false;
110
        }
111

    
112
        /*
113
         * (non-Javadoc)
114
         * @see com.iver.andami.plugins.IExtension#isVisible()
115
         */
116
        public boolean isVisible() {
117
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
118
                if (f == null) {
119
                        return false;
120
                }
121
                if (f instanceof View) {
122
                        View vista = (View) f;
123
                        IProjectView model = vista.getModel();
124
                        MapContext mapa = model.getMapContext();
125
                        return mapa.getLayers().getLayersCount() > 0;
126
                } else {
127
                        return false;
128
                }
129
        }
130

    
131
        /*
132
         * (non-Javadoc)
133
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
134
         */
135
        public void execute(ITocItem item, FLayer[] selectedItems) {
136
                this.execute("band_math");
137
        }
138

    
139
        /*
140
         * (non-Javadoc)
141
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroup()
142
         */
143
        public String getGroup() {
144
                return "RasterProcess";
145
        }
146

    
147
        /*
148
         * (non-Javadoc)
149
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getIcon()
150
         */
151
        public Icon getIcon() {
152
                return PluginServices.getIconTheme().get("blank-icon");
153
        }
154

    
155
        /*
156
         * (non-Javadoc)
157
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getOrder()
158
         */
159
        public int getOrder() {
160
                return 0;
161
        }
162

    
163
        /*
164
         * (non-Javadoc)
165
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getText()
166
         */
167
        public String getText() {
168
                return PluginServices.getText(this, "band_math");
169
        }
170

    
171
        /*
172
         * (non-Javadoc)
173
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
174
         */
175
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
176
                return this.isEnabled();
177
        }
178

    
179
        /*
180
         * (non-Javadoc)
181
         * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
182
         */
183
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
184
                return this.isVisible();
185
        }
186
}