Statistics
| Revision:

root / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / georeferencing / GeoreferencingToolsModule.java @ 3195

History | View | Annotate | Download (4.18 KB)

1
/*
2
 * Created on 02-mar-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package com.iver.cit.gvsig.georeferencing;
48

    
49
import java.util.logging.Logger;
50

    
51
import com.iver.andami.PluginServices;
52
import com.iver.andami.plugins.Extension;
53
import com.iver.cit.gvsig.LayoutControls;
54
import com.iver.cit.gvsig.fmap.MapControl;
55
import com.iver.cit.gvsig.fmap.layers.FLayer;
56
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster;
57
import com.iver.cit.gvsig.gui.View;
58
import com.iver.cit.gvsig.gui.layout.Layout;
59

    
60

    
61
/**
62
 * Extensi?n que carga el modulo de georeferenciaci?n
63
 *
64
 * @author Nacho Brodin (brodin_ign@gva.es)
65
 */
66
public class GeoreferencingToolsModule implements Extension {
67
        private static Logger logger = Logger.getLogger(LayoutControls.class.getName());
68
        //public static boolean visible = false;
69
        private Layout layout = null;
70
                        
71
        /**
72
         * El control est? activo siempre que haya una vista abierta
73
         */
74
        public boolean isEnabled() {
75
                return true;
76
        }
77

    
78
        /**
79
         * El control es visible siempre que haya una vista abierta
80
         */
81
        public boolean isVisible() {
82
                com.iver.andami.ui.mdiManager.View f = null;
83
                try{
84
                        f = PluginServices.getMDIManager().getActiveView();
85
                }catch(ClassCastException exc){
86
                        return false;
87
                }
88
                                
89
                if (f == null) {
90
                        return false;
91
                }
92
                
93
                try{
94
                        for(int i=0;i<((View)f).getMapControl().getMapContext().getLayers().getLayersCount();i++){
95
                                FLayer lyr = ((View)f).getMapControl().getMapContext().getLayers().getLayer(i);
96
                                if(        lyr instanceof FLyrGeoRaster &&
97
                                        lyr.getName().startsWith("*") &&
98
                                        lyr.isActive())
99
                                        return true;
100
                        }
101
                }catch(ClassCastException ex){
102
                        return false;
103
                }
104
                
105
                return false;
106
        }
107

    
108
        /**
109
         * Cuando ejecutamos alguna herramienta de georeferenciaci?n seleccionamos
110
         * la que ha sido activada.
111
         */
112
        public void execute(String s) {
113
                View theView = null;
114
                try{
115
                        theView = (View) PluginServices.getMDIManager().getActiveView();
116
                }catch(ClassCastException exc){
117
                        return;
118
                }
119
                MapControl mapCtrl = theView.getMapControl();
120
                
121
                if (s.compareTo("GEO_PAN") == 0) {
122
                        mapCtrl.setTool("geoPan");
123
                } else if (s.compareTo("GEO_ZOOM") == 0) {
124
                        mapCtrl.setTool("geoZoom");
125
                } else if (s.compareTo("GEO_ZOOM_PREV") == 0) {
126
                        System.out.println(PluginServices.getMDIManager().getActiveView().getViewInfo());
127
                        FLyrGeoRaster lyrGeoRaster = null;
128
                        
129
                        //Obtenemos la capa
130
                        for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
131
                                FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
132
                                if(lyr instanceof FLyrGeoRaster && lyr.getName().startsWith("*"))
133
                                        lyrGeoRaster = (FLyrGeoRaster)lyr;
134
                        }
135
                        
136
                        //Asignamos el ?ltimo extent
137
                        if(lyrGeoRaster != null){
138
                                lyrGeoRaster.setLastExtent();
139
                                mapCtrl.getMapContext().invalidate();
140
                        }
141
                } else if (s.compareTo("GEO_MOVE_POINT") == 0) 
142
                        mapCtrl.setTool("geoMovePoint");
143
        }
144

    
145
        /**
146
         * @see com.iver.andami.plugins.Extension#inicializar()
147
         */
148
        public void inicializar() {
149
                
150
        }
151
}