Statistics
| Revision:

root / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / ClassificationExtension.java @ 13790

History | View | Annotate | Download (1.93 KB)

1
package org.gvsig.remotesensing;
2

    
3
import org.gvsig.remotesensing.classification.gui.ClassificationPanel;
4

    
5
import com.iver.andami.PluginServices;
6
import com.iver.andami.plugins.Extension;
7
import com.iver.cit.gvsig.fmap.MapContext;
8
import com.iver.cit.gvsig.fmap.layers.FLayer;
9
import com.iver.cit.gvsig.project.documents.view.IProjectView;
10
import com.iver.cit.gvsig.project.documents.view.gui.View;
11

    
12

    
13
/**
14
 * Extensi?n para el proceso de classificacion de una imagen
15
 * 
16
 * @author Alejandro Mu?oz S?nchez (alejandro.munoz@uclm.es)
17
 *
18
 */
19

    
20
public class ClassificationExtension extends Extension{
21

    
22
public void initialize() {
23
                
24
        }
25

    
26
        public void execute(String actionCommand) {
27
                if (actionCommand.equals("classification")){
28
                        com.iver.andami.ui.mdiManager.IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow();
29

    
30
                        //si la ventana activa es de tipo Vista 
31
                        if (activeWindow instanceof View) {
32
                                ClassificationPanel clasificationDialog =new ClassificationPanel((View)activeWindow);
33
                                //Mostrar la calculadora.
34
                                PluginServices.getMDIManager().addWindow(clasificationDialog);
35
                        }
36
                }
37
        }
38

    
39
        public boolean isEnabled() {
40
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
41
                if (f == null) {
42
                        return false;
43
                }
44
                if (f.getClass() == View.class) {
45
                        View vista = (View) f;
46
                        IProjectView model = vista.getModel();
47
                        MapContext mapa = model.getMapContext();
48
                        FLayer[] layers =mapa.getLayers().getActives();
49
                        for (int i=0;i<layers.length;i++) {
50
                                if (layers[i].isAvailable()) return true;
51
                        }
52
                }
53
                return true;
54
        }
55

    
56
        public boolean isVisible() {
57
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
58
                if (f == null) {
59
                        return false;
60
                }
61
                if (f instanceof View) {
62
                        View vista = (View) f;
63
                        IProjectView model = vista.getModel();
64
                        MapContext mapa = model.getMapContext();
65
                        return mapa.getLayers().getLayersCount() > 0;
66
                } else {
67
                        return false;
68
                }
69
        }
70
        
71
}