Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / filter / FilterTocMenuEntry.java @ 20646

History | View | Annotate | Download (4.44 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 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.rastertools.filter;
20

    
21
import javax.swing.Icon;
22

    
23
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
24
import org.gvsig.fmap.raster.layers.ILayerState;
25
import org.gvsig.fmap.raster.layers.IRasterLayerActions;
26
import org.gvsig.raster.gui.IGenericToolBarMenuItem;
27
import org.gvsig.raster.util.RasterToolsUtil;
28
import org.gvsig.rastertools.filter.ui.FilterDialog;
29

    
30
import com.iver.cit.gvsig.fmap.layers.FLayer;
31
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
32
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
33
/**
34
 * Punto de entrada del menu para los filtros
35
 *
36
 * @version 02/05/2007
37
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
38
 */
39
public class FilterTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem {
40
        static private FilterTocMenuEntry singleton  = null;
41

    
42
        /**
43
         * Nadie puede crear una instancia a esta clase ?nica, hay que usar el
44
         * getSingleton()
45
         */
46
        private FilterTocMenuEntry() {}
47

    
48
        /**
49
         * Devuelve un objeto unico a dicha clase
50
         * @return
51
         */
52
        static public FilterTocMenuEntry getSingleton() {
53
                if (singleton == null)
54
                        singleton = new FilterTocMenuEntry();
55
                return singleton;
56
        }
57
        
58
        /*
59
         * (non-Javadoc)
60
         * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroup()
61
         */
62
        public String getGroup() {
63
                return "RasterProcess";
64
        }
65

    
66
        /*
67
         * (non-Javadoc)
68
         * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroupOrder()
69
         */
70
        public int getGroupOrder() {
71
                return 55;
72
        }
73

    
74
        /*
75
         * (non-Javadoc)
76
         * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getOrder()
77
         */
78
        public int getOrder() {
79
                return 0;
80
        }
81

    
82
        /*
83
         * (non-Javadoc)
84
         * @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getText()
85
         */
86
        public String getText() {
87
                return RasterToolsUtil.getText(this, "filtros");
88
        }
89

    
90
        /*
91
         * (non-Javadoc)
92
         * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
93
         */
94
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
95
                if ((selectedItems == null) || (selectedItems.length != 1))
96
                        return false;
97

    
98
                if (!(selectedItems[0] instanceof ILayerState))
99
                        return false;
100

    
101
                if (!((ILayerState) selectedItems[0]).isOpen())
102
                        return false;
103

    
104
                return true;
105
        }
106

    
107
        /*
108
         * (non-Javadoc)
109
         * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
110
         */
111
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
112
                if ((selectedItems == null) || (selectedItems.length != 1))
113
                        return false;
114

    
115
                if (!(selectedItems[0] instanceof FLyrRasterSE))
116
                        return false;
117
                
118
                return ((FLyrRasterSE) selectedItems[0]).isActionEnabled(IRasterLayerActions.FILTER);
119
        }
120

    
121
        /*
122
         * (non-Javadoc)
123
         * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
124
         */
125
        public void execute(ITocItem item, FLayer[] selectedItems) {
126
                if ((selectedItems == null) || (selectedItems.length != 1) || (!(selectedItems[0] instanceof FLyrRasterSE)))
127
                        return;
128

    
129
                FilterDialog rasterFilterDialog = new FilterDialog(selectedItems[0], 720, 400);
130
                RasterToolsUtil.addWindow(rasterFilterDialog);
131
        }
132
        
133
        /*
134
         * (non-Javadoc)
135
         * @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getIcon()
136
         */
137
        public Icon getIcon() {
138
                return RasterToolsUtil.getIcon("filter-icon");
139
        }
140
}