Revision 2987 trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/toolListeners/GeorefPointerListener.java

View differences:

GeorefPointerListener.java
40 40
 */
41 41
package com.iver.cit.gvsig.gui.toolListeners;
42 42

  
43
import java.awt.Component;
43 44
import java.awt.geom.Point2D;
44 45

  
46
import javax.swing.JOptionPane;
47

  
45 48
import com.iver.andami.PluginServices;
46 49
import com.iver.cit.gvsig.fmap.DriverException;
47 50
import com.iver.cit.gvsig.fmap.ViewPort;
......
54 57
import com.iver.cit.gvsig.gui.View;
55 58
import com.iver.cit.gvsig.gui.Dialogs.GeoreferencingDialog;
56 59
import com.iver.cit.gvsig.gui.Panels.SelectFilePanel;
60
import com.iver.cit.gvsig.gui.Panels.SelectPointsPanel;
57 61

  
58 62

  
59 63
/**
......
66 70
public class GeorefPointerListener extends GeorefPointerListenerImpl {
67 71
	
68 72
	private GeoreferencingDialog dialog = null;
69
	private boolean firstPoint = true;
70 73
	private View theView = null;
71 74
	private FLyrPoints lyrPoints = null;
72 75
	private FLyrGeoRaster lyrGeoRaster = null;
73 76
	
77
	/**
78
	* true si se va a seleccionar el primer punto y false si se selecciona el segundo.
79
	* 
80
	*/
81
	public static boolean firstPoint = true;
74 82
	
83
	
75 84
	/**
76 85
	 * Posici?n del punto a ser seleccionado. 
77 86
	 */
......
104 113
			FLayer lyr = theView.getMapControl().getMapContext().getLayers().getLayer(i);
105 114
			if(lyr instanceof FLyrPoints)
106 115
				lyrPoints = (FLyrPoints)lyr;
107
			if(lyr instanceof FLyrGeoRaster)
116
			if(lyr instanceof FLyrGeoRaster && lyr.getName().startsWith("*"))
108 117
				lyrGeoRaster = (FLyrGeoRaster)lyr;
109 118
		}
110 119
		
111 120
		ViewPort viewPort = theView.getMapControl().getMapContext().getViewPort();
112 121
		Point2D wcPoint = viewPort.toMapPoint(event.getPoint());
113
		
122
				
114 123
		if(firstPoint){	
115 124
			if(lyrPoints != null){
116
						
125
				
126
				//Si el punto cae fuera de la imagen mostramos un mensaje y salimos
127
				while(	wcPoint.getX() < lyrGeoRaster.getMinX() ||
128
					wcPoint.getX() > lyrGeoRaster.getMaxX() ||
129
					wcPoint.getY() < lyrGeoRaster.getMinY() ||
130
					wcPoint.getY() > lyrGeoRaster.getMaxY()){
131
					JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),
132
							PluginServices.getText(this, "fuera_de_extent"));
133
					return;
134
				}
135
				
117 136
				//Hallamos pixelImg q son las coordenadas en pixeles de la imagen que corresponden
118 137
				//con el punto seleccionado
119 138
				double wcWidth = 0.0, wcHeight = 0.0, ptoWCX = 0.0, ptoWCY = 0.0;
......
141 160
			lyrPoints.getPoint(GeorefPointerListener.posPoint).mapPoint = new Point2D.Double();
142 161
			lyrPoints.getPoint(GeorefPointerListener.posPoint).mapPoint.setLocation(wcPoint);
143 162
			//Cargamos en la ventana el nuevo punto
144
			dialog.getSelectPointsPanel().getLongitud().setText(String.valueOf(wcPoint.getX()));
145
			dialog.getSelectPointsPanel().getLatitud().setText(String.valueOf(wcPoint.getY()));
163
			dialog.getSelectPointsPanel().getLongitud().setText(SelectPointsPanel.tailDecimal(String.valueOf(wcPoint.getX())));
164
			dialog.getSelectPointsPanel().getLatitud().setText(SelectPointsPanel.tailDecimal(String.valueOf(wcPoint.getY())));
146 165
									
147 166
			//Deseleccionamos la herramienta de marcado de puntos
148 167
			theView.getMapControl().setTool(lyrPoints.getLastTool());

Also available in: Unified diff