root / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / utils / PointManager.java @ 5089
History | View | Annotate | Download (17.1 KB)
1 | 4700 | nacho | package com.iver.cit.gvsig.utils; |
---|---|---|---|
2 | |||
3 | import java.awt.Component; |
||
4 | import java.awt.geom.Point2D; |
||
5 | |||
6 | 4841 | nacho | import javax.swing.JDesktopPane; |
7 | 4700 | nacho | import javax.swing.JInternalFrame; |
8 | 4841 | nacho | import javax.swing.JLayeredPane; |
9 | 4700 | nacho | import javax.swing.JOptionPane; |
10 | |||
11 | import com.iver.andami.PluginServices; |
||
12 | 4841 | nacho | import com.iver.andami.ui.mdiFrame.MDIFrame; |
13 | 4700 | nacho | import com.iver.cit.gvsig.fmap.ViewPort; |
14 | 4841 | nacho | import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
15 | 4700 | nacho | import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
16 | import com.iver.cit.gvsig.fmap.layers.GeoPoint; |
||
17 | import com.iver.cit.gvsig.gui.View; |
||
18 | import com.iver.cit.gvsig.gui.dialogs.GeoreferencingDialog; |
||
19 | import com.iver.cit.gvsig.gui.listeners.GeoRasterFrameListener; |
||
20 | import com.iver.cit.gvsig.gui.panels.AdjustGeorefPanel; |
||
21 | import com.iver.cit.gvsig.gui.panels.OptionsPanel; |
||
22 | import com.iver.cit.gvsig.gui.panels.ZoomControlPanel; |
||
23 | import com.iver.cit.gvsig.gui.pointsTable.ButtonsExportImportPanel; |
||
24 | import com.iver.cit.gvsig.gui.pointsTable.TableControlerPanel; |
||
25 | import com.iver.cit.gvsig.gui.pointsTable.TablePointsPanel; |
||
26 | import com.iver.cit.gvsig.gui.pointsTable.TablePointsPanel.PointTable; |
||
27 | import com.iver.cit.gvsig.gui.selectPoints.DataPointPanel; |
||
28 | import com.iver.cit.gvsig.gui.selectPoints.ErrorPointPanel; |
||
29 | import com.iver.cit.gvsig.gui.selectPoints.SelectPointsPanel; |
||
30 | |||
31 | /**
|
||
32 | * Gestor de puntos. Contiene metodos para a?adir. borrar, seleccionar,..
|
||
33 | * puntos coordinando la capa de puntos y la visualizaci?n del interfaz
|
||
34 | * gr?fico.
|
||
35 | *
|
||
36 | * @author Nacho Brodin (brodin_ign@gva.es)
|
||
37 | *
|
||
38 | */
|
||
39 | public class PointManager{ |
||
40 | |||
41 | //**********************Vars**********************************
|
||
42 | private GeoreferencingDialog dialog = null; |
||
43 | |||
44 | private SelectPointsPanel selectPointsPanel = null; |
||
45 | private ErrorPointPanel errorPointPanel = null; |
||
46 | private DataPointPanel dataPointPanel = null; |
||
47 | private TableControlerPanel tableControlerPanel1 = null; |
||
48 | |||
49 | private TablePointsPanel tablePointsPanel = null; |
||
50 | private TableControlerPanel tableControlerPanel2 = null; |
||
51 | private ButtonsExportImportPanel buttonsExportImportPanel = null; |
||
52 | |||
53 | private OptionsPanel optionsPanel = null; |
||
54 | private ZoomControlPanel zoomControlPanelLeft = null; |
||
55 | private ZoomControlPanel zoomControlPanelRight = null; |
||
56 | |||
57 | 4729 | nacho | private FLyrPoints lyrPoints = null; |
58 | private double currentMapX = 0D; |
||
59 | private double currentMapY = 0D; |
||
60 | private double currentPixelX = 0D; |
||
61 | private double currentPixelY = 0D; |
||
62 | 4700 | nacho | //**********************End Vars******************************
|
63 | |||
64 | //**********************Methods*******************************
|
||
65 | /**
|
||
66 | * Constructor
|
||
67 | */
|
||
68 | public PointManager(GeoreferencingDialog dialog, FLyrPoints flyrPoints){
|
||
69 | this.dialog = dialog;
|
||
70 | this.selectPointsPanel = dialog.getSelectPointsPanel();
|
||
71 | this.errorPointPanel = dialog.getSelectPointsPanel().getErrorPointPanel();
|
||
72 | this.dataPointPanel = dialog.getSelectPointsPanel().getDataPointPanel();
|
||
73 | this.tableControlerPanel1 = dialog.getSelectPointsPanel().getTableControlerPanel();
|
||
74 | this.tablePointsPanel = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel();
|
||
75 | this.tableControlerPanel2 = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getTableControlerPanel();
|
||
76 | this.buttonsExportImportPanel = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getPButtonsExportImportPanel();
|
||
77 | this.optionsPanel = dialog.getConectorPanel().getAdjustGeorefPanel().getOptionsPanel();
|
||
78 | this.zoomControlPanelLeft = dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft();
|
||
79 | this.zoomControlPanelRight = dialog.getConectorPanel().getAdjustGeorefPanel().getZoomRight();
|
||
80 | this.lyrPoints = flyrPoints;
|
||
81 | } |
||
82 | |||
83 | /**
|
||
84 | * Crea un nuevo punto vacio en la capa y lo a?ade al interfaz gr?fico para
|
||
85 | * que puedan ser introducidas las coordenadas por el usuario
|
||
86 | */
|
||
87 | public void newEmptyPoint(){ |
||
88 | try{
|
||
89 | //Antes de a?adir un nuevo pto compruba que los textField del anterior no est?n vacios
|
||
90 | if(tableControlerPanel1.getItemCount() > 0) |
||
91 | selectPointsPanel.checkInfoPointText(); |
||
92 | |||
93 | //A?ade un punto vacio a la capa
|
||
94 | lyrPoints.addPoint(null, null); |
||
95 | |||
96 | //A?ade un punto al control de tabla y checkea la activaci?n de los botones
|
||
97 | tableControlerPanel1.addPointToTable(lyrPoints.getCountPoints()); |
||
98 | |||
99 | //Guardamos el ?ltimo punto seleccionado por si hay que recuperarlo
|
||
100 | selectPointsPanel.setLastIndexSelection(lyrPoints.getCountPoints() - 1);
|
||
101 | |||
102 | //resetea los controles de (del, delall, selectFromView y miniimagenes)
|
||
103 | dialog.resetControls(true);
|
||
104 | 4729 | nacho | |
105 | //Desactivamos los controles de las miniimagenes para que no capture los
|
||
106 | //eventos hasta que no se hayan introducido los puntos
|
||
107 | zoomControlPanelLeft.setEnabled(false);
|
||
108 | zoomControlPanelRight.setEnabled(false);
|
||
109 | 4772 | nacho | dialog.getConectorPanel().getAdjustGeorefPanel().setLZoomRight("1:");
|
110 | dialog.getConectorPanel().getAdjustGeorefPanel().setLZoomLeft("1:");
|
||
111 | 4700 | nacho | }catch(NoSuchFieldException exc){ |
112 | JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
||
113 | PluginServices.getText(this, "coordenadas_vacias")); |
||
114 | } |
||
115 | } |
||
116 | |||
117 | /**
|
||
118 | * A partir de nuevas coordenadas actualiza la vista, minimagen, capa de puntos el
|
||
119 | * dialogo y la tabla.
|
||
120 | *
|
||
121 | */
|
||
122 | public void updateData(int nPunto, Point2D pixel, Point2D map, GeoreferencingDialog dialog, View view){ |
||
123 | if(dialog == null) |
||
124 | return;
|
||
125 | if(pixel == null && map == null) |
||
126 | return;
|
||
127 | |||
128 | //Actualizamos los textBox
|
||
129 | if(pixel != null){ |
||
130 | dialog.setPixelText(pixel.getX(), pixel.getY()); |
||
131 | dialog.getSelectPointsPanel().lastTx = String.valueOf(pixel.getX());
|
||
132 | dialog.getSelectPointsPanel().lastTy = String.valueOf(pixel.getY());
|
||
133 | } |
||
134 | if(map != null){ |
||
135 | dialog.setMapCoordText(map.getX(), map.getY()); |
||
136 | dialog.getSelectPointsPanel().lastLong = String.valueOf(map.getX());
|
||
137 | 5089 | nacho | dialog.getSelectPointsPanel().lastLat = String.valueOf(map.getY());
|
138 | 4700 | nacho | } |
139 | |||
140 | //El Checkbox de activaci?n
|
||
141 | GeoPoint gp = ((GeoPoint)lyrPoints.getPoint(nPunto - 1));
|
||
142 | 4723 | nacho | if(gp != null){ |
143 | dataPointPanel.getCbActive().setSelected(gp.active); |
||
144 | dialog.setEnabled(gp.active); |
||
145 | } |
||
146 | 4700 | nacho | |
147 | //Actualizamos la tabla
|
||
148 | |||
149 | while(dialog.getTableRowCount() < nPunto)
|
||
150 | dialog.addTableNew(); |
||
151 | dialog.setTableValueAt(String.valueOf(nPunto - 1),nPunto - 1,0); |
||
152 | |||
153 | if(pixel != null){ |
||
154 | 4745 | nacho | dialog.setTableValueAt(MathUtils.tailDecimals(String.valueOf(pixel.getX()), 5),nPunto - 1,1); |
155 | dialog.setTableValueAt(MathUtils.tailDecimals(String.valueOf(pixel.getY()), 5),nPunto - 1,2); |
||
156 | 4700 | nacho | } |
157 | if(map != null){ |
||
158 | 4745 | nacho | dialog.setTableValueAt(MathUtils.tailDecimals(String.valueOf(map.getX()), 5),nPunto - 1,3); |
159 | dialog.setTableValueAt(MathUtils.tailDecimals(String.valueOf(map.getY()), 5),nPunto - 1,4); |
||
160 | 4700 | nacho | } |
161 | |||
162 | //Actualizamos la capa de puntos
|
||
163 | if(pixel != null || map != null) |
||
164 | lyrPoints.updatePoint(pixel, map, nPunto - 1);
|
||
165 | |||
166 | //Actualizamos la miniimagen
|
||
167 | if(view != null){ |
||
168 | ViewPort viewPort = view.getMapControl().getMapContext().getViewPort(); |
||
169 | |||
170 | if(pixel != null){ |
||
171 | dialog.getZoomControlLeft().setCenterPoint(lyrPoints.getLyrGeoRaster().img2World(pixel)); |
||
172 | dialog.getConectorPanel().getAdjustGeorefPanel().setViewPort(viewPort); |
||
173 | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().draw(); |
||
174 | } |
||
175 | |||
176 | if(map != null){ |
||
177 | dialog.getZoomControlRight().setCenterPoint(map); |
||
178 | dialog.getConectorPanel().getAdjustGeorefPanel().setViewPort(viewPort); |
||
179 | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomRight().draw(); |
||
180 | } |
||
181 | //Actualizamos la vista
|
||
182 | view.getMapControl().getMapContext().invalidate(); |
||
183 | } |
||
184 | } |
||
185 | |||
186 | /**
|
||
187 | * Busca el punto en la capa FLyrPoint que corresponde con la posicion pos
|
||
188 | * y carga la informaci?n de este en el panel de informaci?n pasado por par?metro.
|
||
189 | * @param pos Posici?n del punto
|
||
190 | * @param panel donde se carga la informaci?n
|
||
191 | */
|
||
192 | public void selectPoint(int pos, GeoreferencingDialog dialog){ |
||
193 | GeoPoint pto = null;
|
||
194 | try{
|
||
195 | pto = lyrPoints.getPoint(pos); |
||
196 | if(pto == null) |
||
197 | return;
|
||
198 | }catch(ArrayIndexOutOfBoundsException exc){ |
||
199 | //Todavia no hay puntos por lo que no hacemos nada
|
||
200 | return;
|
||
201 | } |
||
202 | DataPointPanel dpp = dialog.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel(); |
||
203 | |||
204 | //Llenamos los JTextField con los valores del punto
|
||
205 | if(pto.pixelPoint != null){ |
||
206 | dpp.getTX().setText(""+pto.pixelPoint.getX());
|
||
207 | dpp.getTY().setText(""+pto.pixelPoint.getY());
|
||
208 | } |
||
209 | if(pto.mapPoint != null){ |
||
210 | 4750 | nacho | dpp.getLatitud().setText(MathUtils.tailDecimals(String.valueOf(pto.mapPoint.getY()), 5)); |
211 | dpp.getLongitud().setText(MathUtils.tailDecimals(String.valueOf(pto.mapPoint.getX()), 5)); |
||
212 | 4700 | nacho | } |
213 | |||
214 | //El Checkbox de activaci?n
|
||
215 | 4723 | nacho | dataPointPanel.getCbActive().setSelected(pto.active); |
216 | dialog.setEnabled(pto.active); |
||
217 | 4700 | nacho | |
218 | //Seleccionamos la fila de la tabla
|
||
219 | PointTable table = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getJTable(); |
||
220 | try{
|
||
221 | table.getTable().setRowSelectionInterval(pos, pos); |
||
222 | }catch(IllegalArgumentException exc){ |
||
223 | System.err.println("Intervalo erroneo "+pos); |
||
224 | } |
||
225 | |||
226 | //Cargamos las mini imagenes
|
||
227 | dialog.getZoomControlLeft().setCenterPoint(lyrPoints.getCenterPoint(pos, false));
|
||
228 | dialog.getZoomControlLeft().setNewViewPort(lyrPoints.getMiniExtent(pos, false));
|
||
229 | dialog.getZoomControlLeft().draw(); |
||
230 | 4772 | nacho | |
231 | 4700 | nacho | dialog.getZoomControlRight().setCenterPoint(lyrPoints.getCenterPoint(pos, true));
|
232 | dialog.getZoomControlRight().setNewViewPort(lyrPoints.getMiniExtent(pos, true));
|
||
233 | dialog.getZoomControlRight().draw(); |
||
234 | 4772 | nacho | |
235 | 4700 | nacho | //Calculamos los errores
|
236 | String s = lyrPoints.calcRMS(pos);
|
||
237 | dialog.setRMS(MathUtils.tailDecimals(s, 7));
|
||
238 | |||
239 | s = lyrPoints.calcResX(pos); |
||
240 | dialog.setResX(MathUtils.tailDecimals(s, 7));
|
||
241 | |||
242 | s = lyrPoints.calcResY(pos); |
||
243 | dialog.setResY(MathUtils.tailDecimals(s, 7));
|
||
244 | |||
245 | s = lyrPoints.calcTotal(); |
||
246 | dialog.setTotal(MathUtils.tailDecimals(s, 7));
|
||
247 | } |
||
248 | |||
249 | /**
|
||
250 | * Elimina el punto seleccionado de la lista de puntos. Obtiene el punto seleccionado
|
||
251 | * del combobox del tableControler
|
||
252 | */
|
||
253 | public void deletePoint(){ |
||
254 | int op = JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(), |
||
255 | PluginServices.getText(this, "eliminar_punto")); |
||
256 | if(op == JOptionPane.OK_OPTION){ |
||
257 | if(lyrPoints.length() == 1) //Si solo hay un punto reseteamos |
||
258 | clearVisualList(); |
||
259 | else{
|
||
260 | int posSelect = tableControlerPanel1.getSelectedIndex();
|
||
261 | if(posSelect == -1) |
||
262 | return;
|
||
263 | deleteVisualPoint(posSelect); |
||
264 | |||
265 | if(posSelect == 0){ |
||
266 | selectPointsPanel.setLastIndexSelection(posSelect); |
||
267 | }else{
|
||
268 | selectPointsPanel.setLastIndexSelection(posSelect - 1);
|
||
269 | } |
||
270 | } |
||
271 | } |
||
272 | } |
||
273 | |||
274 | /**
|
||
275 | * Elimina todos los puntos de la capa y resetea el dialogo
|
||
276 | */
|
||
277 | public void deleteAllPoints(){ |
||
278 | int op = JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(), |
||
279 | PluginServices.getText(this, "eliminar_todos_puntos")); |
||
280 | if(op == JOptionPane.OK_OPTION){ |
||
281 | clearVisualList(); |
||
282 | } |
||
283 | |||
284 | } |
||
285 | |||
286 | /**
|
||
287 | * Elimina un punto de la lista pasado por par?metro y lo elimina del panel
|
||
288 | * @param pos Posici?n del punto
|
||
289 | * @param grd Panel a limpiar
|
||
290 | */
|
||
291 | private void deleteVisualPoint(int pos){ |
||
292 | lyrPoints.remove(pos); |
||
293 | |||
294 | //Actualiza los controles de tabla y selector
|
||
295 | tableControlerPanel1.setNItems(lyrPoints.length()); |
||
296 | tableControlerPanel2.setNItems(lyrPoints.length()); |
||
297 | |||
298 | //Elimina la fila de la tabla y renumera los puntos
|
||
299 | try{
|
||
300 | dialog.removeTableValueAt(pos); |
||
301 | |||
302 | for(int i=0;i<lyrPoints.length();i++) |
||
303 | dialog.setTableValueAt(String.valueOf(i), i, 0); |
||
304 | }catch(ArrayIndexOutOfBoundsException exc){ |
||
305 | //Si intentamos eliminar una fila que no existe no hacemos nada, simplemente no la eliminamos
|
||
306 | } |
||
307 | |||
308 | //Carga los puntos
|
||
309 | if(pos == 0){ |
||
310 | dialog.getSelectPointsPanel().getTableControlerPanel().setSelectedIndex(pos); |
||
311 | selectPoint(pos, dialog); |
||
312 | }else{
|
||
313 | dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getTableControlerPanel().setSelectedIndex(pos - 1);
|
||
314 | selectPoint(pos - 1, dialog);
|
||
315 | } |
||
316 | |||
317 | //Redibujamos la vista
|
||
318 | View theView = null; |
||
319 | try{
|
||
320 | theView = (View) PluginServices.getMDIManager().getActiveView();
|
||
321 | theView.getMapControl().getMapContext().invalidate(); |
||
322 | }catch(ClassCastException exc){ |
||
323 | return;
|
||
324 | } |
||
325 | } |
||
326 | |||
327 | /**
|
||
328 | * Limpia la lista de puntos .
|
||
329 | */
|
||
330 | public void clearVisualList(){ |
||
331 | AdjustGeorefPanel agp = dialog.getConectorPanel().getAdjustGeorefPanel(); |
||
332 | |||
333 | //Limpiamos la lista de puntos
|
||
334 | lyrPoints.clear(); |
||
335 | //Limpiamos los controles del Selector de puntos
|
||
336 | selectPointsPanel.resetControls(false);
|
||
337 | selectPointsPanel.getTableControlerPanel().resetControls(); |
||
338 | |||
339 | //Limpiamos la tabla y sus controles
|
||
340 | tablePointsPanel.clearTable(); |
||
341 | tablePointsPanel.getTableControlerPanel().resetControls(); |
||
342 | |||
343 | //Limpiamos las miniimagenes
|
||
344 | agp.getZoomLeft().clear(); |
||
345 | agp.getZoomRight().clear(); |
||
346 | |||
347 | //Actualizamos la vista
|
||
348 | View theView = null; |
||
349 | try{
|
||
350 | theView = (View) PluginServices.getMDIManager().getActiveView();
|
||
351 | theView.getMapControl().getMapContext().invalidate(); |
||
352 | }catch(ClassCastException exc){ |
||
353 | return;
|
||
354 | } |
||
355 | } |
||
356 | |||
357 | /**
|
||
358 | * Obtiene la ventana flotante sobre la que ir? el dialogo (GeoreferencingDialog).
|
||
359 | * @param obj
|
||
360 | * @return JInternalFrame
|
||
361 | */
|
||
362 | public static JInternalFrame getInternalFrame(Object obj){ |
||
363 | JInternalFrame panel = new JInternalFrame(); |
||
364 | panel.addInternalFrameListener(new GeoRasterFrameListener());
|
||
365 | panel.setClosable(true);
|
||
366 | panel.setResizable(false);
|
||
367 | panel.setTitle(PluginServices.getText(obj,"georreferenciar"));
|
||
368 | return panel;
|
||
369 | } |
||
370 | 4841 | nacho | |
371 | |||
372 | public static GeoreferencingDialog initWindow(FLyrGeoRaster lyrGeoRaster, boolean show, Object obj){ |
||
373 | lyrGeoRaster.getStackZoom().setInitExtent(lyrGeoRaster.getAssignExtent()); |
||
374 | GeoreferencingDialog geoDialog = null;
|
||
375 | |||
376 | JInternalFrame panel = PointManager.getInternalFrame(obj);
|
||
377 | geoDialog = new GeoreferencingDialog(panel, lyrGeoRaster);
|
||
378 | lyrGeoRaster.getFLyrPoints().saveState(); |
||
379 | lyrGeoRaster.setGeoDialog(geoDialog); |
||
380 | panel.setSize(geoDialog.getWidth() + 12, geoDialog.getHeight() + 10); |
||
381 | panel.getContentPane().add(geoDialog); |
||
382 | |||
383 | MDIFrame mainFrame = (MDIFrame) PluginServices.getMainFrame(); |
||
384 | |||
385 | JDesktopPane desk = new JDesktopPane(); |
||
386 | desk.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
|
||
387 | |||
388 | JLayeredPane lyrPane = mainFrame.getLayeredPane();
|
||
389 | lyrPane.add(panel, JDesktopPane.PALETTE_LAYER);
|
||
390 | lyrPane.add(desk, JDesktopPane.OUTLINE_DRAG_MODE);
|
||
391 | if(show)
|
||
392 | panel.show(); |
||
393 | |||
394 | return geoDialog;
|
||
395 | } |
||
396 | |||
397 | 4700 | nacho | //**********************End Methods***************************
|
398 | |||
399 | //**********************Getters & Setters*********************
|
||
400 | public FLyrPoints getFlyrPoints() {
|
||
401 | return lyrPoints;
|
||
402 | } |
||
403 | |||
404 | public void setFlyrPoints(FLyrPoints flyrPoints) { |
||
405 | this.lyrPoints = flyrPoints;
|
||
406 | } |
||
407 | 4715 | nacho | |
408 | public GeoreferencingDialog getDialog() {
|
||
409 | return dialog;
|
||
410 | } |
||
411 | 4729 | nacho | |
412 | /**
|
||
413 | * Salva en 2 variables de instancia el valor actual en coordenadas del
|
||
414 | * mundo del punto seleccionado. Esto es util para su posterior restauraci?n.
|
||
415 | */
|
||
416 | public void setCurrentWC() { |
||
417 | int posSelect = 0; |
||
418 | 4772 | nacho | try{
|
419 | if(tableControlerPanel1 != null) |
||
420 | posSelect = tableControlerPanel1.getSelectedIndex(); |
||
421 | if(lyrPoints != null){ |
||
422 | this.currentMapX = lyrPoints.getPoint(posSelect).mapPoint.getX();
|
||
423 | this.currentMapY = lyrPoints.getPoint(posSelect).mapPoint.getY();
|
||
424 | } |
||
425 | }catch(NullPointerException exc){ |
||
426 | //Si tableControler o la capa de puntos son null no salvamos el punto
|
||
427 | 4729 | nacho | } |
428 | } |
||
429 | |||
430 | /**
|
||
431 | * Asigna nuevos valores al texto de la latitud y longitud.
|
||
432 | * @param x Longitud
|
||
433 | * @param y Latitud
|
||
434 | */
|
||
435 | public void setTempWC(double x, double y){ |
||
436 | 4750 | nacho | dataPointPanel.getLongitud().setText(MathUtils.tailDecimals(String.valueOf(x), 5) + ""); |
437 | dataPointPanel.getLatitud().setText(MathUtils.tailDecimals(String.valueOf(y), 5) + ""); |
||
438 | 4729 | nacho | } |
439 | |||
440 | /**
|
||
441 | * Restaura el ?ltimo valor seleccionado por el usuario de la latitud
|
||
442 | * y longitud.
|
||
443 | */
|
||
444 | public void replaceWC(){ |
||
445 | 4750 | nacho | dataPointPanel.getLongitud().setText(MathUtils.tailDecimals(String.valueOf(currentMapX), 5) + ""); |
446 | dataPointPanel.getLatitud().setText(MathUtils.tailDecimals(String.valueOf(currentMapY), 5) + ""); |
||
447 | 4729 | nacho | } |
448 | |||
449 | /**
|
||
450 | * Salva en 2 variables de instancia el valor actual en coordenadas del
|
||
451 | * mundo del punto seleccionado. Esto es util para su posterior restauraci?n.
|
||
452 | */
|
||
453 | public void setCurrentPixelCoord() { |
||
454 | int posSelect = 0; |
||
455 | 4772 | nacho | try{
|
456 | if(tableControlerPanel1 != null) |
||
457 | posSelect = tableControlerPanel1.getSelectedIndex(); |
||
458 | if(lyrPoints != null){ |
||
459 | this.currentPixelX = lyrPoints.getPoint(posSelect).pixelPoint.getX();
|
||
460 | this.currentPixelY = lyrPoints.getPoint(posSelect).pixelPoint.getY();
|
||
461 | } |
||
462 | }catch(NullPointerException exc){ |
||
463 | //Si tableControler o la capa de puntos son null no salvamos el punto
|
||
464 | 4729 | nacho | } |
465 | } |
||
466 | |||
467 | /**
|
||
468 | * Asigna nuevos valores al texto de la latitud y longitud.
|
||
469 | * @param x Longitud
|
||
470 | * @param y Latitud
|
||
471 | */
|
||
472 | public void setTempPixelCoord(double x, double y){ |
||
473 | 4750 | nacho | dataPointPanel.getTX().setText(MathUtils.tailDecimals(String.valueOf(x), 5) + ""); |
474 | dataPointPanel.getTY().setText(MathUtils.tailDecimals(String.valueOf(y), 5) + ""); |
||
475 | 4729 | nacho | } |
476 | |||
477 | /**
|
||
478 | * Restaura el ?ltimo valor seleccionado por el usuario de la latitud
|
||
479 | * y longitud.
|
||
480 | */
|
||
481 | public void replacePixelCoord(){ |
||
482 | dataPointPanel.getTX().setText(currentPixelX + "");
|
||
483 | dataPointPanel.getTY().setText(currentPixelY + "");
|
||
484 | } |
||
485 | 4700 | nacho | //**********************End Getters & Setters*****************
|
486 | } |