root / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / utils / PointManager.java @ 5491
History | View | Annotate | Download (24 KB)
1 |
package org.gvsig.georeferencing.utils; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
import java.awt.geom.Point2D; |
5 |
|
6 |
import javax.swing.JDesktopPane; |
7 |
import javax.swing.JInternalFrame; |
8 |
import javax.swing.JLayeredPane; |
9 |
import javax.swing.JOptionPane; |
10 |
|
11 |
import org.gvsig.georeferencing.GeoOperations; |
12 |
import org.gvsig.georeferencing.GeoreferencingToolsModule; |
13 |
import org.gvsig.georeferencing.gui.dialogs.GeoreferencingDialog; |
14 |
import org.gvsig.georeferencing.gui.listeners.GeoRasterFrameListener; |
15 |
import org.gvsig.georeferencing.gui.panels.AdjustGeorefPanel; |
16 |
import org.gvsig.georeferencing.gui.panels.OptionsPanel; |
17 |
import org.gvsig.georeferencing.gui.panels.ZoomControlPanel; |
18 |
import org.gvsig.georeferencing.gui.pointsTable.ButtonsExportImportPanel; |
19 |
import org.gvsig.georeferencing.gui.pointsTable.TableControlerPanel; |
20 |
import org.gvsig.georeferencing.gui.pointsTable.TablePointsPanel; |
21 |
import org.gvsig.georeferencing.gui.pointsTable.TablePointsPanel.PointTable; |
22 |
import org.gvsig.georeferencing.gui.selectPoints.DataPointPanel; |
23 |
import org.gvsig.georeferencing.gui.selectPoints.ErrorPointPanel; |
24 |
import org.gvsig.georeferencing.gui.selectPoints.SelectPointsPanel; |
25 |
|
26 |
import com.iver.andami.PluginServices; |
27 |
import com.iver.andami.ui.mdiFrame.MDIFrame; |
28 |
import com.iver.cit.gvsig.fmap.ViewPort; |
29 |
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
30 |
import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
31 |
import com.iver.cit.gvsig.fmap.layers.GeoPoint; |
32 |
import com.iver.cit.gvsig.fmap.layers.IGeoUi; |
33 |
import com.iver.cit.gvsig.gui.View; |
34 |
|
35 |
/**
|
36 |
* Gestor de puntos. Contiene metodos para a?adir. borrar, seleccionar,..
|
37 |
* puntos coordinando la capa de puntos y la visualizaci?n del interfaz
|
38 |
* gr?fico.
|
39 |
*
|
40 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
41 |
*
|
42 |
*/
|
43 |
public class PointManager{ |
44 |
|
45 |
//**********************Vars**********************************
|
46 |
private GeoreferencingDialog dialog = null; |
47 |
|
48 |
private SelectPointsPanel selectPointsPanel = null; |
49 |
private ErrorPointPanel errorPointPanel = null; |
50 |
private DataPointPanel dataPointPanel = null; |
51 |
private TableControlerPanel tableControlerPanel1 = null; |
52 |
|
53 |
private TablePointsPanel tablePointsPanel = null; |
54 |
private TableControlerPanel tableControlerPanel2 = null; |
55 |
private ButtonsExportImportPanel buttonsExportImportPanel = null; |
56 |
|
57 |
private OptionsPanel optionsPanel = null; |
58 |
private ZoomControlPanel zoomControlPanelLeft = null; |
59 |
private ZoomControlPanel zoomControlPanelRight = null; |
60 |
|
61 |
private FLyrPoints lyrPoints = null; |
62 |
private double currentMapX = 0D; |
63 |
private double currentMapY = 0D; |
64 |
private double currentPixelX = 0D; |
65 |
private double currentPixelY = 0D; |
66 |
private boolean disableAllControls = false; |
67 |
//**********************End Vars******************************
|
68 |
|
69 |
//**********************Methods*******************************
|
70 |
/**
|
71 |
* Constructor
|
72 |
*/
|
73 |
public PointManager(GeoreferencingDialog dialog, FLyrPoints flyrPoints){
|
74 |
this.dialog = dialog;
|
75 |
this.selectPointsPanel = dialog.getSelectPointsPanel();
|
76 |
this.errorPointPanel = dialog.getSelectPointsPanel().getErrorPointPanel();
|
77 |
this.dataPointPanel = dialog.getSelectPointsPanel().getDataPointPanel();
|
78 |
this.tableControlerPanel1 = dialog.getSelectPointsPanel().getTableControlerPanel();
|
79 |
this.tablePointsPanel = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel();
|
80 |
this.tableControlerPanel2 = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getTableControlerPanel();
|
81 |
this.buttonsExportImportPanel = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getPButtonsExportImportPanel();
|
82 |
this.optionsPanel = dialog.getConectorPanel().getAdjustGeorefPanel().getOptionsPanel();
|
83 |
this.zoomControlPanelLeft = dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft();
|
84 |
this.zoomControlPanelRight = dialog.getConectorPanel().getAdjustGeorefPanel().getZoomRight();
|
85 |
this.lyrPoints = flyrPoints;
|
86 |
} |
87 |
|
88 |
/**
|
89 |
* Crea un nuevo punto vacio en la capa y lo a?ade al interfaz gr?fico para
|
90 |
* que puedan ser introducidas las coordenadas por el usuario
|
91 |
*/
|
92 |
public void newEmptyPoint(){ |
93 |
try{
|
94 |
//Antes de a?adir un nuevo pto compruba que los textField del anterior no est?n vacios
|
95 |
if(tableControlerPanel1.getItemCount() > 0) |
96 |
selectPointsPanel.checkInfoPointText(); |
97 |
|
98 |
//A?ade un punto vacio a la capa
|
99 |
lyrPoints.addPoint(null, null); |
100 |
|
101 |
//A?ade un punto al control de tabla y checkea la activaci?n de los botones
|
102 |
tableControlerPanel1.addPointToTable(lyrPoints.getCountPoints()); |
103 |
|
104 |
//Guardamos el ?ltimo punto seleccionado por si hay que recuperarlo
|
105 |
selectPointsPanel.setLastIndexSelection(lyrPoints.getCountPoints() - 1);
|
106 |
|
107 |
//resetea los controles de (del, delall, selectFromView y miniimagenes)
|
108 |
dialog.resetControls(true);
|
109 |
|
110 |
//Desactivamos los controles de las miniimagenes para que no capture los
|
111 |
//eventos hasta que no se hayan introducido los puntos
|
112 |
dialog.getConectorPanel().getAdjustGeorefPanel().setEnabled(false);
|
113 |
dialog.getConectorPanel().getAdjustGeorefPanel().setLZoomRight("1:");
|
114 |
dialog.getConectorPanel().getAdjustGeorefPanel().setLZoomLeft("1:");
|
115 |
|
116 |
}catch(NoSuchFieldException exc){ |
117 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
118 |
PluginServices.getText(this, "coordenadas_vacias")); |
119 |
} |
120 |
} |
121 |
|
122 |
/**
|
123 |
* A partir de nuevas coordenadas actualiza la vista, minimagen, capa de puntos el
|
124 |
* dialogo y la tabla.
|
125 |
*
|
126 |
*/
|
127 |
public void updateData(int nPunto, Point2D pixel, Point2D map, IGeoUi geoUI, View view){ |
128 |
dialog = (GeoreferencingDialog)geoUI; |
129 |
if(dialog == null) |
130 |
return;
|
131 |
if(pixel == null && map == null) |
132 |
return;
|
133 |
|
134 |
//Actualizamos los textBox
|
135 |
if(pixel != null){ |
136 |
dialog.setPixelText(pixel.getX(), pixel.getY()); |
137 |
dialog.getSelectPointsPanel().lastTx = String.valueOf(pixel.getX());
|
138 |
dialog.getSelectPointsPanel().lastTy = String.valueOf(pixel.getY());
|
139 |
} |
140 |
if(map != null){ |
141 |
dialog.setMapCoordText(map.getX(), map.getY()); |
142 |
dialog.getSelectPointsPanel().lastLong = String.valueOf(map.getX());
|
143 |
dialog.getSelectPointsPanel().lastLat = String.valueOf(map.getY());
|
144 |
} |
145 |
|
146 |
//El Checkbox de activaci?n
|
147 |
GeoPoint gp = ((GeoPoint)lyrPoints.getPoint(nPunto - 1));
|
148 |
if(gp != null){ |
149 |
dataPointPanel.getCbActive().setSelected(gp.active); |
150 |
dialog.setEnabled(gp.active); |
151 |
} |
152 |
|
153 |
//Actualizamos la tabla
|
154 |
|
155 |
while(dialog.getTableRowCount() < nPunto)
|
156 |
dialog.addTableNew(); |
157 |
dialog.setTableValueAt(String.valueOf(nPunto), nPunto - 1, 0); |
158 |
|
159 |
if(pixel != null){ |
160 |
dialog.setTableValueAt(MathUtils.tailDecimals(String.valueOf(pixel.getX()), 5), nPunto - 1, 1); |
161 |
dialog.setTableValueAt(MathUtils.tailDecimals(String.valueOf(pixel.getY()), 5), nPunto - 1, 2); |
162 |
} |
163 |
if(map != null){ |
164 |
dialog.setTableValueAt(MathUtils.tailDecimals(String.valueOf(map.getX()), 5), nPunto - 1, 3); |
165 |
dialog.setTableValueAt(MathUtils.tailDecimals(String.valueOf(map.getY()), 5), nPunto - 1, 4); |
166 |
} |
167 |
|
168 |
//Actualizamos la capa de puntos
|
169 |
if(pixel != null || map != null) |
170 |
lyrPoints.updatePoint(pixel, map, nPunto - 1);
|
171 |
|
172 |
//Actualizamos la miniimagen
|
173 |
if(view != null){ |
174 |
ViewPort viewPort = view.getMapControl().getMapContext().getViewPort(); |
175 |
|
176 |
if(pixel != null){ |
177 |
dialog.getZoomControlLeft().setCenterPoint(lyrPoints.getLyrGeoRaster().img2World(pixel)); |
178 |
dialog.getConectorPanel().getAdjustGeorefPanel().setViewPort(viewPort); |
179 |
//Si est? extendido hacemos un draw corriente sino es q est? plegado y tocar? asignar el extent de la miniimagen
|
180 |
if(dialog.isEnlarge())
|
181 |
dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().draw(); |
182 |
else
|
183 |
lyrPoints.setMiniExtent(nPunto - 1,
|
184 |
lyrPoints.getLyrGeoRaster().img2World(pixel), |
185 |
dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().getCanvas().initViewPort(viewPort, lyrPoints.getLyrGeoRaster().img2World(pixel), null),
|
186 |
false);
|
187 |
} |
188 |
|
189 |
if(map != null){ |
190 |
dialog.getZoomControlRight().setCenterPoint(map); |
191 |
dialog.getConectorPanel().getAdjustGeorefPanel().setViewPort(viewPort); |
192 |
//Si est? extendido hacemos un draw corriente sino es q est? plegado y tocar? asignar el extent de la miniimagen
|
193 |
if(dialog.isEnlarge())
|
194 |
dialog.getConectorPanel().getAdjustGeorefPanel().getZoomRight().draw(); |
195 |
else
|
196 |
lyrPoints.setMiniExtent(nPunto - 1,
|
197 |
map, |
198 |
dialog.getConectorPanel().getAdjustGeorefPanel().getZoomRight().getCanvas().initViewPort(viewPort, map, null),
|
199 |
true);
|
200 |
} |
201 |
|
202 |
//Actualizamos la vista
|
203 |
view.getMapControl().getMapContext().invalidate(); |
204 |
} |
205 |
|
206 |
//Calculamos los errores
|
207 |
if(pixel != null && map != null) |
208 |
setErrors(nPunto - 1);
|
209 |
|
210 |
} |
211 |
|
212 |
/**
|
213 |
* Al actualizar un punto debemos recalcular los errores RMS y Total para ello tenemos que
|
214 |
* pedir la transformaci?n de toda la lista de puntos. Esta funci?n calcula esta lista
|
215 |
* transformada y la asigna a un array en la capa de puntos. Esta funci?n tiene en cuenta
|
216 |
* que un punto puede estar inactivo.
|
217 |
*/
|
218 |
private void transformPointList(){ |
219 |
try{
|
220 |
GeoOperations go = new GeoOperations(lyrPoints);
|
221 |
Point2D[] pointList = new Point2D[lyrPoints.getCountActivePoints()]; |
222 |
int pActive = 0; |
223 |
for(int i=0; i< lyrPoints.getCountPoints(); i++){ |
224 |
if(lyrPoints.getPoint(i).active){
|
225 |
pointList[pActive] = lyrPoints.getPoint(i).pixelPoint; |
226 |
pActive ++; |
227 |
} |
228 |
} |
229 |
|
230 |
Point2D[] transformActivePointList = go.transformPoints(pointList); |
231 |
Point2D[] transformPointList = new Point2D[lyrPoints.getCountPoints()]; |
232 |
|
233 |
pActive = 0;
|
234 |
for(int i=0; i< lyrPoints.getCountPoints(); i++){ |
235 |
if(lyrPoints.getPoint(i).active){
|
236 |
transformPointList[i] = transformActivePointList[pActive]; |
237 |
pActive ++; |
238 |
}else
|
239 |
transformPointList[i] = null;
|
240 |
} |
241 |
|
242 |
lyrPoints.setTransformPointList(transformPointList); |
243 |
}catch(NullPointerException e){ |
244 |
//Si ocurre esta excepci?n es que se est? intentando incluir un punto que se acaba de crear
|
245 |
//y por lo tanto no tiene el valor asignado todavia por lo que es mejor no hacer nada
|
246 |
//y seguir con el proceso
|
247 |
} |
248 |
} |
249 |
|
250 |
/**
|
251 |
* Busca el punto en la capa FLyrPoint que corresponde con la posicion pos
|
252 |
* y carga la informaci?n de este en el panel de informaci?n pasado por par?metro.
|
253 |
* @param pos Posici?n del punto
|
254 |
* @param panel donde se carga la informaci?n
|
255 |
*/
|
256 |
public void selectPoint(int pos, GeoreferencingDialog dialog){ |
257 |
GeoPoint pto = null;
|
258 |
try{
|
259 |
pto = lyrPoints.getPoint(pos); |
260 |
if(pto == null) |
261 |
return;
|
262 |
}catch(ArrayIndexOutOfBoundsException exc){ |
263 |
//Todavia no hay puntos por lo que no hacemos nada
|
264 |
return;
|
265 |
} |
266 |
DataPointPanel dpp = dialog.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel(); |
267 |
|
268 |
//Llenamos los JTextField con los valores del punto
|
269 |
if(pto.pixelPoint != null){ |
270 |
dpp.getTX().setText(""+pto.pixelPoint.getX());
|
271 |
dpp.getTY().setText(""+pto.pixelPoint.getY());
|
272 |
} |
273 |
if(pto.mapPoint != null){ |
274 |
dpp.getLatitud().setText(MathUtils.tailDecimals(String.valueOf(pto.mapPoint.getY()), 5)); |
275 |
dpp.getLongitud().setText(MathUtils.tailDecimals(String.valueOf(pto.mapPoint.getX()), 5)); |
276 |
} |
277 |
|
278 |
//El Checkbox de activaci?n
|
279 |
dataPointPanel.getCbActive().setSelected(pto.active); |
280 |
dialog.setEnabled(pto.active); |
281 |
|
282 |
//Seleccionamos la fila de la tabla
|
283 |
PointTable table = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getJTable(); |
284 |
try{
|
285 |
table.getTable().setRowSelectionInterval(pos, pos); |
286 |
}catch(IllegalArgumentException exc){ |
287 |
System.err.println("Intervalo erroneo "+pos); |
288 |
} |
289 |
|
290 |
//Cargamos las mini imagenes
|
291 |
dialog.getZoomControlLeft().setCenterPoint(lyrPoints.getCenterPoint(pos, false));
|
292 |
dialog.getZoomControlLeft().setNewViewPort(lyrPoints.getMiniExtent(pos, false));
|
293 |
dialog.getZoomControlLeft().draw(); |
294 |
|
295 |
dialog.getZoomControlRight().setCenterPoint(lyrPoints.getCenterPoint(pos, true));
|
296 |
dialog.getZoomControlRight().setNewViewPort(lyrPoints.getMiniExtent(pos, true));
|
297 |
dialog.getZoomControlRight().draw(); |
298 |
|
299 |
//Calculamos los errores
|
300 |
if(pto.pixelPoint != null && pto.mapPoint != null) |
301 |
setErrors(pos); |
302 |
} |
303 |
|
304 |
/**
|
305 |
* Obtiene los errores en una matriz de Nx3 en la que cada fila es un punto y la
|
306 |
* columna 0 es el error en X, la columna 1 es el error en Y y la columna 2 es el error RMS.
|
307 |
* @return matriz de errores
|
308 |
*/
|
309 |
public double[][] getErrors(){ |
310 |
|
311 |
transformPointList(); |
312 |
|
313 |
//Al actualizar un punto debemos recalcular los errores RMS y Total para ello tenemos que
|
314 |
//pedir la transformaci?n de toda la lista de puntos
|
315 |
try{
|
316 |
GeoOperations go = new GeoOperations(lyrPoints);
|
317 |
Point2D[] pointList = new Point2D[lyrPoints.length()]; |
318 |
for(int i=0; i< lyrPoints.length(); i++) |
319 |
pointList[i] = lyrPoints.getPoint(i).pixelPoint; |
320 |
|
321 |
Point2D[] transformPointList = go.transformPoints(pointList); |
322 |
lyrPoints.setTransformPointList(transformPointList); |
323 |
}catch(NullPointerException e){ |
324 |
//Si ocurre esta excepci?n es que se est? intentando incluir un punto que se acaba de crear
|
325 |
//y por lo tanto no tiene el valor asignado todavia por lo que es mejor no hacer nada
|
326 |
//y seguir con el proceso
|
327 |
} |
328 |
|
329 |
double[][] err = new double[lyrPoints.getCountPoints()][3]; |
330 |
for(int i = 0; i<lyrPoints.getCountPoints(); i++){ |
331 |
err[i][0] = lyrPoints.calcDoubleResX(i);
|
332 |
err[i][1] = lyrPoints.calcDoubleResY(i);
|
333 |
err[i][2] = lyrPoints.calcDoubleRMS(i);
|
334 |
} |
335 |
return err;
|
336 |
} |
337 |
|
338 |
/**
|
339 |
* Calcula los errores y los asigna al dialogo y tabla. Hay que tener en cuenta que
|
340 |
* hay que tener en la capa de puntos la lista de puntos transformados
|
341 |
* @param pos
|
342 |
*/
|
343 |
public void setErrors(int pos){ |
344 |
|
345 |
if(lyrPoints != null){ |
346 |
transformPointList(); |
347 |
|
348 |
//Calculamos los errores
|
349 |
double d = lyrPoints.calcDoubleRMS(pos);
|
350 |
//System.out.println("-->RMS:"+d);
|
351 |
dialog.setRMS(String.valueOf(MathUtils.tailDecimals(d, 5))); |
352 |
try{
|
353 |
dialog.setTableValueAt(String.valueOf(MathUtils.tailDecimals(d, 5)), pos, 7); |
354 |
}catch(ArrayIndexOutOfBoundsException e){ |
355 |
//No asigna el valor a la tabla
|
356 |
} |
357 |
|
358 |
d = lyrPoints.calcDoubleResX(pos); |
359 |
//System.out.println("-->ResX:"+d);
|
360 |
dialog.setResX(String.valueOf(MathUtils.tailDecimals(d, 5))); |
361 |
try{
|
362 |
dialog.setTableValueAt(String.valueOf(MathUtils.tailDecimals(d, 5)), pos, 5); |
363 |
}catch(ArrayIndexOutOfBoundsException e){ |
364 |
//No asigna el valor a la tabla
|
365 |
} |
366 |
|
367 |
d = lyrPoints.calcDoubleResY(pos); |
368 |
//System.out.println("-->ResY:"+d);
|
369 |
dialog.setResY(String.valueOf(MathUtils.tailDecimals(d, 5))); |
370 |
try{
|
371 |
dialog.setTableValueAt(String.valueOf(MathUtils.tailDecimals(d, 5)), pos, 6); |
372 |
}catch(ArrayIndexOutOfBoundsException e){ |
373 |
//No asigna el valor a la tabla
|
374 |
} |
375 |
|
376 |
d = lyrPoints.calcDoubleTotal(); |
377 |
//System.out.println("-->Total:"+d);
|
378 |
dialog.setTotal(String.valueOf(MathUtils.tailDecimals(d, 5))); |
379 |
} |
380 |
|
381 |
} |
382 |
|
383 |
/**
|
384 |
* Elimina el punto seleccionado de la lista de puntos. Obtiene el punto seleccionado
|
385 |
* del combobox del tableControler
|
386 |
*/
|
387 |
public void deletePoint(){ |
388 |
int op = JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(), |
389 |
PluginServices.getText(this, "eliminar_punto")); |
390 |
if(op == JOptionPane.OK_OPTION){ |
391 |
if(lyrPoints.length() == 1) //Si solo hay un punto reseteamos |
392 |
clearVisualList(); |
393 |
else{
|
394 |
int posSelect = tableControlerPanel1.getSelectedIndex();
|
395 |
if(posSelect == -1) |
396 |
return;
|
397 |
deleteVisualPoint(posSelect); |
398 |
|
399 |
if(posSelect == 0){ |
400 |
selectPointsPanel.setLastIndexSelection(posSelect); |
401 |
}else{
|
402 |
selectPointsPanel.setLastIndexSelection(posSelect - 1);
|
403 |
} |
404 |
} |
405 |
} |
406 |
} |
407 |
|
408 |
/**
|
409 |
* Elimina todos los puntos de la capa y resetea el dialogo
|
410 |
*/
|
411 |
public void deleteAllPoints(){ |
412 |
int op = JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(), |
413 |
PluginServices.getText(this, "eliminar_todos_puntos")); |
414 |
if(op == JOptionPane.OK_OPTION){ |
415 |
clearVisualList(); |
416 |
} |
417 |
|
418 |
} |
419 |
|
420 |
/**
|
421 |
* Elimina un punto de la lista pasado por par?metro y lo elimina del panel
|
422 |
* @param pos Posici?n del punto
|
423 |
* @param grd Panel a limpiar
|
424 |
*/
|
425 |
private void deleteVisualPoint(int pos){ |
426 |
lyrPoints.remove(pos); |
427 |
|
428 |
//Actualiza los controles de tabla y selector
|
429 |
tableControlerPanel1.setNItems(lyrPoints.length()); |
430 |
tableControlerPanel2.setNItems(lyrPoints.length()); |
431 |
|
432 |
//Elimina la fila de la tabla y renumera los puntos
|
433 |
try{
|
434 |
dialog.removeTableValueAt(pos); |
435 |
|
436 |
for(int i=0;i<lyrPoints.length();i++) |
437 |
dialog.setTableValueAt(String.valueOf(i + 1), i, 0); |
438 |
}catch(ArrayIndexOutOfBoundsException exc){ |
439 |
//Si intentamos eliminar una fila que no existe no hacemos nada, simplemente no la eliminamos
|
440 |
} |
441 |
|
442 |
//Carga los puntos
|
443 |
if(pos == 0){ |
444 |
dialog.getSelectPointsPanel().getTableControlerPanel().setSelectedIndex(pos); |
445 |
selectPoint(pos, dialog); |
446 |
}else{
|
447 |
dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getTableControlerPanel().setSelectedIndex(pos - 1);
|
448 |
selectPoint(pos - 1, dialog);
|
449 |
} |
450 |
|
451 |
//Redibujamos la vista
|
452 |
View theView = null; |
453 |
try{
|
454 |
theView = (View) PluginServices.getMDIManager().getActiveView();
|
455 |
theView.getMapControl().getMapContext().invalidate(); |
456 |
}catch(ClassCastException exc){ |
457 |
return;
|
458 |
} |
459 |
} |
460 |
|
461 |
/**
|
462 |
* Limpia la lista de puntos .
|
463 |
*/
|
464 |
public void clearVisualList(){ |
465 |
AdjustGeorefPanel agp = dialog.getConectorPanel().getAdjustGeorefPanel(); |
466 |
|
467 |
//Limpiamos la lista de puntos
|
468 |
lyrPoints.clear(); |
469 |
//Limpiamos los controles del Selector de puntos
|
470 |
selectPointsPanel.resetControls(false);
|
471 |
selectPointsPanel.getTableControlerPanel().resetControls(); |
472 |
|
473 |
//Limpiamos la tabla y sus controles
|
474 |
tablePointsPanel.clearTable(); |
475 |
tablePointsPanel.getTableControlerPanel().resetControls(); |
476 |
|
477 |
//Limpiamos las miniimagenes bloqueamos los controles
|
478 |
agp.getZoomLeft().clear(); |
479 |
agp.getZoomRight().clear(); |
480 |
dialog.getConectorPanel().getAdjustGeorefPanel().setEnabled(false);
|
481 |
|
482 |
//Actualizamos la vista
|
483 |
View theView = null; |
484 |
try{
|
485 |
theView = (View) PluginServices.getMDIManager().getActiveView();
|
486 |
theView.getMapControl().getMapContext().invalidate(); |
487 |
}catch(ClassCastException exc){ |
488 |
return;
|
489 |
} |
490 |
|
491 |
} |
492 |
|
493 |
/**
|
494 |
* Obtiene la ventana flotante sobre la que ir? el dialogo (GeoreferencingDialog).
|
495 |
* @param obj
|
496 |
* @return JInternalFrame
|
497 |
*/
|
498 |
public static JInternalFrame getInternalFrame(Object obj){ |
499 |
JInternalFrame panel = new JInternalFrame(); |
500 |
panel.addInternalFrameListener(new GeoRasterFrameListener());
|
501 |
panel.setClosable(true);
|
502 |
panel.setResizable(false);
|
503 |
panel.setTitle(PluginServices.getText(obj,"georreferenciar"));
|
504 |
return panel;
|
505 |
} |
506 |
|
507 |
|
508 |
public static GeoreferencingDialog initWindow(FLyrGeoRaster lyrGeoRaster, boolean show, Object obj){ |
509 |
GeoreferencingDialog geoDialog = null;
|
510 |
|
511 |
JInternalFrame panel = PointManager.getInternalFrame(obj);
|
512 |
geoDialog = new GeoreferencingDialog(panel, lyrGeoRaster);
|
513 |
lyrGeoRaster.getStackZoom().setInitExtent(lyrGeoRaster.getAssignExtent()); |
514 |
lyrGeoRaster.getFLyrPoints().saveState(); |
515 |
lyrGeoRaster.setGeoDialog(geoDialog); |
516 |
panel.setSize(geoDialog.getWidth() + 12, geoDialog.getHeight() + 10); |
517 |
panel.getContentPane().add(geoDialog); |
518 |
|
519 |
MDIFrame mainFrame = (MDIFrame) PluginServices.getMainFrame(); |
520 |
|
521 |
JDesktopPane desk = new JDesktopPane(); |
522 |
desk.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
|
523 |
|
524 |
JLayeredPane lyrPane = mainFrame.getLayeredPane();
|
525 |
lyrPane.add(panel, JDesktopPane.PALETTE_LAYER);
|
526 |
lyrPane.add(desk, JDesktopPane.OUTLINE_DRAG_MODE);
|
527 |
if(show)
|
528 |
panel.show(); |
529 |
|
530 |
return geoDialog;
|
531 |
} |
532 |
|
533 |
/**
|
534 |
* Esta funci?n deshabilita todos los controles y guarda sus valores
|
535 |
* de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue
|
536 |
* se vuelvan a quedar como estaba
|
537 |
*/
|
538 |
public void disableAllControls(){ |
539 |
if(!disableAllControls){
|
540 |
disableAllControls = true;
|
541 |
//Salvamos los estados y desactivamos controles
|
542 |
tableControlerPanel1.disableAllControls(); |
543 |
tablePointsPanel.disableAllControls(); |
544 |
tableControlerPanel2.disableAllControls(); |
545 |
dialog.disableAllControls(); |
546 |
dataPointPanel.getCbActive().setEnabled(false);
|
547 |
selectPointsPanel.getBExtended().setEnabled(false);
|
548 |
dialog.getFrame().setClosable(false);
|
549 |
|
550 |
//Desactivamos las herramientas de georreferenciaci?n
|
551 |
GeoreferencingToolsModule.setEnabled(false);
|
552 |
dialog.getConectorPanel().getDataPointsTabPanel().getTbPoints().setEnabled(false);
|
553 |
} |
554 |
} |
555 |
|
556 |
/**
|
557 |
* Esta funci?n deja los controles como estaban al ejecutar la funci?n
|
558 |
* disableAllControls
|
559 |
*/
|
560 |
public void restoreControlsValue(){ |
561 |
if(disableAllControls){
|
562 |
disableAllControls = false;
|
563 |
//Activamos controles
|
564 |
tableControlerPanel1.restoreControlsValue(); |
565 |
tablePointsPanel.restoreControlsValue(); |
566 |
tableControlerPanel2.restoreControlsValue(); |
567 |
dialog.restoreControlsValue(); |
568 |
dataPointPanel.getCbActive().setEnabled(true);
|
569 |
selectPointsPanel.getBExtended().setEnabled(true);
|
570 |
dialog.getFrame().setClosable(true);
|
571 |
|
572 |
//Activamos las herramientas de georreferenciaci?n
|
573 |
GeoreferencingToolsModule.setEnabled(true);
|
574 |
dialog.getConectorPanel().getDataPointsTabPanel().getTbPoints().setEnabled(true);
|
575 |
} |
576 |
} |
577 |
//**********************End Methods***************************
|
578 |
|
579 |
//**********************Getters & Setters*********************
|
580 |
public FLyrPoints getFlyrPoints() {
|
581 |
return lyrPoints;
|
582 |
} |
583 |
|
584 |
public void setFlyrPoints(FLyrPoints flyrPoints) { |
585 |
this.lyrPoints = flyrPoints;
|
586 |
} |
587 |
|
588 |
public GeoreferencingDialog getDialog() {
|
589 |
return dialog;
|
590 |
} |
591 |
|
592 |
/**
|
593 |
* Salva en 2 variables de instancia el valor actual en coordenadas del
|
594 |
* mundo del punto seleccionado. Esto es util para su posterior restauraci?n.
|
595 |
*/
|
596 |
public void setCurrentWC() { |
597 |
int posSelect = 0; |
598 |
try{
|
599 |
if(tableControlerPanel1 != null) |
600 |
posSelect = tableControlerPanel1.getSelectedIndex(); |
601 |
if(lyrPoints != null){ |
602 |
this.currentMapX = lyrPoints.getPoint(posSelect).mapPoint.getX();
|
603 |
this.currentMapY = lyrPoints.getPoint(posSelect).mapPoint.getY();
|
604 |
} |
605 |
}catch(NullPointerException exc){ |
606 |
//Si tableControler o la capa de puntos son null no salvamos el punto
|
607 |
} |
608 |
} |
609 |
|
610 |
/**
|
611 |
* Asigna nuevos valores al texto de la latitud y longitud.
|
612 |
* @param x Longitud
|
613 |
* @param y Latitud
|
614 |
*/
|
615 |
public void setTempWC(double x, double y){ |
616 |
dataPointPanel.getLongitud().setText(MathUtils.tailDecimals(String.valueOf(x), 5) + ""); |
617 |
dataPointPanel.getLatitud().setText(MathUtils.tailDecimals(String.valueOf(y), 5) + ""); |
618 |
} |
619 |
|
620 |
/**
|
621 |
* Restaura el ?ltimo valor seleccionado por el usuario de la latitud
|
622 |
* y longitud.
|
623 |
*/
|
624 |
public void replaceWC(){ |
625 |
dataPointPanel.getLongitud().setText(MathUtils.tailDecimals(String.valueOf(currentMapX), 5) + ""); |
626 |
dataPointPanel.getLatitud().setText(MathUtils.tailDecimals(String.valueOf(currentMapY), 5) + ""); |
627 |
} |
628 |
|
629 |
/**
|
630 |
* Salva en 2 variables de instancia el valor actual en coordenadas del
|
631 |
* mundo del punto seleccionado. Esto es util para su posterior restauraci?n.
|
632 |
*/
|
633 |
public void setCurrentPixelCoord() { |
634 |
int posSelect = 0; |
635 |
try{
|
636 |
if(tableControlerPanel1 != null) |
637 |
posSelect = tableControlerPanel1.getSelectedIndex(); |
638 |
if(lyrPoints != null){ |
639 |
this.currentPixelX = lyrPoints.getPoint(posSelect).pixelPoint.getX();
|
640 |
this.currentPixelY = lyrPoints.getPoint(posSelect).pixelPoint.getY();
|
641 |
} |
642 |
}catch(NullPointerException exc){ |
643 |
//Si tableControler o la capa de puntos son null no salvamos el punto
|
644 |
} |
645 |
} |
646 |
|
647 |
/**
|
648 |
* Asigna nuevos valores al texto de la latitud y longitud.
|
649 |
* @param x Longitud
|
650 |
* @param y Latitud
|
651 |
*/
|
652 |
public void setTempPixelCoord(double x, double y){ |
653 |
dataPointPanel.getTX().setText(MathUtils.tailDecimals(String.valueOf(x), 5) + ""); |
654 |
dataPointPanel.getTY().setText(MathUtils.tailDecimals(String.valueOf(y), 5) + ""); |
655 |
} |
656 |
|
657 |
/**
|
658 |
* Restaura el ?ltimo valor seleccionado por el usuario de la latitud
|
659 |
* y longitud.
|
660 |
*/
|
661 |
public void replacePixelCoord(){ |
662 |
dataPointPanel.getTX().setText(currentPixelX + "");
|
663 |
dataPointPanel.getTY().setText(currentPixelY + "");
|
664 |
} |
665 |
|
666 |
/**
|
667 |
* Consulta si se han desactivado los controles salvando sus valores
|
668 |
* @return true si se han desactivado los controles salvando previamente
|
669 |
* sus valores y false si est?n en estado normal.
|
670 |
*/
|
671 |
public boolean isDisableAllControls() { |
672 |
return disableAllControls;
|
673 |
} |
674 |
//**********************End Getters & Setters*****************
|
675 |
} |