Statistics
| Revision:

gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / infobypoint / InfoByRasterPointTocMenuEntry.java @ 2480

History | View | Annotate | Download (3.59 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. 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
package org.gvsig.raster.tools.app.basic.tool.infobypoint;
20

    
21
import javax.swing.Icon;
22

    
23
import org.gvsig.andami.PluginServices;
24
import org.gvsig.andami.plugins.Extension;
25
import org.gvsig.app.project.documents.view.ViewDocument;
26
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
27
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction;
28
import org.gvsig.app.project.documents.view.toc.ITocItem;
29
import org.gvsig.fmap.mapcontext.MapContext;
30
import org.gvsig.fmap.mapcontext.layers.FLayer;
31
import org.gvsig.fmap.mapcontext.layers.FLayers;
32
import org.gvsig.raster.fmap.layers.FLyrRaster;
33
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem;
34
import org.gvsig.raster.tools.app.basic.RasterToolsUtil;
35

    
36
/**
37
 * Entry point to the InfoByRasterPoint tool
38
 * @author Nacho Brodin (nachobrodin@gmail.com)
39
 */
40
public class InfoByRasterPointTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem {
41
        static private InfoByRasterPointTocMenuEntry singleton  = null;
42
        private Extension                            extension  = null;
43
        
44
        /**
45
         * Nadie puede crear una instancia a esta clase ?nica, hay que usar el
46
         * getSingleton()
47
         */
48
        private InfoByRasterPointTocMenuEntry() {
49
                extension = new InfoByRasterPointExtension();
50
                extension.initialize();
51
        }
52
        
53
        /**
54
         * Assigns the extension to be executed
55
         * @param ext
56
         */
57
        public void setExtension(Extension ext) {
58
                this.extension = ext;
59
        }
60

    
61
        /**
62
         * Devuelve un objeto unico a dicha clase
63
         * @return
64
         */
65
        static public InfoByRasterPointTocMenuEntry getSingleton() {
66
                if (singleton == null)
67
                        singleton = new InfoByRasterPointTocMenuEntry();
68
                return singleton;
69
        }
70
        
71
        public String getGroup() {
72
                return "RasterLayer";
73
        }
74

    
75
        public int getGroupOrder() {
76
                return 10;
77
        }
78

    
79
        public int getOrder() {
80
                return 50;
81
        }
82

    
83
        public String getText() {
84
                return RasterToolsUtil.getText(this, "infobypoint");
85
        }
86

    
87
        @SuppressWarnings("deprecation")
88
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
89
                org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
90
                if (f == null)
91
                        return false;
92
                if (f instanceof AbstractViewPanel) {
93
                        AbstractViewPanel vista = (AbstractViewPanel) f;
94
                        ViewDocument model = vista.getModel();
95
                        MapContext mapa = model.getMapContext();
96
                        FLayers layers = mapa.getLayers();
97
                        for (int i = 0; i < layers.getLayersCount(); i++)
98
                                if (layers.getLayer(i) instanceof FLyrRaster && layers.getLayer(i).isActive())
99
                                        return true;
100
                }
101
                return false;
102
        }
103

    
104
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
105
                return true;
106
        }
107

    
108
        public void execute(ITocItem item, FLayer[] selectedItems) {
109
                extension.execute("INFO_BY_PIXEL");
110
        }
111
        
112
        public Icon getIcon() {
113
                return RasterToolsUtil.getIcon("layer-info-by-pixel");
114
        }
115
        
116
}