gvsig-raster / org.gvsig.raster.georeferencing / trunk / org.gvsig.raster.georeferencing / org.gvsig.raster.georeferencing.app / org.gvsig.raster.georeferencing.app.georeferencingclient / src / main / java / org / gvsig / raster / georeferencing / app / georeferencingclient / Georeferencing.java @ 1711
History | View | Annotate | Download (27 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.georeferencing.app.georeferencingclient; |
23 |
|
24 |
import java.awt.geom.Rectangle2D; |
25 |
import java.util.ArrayList; |
26 |
import java.util.List; |
27 |
|
28 |
import javax.swing.JPanel; |
29 |
|
30 |
import org.gvsig.andami.PluginServices; |
31 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
32 |
import org.gvsig.app.ApplicationLocator; |
33 |
import org.gvsig.app.ApplicationManager; |
34 |
import org.gvsig.app.project.documents.Document; |
35 |
import org.gvsig.app.project.documents.view.ViewDocument; |
36 |
import org.gvsig.app.project.documents.view.gui.IView; |
37 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
38 |
import org.gvsig.fmap.geom.primitive.Envelope; |
39 |
import org.gvsig.fmap.mapcontrol.MapControl; |
40 |
import org.gvsig.i18n.Messages; |
41 |
import org.gvsig.raster.georeferencing.app.georeferencingclient.gui.CheckBoxColumnEditor; |
42 |
import org.gvsig.raster.georeferencing.app.georeferencingclient.gui.CheckBoxColumnRenderer; |
43 |
import org.gvsig.raster.georeferencing.app.georeferencingclient.gui.GCPModel; |
44 |
import org.gvsig.raster.georeferencing.app.georeferencingclient.listener.LauncherDialogListener; |
45 |
import org.gvsig.raster.georeferencing.app.georeferencingclient.listener.TableDialogListener; |
46 |
import org.gvsig.raster.georeferencing.app.georeferencingclient.listener.ViewDialogListener; |
47 |
import org.gvsig.raster.georeferencing.app.georeferencingclient.listener.ViewRasterRequestManager; |
48 |
import org.gvsig.raster.georeferencing.framework.GeoreferencingFrameworkLocator; |
49 |
import org.gvsig.raster.georeferencing.framework.GeoreferencingFrameworkManager; |
50 |
import org.gvsig.raster.georeferencing.framework.LayoutEnvironment; |
51 |
import org.gvsig.raster.georeferencing.swing.GeoreferencingLauncher; |
52 |
import org.gvsig.raster.georeferencing.swing.GeoreferencingOptionsDataModel; |
53 |
import org.gvsig.raster.georeferencing.swing.GeoreferencingSwingLibrary; |
54 |
import org.gvsig.raster.georeferencing.swing.GeoreferencingSwingLocator; |
55 |
import org.gvsig.raster.georeferencing.swing.GeoreferencingSwingManager; |
56 |
import org.gvsig.raster.georeferencing.swing.control.GeorefControlPanel; |
57 |
import org.gvsig.raster.georeferencing.swing.exception.InvalidRequestException; |
58 |
import org.gvsig.raster.georeferencing.swing.impl.GeoreferencingSwingImplLibrary; |
59 |
import org.gvsig.raster.georeferencing.swing.impl.tool.SelectPointTool; |
60 |
import org.gvsig.raster.georeferencing.swing.view.GeoreferencingView; |
61 |
import org.gvsig.raster.georeferencing.swing.view.SynchronizedViews; |
62 |
import org.gvsig.raster.georeferencing.swing.view.ToolEvent; |
63 |
import org.gvsig.raster.georeferencing.swing.view.ToolListener; |
64 |
import org.gvsig.raster.georeferencing.swing.view.ViewEvent; |
65 |
import org.gvsig.raster.swing.RasterSwingLocator; |
66 |
import org.gvsig.raster.swing.RasterSwingManager; |
67 |
import org.gvsig.raster.swing.pagedtable.ModelLoader; |
68 |
import org.gvsig.raster.swing.pagedtable.PagedTable; |
69 |
|
70 |
/**
|
71 |
* Clase principal para la georreferenciaci?n. Se encarga de la inicializaci?n
|
72 |
* de la funcionalidad. Las acciones a realizar son:
|
73 |
* <UL>
|
74 |
* <LI>Lanzamiento del dialogo de inicializaci?n.</LI>
|
75 |
* <LI>Carga de la capa raster a georreferenciar.</LI>
|
76 |
* <LI>Creaci?n de las ventanas si no han sido creadas previamente.</LI>
|
77 |
* <LI>Asignaci?n de tama?os y posiciones a las ventanas.</LI>
|
78 |
* </UL>
|
79 |
* 26/12/2007
|
80 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
81 |
*/
|
82 |
public class Georeferencing implements ToolListener { |
83 |
public static final int UNDEFINED = -1; |
84 |
//Algoritmo
|
85 |
public static final int POLYNOMIAL = 0; |
86 |
public static final int AFFINE = 1; |
87 |
|
88 |
//Tipo de georreferenciacion
|
89 |
public static final int WITH_MAP = 0; |
90 |
public static final int WITHOUT_MAP = 1; |
91 |
|
92 |
public static int DEFAULT_DEGREE = 3; |
93 |
public static int ZOOM_RATIO = 5; |
94 |
|
95 |
private GeoreferencingFrameworkManager
|
96 |
fManager = null;
|
97 |
private GeoreferencingSwingManager sManager = null; |
98 |
|
99 |
private RasterDataStore storeToGeoref = null; |
100 |
private String selectedView = null; |
101 |
|
102 |
private static final int smallWindowsHeight = 100; |
103 |
private static final double smallWindowsWidthPercent = 0.5; |
104 |
|
105 |
//Dialogos
|
106 |
private GeoreferencingLauncher initDialog = null; |
107 |
private GeoreferencingView viewRaster = null; |
108 |
private GeoreferencingView viewMap = null; |
109 |
private GeoreferencingView zoomMap = null; |
110 |
private GeoreferencingView zoomRaster = null; |
111 |
|
112 |
//Herramientas de selecci?n
|
113 |
private SelectPointTool viewRasterSelectPointTool = null; |
114 |
private SelectPointTool viewMapSelectPointTool = null; |
115 |
private SelectPointTool zoomRasterSelectPointTool = null; |
116 |
private SelectPointTool zoomMapSelectPointTool = null; |
117 |
|
118 |
private GeorefControlPanel georefControlPanel = null; |
119 |
|
120 |
private PagedTable table = null; |
121 |
private TableDialogListener buttonsListener = null; |
122 |
private GeoreferencingOptionsDataModel
|
123 |
optionsDataModel = null;
|
124 |
private MapControl mapCtrl = null; |
125 |
private GeoreferencingOptionsDataModel
|
126 |
dataModel = null;
|
127 |
|
128 |
//private LayersPointManager layersPointManager = null;
|
129 |
//private ViewsManager viewsManager = null;
|
130 |
|
131 |
public void initialize() { |
132 |
fManager = GeoreferencingFrameworkLocator.getManager(); |
133 |
sManager = GeoreferencingSwingLocator.getSwingManager(); |
134 |
//getLayerPointManager();
|
135 |
//getViewsManager();
|
136 |
launcher(); |
137 |
} |
138 |
|
139 |
/**
|
140 |
* Launcher of the initial dialog
|
141 |
*/
|
142 |
private void launcher() { |
143 |
ApplicationManager application = ApplicationLocator.getManager(); |
144 |
List<Document> docs = application.getProjectManager().getCurrentProject().getDocuments(); |
145 |
List<String> viewList = new ArrayList<String>(); |
146 |
for (int i = 0; i < docs.size(); i++) { |
147 |
Document doc = docs.get(i);
|
148 |
if(doc instanceof ViewDocument) { |
149 |
viewList.add(doc.getName()); |
150 |
} |
151 |
} |
152 |
|
153 |
|
154 |
GeoreferencingLauncher launcher = sManager.createWindowLauncher(viewList, DEFAULT_DEGREE); |
155 |
LauncherDialogListener listener = new LauncherDialogListener(this, launcher); |
156 |
launcher.setButtonsListener(listener); |
157 |
fManager.showWindow(launcher.getComponent(), 400, 420, Messages.getText("georeferencing")); |
158 |
} |
159 |
|
160 |
/**
|
161 |
* Obtiene el gestor para capas de puntos de la aplicaci?n,
|
162 |
* @return LayersPointManager
|
163 |
*/
|
164 |
/* if(layersPointManager == null)
|
165 |
layersPointManager = new LayersPointManager(this);
|
166 |
return layersPointManager;
|
167 |
}*/
|
168 |
|
169 |
/**
|
170 |
* Obtiene el gestor para las vistas de la aplicaci?n,
|
171 |
* @return ViewsManager
|
172 |
*/
|
173 |
/*public ViewsManager getViewsManager() {
|
174 |
if(viewsManager == null)
|
175 |
viewsManager = new ViewsManager();
|
176 |
return viewsManager;
|
177 |
}*/
|
178 |
|
179 |
public void setSelectedView(String selectedView) { |
180 |
this.selectedView = selectedView;
|
181 |
} |
182 |
|
183 |
/**
|
184 |
* Obtiene la lista de capas de la vista de gvSIG
|
185 |
* @return
|
186 |
*/
|
187 |
/*public FLayers getLayers() {
|
188 |
MapControl mapControl = null;
|
189 |
IWindow[] windowList = PluginServices.getMDIManager().getAllWindows();
|
190 |
for (int i = 0; i < windowList.length; i++) {
|
191 |
if(windowList[i] instanceof IView)
|
192 |
mapControl = ((IView)windowList[i]).getMapControl();
|
193 |
}
|
194 |
if(mapControl != null)
|
195 |
return mapControl.getMapContext().getLayers();
|
196 |
return null;
|
197 |
}*/
|
198 |
|
199 |
private MapControl getMapCtrl() {
|
200 |
if(mapCtrl == null) { |
201 |
IWindow[] windowList = PluginServices.getMDIManager().getAllWindows();
|
202 |
for (int i = 0; i < windowList.length; i++) { |
203 |
if(windowList[i] instanceof IView) { |
204 |
String name = ((IView)windowList[i]).getViewDocument().getName();
|
205 |
if(name.equals(dataModel.getSelectedView())) {
|
206 |
mapCtrl = ((IView)windowList[i]).getMapControl(); |
207 |
} |
208 |
} |
209 |
} |
210 |
} |
211 |
return mapCtrl;
|
212 |
} |
213 |
|
214 |
public void endLauncherDialog(GeoreferencingOptionsDataModel dataModel) { |
215 |
this.dataModel = dataModel;
|
216 |
if(dataModel.getType() == Georeferencing.WITH_MAP)
|
217 |
initWindowsWithMap(dataModel); |
218 |
if(dataModel.getType() == Georeferencing.WITHOUT_MAP)
|
219 |
initWindowsWithoutMap(dataModel); |
220 |
} |
221 |
|
222 |
/**
|
223 |
* Colocaci?n inicial de las ventanas del espacio de trabajo. Carga la configuraci?n
|
224 |
* de ventanas con cartograf?a de referencia.
|
225 |
*/
|
226 |
private void initWindowsWithoutMap(GeoreferencingOptionsDataModel dataModel) { |
227 |
RasterDataStore store = dataModel.getDataStore(); |
228 |
|
229 |
getOptions().setType(WITHOUT_MAP); |
230 |
|
231 |
//Inicializaci?n de la ventana con la vista raster
|
232 |
viewRaster = sManager.createView(true, false, true, this); |
233 |
ViewDialogListener listener = new ViewDialogListener(viewRaster, this); |
234 |
ViewRasterRequestManager viewRasterRequestManager = new ViewRasterRequestManager(viewRaster, store);
|
235 |
viewRaster.setViewListener(listener); |
236 |
viewRaster.setRequestListener(viewRasterRequestManager); |
237 |
viewRaster.setTool(GeoreferencingSwingLibrary.SELECT_POINT_TOOL, this);
|
238 |
|
239 |
//Inicializaci?n de la ventana del zoom de la vista raster
|
240 |
zoomRaster = sManager.createZoom(true, false); |
241 |
ViewRasterRequestManager zoomRasterRequestManager = new ViewRasterRequestManager(zoomRaster, store);
|
242 |
zoomRaster.setRequestListener(zoomRasterRequestManager); |
243 |
zoomRaster.setTool(GeoreferencingSwingLibrary.SELECT_POINT_TOOL, this);
|
244 |
|
245 |
georefControlPanel = sManager.createGeorefControlPanel(); |
246 |
|
247 |
//Creamos el layout
|
248 |
LayoutEnvironment layoutEnv = fManager.createLayoutEnvironment(); |
249 |
layoutEnv.setTable((JPanel)getTable(false, dataModel).getComponent()); |
250 |
layoutEnv.setViewRasterToGeoref(viewRaster.getComponent()); |
251 |
layoutEnv.setViewZoomRasterToGeoref(zoomRaster.getComponent()); |
252 |
layoutEnv.setControlBar(georefControlPanel.getComponent()); |
253 |
|
254 |
fManager.createLayout(layoutEnv); |
255 |
SynchronizedViews syncViews = sManager.createSyncViews(null, viewRaster, null, zoomRaster, table, this); |
256 |
|
257 |
//
|
258 |
// viewsManager.setViews(viewRaster, null, zoomRaster, null);
|
259 |
// viewsManager.setRequestsManager(viewRasterRequestManager, null, zoomRasterRequestManager, null);
|
260 |
// viewsManager.setTablePanel(table);
|
261 |
//
|
262 |
try {
|
263 |
viewRaster.setCursorSize(zoomRaster.getCanvasWidth() / ZOOM_RATIO, zoomRaster.getCanvasHeight() / ZOOM_RATIO); |
264 |
viewRaster.setCursorPosition(viewRaster.getCanvasWidth() / 2, viewRaster.getCanvasHeight() / 2); |
265 |
|
266 |
//Inicializamos la vista de raster
|
267 |
viewRasterRequestManager.initRequest(dataModel.getDataStore().getExtent().toRectangle2D()); |
268 |
|
269 |
//Inicializamos el zoom de raster
|
270 |
Rectangle2D ext = viewRaster.getCursorAdjustedWorldCoordinates(zoomRaster.getCanvasWidth(), zoomRaster.getCanvasHeight());
|
271 |
zoomRasterRequestManager.initRequest(dataModel.getDataStore().getExtent().toRectangle2D()); |
272 |
zoomRasterRequestManager.request(ext); |
273 |
|
274 |
} catch (InvalidRequestException e1) {
|
275 |
GeoreferencingSwingImplLibrary.messageBoxError("error_setview_preview", null, e1); |
276 |
fManager.closeAllWindows(); |
277 |
}catch (Exception e1) { |
278 |
GeoreferencingSwingImplLibrary.messageBoxError("error_setview_preview", null, e1); |
279 |
fManager.closeAllWindows(); |
280 |
} |
281 |
} |
282 |
|
283 |
private PagedTable getTable(boolean withMap, GeoreferencingOptionsDataModel dataModel) { |
284 |
if(table == null) { |
285 |
RasterSwingManager manager = RasterSwingLocator.getSwingManager(); |
286 |
String[] columnNames = { |
287 |
"-",
|
288 |
Messages.getText("num"),
|
289 |
Messages.getText("worldx"),
|
290 |
Messages.getText("worldy"),
|
291 |
Messages.getText("imagex"),
|
292 |
Messages.getText("imagey"),
|
293 |
"Error X", "Error Y", "RMS"}; |
294 |
int[] columnSizes = {40, 37, -1, -1, -1, -1, -1, -1, -1}; |
295 |
|
296 |
GCPModel model = new GCPModel(columnNames);
|
297 |
ModelLoader loader = manager.createModelLoader(model); |
298 |
CheckBoxColumnRenderer render = new CheckBoxColumnRenderer(null); |
299 |
CheckBoxColumnEditor editor = new CheckBoxColumnEditor();
|
300 |
loader.setRenderForColumn(0, render);
|
301 |
loader.setCellEditorForColumn(0, editor);
|
302 |
loader.setColumnNames(columnNames); |
303 |
loader.setColumnWidths(columnSizes); |
304 |
|
305 |
table = manager.createPagedTable(loader); |
306 |
} |
307 |
return table;
|
308 |
} |
309 |
|
310 |
/**
|
311 |
* Colocaci?n inicial de las ventanas del espacio de trabajo. Carga la configuraci?n
|
312 |
* de ventanas con cartograf?a de referencia.
|
313 |
*/
|
314 |
private void initWindowsWithMap(GeoreferencingOptionsDataModel dataModel) { |
315 |
RasterDataStore store = dataModel.getDataStore(); |
316 |
|
317 |
getOptions().setType(WITH_MAP); |
318 |
|
319 |
//Inicializaci?n de la ventana con la vista raster
|
320 |
viewRaster = sManager.createView(true, false, true, this); |
321 |
ViewDialogListener listenerRaster = new ViewDialogListener(viewRaster, this); |
322 |
ViewRasterRequestManager viewRasterRequestManager = new ViewRasterRequestManager(viewRaster, store);
|
323 |
viewRaster.setViewListener(listenerRaster); |
324 |
viewRaster.setRequestListener(viewRasterRequestManager); |
325 |
viewRaster.setTool(GeoreferencingSwingLibrary.SELECT_POINT_TOOL, this);
|
326 |
|
327 |
//Inicializaci?n de la ventana del zoom de la vista raster
|
328 |
zoomRaster = sManager.createZoom(true, false); |
329 |
ViewRasterRequestManager zoomRasterRequestManager = new ViewRasterRequestManager(zoomRaster, store);
|
330 |
zoomRaster.setRequestListener(zoomRasterRequestManager); |
331 |
zoomRaster.setTool(GeoreferencingSwingLibrary.SELECT_POINT_TOOL, this);
|
332 |
|
333 |
//Inicializaci?n de la ventana con la vista del terreno
|
334 |
viewMap = sManager.createView(true, false, false, this); |
335 |
ViewDialogListener listenerMap = new ViewDialogListener(viewMap, this); |
336 |
ViewRasterRequestManager viewMapRequestManager = new ViewRasterRequestManager(viewMap, store);
|
337 |
viewMap.setViewListener(listenerMap); |
338 |
viewMap.setRequestListener(viewMapRequestManager); |
339 |
viewMap.setTool(GeoreferencingSwingLibrary.SELECT_POINT_TOOL, this);
|
340 |
|
341 |
//Inicializaci?n de la ventana del zoom de la vista del terreno
|
342 |
zoomMap = sManager.createZoom(true, false); |
343 |
ViewRasterRequestManager zoomMapRequestManager = new ViewRasterRequestManager(zoomMap, store);
|
344 |
zoomMap.setRequestListener(zoomMapRequestManager); |
345 |
zoomMap.setTool(GeoreferencingSwingLibrary.SELECT_POINT_TOOL, this);
|
346 |
|
347 |
georefControlPanel = sManager.createGeorefControlPanel(); |
348 |
|
349 |
//Creamos el layout
|
350 |
LayoutEnvironment layoutEnv = fManager.createLayoutEnvironment(); |
351 |
layoutEnv.setTable((JPanel)getTable(false, dataModel).getComponent()); |
352 |
layoutEnv.setViewRasterToGeoref(viewRaster.getComponent()); |
353 |
layoutEnv.setViewZoomRasterToGeoref(zoomRaster.getComponent()); |
354 |
layoutEnv.setViewBaseCartography(viewMap.getComponent()); |
355 |
layoutEnv.setViewZoomBaseCartography(zoomMap.getComponent()); |
356 |
layoutEnv.setControlBar(georefControlPanel.getComponent()); |
357 |
|
358 |
fManager.createLayout(layoutEnv); |
359 |
SynchronizedViews syncViews = sManager.createSyncViews(viewMap, viewRaster, zoomMap, zoomRaster, table, this);
|
360 |
|
361 |
getOptions().setType(WITH_MAP); |
362 |
//
|
363 |
// viewsManager.setViews(viewRaster, viewMap, zoomRaster, zoomMap);
|
364 |
// viewsManager.setRequestsManager(viewRasterRequestManager, viewMapRequestManager, zoomRasterRequestManager, zoomMapRequestManager);
|
365 |
// viewsManager.setTablePanel(table);
|
366 |
//
|
367 |
try {
|
368 |
viewMap.setCursorSize(zoomMap.getCanvasWidth() / ZOOM_RATIO, zoomMap.getCanvasHeight() / ZOOM_RATIO); |
369 |
viewRaster.setCursorSize(zoomRaster.getCanvasWidth() / ZOOM_RATIO, zoomRaster.getCanvasHeight() / ZOOM_RATIO); |
370 |
viewMap.setCursorPosition(viewMap.getCanvasWidth() / 2, viewMap.getCanvasHeight() / 2); |
371 |
viewRaster.setCursorPosition(viewRaster.getCanvasWidth() / 2, viewRaster.getCanvasHeight() / 2); |
372 |
|
373 |
if(getMapCtrl().getMapContext().getLayers().getFullEnvelope() == null) |
374 |
GeoreferencingSwingImplLibrary.messageBoxError("error_setview_preview", null); |
375 |
|
376 |
//Inicializamos la vista de mapa
|
377 |
Envelope e = getMapCtrl().getMapContext().getLayers().getFullEnvelope(); |
378 |
Rectangle2D r = new Rectangle2D.Double(e.getMinimum(0), e.getMinimum(1), e.getLength(0), e.getLength(1)); |
379 |
viewMapRequestManager.initRequest(r); |
380 |
|
381 |
//Inicializamos la vista de raster
|
382 |
viewRasterRequestManager.initRequest(store.getExtent().toRectangle2D()); |
383 |
|
384 |
//Inicializamos el zoom de mapa
|
385 |
Rectangle2D ext = viewMap.getCursorAdjustedWorldCoordinates(zoomMap.getCanvasWidth(), zoomMap.getCanvasHeight());
|
386 |
zoomMapRequestManager.initRequest(ext); |
387 |
|
388 |
//Inicializamos el zoom de raster
|
389 |
ext = viewRaster.getCursorAdjustedWorldCoordinates(zoomRaster.getCanvasWidth(), zoomRaster.getCanvasHeight()); |
390 |
zoomRasterRequestManager.initRequest(store.getExtent().toRectangle2D()); |
391 |
zoomRasterRequestManager.request(ext); |
392 |
|
393 |
// layersPointManager.createGCPPIxelLayer(viewRaster, viewRasterRequestManager, zoomRasterRequestManager);
|
394 |
// layersPointManager.createGCPMapLayer(viewMap, viewMapRequestManager, zoomMapRequestManager);
|
395 |
//
|
396 |
} catch (InvalidRequestException e1) {
|
397 |
GeoreferencingSwingImplLibrary.messageBoxError("error_setview_preview", this, e1); |
398 |
fManager.closeAllWindows(); |
399 |
}catch (Exception e1) { |
400 |
GeoreferencingSwingImplLibrary.messageBoxError("error_setview_preview", this, e1); |
401 |
fManager.closeAllWindows(); |
402 |
} |
403 |
} |
404 |
|
405 |
/**
|
406 |
* A?ade una capa en la vista del mapa para previsualizar el resultado
|
407 |
* @param lyr
|
408 |
*/
|
409 |
/*public void addTestRasterLayer(FLyrRaster lyr) {
|
410 |
viewsManager.addTestRasterLayer(lyr,
|
411 |
getOptions().getAlgorithm(),
|
412 |
getOptions().getInterpolationMethod(),
|
413 |
getOptions().getDegree(),
|
414 |
getOptions().getOutFile());
|
415 |
}*/
|
416 |
|
417 |
/**
|
418 |
* Elimina la capa de test de la vista de mapa
|
419 |
* @throws InvalidRequestException
|
420 |
*/
|
421 |
/*public void removeTestRasterLayer() {
|
422 |
viewsManager.removeTestRasterLayer();
|
423 |
}*/
|
424 |
|
425 |
/**
|
426 |
* Obtiene la ?ltima capa procesada con los puntos de control
|
427 |
* @return FLyrRaterSE
|
428 |
*/
|
429 |
/*public FLyrRaster getLastTestLayer() {
|
430 |
return viewsManager.getLastTestLayer();
|
431 |
}*/
|
432 |
|
433 |
/**
|
434 |
* Gets the georeferencing options data model
|
435 |
* @return
|
436 |
*/
|
437 |
public GeoreferencingOptionsDataModel getOptions() {
|
438 |
GeoreferencingSwingManager manager = GeoreferencingSwingLocator.getSwingManager(); |
439 |
return manager.getDataModel();
|
440 |
//options = manager.createWindowOptions(Georeferencing.DEFAULT_DEGREE, this);
|
441 |
} |
442 |
|
443 |
/**
|
444 |
* Controla los eventos de finalizaci?n de la capa con el
|
445 |
* cursor gr?fico que controla el ?rea de la miniimagen asociada y
|
446 |
* la terminaci?n de la operaci?n de mover punto
|
447 |
*/
|
448 |
public void endAction(ToolEvent ev) { |
449 |
|
450 |
// //-----------------
|
451 |
// //Operaci?n de zoom
|
452 |
// if(ev.getSource() instanceof ZoomCursorGraphicLayer) {
|
453 |
// try {
|
454 |
// Rectangle2D ext = null;
|
455 |
// if(viewRaster != null) {
|
456 |
// ext = viewRaster.getCursorAdjustedWorldCoordinates(zoomRaster.getCanvasWidth(), zoomRaster.getCanvasHeight());
|
457 |
// viewsManager.getZoomRasterRequestManager().request(ext);
|
458 |
// }
|
459 |
// if(viewMap != null) {
|
460 |
// ext = viewMap.getCursorAdjustedWorldCoordinates(zoomMap.getCanvasWidth(), zoomMap.getCanvasHeight());
|
461 |
// viewsManager.getZoomMapRequestManager().request(ext);
|
462 |
// }
|
463 |
// } catch (InvalidRequestException e1) {
|
464 |
// RasterToolsUtil.messageBoxError("error_setview_preview", this);
|
465 |
// }
|
466 |
// }
|
467 |
//
|
468 |
// //-----------
|
469 |
// //Mover punto
|
470 |
// if(ev.getSource() instanceof GCPsGraphicLayer) {
|
471 |
// buttonsListener.setEnableTableEvent(false);
|
472 |
// //Se redibujan, se obtienen las coordenadas del punto y se actualiza la tabla
|
473 |
// if(layersPointManager != null)
|
474 |
// layersPointManager.redrawPoints();
|
475 |
// GPGraphic gPoint = ((GCPsGraphicLayer)ev.getSource()).getLastPoint();
|
476 |
// Point2D pRaster = gPoint.getGeoPoint().pixelPoint;
|
477 |
// Point2D pMap = gPoint.getGeoPoint().mapPoint;
|
478 |
// try {
|
479 |
// table.updatePoint( new Double(pMap.getX()),
|
480 |
// new Double(pMap.getY()),
|
481 |
// new Double(pRaster.getX()),
|
482 |
// new Double(pRaster.getY()),
|
483 |
// gPoint.getGeoPoint().number);
|
484 |
// table.getTable().getTable().getJTable().setRowSelectionInterval(gPoint.getGeoPoint().number, gPoint.getGeoPoint().number);
|
485 |
// } catch (NotInitializeException e) {
|
486 |
// RasterToolsUtil.messageBoxError("no_rows_selected", table, e);
|
487 |
// } catch (ArrayIndexOutOfBoundsException e) {
|
488 |
// RasterToolsUtil.messageBoxError("no_rows_selected", table, e);
|
489 |
// }
|
490 |
// if(getOptions().isCenterView())
|
491 |
// viewsManager.centerToPoint(gPoint.getGeoPoint().number);
|
492 |
// buttonsListener.setEnableTableEvent(true);
|
493 |
// }
|
494 |
//
|
495 |
// //------------------
|
496 |
// //Selecci?n de punto
|
497 |
// if(ev.getSource() instanceof SelectPointTool) {
|
498 |
// try {
|
499 |
// //Se obtiene el punto seleccionado, se actualiza la tabla y se redibujan
|
500 |
// int nPoint = table.getTable().getSelectedRow();
|
501 |
// GeoPoint gp = layersPointManager.getPointByNumber(nPoint);
|
502 |
//
|
503 |
// if(ev.getSource() == viewRasterSelectPointTool || ev.getSource() == zoomRasterSelectPointTool) {
|
504 |
// Point2D[] p = (Point2D[])((SelectPointTool)ev.getSource()).getResult();
|
505 |
// table.updateRasterPoint(new Double(p[1].getX()), new Double(p[1].getY()), nPoint);
|
506 |
// if(gp != null) {
|
507 |
// gp.pixelPoint = p[1];
|
508 |
// layersPointManager.redrawPoints();
|
509 |
// }
|
510 |
// }
|
511 |
// if(ev.getSource() == viewMapSelectPointTool || ev.getSource() == zoomMapSelectPointTool) {
|
512 |
// Point2D[] p = (Point2D[])((SelectPointTool)ev.getSource()).getResult();
|
513 |
// table.updateMapPoint(new Double(p[1].getX()), new Double(p[1].getY()), nPoint);
|
514 |
// if(gp != null) {
|
515 |
// gp.mapPoint = p[1];
|
516 |
// layersPointManager.redrawPoints();
|
517 |
// }
|
518 |
// }
|
519 |
// if(getOptions().isCenterView())
|
520 |
// viewsManager.centerToPoint(nPoint);
|
521 |
// } catch (NotInitializeException e) {
|
522 |
// RasterToolsUtil.messageBoxError("no_rows_selected", table, e);
|
523 |
// } catch (ArrayIndexOutOfBoundsException e) {
|
524 |
// RasterToolsUtil.messageBoxError("no_rows_selected", table, e);
|
525 |
// }
|
526 |
// }
|
527 |
} |
528 |
|
529 |
/**
|
530 |
* <P>
|
531 |
* Controla las prioridades de eventos sobre la vista en las herramientas y capas de selecci?n.
|
532 |
* Esto es necesario para que no se mezclen eventos entre capas.
|
533 |
* <P></P>
|
534 |
* Prioridades:
|
535 |
* </P>
|
536 |
* <UL>
|
537 |
* <LI>Capa de ZoomCursorGraphicLayer</LI>
|
538 |
* <LI>Capa de GCPsGraphicLayer</LI>
|
539 |
* <LI>Tool de selecci?n de zoom rectangulo</LI>
|
540 |
* <LI>Tool de selecci?n de puntos</LI>
|
541 |
* </UL>
|
542 |
*/
|
543 |
public void onTool(ToolEvent ev) { |
544 |
|
545 |
// //---------------------------
|
546 |
// //Operaci?n de cursor de zoom
|
547 |
// if(ev.getSource() instanceof ZoomCursorGraphicLayer) {
|
548 |
// layersPointManager.setActiveLayerPoints(false);
|
549 |
// viewsManager.sleepActiveTools();
|
550 |
// return;
|
551 |
// }
|
552 |
//
|
553 |
// //-----------
|
554 |
// //Mover punto
|
555 |
// if(ev.getSource() instanceof GCPsGraphicLayer) {
|
556 |
// layersPointManager.setActiveLayerZoomCursor(false);
|
557 |
// viewsManager.sleepActiveTools();
|
558 |
// return;
|
559 |
// }
|
560 |
//
|
561 |
// //------------------
|
562 |
// //Selecci?n de punto
|
563 |
// if(ev.getSource() instanceof SelectPointTool) {
|
564 |
// if(viewMap != null) {
|
565 |
// viewMap.getControl().selectTool(ZoomRectangleTool.class, false);
|
566 |
// viewMap.getControl().selectTool(PanTool.class, false);
|
567 |
// viewMap.getControl().getBSelectZoomArea().setSelected(false);
|
568 |
// viewMap.getControl().getBMove().setSelected(false);
|
569 |
// }
|
570 |
// if(viewRaster != null) {
|
571 |
// viewRaster.getControl().selectTool(ZoomRectangleTool.class, false);
|
572 |
// viewRaster.getControl().selectTool(PanTool.class, false);
|
573 |
// viewRaster.getControl().getBSelectZoomArea().setSelected(false);
|
574 |
// viewRaster.getControl().getBMove().setSelected(false);
|
575 |
// }
|
576 |
// }
|
577 |
//
|
578 |
// //-------------------------
|
579 |
// //Selecci?n de zoom ventana
|
580 |
// if(ev.getSource() instanceof ZoomRectangleTool) {
|
581 |
// if(viewMap != null) {
|
582 |
// viewMap.getControl().selectTool(SelectPointTool.class, false);
|
583 |
// viewMap.getControl().selectTool(PanTool.class, false);
|
584 |
// viewMap.getControl().getBMove().setSelected(false);
|
585 |
// }
|
586 |
// if(viewRaster != null) {
|
587 |
// viewRaster.getControl().selectTool(SelectPointTool.class, false);
|
588 |
// viewRaster.getControl().selectTool(PanTool.class, false);
|
589 |
// viewRaster.getControl().getBMove().setSelected(false);
|
590 |
// }
|
591 |
// table.getToolSelectPointButton().setSelected(false);
|
592 |
// }
|
593 |
//
|
594 |
// //---------------------------
|
595 |
// //Selecci?n de desplazamiento
|
596 |
// if(ev.getSource() instanceof PanTool) {
|
597 |
// if(viewMap != null) {
|
598 |
// viewMap.getControl().selectTool(SelectPointTool.class, false);
|
599 |
// viewMap.getControl().selectTool(ZoomRectangleTool.class, false);
|
600 |
// viewMap.getControl().getBSelectZoomArea().setSelected(false);
|
601 |
// }
|
602 |
// if(viewRaster != null) {
|
603 |
// viewRaster.getControl().selectTool(SelectPointTool.class, false);
|
604 |
// viewRaster.getControl().selectTool(ZoomRectangleTool.class, false);
|
605 |
// viewRaster.getControl().getBSelectZoomArea().setSelected(false);
|
606 |
// }
|
607 |
// table.getToolSelectPointButton().setSelected(false);
|
608 |
// }
|
609 |
} |
610 |
|
611 |
/**
|
612 |
*
|
613 |
*/
|
614 |
public void offTool(ToolEvent ev) { |
615 |
|
616 |
// //-----------------
|
617 |
// //Operaci?n de zoom
|
618 |
// if(ev.getSource() instanceof ZoomCursorGraphicLayer) {
|
619 |
// layersPointManager.setActiveLayerPoints(true);
|
620 |
// viewsManager.awakeActiveTools();
|
621 |
// return;
|
622 |
// }
|
623 |
//
|
624 |
// //-----------
|
625 |
// //Mover punto
|
626 |
// if(ev.getSource() instanceof GCPsGraphicLayer) {
|
627 |
// layersPointManager.setActiveLayerZoomCursor(true);
|
628 |
// viewsManager.awakeActiveTools();
|
629 |
// return;
|
630 |
// }
|
631 |
//
|
632 |
// //Selecci?n de punto
|
633 |
// /*if(ev.getSource() instanceof SelectPointTool) {
|
634 |
// }
|
635 |
// //Selecci?n de zoom ventana
|
636 |
// if(ev.getSource() instanceof ZoomRectangleTool) {
|
637 |
// }*/
|
638 |
} |
639 |
|
640 |
//*******************************************************
|
641 |
//Eventos sobre las vistas
|
642 |
|
643 |
|
644 |
public void addingTool(ViewEvent ev) { |
645 |
} |
646 |
|
647 |
public void endDraw(ViewEvent ev) { |
648 |
} |
649 |
|
650 |
public void startDraw(ViewEvent ev) { |
651 |
} |
652 |
|
653 |
/**
|
654 |
* Cuando cambia el zoom de alguna vista hay que recalcular la posici?n
|
655 |
* del cursor de zoom
|
656 |
*/
|
657 |
public void zoomViewChanged(ViewEvent ev) { |
658 |
// Rectangle2D ext = null;
|
659 |
// try {
|
660 |
// if(viewRaster != null && zoomRaster != null && viewsManager.getZoomRasterRequestManager() != null) {
|
661 |
// ext = viewRaster.getCursorAdjustedWorldCoordinates(zoomRaster.getCanvasWidth(), zoomRaster.getCanvasHeight());
|
662 |
// viewsManager.getZoomRasterRequestManager().request(ext);
|
663 |
// }
|
664 |
// if(viewMap != null && zoomMap != null && viewsManager.getZoomMapRequestManager() != null) {
|
665 |
// ext = viewMap.getCursorAdjustedWorldCoordinates(zoomMap.getCanvasWidth(), zoomMap.getCanvasHeight());
|
666 |
// viewsManager.getZoomMapRequestManager().request(ext);
|
667 |
// }
|
668 |
// }catch(InvalidRequestException ex) {
|
669 |
// RasterToolsUtil.messageBoxError("error_set_view", table, ex);
|
670 |
// }
|
671 |
} |
672 |
|
673 |
/**
|
674 |
* Obtiene la capa a georreferenciar
|
675 |
* @return FLyrRaster
|
676 |
*/
|
677 |
/*public FLyrRaster getLayer() {
|
678 |
return lyrToGeoref;
|
679 |
}*/
|
680 |
|
681 |
} |