svn-gvsig-desktop / tags / v1_1_Build_1003 / extensions / extGeoreferencing / src / org / gvsig / georeferencing / utils / PointManager.java @ 12271
History | View | Annotate | Download (32.1 KB)
1 | 5791 | nacho | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | */
|
||
19 | 5217 | nacho | package org.gvsig.georeferencing.utils; |
20 | |||
21 | import java.awt.Component; |
||
22 | import java.awt.geom.Point2D; |
||
23 | 5697 | nacho | import java.awt.geom.Rectangle2D; |
24 | 5217 | nacho | |
25 | import javax.swing.JDesktopPane; |
||
26 | import javax.swing.JInternalFrame; |
||
27 | import javax.swing.JLayeredPane; |
||
28 | import javax.swing.JOptionPane; |
||
29 | 5598 | nacho | import javax.xml.transform.TransformerException; |
30 | 5217 | nacho | |
31 | import org.gvsig.georeferencing.GeoOperations; |
||
32 | import org.gvsig.georeferencing.GeoreferencingToolsModule; |
||
33 | 5818 | nacho | import org.gvsig.georeferencing.gui.dialog.GeoreferencingDialog; |
34 | 5217 | nacho | import org.gvsig.georeferencing.gui.listeners.GeoRasterFrameListener; |
35 | 5598 | nacho | import org.gvsig.georeferencing.gui.listeners.GeorefPointSelectorListener; |
36 | 5217 | nacho | import org.gvsig.georeferencing.gui.panels.AdjustGeorefPanel; |
37 | import org.gvsig.georeferencing.gui.panels.OptionsPanel; |
||
38 | import org.gvsig.georeferencing.gui.panels.ZoomControlPanel; |
||
39 | 5781 | nacho | import org.gvsig.georeferencing.gui.pointsTable.TablePanelButtons; |
40 | 5217 | nacho | import org.gvsig.georeferencing.gui.pointsTable.TableControlerPanel; |
41 | import org.gvsig.georeferencing.gui.pointsTable.TablePointsPanel; |
||
42 | import org.gvsig.georeferencing.gui.pointsTable.TablePointsPanel.PointTable; |
||
43 | import org.gvsig.georeferencing.gui.selectPoints.DataPointPanel; |
||
44 | import org.gvsig.georeferencing.gui.selectPoints.ErrorPointPanel; |
||
45 | import org.gvsig.georeferencing.gui.selectPoints.SelectPointsPanel; |
||
46 | |||
47 | import com.iver.andami.PluginServices; |
||
48 | import com.iver.andami.ui.mdiFrame.MDIFrame; |
||
49 | import com.iver.cit.gvsig.fmap.ViewPort; |
||
50 | 5241 | nacho | import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
51 | import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
||
52 | import com.iver.cit.gvsig.fmap.layers.GeoPoint; |
||
53 | import com.iver.cit.gvsig.fmap.layers.IGeoUi; |
||
54 | 8765 | jjdelcerro | import com.iver.cit.gvsig.project.documents.view.gui.View; |
55 | 5217 | nacho | |
56 | /**
|
||
57 | * Gestor de puntos. Contiene metodos para a?adir. borrar, seleccionar,..
|
||
58 | * puntos coordinando la capa de puntos y la visualizaci?n del interfaz
|
||
59 | * gr?fico.
|
||
60 | *
|
||
61 | * @author Nacho Brodin (brodin_ign@gva.es)
|
||
62 | *
|
||
63 | */
|
||
64 | public class PointManager{ |
||
65 | |||
66 | //**********************Vars**********************************
|
||
67 | private GeoreferencingDialog dialog = null; |
||
68 | |||
69 | private SelectPointsPanel selectPointsPanel = null; |
||
70 | private ErrorPointPanel errorPointPanel = null; |
||
71 | private DataPointPanel dataPointPanel = null; |
||
72 | private TableControlerPanel tableControlerPanel1 = null; |
||
73 | |||
74 | private TablePointsPanel tablePointsPanel = null; |
||
75 | private TableControlerPanel tableControlerPanel2 = null; |
||
76 | 5818 | nacho | private TablePanelButtons buttonsExportImportPanel = null; |
77 | 5217 | nacho | |
78 | private OptionsPanel optionsPanel = null; |
||
79 | private ZoomControlPanel zoomControlPanelLeft = null; |
||
80 | private ZoomControlPanel zoomControlPanelRight = null; |
||
81 | |||
82 | private FLyrPoints lyrPoints = null; |
||
83 | private double currentMapX = 0D; |
||
84 | private double currentMapY = 0D; |
||
85 | private double currentPixelX = 0D; |
||
86 | private double currentPixelY = 0D; |
||
87 | 5303 | nacho | private boolean disableAllControls = false; |
88 | 5217 | nacho | //**********************End Vars******************************
|
89 | |||
90 | //**********************Methods*******************************
|
||
91 | /**
|
||
92 | * Constructor
|
||
93 | */
|
||
94 | public PointManager(GeoreferencingDialog dialog, FLyrPoints flyrPoints){
|
||
95 | this.dialog = dialog;
|
||
96 | this.selectPointsPanel = dialog.getSelectPointsPanel();
|
||
97 | this.errorPointPanel = dialog.getSelectPointsPanel().getErrorPointPanel();
|
||
98 | this.dataPointPanel = dialog.getSelectPointsPanel().getDataPointPanel();
|
||
99 | this.tableControlerPanel1 = dialog.getSelectPointsPanel().getTableControlerPanel();
|
||
100 | this.tablePointsPanel = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel();
|
||
101 | this.tableControlerPanel2 = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getTableControlerPanel();
|
||
102 | 5781 | nacho | this.buttonsExportImportPanel = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getPTablePanelButtons();
|
103 | 5217 | nacho | this.optionsPanel = dialog.getConectorPanel().getAdjustGeorefPanel().getOptionsPanel();
|
104 | this.zoomControlPanelLeft = dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft();
|
||
105 | this.zoomControlPanelRight = dialog.getConectorPanel().getAdjustGeorefPanel().getZoomRight();
|
||
106 | this.lyrPoints = flyrPoints;
|
||
107 | } |
||
108 | |||
109 | /**
|
||
110 | * Crea un nuevo punto vacio en la capa y lo a?ade al interfaz gr?fico para
|
||
111 | * que puedan ser introducidas las coordenadas por el usuario
|
||
112 | */
|
||
113 | public void newEmptyPoint(){ |
||
114 | try{
|
||
115 | //Antes de a?adir un nuevo pto compruba que los textField del anterior no est?n vacios
|
||
116 | if(tableControlerPanel1.getItemCount() > 0) |
||
117 | selectPointsPanel.checkInfoPointText(); |
||
118 | |||
119 | //A?ade un punto vacio a la capa
|
||
120 | lyrPoints.addPoint(null, null); |
||
121 | |||
122 | //A?ade un punto al control de tabla y checkea la activaci?n de los botones
|
||
123 | tableControlerPanel1.addPointToTable(lyrPoints.getCountPoints()); |
||
124 | |||
125 | //Guardamos el ?ltimo punto seleccionado por si hay que recuperarlo
|
||
126 | selectPointsPanel.setLastIndexSelection(lyrPoints.getCountPoints() - 1);
|
||
127 | |||
128 | //resetea los controles de (del, delall, selectFromView y miniimagenes)
|
||
129 | dialog.resetControls(true);
|
||
130 | |||
131 | //Desactivamos los controles de las miniimagenes para que no capture los
|
||
132 | //eventos hasta que no se hayan introducido los puntos
|
||
133 | dialog.getConectorPanel().getAdjustGeorefPanel().setEnabled(false);
|
||
134 | dialog.getConectorPanel().getAdjustGeorefPanel().setLZoomRight("1:");
|
||
135 | dialog.getConectorPanel().getAdjustGeorefPanel().setLZoomLeft("1:");
|
||
136 | 5304 | nacho | |
137 | 5217 | nacho | }catch(NoSuchFieldException exc){ |
138 | JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
||
139 | PluginServices.getText(this, "coordenadas_vacias")); |
||
140 | } |
||
141 | } |
||
142 | |||
143 | /**
|
||
144 | * A partir de nuevas coordenadas actualiza la vista, minimagen, capa de puntos el
|
||
145 | * dialogo y la tabla.
|
||
146 | *
|
||
147 | */
|
||
148 | 5241 | nacho | public void updateData(int nPunto, Point2D pixel, Point2D map, IGeoUi geoUI, View view){ |
149 | dialog = (GeoreferencingDialog)geoUI; |
||
150 | 5217 | nacho | if(dialog == null) |
151 | return;
|
||
152 | if(pixel == null && map == null) |
||
153 | return;
|
||
154 | |||
155 | //Actualizamos los textBox
|
||
156 | 5598 | nacho | if(pixel != null) |
157 | 5697 | nacho | dialog.setPixelText(GeoUtils.tailDecimals(pixel.getX(), 2), GeoUtils.tailDecimals(pixel.getY(), 2)); |
158 | 5598 | nacho | |
159 | if(map != null) |
||
160 | 5217 | nacho | dialog.setMapCoordText(map.getX(), map.getY()); |
161 | |||
162 | //El Checkbox de activaci?n
|
||
163 | GeoPoint gp = ((GeoPoint)lyrPoints.getPoint(nPunto - 1));
|
||
164 | if(gp != null){ |
||
165 | dataPointPanel.getCbActive().setSelected(gp.active); |
||
166 | dialog.setEnabled(gp.active); |
||
167 | } |
||
168 | |||
169 | //Actualizamos la tabla
|
||
170 | |||
171 | while(dialog.getTableRowCount() < nPunto)
|
||
172 | dialog.addTableNew(); |
||
173 | 5702 | nacho | if(gp != null) |
174 | dialog.setCheckValueAt(new Boolean(gp.active), nPunto - 1); |
||
175 | dialog.setTableValueAt(String.valueOf(nPunto), nPunto - 1, 1); |
||
176 | 5217 | nacho | |
177 | if(pixel != null){ |
||
178 | 5702 | nacho | dialog.setTableValueAt(GeoUtils.tailDecimals(String.valueOf(pixel.getX()), 5), nPunto - 1, 2); |
179 | dialog.setTableValueAt(GeoUtils.tailDecimals(String.valueOf(pixel.getY()), 5), nPunto - 1, 3); |
||
180 | 5217 | nacho | } |
181 | if(map != null){ |
||
182 | 5702 | nacho | dialog.setTableValueAt(GeoUtils.tailDecimals(String.valueOf(map.getX()), 5), nPunto - 1, 4); |
183 | dialog.setTableValueAt(GeoUtils.tailDecimals(String.valueOf(map.getY()), 5), nPunto - 1, 5); |
||
184 | 5217 | nacho | } |
185 | |||
186 | //Actualizamos la capa de puntos
|
||
187 | if(pixel != null || map != null) |
||
188 | lyrPoints.updatePoint(pixel, map, nPunto - 1);
|
||
189 | |||
190 | //Actualizamos la miniimagen
|
||
191 | if(view != null){ |
||
192 | ViewPort viewPort = view.getMapControl().getMapContext().getViewPort(); |
||
193 | |||
194 | if(pixel != null){ |
||
195 | dialog.getZoomControlLeft().setCenterPoint(lyrPoints.getLyrGeoRaster().img2World(pixel)); |
||
196 | 5661 | nacho | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().setViewPort(viewPort, lyrPoints.getPoint(nPunto - 1).zoomLeft);
|
197 | 5217 | nacho | //Si est? extendido hacemos un draw corriente sino es q est? plegado y tocar? asignar el extent de la miniimagen
|
198 | if(dialog.isEnlarge())
|
||
199 | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().draw(); |
||
200 | 5587 | nacho | |
201 | lyrPoints.setMiniExtent(nPunto - 1,
|
||
202 | lyrPoints.getLyrGeoRaster().img2World(pixel), |
||
203 | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().getCanvas().initViewPort(viewPort, lyrPoints.getLyrGeoRaster().img2World(pixel), null, 1), |
||
204 | false);
|
||
205 | 5217 | nacho | } |
206 | |||
207 | if(map != null){ |
||
208 | dialog.getZoomControlRight().setCenterPoint(map); |
||
209 | 5661 | nacho | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomRight().setViewPort(viewPort, lyrPoints.getPoint(nPunto - 1).zoomRight);
|
210 | 5217 | nacho | //Si est? extendido hacemos un draw corriente sino es q est? plegado y tocar? asignar el extent de la miniimagen
|
211 | if(dialog.isEnlarge())
|
||
212 | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomRight().draw(); |
||
213 | 5587 | nacho | |
214 | lyrPoints.setMiniExtent(nPunto - 1,
|
||
215 | map, |
||
216 | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomRight().getCanvas().initViewPort(viewPort, map, null, 1), |
||
217 | true);
|
||
218 | 5217 | nacho | } |
219 | 5396 | nacho | |
220 | 5217 | nacho | //Actualizamos la vista
|
221 | view.getMapControl().getMapContext().invalidate(); |
||
222 | } |
||
223 | 5396 | nacho | |
224 | 5491 | nacho | //Calculamos los errores
|
225 | 5661 | nacho | try{
|
226 | if(pixel != null || map != null) |
||
227 | setErrors(nPunto - 1);
|
||
228 | }catch(ArrayIndexOutOfBoundsException ex){ |
||
229 | //Esta excepci?n ocurre despues de introducir el primer punto ya que map es null
|
||
230 | //En este caso no hacemos nada y no se calcula el error
|
||
231 | } |
||
232 | 5491 | nacho | |
233 | } |
||
234 | |||
235 | /**
|
||
236 | * Al actualizar un punto debemos recalcular los errores RMS y Total para ello tenemos que
|
||
237 | * pedir la transformaci?n de toda la lista de puntos. Esta funci?n calcula esta lista
|
||
238 | * transformada y la asigna a un array en la capa de puntos. Esta funci?n tiene en cuenta
|
||
239 | * que un punto puede estar inactivo.
|
||
240 | */
|
||
241 | private void transformPointList(){ |
||
242 | 5396 | nacho | try{
|
243 | GeoOperations go = new GeoOperations(lyrPoints);
|
||
244 | 5491 | nacho | Point2D[] pointList = new Point2D[lyrPoints.getCountActivePoints()]; |
245 | int pActive = 0; |
||
246 | for(int i=0; i< lyrPoints.getCountPoints(); i++){ |
||
247 | if(lyrPoints.getPoint(i).active){
|
||
248 | pointList[pActive] = lyrPoints.getPoint(i).pixelPoint; |
||
249 | pActive ++; |
||
250 | } |
||
251 | } |
||
252 | 5396 | nacho | |
253 | 5491 | nacho | Point2D[] transformActivePointList = go.transformPoints(pointList); |
254 | Point2D[] transformPointList = new Point2D[lyrPoints.getCountPoints()]; |
||
255 | |||
256 | pActive = 0;
|
||
257 | for(int i=0; i< lyrPoints.getCountPoints(); i++){ |
||
258 | if(lyrPoints.getPoint(i).active){
|
||
259 | transformPointList[i] = transformActivePointList[pActive]; |
||
260 | pActive ++; |
||
261 | }else
|
||
262 | transformPointList[i] = null;
|
||
263 | } |
||
264 | |||
265 | 5396 | nacho | lyrPoints.setTransformPointList(transformPointList); |
266 | }catch(NullPointerException e){ |
||
267 | //Si ocurre esta excepci?n es que se est? intentando incluir un punto que se acaba de crear
|
||
268 | //y por lo tanto no tiene el valor asignado todavia por lo que es mejor no hacer nada
|
||
269 | //y seguir con el proceso
|
||
270 | } |
||
271 | 5217 | nacho | } |
272 | 5491 | nacho | |
273 | 5217 | nacho | /**
|
274 | * Busca el punto en la capa FLyrPoint que corresponde con la posicion pos
|
||
275 | * y carga la informaci?n de este en el panel de informaci?n pasado por par?metro.
|
||
276 | * @param pos Posici?n del punto
|
||
277 | * @param panel donde se carga la informaci?n
|
||
278 | */
|
||
279 | public void selectPoint(int pos, GeoreferencingDialog dialog){ |
||
280 | GeoPoint pto = null;
|
||
281 | try{
|
||
282 | pto = lyrPoints.getPoint(pos); |
||
283 | if(pto == null) |
||
284 | return;
|
||
285 | }catch(ArrayIndexOutOfBoundsException exc){ |
||
286 | //Todavia no hay puntos por lo que no hacemos nada
|
||
287 | return;
|
||
288 | } |
||
289 | 5635 | nacho | |
290 | //Actualizamos el valor del combo
|
||
291 | try{
|
||
292 | tableControlerPanel1.getCPoint().setSelectedIndex(pos); |
||
293 | }catch(IllegalArgumentException ex){} |
||
294 | try{
|
||
295 | tableControlerPanel2.getCPoint().setSelectedIndex(pos); |
||
296 | }catch(IllegalArgumentException ex){} |
||
297 | |||
298 | 5217 | nacho | DataPointPanel dpp = dialog.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel(); |
299 | |||
300 | //Llenamos los JTextField con los valores del punto
|
||
301 | if(pto.pixelPoint != null){ |
||
302 | 5697 | nacho | dpp.getTX().setText(GeoUtils.tailDecimals(pto.pixelPoint.getX(), 2)+""); |
303 | dpp.getTY().setText(GeoUtils.tailDecimals(pto.pixelPoint.getY(), 2)+""); |
||
304 | 5217 | nacho | } |
305 | if(pto.mapPoint != null){ |
||
306 | 5697 | nacho | dpp.getLatitud().setText(GeoUtils.tailDecimals(String.valueOf(pto.mapPoint.getY()), 5)); |
307 | dpp.getLongitud().setText(GeoUtils.tailDecimals(String.valueOf(pto.mapPoint.getX()), 5)); |
||
308 | 5217 | nacho | } |
309 | |||
310 | //El Checkbox de activaci?n
|
||
311 | dataPointPanel.getCbActive().setSelected(pto.active); |
||
312 | dialog.setEnabled(pto.active); |
||
313 | |||
314 | //Seleccionamos la fila de la tabla
|
||
315 | PointTable table = dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getJTable(); |
||
316 | try{
|
||
317 | table.getTable().setRowSelectionInterval(pos, pos); |
||
318 | }catch(IllegalArgumentException exc){ |
||
319 | System.err.println("Intervalo erroneo "+pos); |
||
320 | } |
||
321 | |||
322 | //Cargamos las mini imagenes
|
||
323 | dialog.getZoomControlLeft().setCenterPoint(lyrPoints.getCenterPoint(pos, false));
|
||
324 | 5550 | nacho | |
325 | try{
|
||
326 | 5697 | nacho | ViewPort vpL = GeoUtils.calcZoom(lyrPoints.getMiniExtent(pos, false), lyrPoints.getZoomLeft(pos));
|
327 | 5550 | nacho | dialog.getZoomControlLeft().setNewViewPort(vpL); |
328 | dialog.getZoomControlLeft().draw(); |
||
329 | }catch(NullPointerException ex){ |
||
330 | //Todavia no hay un viewPort por lo que dar? una excepci?n.
|
||
331 | } |
||
332 | 5217 | nacho | |
333 | dialog.getZoomControlRight().setCenterPoint(lyrPoints.getCenterPoint(pos, true));
|
||
334 | 5550 | nacho | try{
|
335 | 5697 | nacho | ViewPort vpR = GeoUtils.calcZoom(lyrPoints.getMiniExtent(pos, true), lyrPoints.getZoomRight(pos));
|
336 | 5550 | nacho | dialog.getZoomControlRight().setNewViewPort(vpR); |
337 | dialog.getZoomControlRight().draw(); |
||
338 | }catch(NullPointerException ex){ |
||
339 | //Todavia no hay un viewPort por lo que dar? una excepci?n
|
||
340 | } |
||
341 | 5217 | nacho | |
342 | 5697 | nacho | //Consultamos si hay que centrar la vista sobre el punto seleccionado
|
343 | |||
344 | if(dialog.isCenterPoint()){
|
||
345 | try{
|
||
346 | centerView(lyrPoints.getCenterPoint(pos, false));
|
||
347 | }catch(NullPointerException ex){ |
||
348 | //Excepci?n cuando se cargan los puntos desde fichero. No hacemos nada
|
||
349 | } |
||
350 | } |
||
351 | |||
352 | 5217 | nacho | //Calculamos los errores
|
353 | 5491 | nacho | if(pto.pixelPoint != null && pto.mapPoint != null) |
354 | setErrors(pos); |
||
355 | 5217 | nacho | } |
356 | |||
357 | /**
|
||
358 | 5460 | nacho | * Obtiene los errores en una matriz de Nx3 en la que cada fila es un punto y la
|
359 | * columna 0 es el error en X, la columna 1 es el error en Y y la columna 2 es el error RMS.
|
||
360 | * @return matriz de errores
|
||
361 | */
|
||
362 | public double[][] getErrors(){ |
||
363 | 5491 | nacho | |
364 | transformPointList(); |
||
365 | |||
366 | 5460 | nacho | //Al actualizar un punto debemos recalcular los errores RMS y Total para ello tenemos que
|
367 | //pedir la transformaci?n de toda la lista de puntos
|
||
368 | try{
|
||
369 | GeoOperations go = new GeoOperations(lyrPoints);
|
||
370 | Point2D[] pointList = new Point2D[lyrPoints.length()]; |
||
371 | for(int i=0; i< lyrPoints.length(); i++) |
||
372 | pointList[i] = lyrPoints.getPoint(i).pixelPoint; |
||
373 | |||
374 | Point2D[] transformPointList = go.transformPoints(pointList); |
||
375 | lyrPoints.setTransformPointList(transformPointList); |
||
376 | }catch(NullPointerException e){ |
||
377 | //Si ocurre esta excepci?n es que se est? intentando incluir un punto que se acaba de crear
|
||
378 | //y por lo tanto no tiene el valor asignado todavia por lo que es mejor no hacer nada
|
||
379 | //y seguir con el proceso
|
||
380 | } |
||
381 | |||
382 | double[][] err = new double[lyrPoints.getCountPoints()][3]; |
||
383 | for(int i = 0; i<lyrPoints.getCountPoints(); i++){ |
||
384 | 5491 | nacho | err[i][0] = lyrPoints.calcDoubleResX(i);
|
385 | err[i][1] = lyrPoints.calcDoubleResY(i);
|
||
386 | err[i][2] = lyrPoints.calcDoubleRMS(i);
|
||
387 | 5460 | nacho | } |
388 | return err;
|
||
389 | } |
||
390 | |||
391 | /**
|
||
392 | 5217 | nacho | * Calcula los errores y los asigna al dialogo y tabla. Hay que tener en cuenta que
|
393 | * hay que tener en la capa de puntos la lista de puntos transformados
|
||
394 | * @param pos
|
||
395 | */
|
||
396 | 5392 | nacho | public void setErrors(int pos){ |
397 | 5491 | nacho | |
398 | if(lyrPoints != null){ |
||
399 | transformPointList(); |
||
400 | |||
401 | //Calculamos los errores
|
||
402 | 6097 | nacho | double rms = lyrPoints.calcDoubleRMS(pos);
|
403 | dialog.setRMS(String.valueOf(GeoUtils.tailDecimals(rms, 5))); |
||
404 | 5491 | nacho | try{
|
405 | 6097 | nacho | dialog.setTableValueAt(String.valueOf(GeoUtils.tailDecimals(rms, 5)), pos, 8); |
406 | 5491 | nacho | }catch(ArrayIndexOutOfBoundsException e){ |
407 | //No asigna el valor a la tabla
|
||
408 | } |
||
409 | |||
410 | 6097 | nacho | double rx = lyrPoints.calcDoubleResX(pos);
|
411 | dialog.setResX(String.valueOf(GeoUtils.tailDecimals(rx, 5))); |
||
412 | 5491 | nacho | try{
|
413 | 6097 | nacho | dialog.setTableValueAt(String.valueOf(GeoUtils.tailDecimals(rx, 5)), pos, 6); |
414 | 5491 | nacho | }catch(ArrayIndexOutOfBoundsException e){ |
415 | //No asigna el valor a la tabla
|
||
416 | } |
||
417 | |||
418 | 6097 | nacho | double ry = lyrPoints.calcDoubleResY(pos);
|
419 | dialog.setResY(String.valueOf(GeoUtils.tailDecimals(ry, 5))); |
||
420 | 5491 | nacho | try{
|
421 | 6097 | nacho | dialog.setTableValueAt(String.valueOf(GeoUtils.tailDecimals(ry, 5)), pos, 7); |
422 | 5491 | nacho | }catch(ArrayIndexOutOfBoundsException e){ |
423 | //No asigna el valor a la tabla
|
||
424 | } |
||
425 | |||
426 | 6097 | nacho | double total = lyrPoints.calcDoubleTotal();
|
427 | dialog.setTotal(String.valueOf(GeoUtils.tailDecimals(total, 5))); |
||
428 | 5491 | nacho | } |
429 | 5217 | nacho | |
430 | } |
||
431 | |||
432 | /**
|
||
433 | * Elimina el punto seleccionado de la lista de puntos. Obtiene el punto seleccionado
|
||
434 | * del combobox del tableControler
|
||
435 | */
|
||
436 | public void deletePoint(){ |
||
437 | int op = JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(), |
||
438 | PluginServices.getText(this, "eliminar_punto")); |
||
439 | if(op == JOptionPane.OK_OPTION){ |
||
440 | if(lyrPoints.length() == 1) //Si solo hay un punto reseteamos |
||
441 | clearVisualList(); |
||
442 | else{
|
||
443 | int posSelect = tableControlerPanel1.getSelectedIndex();
|
||
444 | if(posSelect == -1) |
||
445 | return;
|
||
446 | deleteVisualPoint(posSelect); |
||
447 | |||
448 | if(posSelect == 0){ |
||
449 | selectPointsPanel.setLastIndexSelection(posSelect); |
||
450 | }else{
|
||
451 | selectPointsPanel.setLastIndexSelection(posSelect - 1);
|
||
452 | } |
||
453 | } |
||
454 | } |
||
455 | } |
||
456 | |||
457 | /**
|
||
458 | * Elimina todos los puntos de la capa y resetea el dialogo
|
||
459 | */
|
||
460 | public void deleteAllPoints(){ |
||
461 | int op = JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(), |
||
462 | PluginServices.getText(this, "eliminar_todos_puntos")); |
||
463 | if(op == JOptionPane.OK_OPTION){ |
||
464 | clearVisualList(); |
||
465 | } |
||
466 | |||
467 | } |
||
468 | |||
469 | /**
|
||
470 | * Elimina un punto de la lista pasado por par?metro y lo elimina del panel
|
||
471 | * @param pos Posici?n del punto
|
||
472 | * @param grd Panel a limpiar
|
||
473 | */
|
||
474 | private void deleteVisualPoint(int pos){ |
||
475 | lyrPoints.remove(pos); |
||
476 | |||
477 | //Actualiza los controles de tabla y selector
|
||
478 | tableControlerPanel1.setNItems(lyrPoints.length()); |
||
479 | tableControlerPanel2.setNItems(lyrPoints.length()); |
||
480 | 5635 | nacho | |
481 | 5217 | nacho | //Elimina la fila de la tabla y renumera los puntos
|
482 | try{
|
||
483 | dialog.removeTableValueAt(pos); |
||
484 | |||
485 | for(int i=0;i<lyrPoints.length();i++) |
||
486 | 5702 | nacho | dialog.setTableValueAt(String.valueOf(i + 1), i, 1); |
487 | 5217 | nacho | }catch(ArrayIndexOutOfBoundsException exc){ |
488 | //Si intentamos eliminar una fila que no existe no hacemos nada, simplemente no la eliminamos
|
||
489 | } |
||
490 | |||
491 | //Carga los puntos
|
||
492 | if(pos == 0){ |
||
493 | dialog.getSelectPointsPanel().getTableControlerPanel().setSelectedIndex(pos); |
||
494 | selectPoint(pos, dialog); |
||
495 | }else{
|
||
496 | dialog.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getTableControlerPanel().setSelectedIndex(pos - 1);
|
||
497 | selectPoint(pos - 1, dialog);
|
||
498 | } |
||
499 | |||
500 | 5635 | nacho | //Controlamos las flechas del control de puntos
|
501 | tableControlerPanel1.checkArrows(); |
||
502 | tableControlerPanel2.checkArrows(); |
||
503 | |||
504 | 5217 | nacho | //Redibujamos la vista
|
505 | View theView = null; |
||
506 | try{
|
||
507 | 6880 | cesar | theView = (View) PluginServices.getMDIManager().getActiveWindow();
|
508 | 5217 | nacho | theView.getMapControl().getMapContext().invalidate(); |
509 | }catch(ClassCastException exc){ |
||
510 | return;
|
||
511 | } |
||
512 | } |
||
513 | |||
514 | /**
|
||
515 | 5697 | nacho | * Desplaza la vista centrando esta sobre el punto pasado como par?metro
|
516 | * @param center Punto sobre el que se centra la vista
|
||
517 | */
|
||
518 | private void centerView(Point2D center){ |
||
519 | //Obtenemos la vista
|
||
520 | View theView = null; |
||
521 | try{
|
||
522 | 6880 | cesar | theView = (View) PluginServices.getMDIManager().getActiveWindow();
|
523 | 5697 | nacho | }catch(ClassCastException exc){ |
524 | } |
||
525 | |||
526 | //Calculamos el desplazamiento del extext viejo a partir de la diferencia de centros
|
||
527 | Rectangle2D oldExtent = theView.getMapControl().getMapContext().getViewPort().getExtent();
|
||
528 | double oldCenterX = oldExtent.getMinX() + (oldExtent.getWidth() / 2); |
||
529 | double oldCenterY = oldExtent.getMaxY() - (oldExtent.getHeight() / 2); |
||
530 | double difX = oldCenterX - center.getX();
|
||
531 | double difY = oldCenterY - center.getY();
|
||
532 | |||
533 | double minX = oldExtent.getMinX() - difX;
|
||
534 | double minY = oldExtent.getMinY() - difY;
|
||
535 | |||
536 | //Asignamos a la vista el nuevo extent
|
||
537 | Rectangle2D newExtent = new Rectangle2D.Double(minX, minY, oldExtent.getWidth(), oldExtent.getHeight()); |
||
538 | theView.getMapControl().getMapContext().getViewPort().setExtent(newExtent); |
||
539 | } |
||
540 | |||
541 | /**
|
||
542 | 5217 | nacho | * Limpia la lista de puntos .
|
543 | */
|
||
544 | public void clearVisualList(){ |
||
545 | AdjustGeorefPanel agp = dialog.getConectorPanel().getAdjustGeorefPanel(); |
||
546 | |||
547 | //Limpiamos la lista de puntos
|
||
548 | lyrPoints.clear(); |
||
549 | //Limpiamos los controles del Selector de puntos
|
||
550 | selectPointsPanel.resetControls(false);
|
||
551 | selectPointsPanel.getTableControlerPanel().resetControls(); |
||
552 | |||
553 | //Limpiamos la tabla y sus controles
|
||
554 | tablePointsPanel.clearTable(); |
||
555 | tablePointsPanel.getTableControlerPanel().resetControls(); |
||
556 | |||
557 | //Limpiamos las miniimagenes bloqueamos los controles
|
||
558 | agp.getZoomLeft().clear(); |
||
559 | agp.getZoomRight().clear(); |
||
560 | dialog.getConectorPanel().getAdjustGeorefPanel().setEnabled(false);
|
||
561 | |||
562 | 5818 | nacho | //Desactivamos los controles de salvar puntos
|
563 | if(lyrPoints.getCountPoints() == 0) |
||
564 | dialog.setEnableSaveButtons(false);
|
||
565 | |||
566 | 5217 | nacho | //Actualizamos la vista
|
567 | View theView = null; |
||
568 | try{
|
||
569 | 6880 | cesar | theView = (View) PluginServices.getMDIManager().getActiveWindow();
|
570 | 5217 | nacho | theView.getMapControl().getMapContext().invalidate(); |
571 | }catch(ClassCastException exc){ |
||
572 | return;
|
||
573 | } |
||
574 | 5303 | nacho | |
575 | 5217 | nacho | } |
576 | |||
577 | /**
|
||
578 | 5598 | nacho | * Realiza las acciones necesarias cuando se ha seleccionado el primer punto de la georreferenciaci?n.
|
579 | * Este primer punto corresponde a las coordenadas en pixeles de la imagen. Los par?metros ya vienen
|
||
580 | * validados por quien llama.
|
||
581 | * @param tx Coordenada X en formato cadena
|
||
582 | * @param ty Coordenada Y en formato cadena
|
||
583 | * @throws TransformerException Es lanzada si el punto se encuentra fuera del marco de la imagen
|
||
584 | */
|
||
585 | public void selectFirstPoint(String tx, String ty){ |
||
586 | //Obtenemos el punto seleccionado en coordenadas de la vista
|
||
587 | double x = Double.valueOf(tx).doubleValue(); |
||
588 | double y = Double.valueOf(ty).doubleValue(); |
||
589 | Point2D pixel = new Point2D.Double(); |
||
590 | pixel.setLocation(x, y); |
||
591 | selectFirstPoint(pixel); |
||
592 | } |
||
593 | |||
594 | /**
|
||
595 | * Realiza las acciones necesarias cuando se ha seleccionado el primer punto de la georreferenciaci?n.
|
||
596 | * Este primer punto corresponde a las coordenadas en pixeles de la imagen. Los par?metros ya vienen
|
||
597 | * validados por quien llama.
|
||
598 | * @param pixel Coordenada X, Y del punto
|
||
599 | * @throws TransformerException Es lanzada si el punto se encuentra fuera del marco de la imagen
|
||
600 | */
|
||
601 | public void selectFirstPoint(Point2D pixel){ |
||
602 | restoreControlsValue(); |
||
603 | |||
604 | View theView = null; |
||
605 | try{
|
||
606 | 6880 | cesar | theView = (View)PluginServices.getMDIManager().getActiveWindow();
|
607 | 5598 | nacho | }catch(ClassCastException exc){ |
608 | return;
|
||
609 | } |
||
610 | |||
611 | //Obtenemos del dialogo el n? de pto seleccionado y lo actualizamos en la capa de ptos
|
||
612 | 7091 | nacho | int n = 1; |
613 | try{
|
||
614 | n = Integer.valueOf(dialog.getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue();
|
||
615 | }catch(NullPointerException ex){ |
||
616 | //n vale 1
|
||
617 | } |
||
618 | 5625 | nacho | updateData(n, pixel, null, dialog, theView);
|
619 | 5598 | nacho | dialog.getConectorPanel().getAdjustGeorefPanel().setEnabled(false);
|
620 | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().setEnabled(true);
|
||
621 | |||
622 | 5625 | nacho | disableAllControls(); |
623 | |||
624 | //Consultamos si ha de desactivarse la capa a georreferenciar despu?s del primer punto
|
||
625 | //y si es true la desactivamos
|
||
626 | if(dialog.isOffLayer())
|
||
627 | 5689 | nacho | lyrPoints.getLyrGeoRaster().setVisible(false);
|
628 | 5625 | nacho | |
629 | 5689 | nacho | //Consultamos si ha de desactivarse la capa de puntos despues del primer punto y si es
|
630 | //true la desactivamos.
|
||
631 | if(dialog.isOffPoints())
|
||
632 | lyrPoints.setHideViewOnly(false);
|
||
633 | |||
634 | 5598 | nacho | GeorefPointSelectorListener.firstPoint = false;
|
635 | } |
||
636 | |||
637 | /**
|
||
638 | * Realiza las acciones necesarias cuando se ha seleccionado el segundo punto de la georreferenciaci?n.
|
||
639 | * Este segundo punto corresponde a las coordenadas en coordenadas del mundo. Los par?metros ya vienen
|
||
640 | * validados por quien llama.
|
||
641 | * @param tx Coordenada X en formato cadena
|
||
642 | * @param ty Coordenada Y en formato cadena
|
||
643 | * @throws TransformerException Es lanzada si el punto se encuentra fuera del marco de la imagen
|
||
644 | */
|
||
645 | public void selectSecondPoint(String tx, String ty){ |
||
646 | //Obtenemos el punto seleccionado en coordenadas de la vista
|
||
647 | double x = Double.valueOf(tx).doubleValue(); |
||
648 | double y = Double.valueOf(ty).doubleValue(); |
||
649 | Point2D map = new Point2D.Double(); |
||
650 | map.setLocation(x, y); |
||
651 | selectSecondPoint(map); |
||
652 | } |
||
653 | |||
654 | /**
|
||
655 | * Realiza las acciones necesarias cuando se ha seleccionado el primer punto de la georreferenciaci?n.
|
||
656 | * Este primer punto corresponde a las coordenadas en pixeles de la imagen. Los par?metros ya vienen
|
||
657 | * validados por quien llama.
|
||
658 | * @param pixel Coordenada X, Y del punto
|
||
659 | * @throws TransformerException Es lanzada si el punto se encuentra fuera del marco de la imagen
|
||
660 | */
|
||
661 | public void selectSecondPoint(Point2D map){ |
||
662 | View theView = null; |
||
663 | try{
|
||
664 | 6880 | cesar | theView = (View)PluginServices.getMDIManager().getActiveWindow();
|
665 | 5598 | nacho | }catch(ClassCastException exc){ |
666 | return;
|
||
667 | } |
||
668 | |||
669 | //Deseleccionamos la herramienta de marcado de puntos
|
||
670 | theView.getMapControl().setTool(dialog.getLyrPoints().getLastTool()); |
||
671 | |||
672 | //Volvemos a dejar los controles con su valor habitual
|
||
673 | dialog.getPointManager().restoreControlsValue(); |
||
674 | 5818 | nacho | dialog.setEnableSaveButtons(true);
|
675 | 5598 | nacho | |
676 | //Obtenemos del dialogo el n? de pto seleccionado y lo actualizamos en la capa de ptos
|
||
677 | int n = Integer.valueOf(dialog.getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue(); |
||
678 | 5625 | nacho | updateData(n, null, map, dialog, theView);
|
679 | 5598 | nacho | dialog.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().draw(); |
680 | dialog.getConectorPanel().getAdjustGeorefPanel().setEnabled(true);
|
||
681 | 5625 | nacho | setErrors(n - 1);
|
682 | 5598 | nacho | |
683 | 5625 | nacho | //Consultamos si ha de desactivarse la capa a georreferenciar despu?s del primer punto
|
684 | //y si es true la volvemos a activar despu?s del segundo punto
|
||
685 | if(dialog.isOffLayer())
|
||
686 | 5689 | nacho | lyrPoints.getLyrGeoRaster().setVisible(true);
|
687 | 5625 | nacho | |
688 | 5689 | nacho | //Consultamos si ha de desactivarse la capa de puntos despues del primer punto y si es
|
689 | //true la activamos despu?s del segundo punto.
|
||
690 | if(dialog.isOffPoints())
|
||
691 | lyrPoints.setHideViewOnly(true);
|
||
692 | |||
693 | 5598 | nacho | GeorefPointSelectorListener.firstPoint = true;
|
694 | } |
||
695 | |||
696 | /**
|
||
697 | 5217 | nacho | * Obtiene la ventana flotante sobre la que ir? el dialogo (GeoreferencingDialog).
|
698 | * @param obj
|
||
699 | * @return JInternalFrame
|
||
700 | */
|
||
701 | public static JInternalFrame getInternalFrame(Object obj){ |
||
702 | JInternalFrame panel = new JInternalFrame(); |
||
703 | panel.addInternalFrameListener(new GeoRasterFrameListener());
|
||
704 | panel.setClosable(true);
|
||
705 | panel.setResizable(false);
|
||
706 | panel.setTitle(PluginServices.getText(obj,"georreferenciar"));
|
||
707 | return panel;
|
||
708 | } |
||
709 | |||
710 | |||
711 | public static GeoreferencingDialog initWindow(FLyrGeoRaster lyrGeoRaster, boolean show, Object obj){ |
||
712 | GeoreferencingDialog geoDialog = null;
|
||
713 | |||
714 | JInternalFrame panel = PointManager.getInternalFrame(obj);
|
||
715 | geoDialog = new GeoreferencingDialog(panel, lyrGeoRaster);
|
||
716 | 5584 | nacho | lyrGeoRaster.getStackZoom().setInitExtent(lyrGeoRaster.getAssignExtent(), true);
|
717 | 5217 | nacho | lyrGeoRaster.getFLyrPoints().saveState(); |
718 | lyrGeoRaster.setGeoDialog(geoDialog); |
||
719 | panel.setSize(geoDialog.getWidth() + 12, geoDialog.getHeight() + 10); |
||
720 | panel.getContentPane().add(geoDialog); |
||
721 | |||
722 | MDIFrame mainFrame = (MDIFrame) PluginServices.getMainFrame(); |
||
723 | |||
724 | JDesktopPane desk = new JDesktopPane(); |
||
725 | desk.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
|
||
726 | |||
727 | JLayeredPane lyrPane = mainFrame.getLayeredPane();
|
||
728 | lyrPane.add(panel, JDesktopPane.PALETTE_LAYER);
|
||
729 | lyrPane.add(desk, JDesktopPane.OUTLINE_DRAG_MODE);
|
||
730 | if(show)
|
||
731 | panel.show(); |
||
732 | |||
733 | return geoDialog;
|
||
734 | } |
||
735 | 5303 | nacho | |
736 | /**
|
||
737 | * Esta funci?n deshabilita todos los controles y guarda sus valores
|
||
738 | * de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue
|
||
739 | * se vuelvan a quedar como estaba
|
||
740 | */
|
||
741 | public void disableAllControls(){ |
||
742 | if(!disableAllControls){
|
||
743 | disableAllControls = true;
|
||
744 | //Salvamos los estados y desactivamos controles
|
||
745 | tableControlerPanel1.disableAllControls(); |
||
746 | tablePointsPanel.disableAllControls(); |
||
747 | tableControlerPanel2.disableAllControls(); |
||
748 | dialog.disableAllControls(); |
||
749 | 5304 | nacho | dataPointPanel.getCbActive().setEnabled(false);
|
750 | selectPointsPanel.getBExtended().setEnabled(false);
|
||
751 | 5392 | nacho | dialog.getFrame().setClosable(false);
|
752 | 5303 | nacho | |
753 | //Desactivamos las herramientas de georreferenciaci?n
|
||
754 | GeoreferencingToolsModule.setEnabled(false);
|
||
755 | dialog.getConectorPanel().getDataPointsTabPanel().getTbPoints().setEnabled(false);
|
||
756 | } |
||
757 | } |
||
758 | 5217 | nacho | |
759 | 5303 | nacho | /**
|
760 | * Esta funci?n deja los controles como estaban al ejecutar la funci?n
|
||
761 | * disableAllControls
|
||
762 | */
|
||
763 | public void restoreControlsValue(){ |
||
764 | if(disableAllControls){
|
||
765 | disableAllControls = false;
|
||
766 | //Activamos controles
|
||
767 | tableControlerPanel1.restoreControlsValue(); |
||
768 | tablePointsPanel.restoreControlsValue(); |
||
769 | tableControlerPanel2.restoreControlsValue(); |
||
770 | dialog.restoreControlsValue(); |
||
771 | 5304 | nacho | dataPointPanel.getCbActive().setEnabled(true);
|
772 | selectPointsPanel.getBExtended().setEnabled(true);
|
||
773 | 5392 | nacho | dialog.getFrame().setClosable(true);
|
774 | 5304 | nacho | |
775 | 5303 | nacho | //Activamos las herramientas de georreferenciaci?n
|
776 | GeoreferencingToolsModule.setEnabled(true);
|
||
777 | dialog.getConectorPanel().getDataPointsTabPanel().getTbPoints().setEnabled(true);
|
||
778 | } |
||
779 | } |
||
780 | 5217 | nacho | //**********************End Methods***************************
|
781 | |||
782 | //**********************Getters & Setters*********************
|
||
783 | public FLyrPoints getFlyrPoints() {
|
||
784 | return lyrPoints;
|
||
785 | } |
||
786 | |||
787 | public void setFlyrPoints(FLyrPoints flyrPoints) { |
||
788 | this.lyrPoints = flyrPoints;
|
||
789 | } |
||
790 | |||
791 | public GeoreferencingDialog getDialog() {
|
||
792 | return dialog;
|
||
793 | } |
||
794 | |||
795 | /**
|
||
796 | * Salva en 2 variables de instancia el valor actual en coordenadas del
|
||
797 | * mundo del punto seleccionado. Esto es util para su posterior restauraci?n.
|
||
798 | */
|
||
799 | public void setCurrentWC() { |
||
800 | int posSelect = 0; |
||
801 | try{
|
||
802 | if(tableControlerPanel1 != null) |
||
803 | posSelect = tableControlerPanel1.getSelectedIndex(); |
||
804 | if(lyrPoints != null){ |
||
805 | this.currentMapX = lyrPoints.getPoint(posSelect).mapPoint.getX();
|
||
806 | this.currentMapY = lyrPoints.getPoint(posSelect).mapPoint.getY();
|
||
807 | } |
||
808 | }catch(NullPointerException exc){ |
||
809 | //Si tableControler o la capa de puntos son null no salvamos el punto
|
||
810 | } |
||
811 | } |
||
812 | |||
813 | /**
|
||
814 | * Asigna nuevos valores al texto de la latitud y longitud.
|
||
815 | * @param x Longitud
|
||
816 | * @param y Latitud
|
||
817 | */
|
||
818 | public void setTempWC(double x, double y){ |
||
819 | 5697 | nacho | dataPointPanel.getLongitud().setText(GeoUtils.tailDecimals(String.valueOf(x), 5) + ""); |
820 | dataPointPanel.getLatitud().setText(GeoUtils.tailDecimals(String.valueOf(y), 5) + ""); |
||
821 | 5217 | nacho | } |
822 | |||
823 | /**
|
||
824 | * Restaura el ?ltimo valor seleccionado por el usuario de la latitud
|
||
825 | * y longitud.
|
||
826 | */
|
||
827 | public void replaceWC(){ |
||
828 | 5697 | nacho | dataPointPanel.getLongitud().setText(GeoUtils.tailDecimals(String.valueOf(currentMapX), 5) + ""); |
829 | dataPointPanel.getLatitud().setText(GeoUtils.tailDecimals(String.valueOf(currentMapY), 5) + ""); |
||
830 | 5217 | nacho | } |
831 | |||
832 | /**
|
||
833 | * Salva en 2 variables de instancia el valor actual en coordenadas del
|
||
834 | * mundo del punto seleccionado. Esto es util para su posterior restauraci?n.
|
||
835 | */
|
||
836 | public void setCurrentPixelCoord() { |
||
837 | int posSelect = 0; |
||
838 | try{
|
||
839 | if(tableControlerPanel1 != null) |
||
840 | posSelect = tableControlerPanel1.getSelectedIndex(); |
||
841 | if(lyrPoints != null){ |
||
842 | this.currentPixelX = lyrPoints.getPoint(posSelect).pixelPoint.getX();
|
||
843 | this.currentPixelY = lyrPoints.getPoint(posSelect).pixelPoint.getY();
|
||
844 | } |
||
845 | }catch(NullPointerException exc){ |
||
846 | //Si tableControler o la capa de puntos son null no salvamos el punto
|
||
847 | } |
||
848 | } |
||
849 | |||
850 | /**
|
||
851 | * Asigna nuevos valores al texto de la latitud y longitud.
|
||
852 | * @param x Longitud
|
||
853 | * @param y Latitud
|
||
854 | */
|
||
855 | public void setTempPixelCoord(double x, double y){ |
||
856 | 5697 | nacho | dataPointPanel.getTX().setText(GeoUtils.tailDecimals(String.valueOf(x), 2) + ""); |
857 | dataPointPanel.getTY().setText(GeoUtils.tailDecimals(String.valueOf(y), 2) + ""); |
||
858 | 5217 | nacho | } |
859 | |||
860 | /**
|
||
861 | * Restaura el ?ltimo valor seleccionado por el usuario de la latitud
|
||
862 | * y longitud.
|
||
863 | */
|
||
864 | public void replacePixelCoord(){ |
||
865 | 5697 | nacho | dataPointPanel.getTX().setText(GeoUtils.tailDecimals(currentPixelX, 2) + ""); |
866 | dataPointPanel.getTY().setText(GeoUtils.tailDecimals(currentPixelY, 2) + ""); |
||
867 | 5217 | nacho | } |
868 | 5303 | nacho | |
869 | /**
|
||
870 | * Consulta si se han desactivado los controles salvando sus valores
|
||
871 | * @return true si se han desactivado los controles salvando previamente
|
||
872 | * sus valores y false si est?n en estado normal.
|
||
873 | */
|
||
874 | public boolean isDisableAllControls() { |
||
875 | return disableAllControls;
|
||
876 | } |
||
877 | 5217 | nacho | //**********************End Getters & Setters*****************
|
878 | } |