Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / georeferencing / GeoreferencingModule.java @ 3102

History | View | Annotate | Download (7.1 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 javax.swing.JDesktopPane;
50
import javax.swing.JInternalFrame;
51
import javax.swing.JLayeredPane;
52
import javax.swing.event.InternalFrameEvent;
53
import javax.swing.event.InternalFrameListener;
54

    
55
import com.iver.andami.PluginServices;
56
import com.iver.andami.plugins.Extension;
57
import com.iver.andami.ui.mdiFrame.MDIFrame;
58
import com.iver.cit.gvsig.AddLayer;
59
import com.iver.cit.gvsig.fmap.MapControl;
60
import com.iver.cit.gvsig.fmap.layers.FLayer;
61
import com.iver.cit.gvsig.fmap.layers.FLyrPoints;
62
import com.iver.cit.gvsig.gui.View;
63
import com.iver.cit.gvsig.gui.Dialogs.GeoreferencingDialog;
64
import com.iver.cit.gvsig.gui.Panels.GeoRasterWizard;
65
import com.iver.cit.gvsig.gui.toc.FPopupMenu;
66
import com.iver.cit.gvsig.gui.toc.GeoRasterTocMenuEntry;
67

    
68

    
69
/**
70
 * Extensi?n que carga el modulo de georeferenciaci?n
71
 *
72
 * @author Nacho Brodin (brodin_ign@gva.es)
73
 */
74
public class GeoreferencingModule implements Extension, InternalFrameListener {
75
        
76
        private GeoreferencingDialog geoDialog = null;
77
                        
78
        /**
79
         * El control est? activo siempre que haya una vista abierta
80
         */
81
        public boolean isEnabled() {
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
                return (f.getClass() == View.class);
94
        }
95

    
96
        /**
97
         * El control es visible siempre que haya una vista abierta
98
         */
99
        public boolean isVisible() {
100
                com.iver.andami.ui.mdiManager.View f = null;
101
                try{
102
                        f = PluginServices.getMDIManager().getActiveView();
103
                }catch(ClassCastException exc){
104
                        return false;
105
                }
106
                
107
                if (f == null) {
108
                        return false;
109
                }
110

    
111
                return (f.getClass() == View.class);
112
        }
113

    
114
        /**
115
         * Cuando ejecutamos el control de georeferenciaci?n se activan las heramientas
116
         * de georeferenciaci?n y se carga el wizard.
117
         */
118
        public void execute(String s) {
119
                //GeoreferencingToolsModule.visible = true;
120
                PluginServices.getMainFrame().enableControls();
121
                View vista = null;
122
                try{
123
                        vista = (View) PluginServices.getMDIManager().getActiveView();
124
                }catch(ClassCastException exc){
125
                        return;
126
                }
127
                MapControl mapCtrl = vista.getMapControl();
128
                
129
                JInternalFrame panel = new JInternalFrame();
130
                panel.addInternalFrameListener(this);
131
        panel.setClosable(true);
132
        geoDialog = new GeoreferencingDialog(panel);
133
        if(geoDialog.isEnlarge()){
134
                panel.setSize(geoDialog.getWidth(), 417);
135
                panel.setPreferredSize(new java.awt.Dimension(geoDialog.getWidth(), 417));
136
        }else{
137
                panel.setSize(geoDialog.getWidth(), 250);
138
                panel.setPreferredSize(new java.awt.Dimension(geoDialog.getWidth(), 250));
139
        }
140
        //panel.setSize(geoDialog.getWidth(), geoDialog.getHeight() + 25);
141
        panel.setTitle(PluginServices.getText(this,"georreferenciar"));
142
        panel.getContentPane().add(geoDialog);
143
       
144
        MDIFrame mainFrame = (MDIFrame) PluginServices.getMainFrame();
145
        JLayeredPane lyrPane = mainFrame.getLayeredPane();
146
        lyrPane.add(panel, JDesktopPane.PALETTE_LAYER);      
147
        panel.pack();
148
        panel.show();
149
        
150
                /*if (PluginServices.getMainFrame() == null){
151
                        JDialog dialog = new JDialog();
152
                        geoDialog.setPreferredSize(geoDialog.getSize());
153
                        dialog.getContentPane().add(geoDialog);
154
                        dialog.setModal(false);                        
155
                        dialog.pack();
156
                        dialog.show();
157
                        
158
                }else{
159
                
160
                        geoDialog = (GeoreferencingDialog) PluginServices.getMDIManager().addView(geoDialog);
161
                }*/
162
        }
163

    
164
        /**
165
         * @see com.iver.andami.plugins.Extension#inicializar()
166
         */
167
        public void inicializar() {
168
                AddLayer.addWizard(GeoRasterWizard.class);
169
                FPopupMenu.addEntry(new GeoRasterTocMenuEntry());
170
        }
171
        
172
        
173
        /**
174
         * Cuando cerramos la ventana de georreferenciaci?n se elimina la barra de herramientas
175
         * y se destruye la capa de puntos.
176
         */
177
        public void internalFrameClosing(InternalFrameEvent arg0) {
178
                //Eliminamos la capa de puntos 
179
                View theView = (View) PluginServices.getMDIManager().getActiveView();
180
                FLyrPoints lyrPoints = null;
181
                for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
182
                        FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
183
                        if(lyr instanceof FLyrPoints && lyr.getName().startsWith("*"))
184
                                theView.getMapControl().getMapContext().getLayers().removeLayer(i);
185
                }
186
                //GeoreferencingToolsModule.visible = false;
187
                PluginServices.getMainFrame().enableControls();
188
        }
189
        
190
        /* (non-Javadoc)
191
         * @see javax.swing.event.InternalFrameListener#internalFrameActivated(javax.swing.event.InternalFrameEvent)
192
         */
193
        public void internalFrameActivated(InternalFrameEvent arg0) {
194
                // TODO Auto-generated method stub
195

    
196
        }
197
        /* (non-Javadoc)
198
         * @see javax.swing.event.InternalFrameListener#internalFrameClosed(javax.swing.event.InternalFrameEvent)
199
         */
200
        public void internalFrameClosed(InternalFrameEvent arg0) {
201
                // TODO Auto-generated method stub
202

    
203
        }
204

    
205
        /* (non-Javadoc)
206
         * @see javax.swing.event.InternalFrameListener#internalFrameDeactivated(javax.swing.event.InternalFrameEvent)
207
         */
208
        public void internalFrameDeactivated(InternalFrameEvent arg0) {
209
                // TODO Auto-generated method stub
210

    
211
        }
212
        /* (non-Javadoc)
213
         * @see javax.swing.event.InternalFrameListener#internalFrameDeiconified(javax.swing.event.InternalFrameEvent)
214
         */
215
        public void internalFrameDeiconified(InternalFrameEvent arg0) {
216
                // TODO Auto-generated method stub
217

    
218
        }
219
        /* (non-Javadoc)
220
         * @see javax.swing.event.InternalFrameListener#internalFrameIconified(javax.swing.event.InternalFrameEvent)
221
         */
222
        public void internalFrameIconified(InternalFrameEvent arg0) {
223
                // TODO Auto-generated method stub
224

    
225
        }
226
        /* (non-Javadoc)
227
         * @see javax.swing.event.InternalFrameListener#internalFrameOpened(javax.swing.event.InternalFrameEvent)
228
         */
229
        public void internalFrameOpened(InternalFrameEvent arg0) {
230
                // TODO Auto-generated method stub
231

    
232
        }
233
}