Revision 2998

View differences:

trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/fmap/layers/FLyrPoints.java
46 46
import java.awt.geom.Rectangle2D;
47 47
import java.awt.image.BufferedImage;
48 48
import java.util.ArrayList;
49
import java.util.Iterator;
49 50

  
50 51
import com.iver.andami.PluginServices;
51 52
import com.iver.cit.gvsig.fmap.DriverException;
......
157 158
	}
158 159
	
159 160
	/**
161
	 * Elimina los puntos de la lista que no tiene las dos coordenadas asignadas.
162
	 */
163
	public void clean(){
164
		Iterator iter = pointList.iterator();
165
		while (iter.hasNext()) {
166
			GeoPoint gp = (GeoPoint) iter.next();
167
			if(gp.mapPoint == null || gp.pixelPoint == null)
168
				iter.remove();
169
		}
170
	}
171
	/**
160 172
	 * A?ade un punto a la lista
161 173
	 * @param point punto para la lista
162 174
	 */
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/Dialogs/GeoreferencingDialog.java
360 360
			bCancelar = new JButton();
361 361
			bCancelar.setText(PluginServices.getText(this,"cancelar"));
362 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
363
				public void actionPerformed(java.awt.event.ActionEvent e) {   					
364
					//Cerramos la ventana 
365
					//(se ejecuta el evento internalFrameClosing de GeoRasterFrameListener)
384 366
					try{
385 367
						frame.setClosed(true);
386 368
					}catch(PropertyVetoException exc){}
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/Panels/GeoRasterWizard.java
90 90
 * Clase que implementa el Wizard para la georreferenciaci?n
91 91
 * @author Nacho Brodin (brodin_ign@gva.es)
92 92
 */
93
public class GeoRasterWizard extends WizardPanel implements InternalFrameListener {
93
public class GeoRasterWizard extends WizardPanel{
94 94
	private JPanel pGeneral = null;
95 95
	private JPanel pFileSelection = null;
96 96
	private JPanel pControls = null;
......
436 436
			lyrGeoRaster.setAssignExtent(ext);    
437 437
		
438 438
		JInternalFrame panel = new JInternalFrame();
439
		panel.addInternalFrameListener(this);
439
		panel.addInternalFrameListener(new com.iver.cit.gvsig.gui.toolListeners.GeoRasterFrameListener());
440 440
        panel.setClosable(true);
441 441
        geoDialog = new GeoreferencingDialog(panel);
442 442
        panel.setSize(400, 340);
......
594 594
		super.setTabName(name);
595 595
	}
596 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 597
}
658 598

  
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/Panels/SelectPointsPanel.java
112 112
			lPoint.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
113 113
			lPoint.setPreferredSize(new java.awt.Dimension(46,15));
114 114
			lNumberOfPoints = new JLabel();
115
			lNumberOfPoints.setText(PluginServices.getText(this, "de") + " 1");
115
			lNumberOfPoints.setText(PluginServices.getText(this, "de") + " 0");
116 116
			lNumberOfPoints.setPreferredSize(new java.awt.Dimension(37,15));
117 117
			FlowLayout flowLayout = new FlowLayout();
118 118
			flowLayout.setVgap(8);
......
296 296
		resetControls(false);
297 297
		isNew = true;
298 298
		getCPoint().removeAllItems();
299
		lNumberOfPoints.setText(PluginServices.getText(this, "de") + " " + lyrPoints.getCountPoints());
299 300
		checkArrows();
300 301
		View theView = (View) PluginServices.getMDIManager().getActiveView();
301 302
		theView.getMapControl().getMapContext().invalidate();
......
382 383
						lyrPoints.addPoint(null, null);
383 384
						isNew = true;
384 385
						getCPoint().addItem("" + lyrPoints.getCountPoints());
386
						lNumberOfPoints.setText(PluginServices.getText(this, "de ") + " " + lyrPoints.getCountPoints());
385 387
						isNew = true;
386 388
						lastIndexSelection = lyrPoints.getCountPoints() - 1;
387 389
						getCPoint().setSelectedIndex(getCPoint().getItemCount() - 1);
......
453 455
							getCPoint().setSelectedIndex(posSelect - 1);
454 456
							loadInfoPoint(posSelect - 1);
455 457
						}
458
						lNumberOfPoints.setText(PluginServices.getText(this, "de ") + " " + lyrPoints.getCountPoints());
456 459
						checkArrows();
457 460
					}
458 461
				}
......
826 829
	 */
827 830
	public void loadFromLyrPoints(FLyrPoints lyr){
828 831
		if(lyr != null){
832
			lyr.clean();
829 833
			lyrPoints = lyr;
830 834
			View theView = (View) PluginServices.getMDIManager().getActiveView();
831 835
			theView.getMapControl().getMapContext().beginAtomicEvent();
......
835 839
			this.getCPoint().removeAllItems();
836 840
			for(int i=0;i<lyr.getCountPoints();i++)
837 841
				this.getCPoint().addItem("" + (i + 1));
842
			lNumberOfPoints.setText(PluginServices.getText(this, "de") + " " + lyrPoints.getCountPoints());
838 843
			if(lyr.getCountPoints() >= 1){
839 844
				changePoint(true, 0);
840 845
				getBSelectFromView().setEnabled(true);
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/toc/GeoRasterTocMenuEntry.java
46 46
import javax.swing.JInternalFrame;
47 47
import javax.swing.JLayeredPane;
48 48
import javax.swing.JMenuItem;
49
import javax.swing.event.InternalFrameEvent;
50
import javax.swing.event.InternalFrameListener;
51 49

  
52 50
import com.iver.andami.PluginServices;
53 51
import com.iver.andami.ui.mdiFrame.MDIFrame;
54 52
import com.iver.cit.gvsig.fmap.MapControl;
55 53
import com.iver.cit.gvsig.fmap.layers.FLayer;
56 54
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster;
57
import com.iver.cit.gvsig.fmap.layers.FLyrPoints;
58 55
import com.iver.cit.gvsig.gui.View;
59
import com.iver.cit.gvsig.gui.Dialogs.GeoreferencingDialog;
60 56
import com.iver.cit.gvsig.gui.Panels.GeoRasterWizard;
61 57

  
62 58
/**
......
64 60
 * 
65 61
 * @author Nacho Brodin brodin_ign@gva.es
66 62
 */
67
public class GeoRasterTocMenuEntry  extends TocMenuEntry implements InternalFrameListener {
63
public class GeoRasterTocMenuEntry  extends TocMenuEntry{
68 64
	private JMenuItem propsMenuItem;
69 65
	private FLayer lyr = null;
70 66

  
......
107 103
		MapControl mapCtrl = vista.getMapControl();
108 104
				
109 105
		JInternalFrame panel = new JInternalFrame();
110
		panel.addInternalFrameListener(this);
106
		panel.addInternalFrameListener(new com.iver.cit.gvsig.gui.toolListeners.GeoRasterFrameListener());
111 107
        panel.setClosable(true);
112 108
        panel.setSize(400, 340);
113 109
        panel.setTitle(PluginServices.getText(this,"georreferenciar"));
......
122 118
        //Cargamos la capa de puntos y los puntos desde la capa en el cuadro.
123 119
        GeoRasterWizard.geoDialog.getSelectPointsPanel().loadFromLyrPoints(lyrGeoRaster.getFLyrPoints());
124 120
	}
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 121
}
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/toolListeners/GeoRasterFrameListener.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.toolListeners;
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 maneja los eventos del frame que contiene los paneles de georreferenciaci?n.
91
* @author Nacho Brodin (brodin_ign@gva.es)
92
*/
93
public class GeoRasterFrameListener implements InternalFrameListener {
94
		
95
	/**
96
	 * This is the default constructor
97
	 */
98
	public GeoRasterFrameListener() {
99
		super();
100
	}
101
	
102
	/**
103
	 * Cuando cerramos la ventana de georreferenciaci?n se elimina la barra de herramientas
104
	 * y se destruye la capa de puntos.
105
	 */
106
	public void internalFrameClosing(InternalFrameEvent arg0) {
107

  
108
		//Anulamos todos los cambios cargando el extent de origen a la capa 
109
		//Cambiamos el nombre a la capa de georreferenciaci?n y eliminamos la capa de puntos.
110
		View theView = (View) PluginServices.getMDIManager().getActiveView();
111
		FLyrPoints lyrPoints = null;
112
		
113
		for(int i=0;i<theView.getMapControl().getMapContext().getLayers().getLayersCount();i++){
114
			FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
115
			if(	lyr instanceof FLyrGeoRaster && 
116
				lyr.getName().startsWith("*") &&
117
				lyr.isActive()){
118
				lyr.setName(lyr.getName().substring(1, lyr.getName().length()));
119
				Extent initExtent = ((FLyrGeoRaster)lyr).getStackZoom().getInitExtent();
120
				if(initExtent != null){
121
					((FLyrGeoRaster)theView.getMapControl().getMapContext().getLayers().getLayer(lyr.getName())).setAssignExtent(initExtent);
122
					theView.getMapControl().getMapContext().invalidate();
123
				}
124
			}
125
			if(	lyr instanceof FLyrPoints)
126
				theView.getMapControl().getMapContext().getLayers().removeLayer(i);
127
			
128
			
129
		}
130
		
131
		PluginServices.getMainFrame().enableControls();
132
	}
133
	
134
	/* (non-Javadoc)
135
	 * @see javax.swing.event.InternalFrameListener#internalFrameActivated(javax.swing.event.InternalFrameEvent)
136
	 */
137
	public void internalFrameActivated(InternalFrameEvent arg0) {
138
		// TODO Auto-generated method stub
139

  
140
	}
141
	
142
	/* (non-Javadoc)
143
	 * @see javax.swing.event.InternalFrameListener#internalFrameClosed(javax.swing.event.InternalFrameEvent)
144
	 */
145
	public void internalFrameClosed(InternalFrameEvent arg0) {
146
		// TODO Auto-generated method stub
147
	}
148

  
149
	/* (non-Javadoc)
150
	 * @see javax.swing.event.InternalFrameListener#internalFrameDeactivated(javax.swing.event.InternalFrameEvent)
151
	 */
152
	public void internalFrameDeactivated(InternalFrameEvent arg0) {
153
		// TODO Auto-generated method stub
154
	}
155
	
156
	/* (non-Javadoc)
157
	 * @see javax.swing.event.InternalFrameListener#internalFrameDeiconified(javax.swing.event.InternalFrameEvent)
158
	 */
159
	public void internalFrameDeiconified(InternalFrameEvent arg0) {
160
		// TODO Auto-generated method stub
161
	}
162
	
163
	/* (non-Javadoc)
164
	 * @see javax.swing.event.InternalFrameListener#internalFrameIconified(javax.swing.event.InternalFrameEvent)
165
	 */
166
	public void internalFrameIconified(InternalFrameEvent arg0) {
167
		// TODO Auto-generated method stub
168
	}
169
	
170
	/* (non-Javadoc)
171
	 * @see javax.swing.event.InternalFrameListener#internalFrameOpened(javax.swing.event.InternalFrameEvent)
172
	 */
173
	public void internalFrameOpened(InternalFrameEvent arg0) {
174
		// TODO Auto-generated method stub
175
	}
176
}
177

  
0 178

  

Also available in: Unified diff