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 / filter / FilterTocMenuEntry.java @ 2176

History | View | Annotate | Download (3.41 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
package org.gvsig.raster.tools.app.basic.tool.filter;
23

    
24
import javax.swing.Icon;
25

    
26
import org.gvsig.andami.PluginServices;
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.layers.FLayer;
30
import org.gvsig.raster.fmap.layers.FLyrRaster;
31
import org.gvsig.raster.fmap.layers.ILayerState;
32
import org.gvsig.raster.fmap.layers.IRasterLayerActions;
33
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem;
34
import org.gvsig.raster.tools.app.basic.RasterToolsUtil;
35
import org.gvsig.raster.tools.app.basic.tool.filter.ui.FilterDialog;
36

    
37
/**
38
 * Punto de entrada del menu para los filtros
39
 *
40
 * @version 02/05/2007
41
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
42
 */
43
public class FilterTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem {
44
        static private FilterTocMenuEntry singleton  = null;
45

    
46
        /**
47
         * Nadie puede crear una instancia a esta clase ?nica, hay que usar el
48
         * getSingleton()
49
         */
50
        private FilterTocMenuEntry() {}
51

    
52
        /**
53
         * Devuelve un objeto unico a dicha clase
54
         * @return
55
         */
56
        static public FilterTocMenuEntry getSingleton() {
57
                if (singleton == null)
58
                        singleton = new FilterTocMenuEntry();
59
                return singleton;
60
        }
61
        
62
        public String getGroup() {
63
                return "Enhanced";
64
        }
65

    
66
        public int getGroupOrder() {
67
                return 55;
68
        }
69

    
70
        public int getOrder() {
71
                return 0;
72
        }
73

    
74
        public String getText() {
75
                return RasterToolsUtil.getText(this, "filtros");
76
        }
77

    
78
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
79
                if ((selectedItems == null) || (selectedItems.length != 1))
80
                        return false;
81

    
82
                if (!(selectedItems[0] instanceof ILayerState))
83
                        return false;
84

    
85
                if (!((ILayerState) selectedItems[0]).isOpen())
86
                        return false;
87

    
88
                return true;
89
        }
90

    
91
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
92
                if ((selectedItems == null) || (selectedItems.length != 1))
93
                        return false;
94

    
95
                if (!(selectedItems[0] instanceof IRasterLayerActions))
96
                        return false;
97
                
98
                return ((IRasterLayerActions) selectedItems[0]).isActionEnabled(IRasterLayerActions.FILTER);
99
        }
100

    
101
        public void execute(ITocItem item, FLayer[] selectedItems) {
102
                if ((selectedItems == null) || (selectedItems.length != 1) || (!(selectedItems[0] instanceof FLyrRaster)))
103
                        return;
104

    
105
                FilterDialog rasterFilterDialog = new FilterDialog((FLyrRaster) selectedItems[0], 740, 400);
106
                PluginServices.getMDIManager().addCentredWindow(rasterFilterDialog);
107
        }
108
        
109
        public Icon getIcon() {
110
                return RasterToolsUtil.getIcon("layer-filter-raster");
111
        }
112
        
113
}