Revision 18251 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/georeferencing/Georeferencing.java

View differences:

Georeferencing.java
30 30
import org.gvsig.raster.util.RasterToolsUtil;
31 31
import org.gvsig.rastertools.georeferencing.ui.launcher.GeorefLauncherDialog;
32 32
import org.gvsig.rastertools.georeferencing.ui.table.GCPTablePanel;
33
import org.gvsig.rastertools.georeferencing.ui.zoom.InvalidRequestException;
33 34
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewRasterRequestManager;
35
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.ZoomCursorGraphicLayer;
36
import org.gvsig.rastertools.georeferencing.ui.zoom.tools.ToolEvent;
37
import org.gvsig.rastertools.georeferencing.ui.zoom.tools.ToolListener;
34 38
import org.gvsig.rastertools.georeferencing.view.ViewDialog;
35 39
import org.gvsig.rastertools.georeferencing.view.ZoomMapDialog;
36 40
import org.gvsig.rastertools.georeferencing.view.ZoomRasterDialog;
......
58 62
 * 26/12/2007
59 63
 * @author Nacho Brodin (nachobrodin@gmail.com)
60 64
 */
61
public class Georeferencing implements ButtonsPanelListener {
62
	public static final int               UNDEFINED = -1;
65
public class Georeferencing implements ButtonsPanelListener, ToolListener {
66
	public static final int               UNDEFINED                      = -1;
63 67
	//Algoritmo
64
	public static final int               POLYNOMIAL = 0;
65
	public static final int               AFFINE = 1;
68
	public static final int               POLYNOMIAL                     = 0;
69
	public static final int               AFFINE                         = 1;
66 70
	
67 71
	//Tipo de georreferenciacion
68
	public static final int               WITH_MAP = 0;
69
	public static final int               WITHOUT_MAP = 1;
72
	public static final int               WITH_MAP                       = 0;
73
	public static final int               WITHOUT_MAP                    = 1;
70 74
	
71
	private static int                    DEFAULT_DEGREE = 3;
75
	private static int                    DEFAULT_DEGREE                 = 3;
72 76
	
73
	private GeorefLauncherDialog          initDialog = null;
74
	private FLyrRasterSE                  lyrToGeoref = null;
75
	private static GCPTablePanel          table = null;
76
	private static ZoomMapDialog          zoomMap = null;
77
	private static ZoomRasterDialog       zoomPixel = null;
78
	private static ViewDialog              view = null;
79
	private static final int              smallWindowsHeight = 100;
80
	private static final double           smallWindowsWidthPercent = 0.5;
81
	private ViewRasterRequestManager      viewRequestManager = null;
77
	private GeorefLauncherDialog          initDialog                     = null;
78
	private FLyrRasterSE                  lyrToGeoref                    = null;
79
	private static GCPTablePanel          table                          = null;
80
	private static ZoomMapDialog          zoomMap                        = null;
81
	private static ZoomRasterDialog       zoomPixel                      = null;
82
	private static ViewDialog             view                           = null;
83
	private static final int              smallWindowsHeight             = 100;
84
	private static final double           smallWindowsWidthPercent       = 0.5;
85
	private ViewRasterRequestManager      viewRequestManager             = null;
86
	private ViewRasterRequestManager      viewRequestManagerZoomPixel    = null;
82 87
	
83 88
	public Georeferencing() {
84 89
		
......
123 128
		if(table != null)
124 129
			PluginServices.getMDIManager().closeWindow(table);
125 130
		
126
		zoomMap = new ZoomMapDialog(0, posYViews, smallWindowsWidth, smallWindowsHeight);
127 131
		table = new GCPTablePanel(smallWindowsWidth, posYViews, tableWidth, smallWindowsHeight);
128
		zoomPixel = new ZoomRasterDialog(smallWindowsWidth + tableWidth, posYViews, smallWindowsWidth, smallWindowsHeight);
129 132
		
130
		view = new ViewDialog(wViews, 0, wViews, hViews);
133
		//Inicializaci?n de la vista raster
134
		view = new ViewDialog(wViews, 0, wViews, hViews, this);
131 135
		view.setShowInfo(true);
132
		//Gestor de peticiones a la capa (IExtensionRequest)
133
		ViewRasterRequestManager viewRequestManager = new ViewRasterRequestManager(view, lyrToGeoref);
134
		//Asignamos al componente cual ser? su gestor de peticiones. Cada vez que se pulse un zoom el componente har? 
135
		//una llamada request a su gestor de peticiones
136
		viewRequestManager = new ViewRasterRequestManager(view, lyrToGeoref);
136 137
		view.setExtensionRequest(viewRequestManager);
137 138
		
139
		//Inicializaci?n del zoom de la vista raster
140
		zoomPixel = new ZoomRasterDialog(smallWindowsWidth + tableWidth, posYViews, smallWindowsWidth, smallWindowsHeight);
141
		viewRequestManagerZoomPixel = new ViewRasterRequestManager(zoomPixel, lyrToGeoref);
142
		zoomPixel.setExtensionRequest(viewRequestManagerZoomPixel);
143
		
144
		//Inicializaci?n del zoom de la vista de referencia
145
		zoomMap = new ZoomMapDialog(0, posYViews, smallWindowsWidth, smallWindowsHeight);
146
		
138 147
		/*GeoPoint gp = new GeoPoint(new Point2D.Double(100, 100), null);
139 148
		GPGraphic gpg = new GPGraphic(GPGraphic.PIXEL, gp);
140 149
		view.getPixelGraphicLayer().addGeoPoint(gpg);*/
......
145 154
		if(imgRasterToGeoref != null)
146 155
			setPixelParams(imgRasterToGeoref, lyrToGeoref);
147 156
		*/
157
		//A?adimos las ventanas a gvSIG
148 158
		PluginServices.getMDIManager().addWindow(view);
149 159
		PluginServices.getMDIManager().addWindow(table);
150 160
		PluginServices.getMDIManager().addWindow(zoomMap);
151 161
		PluginServices.getMDIManager().addWindow(zoomPixel);
152 162
		
153 163
		//Inicializamos la extensi?n del componente y dibujamos
154
		viewRequestManager.initRequest(lyrToGeoref.getFullExtent());
155
		view.setZoomCursorSize(zoomPixel.getCanvasWidth(), zoomPixel.getCanvasHeight());
164
		try {
165
			viewRequestManager.initRequest(lyrToGeoref.getFullExtent());
166
			view.setZoomCursorSize(zoomPixel.getCanvasWidth() / 3, zoomPixel.getCanvasHeight() / 3);
167
			
168
			Rectangle2D ext = view.getCursorWorldCoordinates();
169
			viewRequestManagerZoomPixel.request(ext);
170
		} catch (InvalidRequestException e1) {
171
			RasterToolsUtil.messageBoxError("error_setview_preview", this);
172
		}
173
		
156 174
	}
157 175
	
158 176
	/**
......
164 182
		if(zoomMap != null && img != null) {
165 183
			Rectangle2D r = vp.getAdjustedExtent();
166 184
			int w = vp.getImageWidth();
167
			zoomMap.setMapDrawParams(img, r, r.getWidth() / w, new Point2D.Double(r.getCenterX(), r.getCenterY()));
185
			zoomMap.setDrawParams(img, r, r.getWidth() / w, new Point2D.Double(r.getCenterX(), r.getCenterY()));
168 186
			zoomMap.getMapGraphicLayer();
169 187
		}
170 188
	}
......
176 194
	 */
177 195
	public void setPixelParams(BufferedImage img, FLyrRasterSE lyr) {
178 196
		if(view != null && zoomPixel != null && img != null && lyr != null) {
179
			Rectangle2D extBuf = viewRequestManager.request(null);
180
			
181
			viewRequestManager.setDrawParams(img, extBuf);	
182
			zoomPixel.setPixelDrawParams(img, extBuf, extBuf.getHeight()/img.getHeight(), new Point2D.Double(extBuf.getCenterX(), extBuf.getCenterY()));
183
			zoomPixel.getPixelGraphicLayer();
197
			Rectangle2D extBuf;
198
			try {
199
				extBuf = viewRequestManager.request(null);
200
				viewRequestManager.setDrawParams(img, extBuf);	
201
				zoomPixel.setDrawParams(img, extBuf, extBuf.getHeight()/img.getHeight(), new Point2D.Double(extBuf.getCenterX(), extBuf.getCenterY()));
202
				zoomPixel.getPixelGraphicLayer();
203
			} catch (InvalidRequestException e1) {
204
				RasterToolsUtil.messageBoxError("error_setview_preview", this);
205
			}
184 206
		}
185 207
	}
186 208
	
......
220 242
				PluginServices.getMDIManager().closeWindow(initDialog);
221 243
		}
222 244
	}
245

  
246
	/**
247
	 * Evento de finalizaci?n de la capa con el 
248
	 * cursor gr?fico que controla el ?rea de la miniimagen asociada
249
	 */
250
	public void endAction(ToolEvent ev) {
251
		if(ev.getSource() instanceof ZoomCursorGraphicLayer) {
252
			try {				
253
				Rectangle2D ext = view.getCursorAdjustedWorldCoordinates(zoomPixel.getCanvasWidth(), zoomPixel.getCanvasHeight());
254
				viewRequestManagerZoomPixel.request(ext);
255
			} catch (InvalidRequestException e1) {
256
				RasterToolsUtil.messageBoxError("error_setview_preview", this);
257
			}
258
		}
259
	}
223 260
}

Also available in: Unified diff