Revision 2993

View differences:

trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/georeferencing/GeoreferencingModule.java
46 46
 */
47 47
package com.iver.cit.gvsig.georeferencing;
48 48

  
49
import java.awt.event.WindowEvent;
50

  
51 49
import javax.swing.JDesktopPane;
52 50
import javax.swing.JInternalFrame;
53 51
import javax.swing.JLayeredPane;
......
57 55
import com.iver.andami.PluginServices;
58 56
import com.iver.andami.plugins.Extension;
59 57
import com.iver.andami.ui.mdiFrame.MDIFrame;
58
import com.iver.cit.gvsig.AddLayer;
60 59
import com.iver.cit.gvsig.fmap.MapControl;
61 60
import com.iver.cit.gvsig.fmap.layers.FLayer;
62 61
import com.iver.cit.gvsig.fmap.layers.FLyrPoints;
63 62
import com.iver.cit.gvsig.gui.View;
64 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;
65 67

  
66 68

  
67 69
/**
......
104 106
	 * de georeferenciaci?n y se carga el wizard.
105 107
	 */
106 108
	public void execute(String s) {
107
		GeoreferencingToolsModule.visible = true;
109
		//GeoreferencingToolsModule.visible = true;
108 110
		PluginServices.getMainFrame().enableControls();
109 111
		View vista = (View) PluginServices.getMDIManager().getActiveView();
110 112
		MapControl mapCtrl = vista.getMapControl();
......
140 142
	 * @see com.iver.andami.plugins.Extension#inicializar()
141 143
	 */
142 144
	public void inicializar() {
143
	
145
		AddLayer.addWizard(GeoRasterWizard.class);
146
		FPopupMenu.addEntry(new GeoRasterTocMenuEntry());
144 147
	}
145 148
	
146 149
	
......
157 160
			if(lyr instanceof FLyrPoints && lyr.getName().startsWith("*"))
158 161
				theView.getMapControl().getMapContext().getLayers().removeLayer(i);
159 162
		}
160
		GeoreferencingToolsModule.visible = false;
163
		//GeoreferencingToolsModule.visible = false;
161 164
		PluginServices.getMainFrame().enableControls();
162 165
	}
163 166
	
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/georeferencing/GeoreferencingToolsModule.java
65 65
 */
66 66
public class GeoreferencingToolsModule implements Extension {
67 67
	private static Logger logger = Logger.getLogger(LayoutControls.class.getName());
68
	public static boolean visible = false;
68
	//public static boolean visible = false;
69 69
	private Layout layout = null;
70 70
			
71 71
	/**
......
86 86
			return false;
87 87
		}
88 88
		
89
		return (this.visible);
89
		try{
90
			View theView = (View) PluginServices.getMDIManager().getActiveView();
91
			for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
92
				FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
93
				if(	lyr instanceof FLyrGeoRaster &&
94
					lyr.isActive() &&
95
					lyr.getName().startsWith("*"))
96
					return true;
97
			}
98
		}catch(ClassCastException ex){
99
			return false;
100
		}
101
		
102
		return false;
90 103
	}
91 104

  
92 105
	/**
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/fmap/layers/FLyrGeoRaster.java
50 50
import com.iver.cit.gvsig.StackZoom;
51 51
import com.iver.cit.gvsig.fmap.DriverException;
52 52
import com.iver.cit.gvsig.fmap.ViewPort;
53
import com.iver.cit.gvsig.fmap.layers.FLyrPoints.GeoPoint;
53 54
import com.iver.cit.gvsig.fmap.operations.Cancellable;
54 55
import com.iver.cit.gvsig.gui.Panels.SelectFilePanel;
55 56

  
......
63 64
	
64 65
	private Extent assignExtent = null;
65 66
	private StackZoom zoom = new StackZoom();
67
	private FLyrPoints lyrPoint = null; 
68
	private double widthPxImg, heightPxImg;
66 69
	
67 70
	/**
68 71
	 * Funci?n encargada de realizar la transformaci?n para las coordenadas
......
283 286
		try{
284 287
			wcWidth = getFullExtent().getWidth();
285 288
			wcHeight = getFullExtent().getHeight();
286
			pixelImgX = (int)((((pixel.getX() * wcWidth) / SelectFilePanel.widthPxImg)) + this.getFullExtent().getMinX());
287
			pixelImgY = (int)((((pixel.getY() * wcHeight) / SelectFilePanel.heightPxImg)) + this.getFullExtent().getMinY());
289
			pixelImgX = (int)((((pixel.getX() * wcWidth) / widthPxImg)) + this.getFullExtent().getMinX());
290
			pixelImgY = (int)((((pixel.getY() * wcHeight) / heightPxImg)) + this.getFullExtent().getMinY());
288 291
		}catch(DriverException ex){}
289 292
		p.setLocation(pixelImgX, pixelImgY);
290 293
		return p;
......
302 305
		p.setLocation(x, y);
303 306
		return this.img2World(p);
304 307
	}
308
	
309
	/**
310
	 * Asigna la capa de puntos asociada a la capa Georraster
311
	 * @param lyr Capa de puntos
312
	 */
313
	public void setFLyrPoints(FLyrPoints lyr){
314
		this.lyrPoint = lyr;
315
	}
316
	
317
	/**
318
	 * Obtiene la capa de puntos asociada a la capa Georraster
319
	 * @return	Capa de puntos
320
	 */
321
	public FLyrPoints getFLyrPoints(){
322
		return this.lyrPoint;
323
	}
324
	
325
	/**
326
	 * Asigna la dimensi?n de la imagen de disco en pixeles
327
	 * @param w	Ancho
328
	 * @param h Alto
329
	 */
330
	public void setImageDimension(double w, double h){
331
		this.widthPxImg = w;
332
		this.heightPxImg = h;
333
	}
334
	
335
	/**
336
	 * Obtiene el ancho de la imagen de disco en pixeles
337
	 * @return
338
	 */
339
	public double getImageWidth(){
340
		return this.widthPxImg;
341
	}
342
	
343
	/**
344
	 * Obtiene el alto de la imagen de disco en pixeles
345
	 * @return
346
	 */
347
	public double getImageHeight(){
348
		return this.heightPxImg;
349
	}
305 350
}
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/fmap/layers/FLyrPoints.java
76 76
	private final int DIAM_CIRCLE = 18;
77 77
	private String lastTool = null;
78 78
	
79
	/**
80
	 * Obtiene el array de puntos
81
	 * @return
82
	 */
83
	public ArrayList getListPoint(){
84
		return pointList;
85
	}
79 86
	
80 87
	/**
88
	 * Asigna el array de puntos 
89
	 * @param list
90
	 */
91
	public void setListPoint(ArrayList list){
92
		pointList = list;
93
	}
94
	
95
	/**
81 96
	 * Dibujado de la capa de raster georeferenciado aplicando la 
82 97
	 * transformaci?n del viewPort.
83 98
	 */
......
94 109
		
95 110
		for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
96 111
			FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
97
			if(lyr instanceof FLyrGeoRaster && lyr.getName().startsWith("*"));
112
			if(	lyr instanceof FLyrGeoRaster && 
113
				lyr.getName().startsWith("*") &&
114
				lyr.isActive())
98 115
				lyrGeoRaster = (FLyrGeoRaster)lyr;
99 116
		}
100 117
		
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/Dialogs/GeoreferencingDialog.java
70 70
    }
71 71

  
72 72
    /**
73
     * Asigna el frame
74
     * @param f
75
     */
76
    public void setFrame(JInternalFrame f){
77
    	frame = f;
78
    }
79
    
80
    /**
73 81
     * En la inicializaci?n de la ventana a?adimos los tags de est? y cargamos 
74 82
     * ls herramientas para manejar las imagenes a georeferenciar.
75 83
     */
......
106 114
        this.add(getPBotones(), java.awt.BorderLayout.SOUTH);
107 115
        selectFilePanel = new SelectFilePanel(this);
108 116
        selectPointsPanel = new SelectPointsPanel();
109
        this.addTab(PluginServices.getText(this, "cargar_fichero"), selectFilePanel);
117
        //this.addTab(PluginServices.getText(this, "cargar_fichero"), selectFilePanel);
110 118
        this.addTab(PluginServices.getText(this, "seleccionar_puntos"), selectPointsPanel);
111 119
               
112 120
    }
......
168 176
		return pBotones;
169 177
	}
170 178
	
171
	/**
172
	 * This method initializes bProcesar	
173
	 * 	
174
	 * @return javax.swing.JButton	
175
	 */    
176
	private JButton getBProcesar() {
177
		if (bProcesar == null) {
178
			bProcesar = new JButton();
179
			bProcesar.setText(PluginServices.getText(this,"procesar"));
180
			bProcesar.setEnabled(false);
181
			bProcesar.setPreferredSize(new java.awt.Dimension(87,25));
182
			bProcesar.addActionListener(new java.awt.event.ActionListener() { 
183
				public void actionPerformed(java.awt.event.ActionEvent e) {
184
                    /*if (PluginServices.getMainFrame() == null) {
185
                        ((JDialog) (getParent().getParent().getParent()
186
                                .getParent())).dispose();
187
                    } else {
188
                        PluginServices.getMDIManager().closeView((com.iver.andami.ui.mdiManager.View) GeoreferencingDialog.this);
189
                    }*/
190
				}
191
			});
192
		}
193
		return bProcesar;
194
	}
195
	/**
196
	 * El bot?n cancelar restaura el extent con el que se carg? la imagen a georreferenciar
197
	 * y cierra la ventana. 	
198
	 * 	
199
	 * @return javax.swing.JButton	
200
	 */    
201
	private JButton getBCancelar() {
202
		if (bCancelar == null) {
203
			bCancelar = new JButton();
204
			bCancelar.setText(PluginServices.getText(this,"cancelar"));
205
			bCancelar.addActionListener(new java.awt.event.ActionListener() { 
206
				public void actionPerformed(java.awt.event.ActionEvent e) {    
207
					
208
					//Anulamos todos los cambios cargando el extent de origen a la capa
209
					View theView = (View) PluginServices.getMDIManager().getActiveView();
210
					
211
					for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
212
						FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
213
						if(lyr instanceof FLyrGeoRaster && lyr.getName().startsWith("*")){
214
							Extent initExtent = ((FLyrGeoRaster)lyr).getStackZoom().getInitExtent();
215
							if(initExtent != null){
216
								((FLyrGeoRaster)theView.getMapControl().getMapContext().getLayers().getLayer(lyr.getName())).setAssignExtent(initExtent);
217
								theView.getMapControl().getMapContext().invalidate();
218
							}
219
						}
220
					}
221
					
222
					//Cerramos la ventana
223
					try{
224
						frame.setClosed(true);
225
					}catch(PropertyVetoException exc){}
226
				}
227
			});
228
		}
229
		return bCancelar;
230
	}
231
		
179
	
180
	
232 181
	public class DialogWizardListener implements WizardListener {
233 182

  
234 183
		/**
......
252 201
		GeoreferencingDialog.proj = proj;
253 202
	}
254 203

  
255
	/**
256
	 * This method initializes jButton	
257
	 * 	
258
	 * @return javax.swing.JButton	
259
	 */
260
	private JButton getBSave() {
261
		if (bSave == null) {
262
			bSave = new JButton();
263
			bSave.setText(PluginServices.getText(this,"guardar"));
264
			bSave.setEnabled(false);
265
		}
266
		return bSave;
267
	}
268 204

  
205

  
269 206
	/**
270 207
	 * @return Returns the GeoRedimBehavior.
271 208
	 */
......
356 293
				public void actionPerformed(java.awt.event.ActionEvent e) {
357 294
					View theView = (View) PluginServices.getMDIManager().getActiveView();
358 295
					
359
					//Obtenemos la capa de puntos y la capa de georaster
296
					//Obtenemos la capa de georaster y le cambiamos el nombre
360 297
					FLyrGeoRaster lyrGeoRaster = null;
298
					FLyrPoints lyrPoints = null;
361 299
					for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
362 300
						FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
363
						if(lyr instanceof FLyrGeoRaster && lyr.getName().startsWith("*")){
301
						if(	lyr instanceof FLyrGeoRaster && 
302
							lyr.getName().startsWith("*")){
364 303
							lyrGeoRaster = (FLyrGeoRaster)lyr;
365 304
							lyrGeoRaster.setName(lyrGeoRaster.getName().substring(1, lyrGeoRaster.getName().length()));
366 305
						}
306
						if(	lyr instanceof FLyrPoints){
307
							lyrPoints = (FLyrPoints)lyr;
308
							theView.getMapControl().getMapContext().getLayers().removeLayer(i);
309
						}
367 310
					}
368 311
					
312
					//A la capa Georraster le asignamos la capa de puntos para poder recuperarla
313
					lyrGeoRaster.setFLyrPoints(lyrPoints);
314
					
315
					theView.getMapControl().setTool("zoomIn");
316
					
369 317
					//Cerramos la ventana
370 318
					try{
371 319
						frame.setClosed(true);
......
375 323
		}
376 324
		return bAceptar;
377 325
	}
326
	
327
	/**
328
	 * This method initializes bProcesar	
329
	 * 	
330
	 * @return javax.swing.JButton	
331
	 */    
332
	private JButton getBProcesar() {
333
		if (bProcesar == null) {
334
			bProcesar = new JButton();
335
			bProcesar.setText(PluginServices.getText(this,"procesar"));
336
			bProcesar.setEnabled(false);
337
			bProcesar.setPreferredSize(new java.awt.Dimension(87,25));
338
			bProcesar.addActionListener(new java.awt.event.ActionListener() { 
339
				public void actionPerformed(java.awt.event.ActionEvent e) {
340
                    /*if (PluginServices.getMainFrame() == null) {
341
                        ((JDialog) (getParent().getParent().getParent()
342
                                .getParent())).dispose();
343
                    } else {
344
                        PluginServices.getMDIManager().closeView((com.iver.andami.ui.mdiManager.View) GeoreferencingDialog.this);
345
                    }*/
346
				}
347
			});
348
		}
349
		return bProcesar;
350
	}
351
	
352
	/**
353
	 * El bot?n cancelar restaura el extent con el que se carg? la imagen a georreferenciar
354
	 * y cierra la ventana. 	
355
	 * 	
356
	 * @return javax.swing.JButton	
357
	 */    
358
	private JButton getBCancelar() {
359
		if (bCancelar == null) {
360
			bCancelar = new JButton();
361
			bCancelar.setText(PluginServices.getText(this,"cancelar"));
362
			bCancelar.addActionListener(new java.awt.event.ActionListener() { 
363
				public void actionPerformed(java.awt.event.ActionEvent e) {    
364
					
365
					//Anulamos todos los cambios cargando el extent de origen a la capa
366
					View theView = (View) PluginServices.getMDIManager().getActiveView();
367
					FLyrPoints lyrPoints = null;
368
					for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
369
						FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
370
						if(lyr instanceof FLyrGeoRaster && lyr.getName().startsWith("*")){
371
							Extent initExtent = ((FLyrGeoRaster)lyr).getStackZoom().getInitExtent();
372
							if(initExtent != null){
373
								((FLyrGeoRaster)theView.getMapControl().getMapContext().getLayers().getLayer(lyr.getName())).setAssignExtent(initExtent);
374
								theView.getMapControl().getMapContext().invalidate();
375
							}
376
						}
377
						if(	lyr instanceof FLyrPoints)
378
							theView.getMapControl().getMapContext().getLayers().removeLayer(i);
379
						
380
					}
381
					
382
					
383
					//Cerramos la ventana
384
					try{
385
						frame.setClosed(true);
386
					}catch(PropertyVetoException exc){}
387
				}
388
			});
389
		}
390
		return bCancelar;
391
	}
392
		
393
	/**
394
	 * This method initializes jButton	
395
	 * 	
396
	 * @return javax.swing.JButton	
397
	 */
398
	private JButton getBSave() {
399
		if (bSave == null) {
400
			bSave = new JButton();
401
			bSave.setText(PluginServices.getText(this,"guardar"));
402
			bSave.setEnabled(false);
403
		}
404
		return bSave;
405
	}
378 406
   }  //  @jve:decl-index=0:visual-constraint="10,10"
379 407
 //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
380 408
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/Panels/GeoRasterWizard.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.gui.Panels;
42

  
43
import java.awt.FlowLayout;
44
import java.awt.GridBagConstraints;
45
import java.awt.GridBagLayout;
46
import java.awt.event.ActionEvent;
47
import java.awt.geom.Rectangle2D;
48
import java.io.File;
49

  
50
import javax.swing.JButton;
51
import javax.swing.JCheckBox;
52
import javax.swing.JDesktopPane;
53
import javax.swing.JDialog;
54
import javax.swing.JFileChooser;
55
import javax.swing.JInternalFrame;
56
import javax.swing.JLabel;
57
import javax.swing.JLayeredPane;
58
import javax.swing.JPanel;
59
import javax.swing.JTextField;
60
import javax.swing.event.InternalFrameEvent;
61
import javax.swing.event.InternalFrameListener;
62
import javax.swing.filechooser.FileFilter;
63

  
64
import org.cresques.cts.IProjection;
65
import org.cresques.io.GeoRasterFile;
66
import org.cresques.px.Extent;
67

  
68
import com.hardcode.driverManager.DriverLoadException;
69
import com.iver.andami.PluginServices;
70
import com.iver.andami.messages.NotificationManager;
71
import com.iver.andami.ui.mdiFrame.MDIFrame;
72
import com.iver.cit.gvsig.fmap.DriverException;
73
import com.iver.cit.gvsig.fmap.ViewPort;
74
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
75
import com.iver.cit.gvsig.fmap.drivers.RasterDriver;
76
import com.iver.cit.gvsig.fmap.layers.FLayer;
77
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster;
78
import com.iver.cit.gvsig.fmap.layers.FLyrPoints;
79
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
80
import com.iver.cit.gvsig.fmap.layers.RasterAdapter;
81
import com.iver.cit.gvsig.fmap.layers.RasterFileAdapter;
82
import com.iver.cit.gvsig.gui.FOpenDialog;
83
import com.iver.cit.gvsig.gui.View;
84
import com.iver.cit.gvsig.gui.WizardPanel;
85
import com.iver.cit.gvsig.gui.Dialogs.GeoreferencingDialog;
86
import com.iver.cit.gvsig.gui.wizards.WizardListener;
87
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport;
88
 
89
/**
90
 * Clase que implementa el Wizard para la georreferenciaci?n
91
 * @author Nacho Brodin (brodin_ign@gva.es)
92
 */
93
public class GeoRasterWizard extends WizardPanel implements InternalFrameListener {
94
	private JPanel pGeneral = null;
95
	private JPanel pFileSelection = null;
96
	private JPanel pControls = null;
97
	private JTextField tFile = null;
98
	private JButton bSelectFile = null;
99
	private JPanel pProyection = null;
100
	private WizardListenerSupport listenerSupport = new WizardListenerSupport();
101
	/**
102
	 * Lista de formatos soportados
103
	 */
104
	private String[] fileFilters = {"ecw", "sid", "tif", "jpg", "png", "jp2"};
105
	/**
106
	 * Nombre del fichero seleccionado
107
	 */
108
	private String fName = "";
109
	
110
	/**
111
	 * Nombre de la capa
112
	 */
113
	private String lyrName = "";
114
	/**
115
	 * Recuerda la ?ltima ruta seleccionada por el usuario
116
	 */
117
	private String lastPath = "./";
118

  
119
	private FLyrGeoRaster lyrGeoRaster = null;
120
	
121
	private JPanel pCheckUseGeoref = null;
122
	private JCheckBox cbUseGeoref = null;
123
	private JLabel lUseGeoref = null;
124
	private double widthPxImg, heightPxImg;
125
	
126
	/**
127
	 * Extent calculado a partir de la vista.
128
	 */
129
	private Extent ext = null;
130
	
131
	/**
132
	 * Dialogo para la asignaci?n de puntos en la imagen.
133
	 */
134
	public static GeoreferencingDialog geoDialog = null;
135
	
136
	
137
	/**
138
	 * This is the default constructor
139
	 */
140
	public GeoRasterWizard() {
141
		super();
142
		initialize();
143
	}
144

  
145
	/**
146
	 * This method initializes this
147
	 * 
148
	 * @return void
149
	 */
150
	private void initialize() {
151
        this.setPreferredSize(new java.awt.Dimension(750,320));
152
        this.setSize(new java.awt.Dimension(510,311));
153
        this.setLocation(new java.awt.Point(0,0));
154
        this.add(getPGeneral(), null);
155
        this.getBSelectFile().addActionListener(new java.awt.event.ActionListener() {
156
            public void actionPerformed(java.awt.event.ActionEvent evt) {
157
            	acceptButtonActionPerformed(evt);
158
            }
159
        });
160
	 }
161

  
162
	/**
163
	 * This method initializes jPanel	
164
	 * 	
165
	 * @return javax.swing.JPanel	
166
	 */
167
	private JPanel getPGeneral() {
168
		if (pGeneral == null) {
169
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
170
			gridBagConstraints1.insets = new java.awt.Insets(5,0,0,0);
171
			gridBagConstraints1.gridy = 1;
172
			gridBagConstraints1.gridx = 0;
173
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
174
			gridBagConstraints.insets = new java.awt.Insets(0,0,2,0);
175
			gridBagConstraints.gridy = 0;
176
			gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
177
			gridBagConstraints.gridx = 0;
178
			pGeneral = new JPanel();
179
			pGeneral.setLayout(new GridBagLayout());
180
			pGeneral.setPreferredSize(new java.awt.Dimension(750,320));
181
			gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTH;
182
			pGeneral.add(getPFileSelection(), gridBagConstraints);
183
			pGeneral.add(getPControls(), gridBagConstraints1);
184
		}
185
		return pGeneral;
186
	}
187

  
188
	/**
189
	 * This method initializes jPanel	
190
	 * 	
191
	 * @return javax.swing.JPanel	
192
	 */
193
	private JPanel getPFileSelection() {
194
		if (pFileSelection == null) {
195
			FlowLayout flowLayout = new FlowLayout();
196
			flowLayout.setVgap(10);
197
			pFileSelection = new JPanel();
198
			pFileSelection.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"cargar"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
199
			pFileSelection.setLayout(flowLayout);
200
			pFileSelection.setPreferredSize(new java.awt.Dimension(475,70));
201
			pFileSelection.add(getTFile(), null);
202
			pFileSelection.add(getBSelectFile(), null);
203
		}
204
		return pFileSelection;
205
	}
206

  
207
	private JPanel getPControls() {
208
		if (pControls == null) {
209
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
210
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
211
			gridBagConstraints2.gridx = 0;
212
			gridBagConstraints2.gridy = 1;
213
			pControls = new JPanel();
214
			pControls.setLayout(new GridBagLayout());
215
			pControls.setPreferredSize(new java.awt.Dimension(475,200));
216
			pControls.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
217
			gridBagConstraints11.gridx = 0;
218
			gridBagConstraints11.gridy = 0;
219
			pControls.add(getPCheckUseGeoref(), gridBagConstraints11);
220
			pControls.add(getPProyection(), gridBagConstraints2);
221
		}
222
		return pControls;
223
	}
224
	
225
	/**
226
	 * This method initializes jTextField	
227
	 * 	
228
	 * @return javax.swing.JTextField	
229
	 */
230
	private JTextField getTFile() {
231
		if (tFile == null) {
232
			tFile = new JTextField();
233
			tFile.setPreferredSize(new java.awt.Dimension(350,25));
234
		}
235
		return tFile;
236
	}
237

  
238
	/**
239
	 * This method initializes jButton	
240
	 * 	
241
	 * @return javax.swing.JButton	
242
	 */
243
	private JButton getBSelectFile() {
244
		if (bSelectFile == null) {
245
			bSelectFile = new JButton();
246
			bSelectFile.setText(PluginServices.getText(this, "cargar"));
247
		}
248
		return bSelectFile;
249
	}
250
	
251
	/**
252
	 * This method initializes jPanel	
253
	 * 	
254
	 * @return javax.swing.JPanel	
255
	 */    
256
	private ProjChooserPanel getPProyection() {
257
		if (pProyection == null) {
258
			pProyection = new ProjChooserPanel(GeoreferencingDialog.getLastProjection());
259
			((ProjChooserPanel)pProyection).addActionListener(new java.awt.event.ActionListener() { 
260
				public void actionPerformed(java.awt.event.ActionEvent e) {
261
			        if (((ProjChooserPanel)pProyection).isOkPressed()) {
262
			        	FOpenDialog.setLastProjection(((ProjChooserPanel)pProyection).getCurProj());
263
			        }
264
				}
265
			});
266
		}
267
		return ((ProjChooserPanel)pProyection);
268
	}
269

  
270
	/**
271
	 * Crea una capa Raster a partir del nombre driver, fichero y proyecci?n y 
272
	 * coordenadas de georeferenciaci?n. Esta funci?n es para georeferenciar 
273
	 * capas raster. Para imagenes que no tienen georeferenciaci?n hay que asignarle
274
	 * una temporal, normalmente a partir de la vista activa.
275
	 *
276
	 * @param layerName Nombre de la capa.
277
	 * @param d RasterDriver.
278
	 * @param f Fichero.
279
	 * @param proj Proyecci?n.
280
	 * @param extent Extent de la vista activa
281
	 *
282
	 * @return Nueva capa de tipo raster.
283
	 *
284
	 * @throws DriverIOException
285
	 */
286
	private FLyrGeoRaster createLayer(String layerName, RasterDriver d,
287
		File f, IProjection proj) throws DriverException {
288
		RasterAdapter adapter = new RasterFileAdapter(f);
289
		adapter.setDriver(d);
290
		FLyrGeoRaster capa = new FLyrGeoRaster();
291
		if (capa != null) {
292
			capa.setName(layerName);
293
			capa.setSource(adapter);
294
			capa.setProjection(proj);
295
			capa.setImageDimension(widthPxImg, heightPxImg);
296
			try {
297
				capa.load();
298
			} catch (DriverIOException e) {
299
				throw new DriverException(e);
300
			}
301
	        
302
	        capa.setVisible(true);
303
		}else 
304
			return null;
305
		return capa;
306
	}
307
	
308
	/**
309
	 * Calcula un extent posible para la imagen a partir del extent de la vista.
310
	 * En este caso centra la imagen en la vista.
311
	 * @param w	Ancho de la imagen
312
	 * @param h Alto de la imagen
313
	 * @return	Extent para la imagen
314
	 */
315
	protected Extent calcTempExtent(String file, ViewPort vp, IProjection proj){
316
		
317
		//Obtenemos el ancho y alto de la imagen y obtenemos un extent a partir
318
		//del viewport.
319
		Extent tempExtent = null;
320
		GeoRasterFile grf = GeoRasterFile.openFile(proj, file);
321
		widthPxImg = grf.getWidth();
322
		heightPxImg = grf.getHeight();
323
		if(vp == null || vp.getAdjustedExtent() == null){
324
			vp = new ViewPort(proj);
325
			Rectangle2D r2d = new Rectangle2D.Double(0, 0, widthPxImg, heightPxImg);
326
			vp.setExtent(r2d);
327
			tempExtent = new Extent(0, 0, widthPxImg, heightPxImg);
328
		}else
329
			tempExtent = new Extent(vp.getAdjustedExtent());
330
		grf.close();
331
		
332
		
333
		double ulX = 0D, ulY = 0D, lrX = 0D, lrY = 0D;
334
		if(widthPxImg > heightPxImg){
335
			double widthView = tempExtent.maxX() - tempExtent.minX();
336
			ulX = tempExtent.minX() + (widthView / 4);
337
			lrX = ulX + (widthView / 2);
338
			double newAlto = ((heightPxImg * (widthView / 2)) / widthPxImg);
339
			double centroY = tempExtent.minY()+((tempExtent.maxY() - tempExtent.minY())/2);
340
			ulY = centroY - (newAlto / 2);
341
			lrY = centroY + (newAlto / 2);
342
		}else{
343
			double heightView = tempExtent.maxY() - tempExtent.minY();
344
			ulY = tempExtent.minY() + (heightView / 4);
345
			lrY = ulY + (heightView / 2);
346
			double newAncho = ((widthPxImg * (heightView / 2)) / heightPxImg);
347
			double centroX = tempExtent.minX()+((tempExtent.maxX() - tempExtent.minX())/2);
348
			ulX = centroX - (newAncho / 2);
349
			lrX = centroX + (newAncho / 2);
350
		}
351
		return new Extent(ulX, ulY, lrX, lrY);
352
	}
353
	
354
	/**
355
	 * Evento de pulsado del bot?n de seleccionar fichero
356
	 * @param e
357
	 */
358
	private void acceptButtonActionPerformed(ActionEvent e) {
359
		//Selector de Fichero que se quiere georeferenciar
360
				
361
		if(	e.getSource().equals(this.getBSelectFile())){
362
			JFileChooser chooser = new JFileChooser(lastPath);
363
			chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero"));
364
			FileFilter f = null;
365
			for(int i=0; i<this.fileFilters.length;i++){
366
				f = new SelectFileFilter(chooser, this.fileFilters[i]);
367
				chooser.addChoosableFileFilter(f);
368
			}
369
			int returnVal = chooser.showOpenDialog(this);
370
			if(returnVal == JFileChooser.APPROVE_OPTION){
371
			 	this.fName = chooser.getSelectedFile().toString();
372
			 	FileFilter filter = chooser.getFileFilter();
373
			 	this.getTFile().setText(fName);
374
			 	lastPath = chooser.getCurrentDirectory().getAbsolutePath();
375
			 	
376
			 	if (PluginServices.getMainFrame() == null) {
377
                    ((JDialog) (getParent().getParent().getParent()
378
                            .getParent())).dispose();
379
                } else {
380
                	//Creamos la capa y la cargamos
381
                	IProjection proj = this.getPProyection().getCurProj();
382
                	try{
383
                		View theView = (View) PluginServices.getMDIManager().getActiveView();
384
                		
385
                		com.hardcode.driverManager.Driver driver = LayerFactory.getDM().getDriver("gvSIG Image Driver");
386
                	                		
387
                		File fich = new File(fName);
388
                		
389
						ViewPort viewPort = theView.getMapControl().getMapContext().getViewPort();
390
						
391
						ext = calcTempExtent(	fName, 
392
												viewPort, 
393
												proj);
394
						
395
                		this.setLyrName("*"+fName.substring(fName.lastIndexOf("/")+1));
396
                		
397
                		lyrGeoRaster = this.createLayer(this.getLyrName(), 
398
                										(RasterDriver) driver, 
399
														fich, 
400
														proj);
401
                		         			
402

  
403
                		if(lyrGeoRaster != null){	
404
                    		//theView.getMapControl().getMapContext().beginAtomicEvent();
405
                    		//theView.getMapControl().getMapContext().getLayers().addLayer(lyrGeoRaster);
406
                    		//theView.getMapControl().getMapContext().endAtomicEvent();
407
                    		lyrGeoRaster.getStackZoom().setInitExtent(ext);
408
                    		lyrGeoRaster.setActive(true);
409
                    	}
410
                		
411
                		if(	ext != null && 
412
                				fich != null && 
413
                				this.lyrGeoRaster != null && 
414
                				!getTFile().getText().equals(""))
415
                				listenerSupport.callStateChanged(true);
416
                		
417
                	}catch(DriverLoadException exc){
418
                		NotificationManager.addError("No se pudo acceder a los drivers", exc);
419
                	}catch(DriverException exc){
420
                		NotificationManager.addError("El driver ha producido un error", exc);
421
                	}
422
                   
423
                }
424
			 }
425
	    }	
426
		
427
	}
428
	
429
	/**
430
	 * M?todo que se ejecuta al pulsar el bot?n de aceptar. En este caso asignamos el
431
	 * extent calculado desde la vista si el checkbox no est? marcado y lanzaremos el
432
	 * dialogo de georeferenciaci?n. El resto del trabajo lo realiza la clase AddLayer.
433
	 */
434
	public void execute() {
435
		if(!this.getCbUseGeoref().isSelected())
436
			lyrGeoRaster.setAssignExtent(ext);    
437
		
438
		JInternalFrame panel = new JInternalFrame();
439
		panel.addInternalFrameListener(this);
440
        panel.setClosable(true);
441
        geoDialog = new GeoreferencingDialog(panel);
442
        panel.setSize(400, 340);
443
        panel.setTitle(PluginServices.getText(this,"georreferenciar"));
444
        panel.getContentPane().add(geoDialog);
445
       
446
        MDIFrame mainFrame = (MDIFrame) PluginServices.getMainFrame();
447
        JLayeredPane lyrPane = mainFrame.getLayeredPane();
448
        lyrPane.add(panel, JDesktopPane.PALETTE_LAYER);       
449
        panel.show();
450
	}
451
	
452
	/**
453
	 * @return Returns the lyrRaster.
454
	 */
455
	public FLyrGeoRaster getFLyrGeoRaster() {
456
		return lyrGeoRaster;
457
	}
458

  
459
	/**
460
	 * @param lyrRaster The lyrRaster to set.
461
	 */
462
	public void setFLyrGeoRaster(FLyrGeoRaster lyrGeoRaster) {
463
		this.lyrGeoRaster = lyrGeoRaster;
464
	}
465
   
466
	/**
467
	 * 
468
	 * @author Nacho Brodin (brodin_ign@gva.es)
469
	 *
470
	 */
471
	class SelectFileFilter extends javax.swing.filechooser.FileFilter {
472
		
473
		private JFileChooser chooser = null;
474
		private String file = null;
475
		
476
		public SelectFileFilter(JFileChooser ch, String file){
477
			this.chooser = ch;
478
			this.file = file;
479
		}
480
		
481
	    public boolean accept(File f) {
482

  
483
	    	return f.isDirectory() || f.getName().toLowerCase().endsWith("."+file);
484
	    }
485
	    
486
	    public String getDescription() {
487
	    	return file;
488
	    }
489
	    
490
	}
491
	
492
	/**
493
	 * @return Returns the fName.
494
	 */
495
	public String getLyrName() {
496
		return lyrName;
497
	}
498
	/**
499
	 * @param name The fName to set.
500
	 */
501
	public void setLyrName(String name) {
502
		lyrName = name;
503
	}
504
	/**
505
	 * This method initializes jPanel	
506
	 * 	
507
	 * @return javax.swing.JPanel	
508
	 */    
509
	private JPanel getPCheckUseGeoref() {
510
		if (pCheckUseGeoref == null) {
511
			FlowLayout flowLayout1 = new FlowLayout();
512
			flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
513
			lUseGeoref = new JLabel();
514
			pCheckUseGeoref = new JPanel();
515
			pCheckUseGeoref.setLayout(flowLayout1);
516
			pCheckUseGeoref.setPreferredSize(new java.awt.Dimension(370,31));
517
			lUseGeoref.setText("Usar georeferenciaci?n de la imagen");
518
			pCheckUseGeoref.add(getCbUseGeoref(), null);
519
			pCheckUseGeoref.add(lUseGeoref, null);
520
		}
521
		return pCheckUseGeoref;
522
	}
523
	/**
524
	 * This method initializes jCheckBox	
525
	 * 	
526
	 * @return javax.swing.JCheckBox	
527
	 */    
528
	private JCheckBox getCbUseGeoref() {
529
		if (cbUseGeoref == null) {
530
			cbUseGeoref = new JCheckBox();
531
			cbUseGeoref.setSelected(true);
532
		}
533
		return cbUseGeoref;
534
	}
535
	
536
	public void initWizard() {
537
	
538
	}
539

  
540
	/**
541
	 * Adds the gvSIG's wizard listener 
542
	 * 
543
	 * @param listener
544
	 */
545
	public void addWizardListener(WizardListener listener) { 
546
		listenerSupport.addWizardListener(listener);
547
	}
548

  
549
	/* (non-Javadoc)
550
	 * @see com.iver.cit.gvsig.gui.WizardPanel#callError(java.lang.Exception)
551
	 */
552
	public void callError(Exception descripcion) {
553
		// TODO Auto-generated method stub
554
		super.callError(descripcion);
555
	}
556

  
557
	/* (non-Javadoc)
558
	 * @see com.iver.cit.gvsig.gui.WizardPanel#callStateChanged(boolean)
559
	 */
560
	public void callStateChanged(boolean finishable) {
561
		// TODO Auto-generated method stub
562
		super.callStateChanged(finishable);
563
	}
564

  
565
	/* (non-Javadoc)
566
	 * @see com.iver.cit.gvsig.gui.WizardPanel#getLayer()
567
	 */
568
	public FLayer getLayer() {
569
		if(lyrGeoRaster != null)
570
			return lyrGeoRaster;
571
		return null;
572
	}
573

  
574
	/* (non-Javadoc)
575
	 * @see com.iver.cit.gvsig.gui.WizardPanel#getTabName()
576
	 */
577
	public String getTabName() {
578
		return PluginServices.getText(this, "georef");
579
	}
580

  
581
	/* (non-Javadoc)
582
	 * @see com.iver.cit.gvsig.gui.WizardPanel#removeWizardListener(com.iver.cit.gvsig.gui.wizards.WizardListener)
583
	 */
584
	public void removeWizardListener(WizardListener listener) {
585
		// TODO Auto-generated method stub
586
		super.removeWizardListener(listener);
587
	}
588

  
589
	/* (non-Javadoc)
590
	 * @see com.iver.cit.gvsig.gui.WizardPanel#setTabName(java.lang.String)
591
	 */
592
	protected void setTabName(String name) {
593
		// TODO Auto-generated method stub
594
		super.setTabName(name);
595
	}
596
	
597
	/**
598
	 * Cuando cerramos la ventana de georreferenciaci?n se elimina la barra de herramientas
599
	 * y se destruye la capa de puntos.
600
	 */
601
	public void internalFrameClosing(InternalFrameEvent arg0) {
602
		//Eliminamos la capa de puntos 
603
		View theView = (View) PluginServices.getMDIManager().getActiveView();
604
		FLyrPoints lyrPoints = null;
605
		for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
606
			FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
607
			if(lyr instanceof FLyrPoints && lyr.getName().startsWith("*"))
608
				theView.getMapControl().getMapContext().getLayers().removeLayer(i);
609
		}
610
		//GeoreferencingToolsModule.visible = false;
611
		PluginServices.getMainFrame().enableControls();
612
	}
613
	
614
	/* (non-Javadoc)
615
	 * @see javax.swing.event.InternalFrameListener#internalFrameActivated(javax.swing.event.InternalFrameEvent)
616
	 */
617
	public void internalFrameActivated(InternalFrameEvent arg0) {
618
		// TODO Auto-generated method stub
619

  
620
	}
621
	/* (non-Javadoc)
622
	 * @see javax.swing.event.InternalFrameListener#internalFrameClosed(javax.swing.event.InternalFrameEvent)
623
	 */
624
	public void internalFrameClosed(InternalFrameEvent arg0) {
625
		// TODO Auto-generated method stub
626

  
627
	}
628

  
629
	/* (non-Javadoc)
630
	 * @see javax.swing.event.InternalFrameListener#internalFrameDeactivated(javax.swing.event.InternalFrameEvent)
631
	 */
632
	public void internalFrameDeactivated(InternalFrameEvent arg0) {
633
		// TODO Auto-generated method stub
634

  
635
	}
636
	/* (non-Javadoc)
637
	 * @see javax.swing.event.InternalFrameListener#internalFrameDeiconified(javax.swing.event.InternalFrameEvent)
638
	 */
639
	public void internalFrameDeiconified(InternalFrameEvent arg0) {
640
		// TODO Auto-generated method stub
641

  
642
	}
643
	/* (non-Javadoc)
644
	 * @see javax.swing.event.InternalFrameListener#internalFrameIconified(javax.swing.event.InternalFrameEvent)
645
	 */
646
	public void internalFrameIconified(InternalFrameEvent arg0) {
647
		// TODO Auto-generated method stub
648

  
649
	}
650
	/* (non-Javadoc)
651
	 * @see javax.swing.event.InternalFrameListener#internalFrameOpened(javax.swing.event.InternalFrameEvent)
652
	 */
653
	public void internalFrameOpened(InternalFrameEvent arg0) {
654
		// TODO Auto-generated method stub
655

  
656
	}
657
}
658

  
0 659

  
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/Panels/SelectPointsPanel.java
481 481
		//Si no hemos encontrado ninguna la creamos
482 482
		if(lyrPoints == null){
483 483
			lyrPoints = new FLyrPoints();
484
			lyrPoints.setName("layerPoints");
484
			lyrPoints.setName("Points");
485 485
			lyrPoints.setVisible(true);
486
			theView.getMapControl().getMapContext().beginAtomicEvent();
486 487
			theView.getMapControl().getMapContext().getLayers().addLayer(lyrPoints);
488
			theView.getMapControl().getMapContext().endAtomicEvent();
487 489
		}
488 490
		return lyrPoints;
489 491
	}
......
508 510
					loadLyrPoint();
509 511
					lyrPoints.setLastTool(theView.getMapControl().getTool());
510 512
					GeorefPointerListener.posPoint = getCPoint().getSelectedIndex();
513
					System.out.println("---->"+GeorefPointerListener.posPoint);
511 514
					GeorefPointerListener.firstPoint = true;
512 515
					theView.getMapControl().setTool("pointLyrSelection");
513 516
				}
......
816 819
		}
817 820
		return pSelectFromView;
818 821
	}
822
	
823
	/**
824
	 * Carga el panel desde los datos contenidos en una capa de puntos
825
	 * @param lyr
826
	 */
827
	public void loadFromLyrPoints(FLyrPoints lyr){
828
		if(lyr != null){
829
			lyrPoints = lyr;
830
			View theView = (View) PluginServices.getMDIManager().getActiveView();
831
			theView.getMapControl().getMapContext().beginAtomicEvent();
832
			theView.getMapControl().getMapContext().getLayers().addLayer(lyr);
833
			theView.getMapControl().getMapContext().endAtomicEvent();
834
			
835
			this.getCPoint().removeAllItems();
836
			for(int i=0;i<lyr.getCountPoints();i++)
837
				this.getCPoint().addItem("" + (i + 1));
838
			if(lyr.getCountPoints() >= 1){
839
				changePoint(true, 0);
840
				getBSelectFromView().setEnabled(true);
841
				getBClear().setEnabled(true);
842
				getBDelPoint().setEnabled(true);
843
			}
844
		}
845
	}
819 846

  
820 847
   }
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/Panels/SelectFilePanel.java
66 66
	private JPanel pCheckUseGeoref = null;
67 67
	private JCheckBox cbUseGeoref = null;
68 68
	private JLabel lUseGeoref = null;
69
	public static double widthPxImg, heightPxImg;
69
	public double widthPxImg, heightPxImg;
70 70
	
71 71
	/**
72 72
	 * This is the default constructor
......
252 252
		//del viewport.
253 253
		Extent tempExtent = null;
254 254
		GeoRasterFile grf = GeoRasterFile.openFile(proj, file);
255
		double w = widthPxImg = grf.getWidth();
256
		double h = heightPxImg = grf.getHeight();
255
		widthPxImg = grf.getWidth();
256
		heightPxImg = grf.getHeight();
257 257
		if(vp == null || vp.getAdjustedExtent() == null){
258 258
			vp = new ViewPort(proj);
259
			Rectangle2D r2d = new Rectangle2D.Double(0, 0, w, h);
259
			Rectangle2D r2d = new Rectangle2D.Double(0, 0, widthPxImg, heightPxImg);
260 260
			vp.setExtent(r2d);
261
			tempExtent = new Extent(0, 0, w, h);
261
			tempExtent = new Extent(0, 0, widthPxImg, heightPxImg);
262 262
		}else
263 263
			tempExtent = new Extent(vp.getAdjustedExtent());
264 264
		grf.close();
265 265
		
266 266
		
267 267
		double ulX = 0D, ulY = 0D, lrX = 0D, lrY = 0D;
268
		if(w > h){
268
		if(widthPxImg > heightPxImg){
269 269
			double widthView = tempExtent.maxX() - tempExtent.minX();
270 270
			ulX = tempExtent.minX() + (widthView / 4);
271 271
			lrX = ulX + (widthView / 2);
272
			double newAlto = ((h * (widthView / 2)) / w);
272
			double newAlto = ((heightPxImg * (widthView / 2)) / widthPxImg);
273 273
			double centroY = tempExtent.minY()+((tempExtent.maxY() - tempExtent.minY())/2);
274 274
			ulY = centroY - (newAlto / 2);
275 275
			lrY = centroY + (newAlto / 2);
......
277 277
			double heightView = tempExtent.maxY() - tempExtent.minY();
278 278
			ulY = tempExtent.minY() + (heightView / 4);
279 279
			lrY = ulY + (heightView / 2);
280
			double newAncho = ((w * (heightView / 2)) / h);
280
			double newAncho = ((widthPxImg * (heightView / 2)) / heightPxImg);
281 281
			double centroX = tempExtent.minX()+((tempExtent.maxX() - tempExtent.minX())/2);
282 282
			ulX = centroX - (newAncho / 2);
283 283
			lrX = centroX + (newAncho / 2);
......
346 346
                			lyrGeoRaster.setAssignExtent(ext);                			
347 347
                		
348 348
                			                	
349
	                	if(lyrGeoRaster != null){	                		
349
	                	if(lyrGeoRaster != null){	        
350
	                		theView.getMapControl().getMapContext().beginAtomicEvent();
350 351
	                		theView.getMapControl().getMapContext().getLayers().addLayer(lyrGeoRaster);
352
	                		theView.getMapControl().getMapContext().endAtomicEvent();
351 353
	                		lyrGeoRaster.getStackZoom().setInitExtent(ext);
354
	                		lyrGeoRaster.setActive(true);
352 355
	                	}
353 356
                		
354 357
                	}catch(DriverLoadException exc){
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/toc/GeoRasterTocMenuEntry.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*
19
* For more information, contact:
20
*
21
*  Generalitat Valenciana
22
*   Conselleria d'Infraestructures i Transport
23
*   Av. Blasco Ib??ez, 50
24
*   46010 VALENCIA
25
*   SPAIN
26
*
27
*      +34 963862235
28
*   gvsig@gva.es
29
*      www.gvsig.gva.es
30
*
31
*    or
32
*
33
*   IVER T.I. S.A
34
*   Salamanca 50
35
*   46005 Valencia
36
*   Spain
37
*
38
*   +34 963163400
39
*   dac@iver.es
40
*/
41
package com.iver.cit.gvsig.gui.toc;
42

  
43
import java.awt.event.ActionEvent;
44

  
45
import javax.swing.JDesktopPane;
46
import javax.swing.JInternalFrame;
47
import javax.swing.JLayeredPane;
48
import javax.swing.JMenuItem;
49
import javax.swing.event.InternalFrameEvent;
50
import javax.swing.event.InternalFrameListener;
51

  
52
import com.iver.andami.PluginServices;
53
import com.iver.andami.ui.mdiFrame.MDIFrame;
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.fmap.layers.FLyrPoints;
58
import com.iver.cit.gvsig.gui.View;
59
import com.iver.cit.gvsig.gui.Dialogs.GeoreferencingDialog;
60
import com.iver.cit.gvsig.gui.Panels.GeoRasterWizard;
61

  
62
/**
63
 * Cambia las propiedades de la conexi?n al servidor WCS.
64
 * 
65
 * @author Nacho Brodin brodin_ign@gva.es
66
 */
67
public class GeoRasterTocMenuEntry  extends TocMenuEntry implements InternalFrameListener {
68
	private JMenuItem propsMenuItem;
69
	private FLayer lyr = null;
70

  
71
	
72
	public void initialize(FPopupMenu m) {
73
		super.initialize(m);
74
		
75
		if (isTocItemBranch()) {
76
			lyr = getNodeLayer();
77
			
78
    		// Opcciones para capas FLyrGeoRaster
79
    		if ((lyr instanceof FLyrGeoRaster)) {
80
    			propsMenuItem = new JMenuItem(PluginServices.getText(this, "georaster_properties"));
81
    			getMenu().add( propsMenuItem );
82
    			propsMenuItem.setFont(FPopupMenu.theFont);
83
    			getMenu().setEnabled(true);
84
    			propsMenuItem.addActionListener(this);   			
85
     		}
86
		}
87
	}
88
		
89
	/**
90
	 * Evento producido al pulsar la entrada de men? del toc
91
	 * que muestra el cuadro con el dialogo de las propiedades 
92
	 * de la capa de raster georreferenciada.
93
	 */
94
	public void actionPerformed(ActionEvent e) {
95
		FLyrGeoRaster lyrGeoRaster = null;
96
       	lyr = getNodeLayer();
97
       	
98
       	//Modificamos el nombre de la capa
99
		if ((lyr instanceof FLyrGeoRaster)){
100
			lyrGeoRaster = (FLyrGeoRaster)lyr;
101
			lyrGeoRaster.setName("*"+lyrGeoRaster.getName());
102
		}
103
		
104
		//Lanzamos el dialogo 
105
		PluginServices.getMainFrame().enableControls();
106
		View vista = (View) PluginServices.getMDIManager().getActiveView();
107
		MapControl mapCtrl = vista.getMapControl();
108
				
109
		JInternalFrame panel = new JInternalFrame();
110
		panel.addInternalFrameListener(this);
111
        panel.setClosable(true);
112
        panel.setSize(400, 340);
113
        panel.setTitle(PluginServices.getText(this,"georreferenciar"));
114
        panel.getContentPane().add(GeoRasterWizard.geoDialog);
115
        GeoRasterWizard.geoDialog.setFrame(panel);
116
        
117
        MDIFrame mainFrame = (MDIFrame) PluginServices.getMainFrame();
118
        JLayeredPane lyrPane = mainFrame.getLayeredPane();
119
        lyrPane.add(panel, JDesktopPane.PALETTE_LAYER);       
120
        panel.show();   
121
        
122
        //Cargamos la capa de puntos y los puntos desde la capa en el cuadro.
123
        GeoRasterWizard.geoDialog.getSelectPointsPanel().loadFromLyrPoints(lyrGeoRaster.getFLyrPoints());
124
	}
125
	
126
	/**
127
	 * Cuando cerramos la ventana de georreferenciaci?n se elimina la barra de herramientas
128
	 * y se destruye la capa de puntos.
129
	 */
130
	public void internalFrameClosing(InternalFrameEvent arg0) {
131
		//Eliminamos la capa de puntos 
132
		
133
		FLyrPoints lyrPoints = null;
134
		View theView = (View) PluginServices.getMDIManager().getActiveView();
135
		for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
136
			FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
137
			if(lyr instanceof FLyrPoints)
138
				theView.getMapControl().getMapContext().getLayers().removeLayer(i);
139
		}
140
	
141
		PluginServices.getMainFrame().enableControls();
142
	}
143
	
144
	/* (non-Javadoc)
145
	 * @see javax.swing.event.InternalFrameListener#internalFrameActivated(javax.swing.event.InternalFrameEvent)
146
	 */
147
	public void internalFrameActivated(InternalFrameEvent arg0) {
148
		// TODO Auto-generated method stub
149

  
150
	}
151
	/* (non-Javadoc)
152
	 * @see javax.swing.event.InternalFrameListener#internalFrameClosed(javax.swing.event.InternalFrameEvent)
153
	 */
154
	public void internalFrameClosed(InternalFrameEvent arg0) {
155
		// TODO Auto-generated method stub
156

  
157
	}
158

  
159
	/* (non-Javadoc)
160
	 * @see javax.swing.event.InternalFrameListener#internalFrameDeactivated(javax.swing.event.InternalFrameEvent)
161
	 */
162
	public void internalFrameDeactivated(InternalFrameEvent arg0) {
163
		// TODO Auto-generated method stub
164

  
165
	}
166
	/* (non-Javadoc)
167
	 * @see javax.swing.event.InternalFrameListener#internalFrameDeiconified(javax.swing.event.InternalFrameEvent)
168
	 */
169
	public void internalFrameDeiconified(InternalFrameEvent arg0) {
170
		// TODO Auto-generated method stub
171

  
172
	}
173
	/* (non-Javadoc)
174
	 * @see javax.swing.event.InternalFrameListener#internalFrameIconified(javax.swing.event.InternalFrameEvent)
175
	 */
176
	public void internalFrameIconified(InternalFrameEvent arg0) {
177
		// TODO Auto-generated method stub
178

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

  
186
	}
187
}
0 188

  
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/toolListeners/GeorefPointerListener.java
142 142
					wcHeight = lyrGeoRaster.getFullExtent().getHeight();
143 143
					ptoWCX = wcPoint.getX() - lyrGeoRaster.getFullExtent().getMinX();
144 144
					ptoWCY = wcPoint.getY() - lyrGeoRaster.getFullExtent().getMinY();
145
					pixelImgX = (int)((ptoWCX * SelectFilePanel.widthPxImg) / wcWidth);
146
					pixelImgY = (int)((ptoWCY * SelectFilePanel.heightPxImg) / wcHeight);
145
					pixelImgX = (int)((ptoWCX * lyrGeoRaster.getImageWidth()) / wcWidth);
146
					pixelImgY = (int)((ptoWCY * lyrGeoRaster.getImageHeight()) / wcHeight);
147 147
				}catch(DriverException ex){}
148 148
				 
149 149
				
trunk/extensions/extGeoreferencing/text.properties
17 17
coordenadas_vacias=Coordenadas vacias
18 18
asignar_coordenadas=Asignar Coordenadas
19 19
fuera_de_extent=El punto seleccionado est? fuera del extent de la imagen
20
georef=Georreferenciar
trunk/extensions/extGeoreferencing/config/config.xml
8 8
			description="Extensi?n encargada activar las herramientas de georeferenciar raster."
9 9
			active="true" 
10 10
			priority="1">
11
			<!--
11 12
			<tool-bar name="GeoreferencingWizard">
12 13
				<action-tool icon="images/georef.png" action-command="GEOREF_WIZARD" tooltip="Georeferenciar"/>
13 14
			</tool-bar>
15
			-->
14 16
		</extension>
15
			<extension class-name="com.iver.cit.gvsig.georeferencing.GeoreferencingToolsModule" 
17
		<extension class-name="com.iver.cit.gvsig.georeferencing.GeoreferencingToolsModule" 
16 18
			description="Extensi?n encargada georeferenciar raster."
17 19
			active="true" 
18 20
			priority="1">
19 21
			<tool-bar name="GeoreferencingTools">
20
				<action-tool icon="images/mas.png" action-command="GEO_ZOOM" tooltip="Zoom_Mas"/>
21
				<action-tool icon="images/clean.png" action-command="GEO_PAN"  tooltip="Mover"/>
22
				<action-tool icon="images/back.png" action-command="GEO_ZOOM_PREV"  tooltip="Zoom_previo"/>
22
				<selectable-tool icon="images/mas.png" action-command="GEO_ZOOM" tooltip="Zoom_Mas"/>
23
				<selectable-tool icon="images/clean.png" action-command="GEO_PAN"  tooltip="Mover"/>
24
				<selectable-tool icon="images/back.png" action-command="GEO_ZOOM_PREV"  tooltip="Zoom_previo"/>
23 25
			</tool-bar>
24 26
		</extension>
25 27
	</extensions>

Also available in: Unified diff