Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / EnhancedTocMenuEntry.java @ 22827

History | View | Annotate | Download (4.94 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.enhanced;
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.IProcessActions;
27
import org.gvsig.raster.gui.IGenericToolBarMenuItem;
28
import org.gvsig.raster.util.RasterToolsUtil;
29
import org.gvsig.rastertools.enhanced.ui.EnhancedDialog;
30
import org.gvsig.rastertools.statistics.StatisticsProcess;
31

    
32
import com.iver.cit.gvsig.fmap.layers.FLayer;
33
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
34
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
35

    
36
/**
37
 * Punto de entrada para la funcionalidad de realce por expansi?n del contraste
38
 * 19/02/2008
39
 * @author Nacho Brodin nachobrodin@gmail.com
40
 */
41
public class EnhancedTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem, IProcessActions {
42
        static private EnhancedTocMenuEntry   singleton   = null;
43
        private FLyrRasterSE                  lyr         = null;
44

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

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

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

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

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

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

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

    
104
                if (!((ILayerState) selectedItems[0]).isOpen())
105
                        return false;
106

    
107
                return true;
108
        }
109

    
110
        /*
111
         * (non-Javadoc)
112
         * @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[])
113
         */
114
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
115
                if ((selectedItems == null) || (selectedItems.length != 1))
116
                        return false;
117

    
118
                if (!(selectedItems[0] instanceof FLyrRasterSE))
119
                        return false;
120
                
121
                return ((FLyrRasterSE) selectedItems[0]).isActionEnabled(IRasterLayerActions.ENHANCED);
122
        }
123

    
124
        /*
125
         * (non-Javadoc)
126
         * @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[])
127
         */
128
        public void execute(ITocItem item, FLayer[] selectedItems) {
129
                if ((selectedItems == null) || (selectedItems.length != 1) || (!(selectedItems[0] instanceof FLyrRasterSE)))
130
                        return;
131
                                
132
                this.lyr = (FLyrRasterSE)selectedItems[0];
133
                if(!lyr.getDataSource().getStatistics().isCalculated()) 
134
                        StatisticsProcess.launcher(lyr, this);
135
                else
136
                        end(null);
137
        }
138
        
139
        /*
140
         * (non-Javadoc)
141
         * @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getIcon()
142
         */
143
        public Icon getIcon() {
144
                return RasterToolsUtil.getIcon("brush-icon");
145
        }
146

    
147
        /**
148
         * Lanzamos la ventana al final del proceso de calculo de estad?sticas.
149
         */
150
        public void end(Object param) {
151
                EnhancedDialog enhancedDialog = new EnhancedDialog(lyr, 760, 421);
152
                RasterToolsUtil.addWindow(enhancedDialog);
153
        }
154

    
155
        public void interrupted() {
156
        }
157
}