Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / clipping / ClippingTocMenuEntry.java @ 20646

History | View | Annotate | Download (4.69 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.rastertools.clipping;
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.clipping.ui.ClippingDialog;
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
 * <code>ClippingTocMenuEntry</code> es el punto de entrada del menu del
35
 * recorte.
36
 *
37
 * @version 17/04/2007
38
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
39
 */
40
public class ClippingTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem {
41
        static private ClippingTocMenuEntry singleton = null;
42

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

    
49
        /**
50
         * Devuelve un objeto unico a dicha clase
51
         * @return
52
         */
53
        static public ClippingTocMenuEntry getSingleton() {
54
                if (singleton == null)
55
                        singleton = new ClippingTocMenuEntry();
56
                return singleton;
57
        }
58

    
59
        /*
60
         * (non-Javadoc)
61
         * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroup()
62
         */
63
        public String getGroup() {
64
                return "RasterExport";
65
        }
66

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

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

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

    
91
        /*
92
         * (non-Javadoc)
93
         * @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[])
94
         */
95
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
96
                if ((selectedItems == null) || (selectedItems.length != 1))
97
                        return false;
98

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

    
102
                if (!((ILayerState) selectedItems[0]).isOpen())
103
                        return false;
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
                FLayer fLayer = null;
127

    
128
                if (selectedItems.length != 1)
129
                        return;
130

    
131
                fLayer = selectedItems[0];
132

    
133
                if (!(fLayer instanceof FLyrRasterSE))
134
                        return;
135

    
136
                ClippingDialog clippingDialog = new ClippingDialog(420, 290);
137
                clippingDialog.setLayer((FLyrRasterSE)fLayer);
138
                RasterToolsUtil.addWindow(clippingDialog);
139
        }
140

    
141
        /*
142
         * (non-Javadoc)
143
         * @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getIcon()
144
         */
145
        public Icon getIcon() {
146
                return RasterToolsUtil.getIcon("clipping-icon");
147
        }
148
}