Statistics
| Revision:

root / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / georeferencing / GeoreferencingModule.java @ 3079

History | View | Annotate | Download (6.9 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 = PluginServices.getMDIManager().getActiveView();
83

    
84
                if (f == null) {
85
                        return false;
86
                }
87

    
88
                return (f.getClass() == View.class);
89
        }
90

    
91
        /**
92
         * El control es visible siempre que haya una vista abierta
93
         */
94
        public boolean isVisible() {
95
                com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
96
                                                                                                                         .getActiveView();
97
                if (f == null) {
98
                        return false;
99
                }
100

    
101
                return (f.getClass() == View.class);
102
        }
103

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

    
149
        /**
150
         * @see com.iver.andami.plugins.Extension#inicializar()
151
         */
152
        public void inicializar() {
153
                AddLayer.addWizard(GeoRasterWizard.class);
154
                FPopupMenu.addEntry(new GeoRasterTocMenuEntry());
155
        }
156
        
157
        
158
        /**
159
         * Cuando cerramos la ventana de georreferenciaci?n se elimina la barra de herramientas
160
         * y se destruye la capa de puntos.
161
         */
162
        public void internalFrameClosing(InternalFrameEvent arg0) {
163
                //Eliminamos la capa de puntos 
164
                View theView = (View) PluginServices.getMDIManager().getActiveView();
165
                FLyrPoints lyrPoints = null;
166
                for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
167
                        FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
168
                        if(lyr instanceof FLyrPoints && lyr.getName().startsWith("*"))
169
                                theView.getMapControl().getMapContext().getLayers().removeLayer(i);
170
                }
171
                //GeoreferencingToolsModule.visible = false;
172
                PluginServices.getMainFrame().enableControls();
173
        }
174
        
175
        /* (non-Javadoc)
176
         * @see javax.swing.event.InternalFrameListener#internalFrameActivated(javax.swing.event.InternalFrameEvent)
177
         */
178
        public void internalFrameActivated(InternalFrameEvent arg0) {
179
                // TODO Auto-generated method stub
180

    
181
        }
182
        /* (non-Javadoc)
183
         * @see javax.swing.event.InternalFrameListener#internalFrameClosed(javax.swing.event.InternalFrameEvent)
184
         */
185
        public void internalFrameClosed(InternalFrameEvent arg0) {
186
                // TODO Auto-generated method stub
187

    
188
        }
189

    
190
        /* (non-Javadoc)
191
         * @see javax.swing.event.InternalFrameListener#internalFrameDeactivated(javax.swing.event.InternalFrameEvent)
192
         */
193
        public void internalFrameDeactivated(InternalFrameEvent arg0) {
194
                // TODO Auto-generated method stub
195

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

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

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

    
217
        }
218
}