root / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / georeferencing / GeoreferencingModule.java @ 2972
History | View | Annotate | Download (6.27 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.awt.event.WindowEvent; |
50 |
|
51 |
import javax.swing.JDesktopPane; |
52 |
import javax.swing.JInternalFrame; |
53 |
import javax.swing.JLayeredPane; |
54 |
import javax.swing.event.InternalFrameEvent; |
55 |
import javax.swing.event.InternalFrameListener; |
56 |
|
57 |
import com.iver.andami.PluginServices; |
58 |
import com.iver.andami.plugins.Extension; |
59 |
import com.iver.andami.ui.mdiFrame.MDIFrame; |
60 |
import com.iver.cit.gvsig.fmap.MapControl; |
61 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
62 |
import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
63 |
import com.iver.cit.gvsig.gui.View; |
64 |
import com.iver.cit.gvsig.gui.Dialogs.GeoreferencingDialog; |
65 |
|
66 |
|
67 |
/**
|
68 |
* Extensi?n que carga el modulo de georeferenciaci?n
|
69 |
*
|
70 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
71 |
*/
|
72 |
public class GeoreferencingModule implements Extension, InternalFrameListener { |
73 |
|
74 |
private GeoreferencingDialog geoDialog = null; |
75 |
|
76 |
/**
|
77 |
* El control est? activo siempre que haya una vista abierta
|
78 |
*/
|
79 |
public boolean isEnabled() { |
80 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager().getActiveView(); |
81 |
|
82 |
if (f == null) { |
83 |
return false; |
84 |
} |
85 |
|
86 |
return (f.getClass() == View.class); |
87 |
} |
88 |
|
89 |
/**
|
90 |
* El control es visible siempre que haya una vista abierta
|
91 |
*/
|
92 |
public boolean isVisible() { |
93 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
94 |
.getActiveView(); |
95 |
if (f == null) { |
96 |
return false; |
97 |
} |
98 |
|
99 |
return (f.getClass() == View.class); |
100 |
} |
101 |
|
102 |
/**
|
103 |
* Cuando ejecutamos el control de georeferenciaci?n se activan las heramientas
|
104 |
* de georeferenciaci?n y se carga el wizard.
|
105 |
*/
|
106 |
public void execute(String s) { |
107 |
GeoreferencingToolsModule.visible = true;
|
108 |
PluginServices.getMainFrame().enableControls(); |
109 |
View vista = (View) PluginServices.getMDIManager().getActiveView(); |
110 |
MapControl mapCtrl = vista.getMapControl(); |
111 |
|
112 |
JInternalFrame panel = new JInternalFrame(); |
113 |
panel.addInternalFrameListener(this);
|
114 |
panel.setClosable(true);
|
115 |
geoDialog = new GeoreferencingDialog(panel);
|
116 |
panel.setSize(geoDialog.getWidth(), geoDialog.getHeight() + 25);
|
117 |
panel.setTitle(PluginServices.getText(this,"georreferenciar")); |
118 |
panel.getContentPane().add(geoDialog); |
119 |
|
120 |
MDIFrame mainFrame = (MDIFrame) PluginServices.getMainFrame(); |
121 |
JLayeredPane lyrPane = mainFrame.getLayeredPane();
|
122 |
lyrPane.add(panel, JDesktopPane.PALETTE_LAYER);
|
123 |
panel.show(); |
124 |
|
125 |
/*if (PluginServices.getMainFrame() == null){
|
126 |
JDialog dialog = new JDialog();
|
127 |
geoDialog.setPreferredSize(geoDialog.getSize());
|
128 |
dialog.getContentPane().add(geoDialog);
|
129 |
dialog.setModal(false);
|
130 |
dialog.pack();
|
131 |
dialog.show();
|
132 |
|
133 |
}else{
|
134 |
|
135 |
geoDialog = (GeoreferencingDialog) PluginServices.getMDIManager().addView(geoDialog);
|
136 |
}*/
|
137 |
} |
138 |
|
139 |
/**
|
140 |
* @see com.iver.andami.plugins.Extension#inicializar()
|
141 |
*/
|
142 |
public void inicializar() { |
143 |
|
144 |
} |
145 |
|
146 |
/**
|
147 |
* Cuando cerramos la ventana de georreferenciaci?n se elimina la barra de herramientas
|
148 |
* y se destruye la capa de puntos.
|
149 |
*/
|
150 |
public void internalFrameClosing(InternalFrameEvent arg0) { |
151 |
//Eliminamos la capa de puntos
|
152 |
View theView = (View) PluginServices.getMDIManager().getActiveView(); |
153 |
FLyrPoints lyrPoints = null;
|
154 |
for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){ |
155 |
FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i); |
156 |
if(lyr instanceof FLyrPoints) |
157 |
theView.getMapControl().getMapContext().getLayers().removeLayer(i); |
158 |
} |
159 |
GeoreferencingToolsModule.visible = false;
|
160 |
PluginServices.getMainFrame().enableControls(); |
161 |
} |
162 |
|
163 |
/* (non-Javadoc)
|
164 |
* @see javax.swing.event.InternalFrameListener#internalFrameActivated(javax.swing.event.InternalFrameEvent)
|
165 |
*/
|
166 |
public void internalFrameActivated(InternalFrameEvent arg0) { |
167 |
// TODO Auto-generated method stub
|
168 |
|
169 |
} |
170 |
/* (non-Javadoc)
|
171 |
* @see javax.swing.event.InternalFrameListener#internalFrameClosed(javax.swing.event.InternalFrameEvent)
|
172 |
*/
|
173 |
public void internalFrameClosed(InternalFrameEvent arg0) { |
174 |
// TODO Auto-generated method stub
|
175 |
|
176 |
} |
177 |
|
178 |
/* (non-Javadoc)
|
179 |
* @see javax.swing.event.InternalFrameListener#internalFrameDeactivated(javax.swing.event.InternalFrameEvent)
|
180 |
*/
|
181 |
public void internalFrameDeactivated(InternalFrameEvent arg0) { |
182 |
// TODO Auto-generated method stub
|
183 |
|
184 |
} |
185 |
/* (non-Javadoc)
|
186 |
* @see javax.swing.event.InternalFrameListener#internalFrameDeiconified(javax.swing.event.InternalFrameEvent)
|
187 |
*/
|
188 |
public void internalFrameDeiconified(InternalFrameEvent arg0) { |
189 |
// TODO Auto-generated method stub
|
190 |
|
191 |
} |
192 |
/* (non-Javadoc)
|
193 |
* @see javax.swing.event.InternalFrameListener#internalFrameIconified(javax.swing.event.InternalFrameEvent)
|
194 |
*/
|
195 |
public void internalFrameIconified(InternalFrameEvent arg0) { |
196 |
// TODO Auto-generated method stub
|
197 |
|
198 |
} |
199 |
/* (non-Javadoc)
|
200 |
* @see javax.swing.event.InternalFrameListener#internalFrameOpened(javax.swing.event.InternalFrameEvent)
|
201 |
*/
|
202 |
public void internalFrameOpened(InternalFrameEvent arg0) { |
203 |
// TODO Auto-generated method stub
|
204 |
|
205 |
} |
206 |
} |