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 @ 2595

History | View | Annotate | Download (3.61 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.i18n.Messages;
33
import org.gvsig.raster.fmap.layers.FLyrRaster;
34
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem;
35
import org.gvsig.raster.tools.app.basic.RasterToolsUtil;
36

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

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

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

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

    
84
        public String getText() {
85
                return Messages.getText("infobypoint");
86
        }
87

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

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

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