root / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / gui / dialog / GeoreferencingDialog.java @ 12546
History | View | Annotate | Download (43.3 KB)
1 |
/* 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 |
package org.gvsig.georeferencing.gui.dialog; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Component; |
23 |
import java.awt.Dimension; |
24 |
import java.awt.FlowLayout; |
25 |
import java.awt.event.ActionListener; |
26 |
import java.awt.event.ComponentEvent; |
27 |
import java.awt.event.ComponentListener; |
28 |
import java.awt.geom.Point2D; |
29 |
import java.awt.geom.Rectangle2D; |
30 |
import java.beans.PropertyVetoException; |
31 |
import java.io.File; |
32 |
|
33 |
import javax.swing.JButton; |
34 |
import javax.swing.JCheckBox; |
35 |
import javax.swing.JFileChooser; |
36 |
import javax.swing.JInternalFrame; |
37 |
import javax.swing.JOptionPane; |
38 |
import javax.swing.JPanel; |
39 |
import javax.swing.JToggleButton; |
40 |
import javax.swing.filechooser.FileFilter; |
41 |
import javax.swing.table.DefaultTableModel; |
42 |
|
43 |
import org.cresques.cts.IProjection; |
44 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
45 |
import org.gvsig.georeferencing.GeoOperations; |
46 |
import org.gvsig.georeferencing.gui.listeners.GeoRasterFrameListener; |
47 |
import org.gvsig.georeferencing.gui.listeners.GeorefMovePointListener; |
48 |
import org.gvsig.georeferencing.gui.listeners.GeorefPanListener; |
49 |
import org.gvsig.georeferencing.gui.listeners.GeorefPointSelectorListener; |
50 |
import org.gvsig.georeferencing.gui.listeners.ZoomGeorefListener; |
51 |
import org.gvsig.georeferencing.gui.panels.ConectorPanel; |
52 |
import org.gvsig.georeferencing.gui.panels.OptionsPanel; |
53 |
import org.gvsig.georeferencing.gui.panels.ZoomControlPanel; |
54 |
import org.gvsig.georeferencing.gui.pointsTable.TablePointsPanel; |
55 |
import org.gvsig.georeferencing.gui.pointsTable.TablePointsPanel.PointTable; |
56 |
import org.gvsig.georeferencing.gui.selectPoints.SelectPointsPanel; |
57 |
import org.gvsig.georeferencing.toc.GeoRasterTocMenuEntry; |
58 |
import org.gvsig.georeferencing.utils.GeoLayerFactory; |
59 |
import org.gvsig.georeferencing.utils.GeoPointPersistence; |
60 |
import org.gvsig.georeferencing.utils.GeoUtils; |
61 |
import org.gvsig.georeferencing.utils.PointManager; |
62 |
import org.gvsig.georeferencing.utils.StackZoom; |
63 |
import org.gvsig.raster.datastruct.Extent; |
64 |
|
65 |
import com.iver.andami.PluginServices; |
66 |
import com.iver.cit.gvsig.fmap.MapControl; |
67 |
import com.iver.cit.gvsig.fmap.ViewPort; |
68 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
69 |
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
70 |
import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
71 |
import com.iver.cit.gvsig.fmap.layers.IGeoUi; |
72 |
import com.iver.cit.gvsig.fmap.tools.ZoomOutRightButtonListener; |
73 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
74 |
import com.iver.cit.gvsig.fmap.tools.Behavior.DraggedBehavior; |
75 |
import com.iver.cit.gvsig.fmap.tools.Behavior.GeoMoveBehavior; |
76 |
import com.iver.cit.gvsig.fmap.tools.Behavior.GeoRedimBehavior; |
77 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
78 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
79 |
import com.iver.cit.gvsig.gui.wizards.WizardListener; |
80 |
import com.iver.cit.gvsig.project.Project; |
81 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
82 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
83 |
|
84 |
/**
|
85 |
* Panel que contiene el Wizard de georeferenciaci?n con los tabs
|
86 |
* interiores
|
87 |
*
|
88 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
89 |
*/
|
90 |
public class GeoreferencingDialog extends JPanel implements IGeoUi, ActionListener, ComponentListener { |
91 |
|
92 |
//**********************Vars**********************************
|
93 |
static private IProjection proj = Project.getDefaultProjection(); |
94 |
private JPanel pBotones = null; // @jve:decl-index=0: |
95 |
private JButton bProcesar = null; // @jve:decl-index=0: |
96 |
private JButton bCancelar = null; // @jve:decl-index=0: |
97 |
private WizardListener wizardListener = new DialogWizardListener(); |
98 |
private GeoRedimBehavior rb = null; |
99 |
private GeoMoveBehavior mb = null; |
100 |
private boolean loadTools = false; |
101 |
private JInternalFrame frame = null; |
102 |
/**
|
103 |
* Lista de formatos soportados
|
104 |
*/
|
105 |
private String[] fileFilters = {"csv"}; |
106 |
/**
|
107 |
* Recuerda la ?ltima ruta seleccionada por el usuario
|
108 |
*/
|
109 |
private String lastPathLoad = "./"; |
110 |
private String lastPathSave = "./"; |
111 |
private ConectorPanel conectorPanel = null; |
112 |
|
113 |
private boolean enlarge = false; |
114 |
private int normalWidth = 400; |
115 |
private int normalHeight = 273; |
116 |
private int enlargeHeight = 448; |
117 |
private int tmpWidth = normalWidth; |
118 |
|
119 |
private JButton bAceptar = null; |
120 |
|
121 |
private FLyrGeoRaster lyrGeoRaster = null; |
122 |
private TablePointsPanel tablePointsPanel = null; |
123 |
private PointManager pointManager = null; |
124 |
/**
|
125 |
* True si ha de crearse un fichero de georreferenciaci?n
|
126 |
*/
|
127 |
private boolean createWorldFile = true; |
128 |
/**
|
129 |
* True si los errores han de incluirse en el fichero csv
|
130 |
*/
|
131 |
private boolean errorCSV = true; |
132 |
/**
|
133 |
* Estado de los botones cuando se ejecuta disableAllControls
|
134 |
*/
|
135 |
private boolean[] buttonsState = new boolean[7]; |
136 |
/**
|
137 |
* DisableAllControls ha sido ejecutada si est? a true esta variabled
|
138 |
*/
|
139 |
private boolean disableAllControls = false; |
140 |
/**
|
141 |
* Variable que controla si la capa de georreferenciaci?n se ha de desactivar
|
142 |
* despu?s del primer punto.
|
143 |
*/
|
144 |
private boolean offLayer = true; |
145 |
/**
|
146 |
* Variable que controla si la vista ha de centrarse sobre el punto seleccionado
|
147 |
* o no
|
148 |
*/
|
149 |
private boolean centerPoint = true; |
150 |
/**
|
151 |
* Variable que controla si la capa de puntos se ha de desactivar
|
152 |
* despu?s del primer punto.
|
153 |
*/
|
154 |
private boolean offPoints = true; |
155 |
/**
|
156 |
* Panel que contiene los botones de la barra inferior
|
157 |
*/
|
158 |
private DialogButtons dialogButtons = null; |
159 |
//**********************End Vars******************************
|
160 |
|
161 |
//**********************Classes*******************************
|
162 |
/**
|
163 |
* Filtro para selecci?n de ficheros.
|
164 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
165 |
*/
|
166 |
class SelectFileFilter extends javax.swing.filechooser.FileFilter { |
167 |
|
168 |
private JFileChooser chooser = null; |
169 |
private String file = null; |
170 |
|
171 |
public SelectFileFilter(JFileChooser ch, String file){ |
172 |
this.chooser = ch;
|
173 |
this.file = file;
|
174 |
} |
175 |
|
176 |
public boolean accept(File f) { |
177 |
|
178 |
return f.isDirectory() || f.getName().toLowerCase().endsWith("."+file); |
179 |
} |
180 |
|
181 |
public String getDescription() { |
182 |
return file;
|
183 |
} |
184 |
|
185 |
} |
186 |
|
187 |
/**
|
188 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
189 |
*/
|
190 |
public class DialogWizardListener implements WizardListener { |
191 |
|
192 |
/**
|
193 |
* @see org.gvsig.georeferencing.gui.wms.WizardListener#error(java.lang.Exception)
|
194 |
*/
|
195 |
public void error(Exception e) { |
196 |
} |
197 |
|
198 |
/**
|
199 |
* @see org.gvsig.georeferencing.gui.wms.WizardListener#wizardStateChanged(boolean)
|
200 |
*/
|
201 |
public void wizardStateChanged(boolean finishable) { |
202 |
getBProcess().setEnabled(finishable); |
203 |
} |
204 |
|
205 |
} |
206 |
//**********************End Classes***************************
|
207 |
|
208 |
//**********************Methods*******************************
|
209 |
/**
|
210 |
* Constructor.
|
211 |
*/
|
212 |
public GeoreferencingDialog(JInternalFrame f, FLyrGeoRaster lyr) { |
213 |
frame = f; |
214 |
lyrGeoRaster = lyr; |
215 |
|
216 |
frame.addComponentListener(this);
|
217 |
initialize(); |
218 |
|
219 |
//Creamos el pointManager y lo asignamos a la capa de puntos
|
220 |
pointManager = new PointManager(this, lyrGeoRaster.getFLyrPoints()); |
221 |
this.lyrGeoRaster.getFLyrPoints().setPointManager(pointManager);
|
222 |
|
223 |
//En estos casos entra cuando la capa se crea al abrir un proyecto
|
224 |
if(lyrGeoRaster.getPersistence() == null){ |
225 |
lyrGeoRaster.setPersistence(new GeoPointPersistence(lyrGeoRaster.getFLyrPoints()));
|
226 |
f.addInternalFrameListener(new GeoRasterFrameListener());
|
227 |
GeoRasterTocMenuEntry.isOpen = true;
|
228 |
} |
229 |
if(lyrGeoRaster.getStackZoom() == null) |
230 |
lyrGeoRaster.setZoom(new StackZoom());
|
231 |
|
232 |
} |
233 |
|
234 |
/**
|
235 |
* En la inicializaci?n de la ventana a?adimos los tags de est? y cargamos
|
236 |
* ls herramientas para manejar las imagenes a georeferenciar.
|
237 |
*/
|
238 |
private void initialize() { |
239 |
//Cargamos las herramientas la primera vez que abrimos la ventana
|
240 |
if(!loadTools){
|
241 |
com.iver.cit.gvsig.project.documents.view.gui.View vista = null;
|
242 |
try{
|
243 |
vista = (com.iver.cit.gvsig.project.documents.view.gui.View) PluginServices.getMDIManager().getActiveWindow(); |
244 |
}catch(ClassCastException exc){ |
245 |
return;
|
246 |
} |
247 |
|
248 |
MapControl mapCtrl = null;
|
249 |
if(vista != null) |
250 |
mapCtrl = vista.getMapControl(); |
251 |
|
252 |
if(mapCtrl != null){ |
253 |
loadTools = true;
|
254 |
StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
255 |
|
256 |
ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(mapCtrl);
|
257 |
ZoomGeorefListener zigl = new ZoomGeorefListener(mapCtrl);
|
258 |
rb = new GeoRedimBehavior(zigl);
|
259 |
mapCtrl.addMapTool("geoZoom", new Behavior[]{rb, |
260 |
new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
261 |
|
262 |
GeorefPanListener pl = new GeorefPanListener(mapCtrl);
|
263 |
mb = new GeoMoveBehavior(pl);
|
264 |
mapCtrl.addMapTool("geoPan", new Behavior[]{mb, new MouseMovementBehavior(sbl)}); |
265 |
|
266 |
//Seleccion de un punto sobre la vista
|
267 |
GeorefPointSelectorListener psl = new GeorefPointSelectorListener(this); |
268 |
mapCtrl.addMapTool("pointLyrSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)}); |
269 |
|
270 |
GeorefMovePointListener mpl = new GeorefMovePointListener(this); |
271 |
mapCtrl.addMapTool("geoMovePoint", new Behavior[]{new DraggedBehavior(mpl), new MouseMovementBehavior(sbl)}); |
272 |
} |
273 |
} |
274 |
|
275 |
this.setLayout(new BorderLayout()); |
276 |
if(!enlarge){
|
277 |
this.setPreferredSize(new java.awt.Dimension(normalWidth, normalHeight)); |
278 |
this.setSize(new java.awt.Dimension(normalWidth, normalHeight)); |
279 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().setVisible(false); |
280 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomRight().setVisible(false); |
281 |
}else{
|
282 |
this.setPreferredSize(new java.awt.Dimension(normalWidth, enlargeHeight)); |
283 |
this.setSize(new java.awt.Dimension(normalWidth, enlargeHeight)); |
284 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().setVisible(true); |
285 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomRight().setVisible(true); |
286 |
} |
287 |
this.setLocation(new java.awt.Point(0,0)); |
288 |
|
289 |
this.add(this.getPBotones(), BorderLayout.SOUTH); |
290 |
this.add(this.getConectorPanel(), BorderLayout.NORTH); |
291 |
|
292 |
//A?adimos los listener de los botones de la tabla
|
293 |
//Los botones de borrado los gestiona SelectPointsPanel
|
294 |
//Los botones de cargar y exportar los gestiona GeoreferencigDialog
|
295 |
tablePointsPanel = getConectorPanel().getDataPointsTabPanel().getTablePointsPanel(); |
296 |
tablePointsPanel.getTableControlerPanel().getBClear().addActionListener(this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel());
|
297 |
tablePointsPanel.getTableControlerPanel().getBDelPoint().addActionListener(this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel());
|
298 |
|
299 |
getDialogButtons().getBExportToCSV().addActionListener(this);
|
300 |
getDialogButtons().getBImportFromCSV().addActionListener(this);
|
301 |
getDialogButtons().getBLoad().addActionListener(this);
|
302 |
getDialogButtons().getBSave().addActionListener(this);
|
303 |
|
304 |
conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel().getCbActive().addActionListener(this);
|
305 |
getBInsertPointOfTablePoints().addActionListener(conectorPanel.getDataPointsTabPanel().getSelectPointsPanel()); |
306 |
getBNewPointOfTablePoints().addActionListener(conectorPanel.getDataPointsTabPanel().getSelectPointsPanel()); |
307 |
} |
308 |
|
309 |
/**
|
310 |
* Comprueba si existe el fichero pasado por par?metro existe solicitando confirmaci?n
|
311 |
* de sobreescritura. Si el usuario acepta devolver? true y si no acepta devuelve false.
|
312 |
* Si se acepta la sobreescritura el fichero es borrado.
|
313 |
* @param file Cadena con el nombre del fichero a comprobar su existencia.
|
314 |
* @return Devuelve true si el fichero existe y va a ser sobreescrito
|
315 |
*/
|
316 |
public boolean checkFileExists(String file, boolean delete){ |
317 |
File f = new File(file); |
318 |
if(f.exists()){
|
319 |
if (messageBoxYesOrNot("file_exists")){ |
320 |
if(delete)
|
321 |
f.delete(); |
322 |
return true; |
323 |
}else
|
324 |
return false; |
325 |
} |
326 |
return true; |
327 |
} |
328 |
|
329 |
/**
|
330 |
* MessageBox con dos botones (OK y Cancel) que mostrar? el mensaje pasado por
|
331 |
* par?metro
|
332 |
* @param msg Mensaje a mostrar
|
333 |
* @return true si el usuario pulsa Ok y false si pulsa Cancel
|
334 |
*/
|
335 |
public boolean messageBoxYesOrNot(String msg){ |
336 |
String string1 = PluginServices.getText(this, "yes"); |
337 |
String string2 = PluginServices.getText(this, "no"); |
338 |
Object[] options = {string1, string2}; |
339 |
int n = JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(), |
340 |
PluginServices.getText(this, msg),
|
341 |
PluginServices.getText(this, "confirmacion"), |
342 |
JOptionPane.YES_NO_OPTION,
|
343 |
JOptionPane.QUESTION_MESSAGE,
|
344 |
null,
|
345 |
options, |
346 |
string1); |
347 |
if (n == JOptionPane.YES_OPTION) |
348 |
return true; |
349 |
else
|
350 |
return false; |
351 |
} |
352 |
|
353 |
/**
|
354 |
* Acci?n cuando se pulsa el bot?n de aceptar en el dialogo.
|
355 |
* <UL>
|
356 |
* <LI>Cambiamos el nombre a la capa georraster</LI>
|
357 |
* <LI>A la capa Georraster le asignamos la capa de puntos para poder recuperarla</LI>
|
358 |
* <LI>Cerramos la ventana</LI>
|
359 |
* </UL>
|
360 |
*/
|
361 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
362 |
com.iver.cit.gvsig.project.documents.view.gui.View theView = null;
|
363 |
try{
|
364 |
theView = (com.iver.cit.gvsig.project.documents.view.gui.View) PluginServices.getMDIManager().getActiveWindow(); |
365 |
}catch(ClassCastException exc){ |
366 |
return;
|
367 |
} |
368 |
|
369 |
try{
|
370 |
//ACEPTAR
|
371 |
if(e.getSource() == bAceptar)
|
372 |
accept(theView); |
373 |
|
374 |
//CANCELAR
|
375 |
if(e.getSource() == bCancelar)
|
376 |
cancel(theView); |
377 |
|
378 |
//CARGAR PUNTOS
|
379 |
if(e.getSource() == getDialogButtons().getBLoad())
|
380 |
loadPoints(theView); |
381 |
|
382 |
//SALVAR PUNTOS
|
383 |
if(e.getSource() == getDialogButtons().getBSave())
|
384 |
savePoints(); |
385 |
|
386 |
//EXPORTAR A CSV
|
387 |
if(e.getSource() == getDialogButtons().getBExportToCSV())
|
388 |
exportToCSV(theView); |
389 |
|
390 |
//IMPORTAR DESDE CSV
|
391 |
if(e.getSource() == getDialogButtons().getBImportFromCSV())
|
392 |
importFromCSV(theView); |
393 |
|
394 |
//DESACTIVAR PANELES
|
395 |
JCheckBox cb = this.conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel().getCbActive(); |
396 |
if(e.getSource() == cb)
|
397 |
deactivatePanel(theView, cb); |
398 |
|
399 |
//PROCESAR
|
400 |
if(e.getSource() == this.getBProcess()) |
401 |
process(theView); |
402 |
}catch(Exception exc){ |
403 |
exc.printStackTrace(); |
404 |
return;
|
405 |
} |
406 |
} |
407 |
|
408 |
/**
|
409 |
* Cierra el dialogo
|
410 |
*/
|
411 |
public void close(){ |
412 |
try{
|
413 |
frame.setClosed(true);
|
414 |
}catch(PropertyVetoException exc){} |
415 |
} |
416 |
|
417 |
/**
|
418 |
* Funci?n que se ejecuta al pulsar el bot?n procesar. Este procesamiento calcula a partir de
|
419 |
* los puntos de control la georreferenciaci?n de la imagen y la asigna como extent temporal de
|
420 |
* la capa FLyrGeoRaster. Cuando termina actualiza la visualizaci?n.
|
421 |
* @param theView
|
422 |
*/
|
423 |
private void process(View theView)throws Exception{ |
424 |
if(getLyrPoints() == null) |
425 |
throw new Exception("LyrPoints not loaded."); |
426 |
|
427 |
if(this.getLyrPoints().getCountPoints() > 0){ |
428 |
|
429 |
//Salvamos los centros
|
430 |
Point2D[] oldCenter = new Point2D.Double[lyrGeoRaster.getFLyrPoints().getCountPoints()]; |
431 |
for(int i=0; i<lyrGeoRaster.getFLyrPoints().getCountPoints(); i++) |
432 |
oldCenter[i] = lyrGeoRaster.img2World(lyrGeoRaster.getFLyrPoints().getPoint(i).pixelPoint); |
433 |
|
434 |
//Calculamos las coordenadas de georreferenciaci?n
|
435 |
GeoOperations go = new GeoOperations(getLyrPoints());
|
436 |
|
437 |
double[] begin = go.transformPoint(0, 0, go.getAffine()); |
438 |
double[] end = go.transformPoint((int)lyrGeoRaster.getImageWidth(), (int)lyrGeoRaster.getImageHeight(), go.getAffine()); |
439 |
Extent ext = new Extent(begin[0], begin[1], end[0], end[1]); |
440 |
|
441 |
//Asignamos el extent temporal a la capa de georreferenciaci?n
|
442 |
ViewPort vp = theView.getMapControl().getMapContext().getViewPort(); |
443 |
((FLyrGeoRaster)theView.getMapControl().getMapContext().getLayers().getLayer(lyrGeoRaster.getName())).setAssignExtent(ext); |
444 |
|
445 |
//Si la capa tiene puntos de control hacemos un update de estos
|
446 |
//a su posici?n para que se actualicen los controles
|
447 |
|
448 |
for(int i=0; i<lyrGeoRaster.getFLyrPoints().getCountPoints(); i++){ |
449 |
Point2D center = lyrGeoRaster.img2World(lyrGeoRaster.getFLyrPoints().getPoint(i).pixelPoint);
|
450 |
lyrGeoRaster.getFLyrPoints().setMiniExtent( i, |
451 |
center, |
452 |
GeoUtils.shiftExtent(oldCenter[i], center, getLyrPoints().getMiniExtent(i, false)),
|
453 |
false);
|
454 |
if(i == getSelectedPoint())
|
455 |
updateData(i + 1, lyrGeoRaster.getFLyrPoints().getPoint(i).pixelPoint, null, null); |
456 |
} |
457 |
theView.getMapControl().getMapContext().invalidate(); |
458 |
} |
459 |
} |
460 |
|
461 |
/**
|
462 |
* Funci?n que se ejecuta al pulsar el bot?n aceptar. Este procesamiento calcula a partir de
|
463 |
* los puntos de control la georreferenciaci?n de la imagen, crear el fichero .rmf de georreferenciaci?n
|
464 |
* y descarga la capa del TOC. A continuaci?n vuelve a cargar la capa como FLyrRaster dando
|
465 |
* por finalizada la georreferenciaci?n.
|
466 |
* @param theView
|
467 |
*/
|
468 |
private void accept(View theView)throws Exception{ |
469 |
if(getLyrPoints() == null) |
470 |
throw new Exception("LyrPoints not loaded."); |
471 |
|
472 |
if(this.getLyrPoints().getCountPoints() > 0){ |
473 |
savePoints(); |
474 |
|
475 |
//Creamos el fichero de georreferenciaci?n
|
476 |
GeoOperations go = new GeoOperations(getLyrPoints());
|
477 |
go.setCreateWorldFile(this.createWorldFile);
|
478 |
go.createGeorefFile( (int)getLyrGeoRaster().getImageWidth(),
|
479 |
(int)getLyrGeoRaster().getImageHeight(),
|
480 |
getLyrGeoRaster().getFileName()[0]);
|
481 |
|
482 |
FLayers lyrs = this.getLyrGeoRaster().getParentLayer();
|
483 |
|
484 |
for(int i = 0; i < lyrs.getLayersCount();i++){ |
485 |
if(this.getLyrGeoRaster().getName().equals(lyrs.getLayer(i).getName())){ |
486 |
|
487 |
//Eliminamos la capa
|
488 |
lyrs.removeLayer(i); |
489 |
File fich = new File(getLyrGeoRaster().getFileName()[0]); |
490 |
//Creamos la nueva capa GeoRaster y la a?adimos al TOC.
|
491 |
FLyrRasterSE lyrRaster = GeoLayerFactory.createLayer(getLyrGeoRaster().getName().substring(1, getLyrGeoRaster().getName().length()),
|
492 |
getLyrGeoRaster().getFileName()[0],
|
493 |
getLyrGeoRaster().getProjection()); |
494 |
lyrs.addLayer(lyrRaster); |
495 |
theView.getMapControl().getMapContext().invalidate(); |
496 |
break;
|
497 |
} |
498 |
} |
499 |
} |
500 |
//Cerramos la ventana
|
501 |
try{
|
502 |
frame.setClosed(true);
|
503 |
}catch(PropertyVetoException exc){} |
504 |
|
505 |
} |
506 |
|
507 |
/**
|
508 |
* Funci?n que se ejecuta al pulsar el bot?n cancelar
|
509 |
* @param theView
|
510 |
*/
|
511 |
private void cancel(View theView)throws Exception{ |
512 |
if(getLyrPoints() == null) |
513 |
throw new Exception("LyrPoints not loaded."); |
514 |
|
515 |
//Cerramos la ventana
|
516 |
//(se ejecuta el evento internalFrameClosing de GeoRasterFrameListener)
|
517 |
try{
|
518 |
frame.setClosed(true);
|
519 |
theView.getMapControl().getMapContext().invalidate(); |
520 |
}catch(PropertyVetoException exc){} |
521 |
} |
522 |
|
523 |
/**
|
524 |
* Funci?n que se ejecuta al pulsar el bot?n de cargar puntos
|
525 |
* @param theView
|
526 |
*/
|
527 |
private void loadPoints(View theView)throws Exception{ |
528 |
if(getLyrPoints() == null) |
529 |
throw new Exception("LyrPoints not loaded."); |
530 |
|
531 |
if(messageBoxYesOrNot("cargar_puntos")){ |
532 |
String name = lyrGeoRaster.getName().substring(lyrGeoRaster.getName().indexOf("*") + 1, lyrGeoRaster.getName().lastIndexOf(".")); |
533 |
String path = lyrGeoRaster.getFileName()[0]; |
534 |
String nameRmf = path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".rmf"; |
535 |
|
536 |
//Antes de cargar puntos plegamos el cuadro
|
537 |
getSelectPointsPanel().setEnlarge(true);
|
538 |
|
539 |
getLyrPoints().saveState(); |
540 |
getLyrPoints().XML2PointList(nameRmf); |
541 |
|
542 |
//Esto es por si el panel ha sido estirado cuando cargamos los puntos
|
543 |
frame.pack(); |
544 |
frame.show(); |
545 |
|
546 |
//Por problemas con repaint e hilos concurrentes tenemos que poner esto explicitamente
|
547 |
//ya que es posible que se haga un paint de las miniimagenes antes de que cleanCanvas vuelva a valer false
|
548 |
this.getZoomControlLeft().getCanvas().setCleanCanvas(false); |
549 |
this.getZoomControlRight().getCanvas().setCleanCanvas(false); |
550 |
|
551 |
if(getLyrPoints().getCountPoints() > 0) |
552 |
setEnableSaveButtons(true);
|
553 |
} |
554 |
} |
555 |
|
556 |
/**
|
557 |
* Funci?n usada para salvar puntos
|
558 |
* @param theView
|
559 |
*/
|
560 |
public void savePoints()throws Exception{ |
561 |
if(getLyrPoints() == null) |
562 |
throw new Exception("LyrPoints not loaded."); |
563 |
String name = lyrGeoRaster.getName().substring(lyrGeoRaster.getName().indexOf("*") + 1, lyrGeoRaster.getName().lastIndexOf(".")); |
564 |
String path = lyrGeoRaster.getFileName()[0]; |
565 |
String nameRmf = path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".rmf"; |
566 |
|
567 |
File f = new File(nameRmf); |
568 |
if(f.exists()){
|
569 |
if (messageBoxYesOrNot(PluginServices.getText(this, "gcps_exist"))){ |
570 |
if(getLyrPoints() != null) |
571 |
getLyrPoints().PointList2XML( path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".grf"); |
572 |
} |
573 |
}else
|
574 |
getLyrPoints().PointList2XML( path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".grf"); |
575 |
} |
576 |
|
577 |
/**
|
578 |
* Funci?n que se ejecuta al pulsar el bot?n de export a ascii
|
579 |
* @param theView
|
580 |
*/
|
581 |
private void exportToCSV(View theView)throws Exception{ |
582 |
if(getLyrPoints() == null) |
583 |
throw new Exception("LyrPoints not loaded."); |
584 |
|
585 |
JFileChooser chooser = new JFileChooser(lastPathSave); |
586 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
587 |
|
588 |
FileFilter f = null; |
589 |
for(int i=0; i<this.fileFilters.length;i++){ |
590 |
f = new SelectFileFilter(chooser, this.fileFilters[i]); |
591 |
chooser.addChoosableFileFilter(f); |
592 |
} |
593 |
int returnVal = chooser.showOpenDialog(this); |
594 |
if(returnVal == JFileChooser.APPROVE_OPTION){ |
595 |
String fName = chooser.getSelectedFile().toString();
|
596 |
if(!fName.endsWith(".csv")) |
597 |
fName = fName + ".csv";
|
598 |
lastPathSave = chooser.getCurrentDirectory().getAbsolutePath(); |
599 |
if(checkFileExists(fName, true)){ |
600 |
if(getLyrPoints() != null) |
601 |
getLyrPoints().PointList2CSV(fName); |
602 |
} |
603 |
} |
604 |
} |
605 |
|
606 |
/**
|
607 |
* Funci?n que se ejecuta al pulsar el bot?n de importar desde CSV
|
608 |
* @param theView
|
609 |
*/
|
610 |
private void importFromCSV(View theView)throws Exception{ |
611 |
if(getLyrPoints() == null) |
612 |
throw new Exception("LyrPoints not loaded."); |
613 |
|
614 |
JFileChooser chooser = new JFileChooser(lastPathSave); |
615 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
616 |
|
617 |
FileFilter f = null; |
618 |
for(int i=0; i<this.fileFilters.length;i++){ |
619 |
f = new SelectFileFilter(chooser, this.fileFilters[i]); |
620 |
chooser.addChoosableFileFilter(f); |
621 |
} |
622 |
int returnVal = chooser.showOpenDialog(this); |
623 |
if(returnVal == JFileChooser.APPROVE_OPTION){ |
624 |
String fName = chooser.getSelectedFile().toString();
|
625 |
lastPathSave = chooser.getCurrentDirectory().getAbsolutePath(); |
626 |
getLyrPoints().PointListFromCSV(fName); |
627 |
|
628 |
//Antes de cargar puntos plegamos el cuadro
|
629 |
getSelectPointsPanel().setEnlarge(true);
|
630 |
|
631 |
//Por problemas con repaint e hilos concurrentes tenemos que poner esto explicitamente
|
632 |
//ya que es posible que se haga un paint de las miniimagenes antes de que cleanCanvas vuelva a valer false
|
633 |
this.getZoomControlLeft().getCanvas().setCleanCanvas(false); |
634 |
this.getZoomControlRight().getCanvas().setCleanCanvas(false); |
635 |
|
636 |
//Si se han cargado puntos desde el CSV se activan los controles
|
637 |
if(getLyrPoints().getCountPoints() > 0) |
638 |
setEnableSaveButtons(true);
|
639 |
} |
640 |
} |
641 |
|
642 |
/**
|
643 |
* Funci?n que se ejecuta al pulsar el bot?n desactivar panel
|
644 |
* @param theView
|
645 |
*/
|
646 |
public void deactivatePanel(View theView, JCheckBox cb)throws Exception{ |
647 |
if(getLyrPoints() == null) |
648 |
throw new Exception("LyrPoints not loaded."); |
649 |
|
650 |
//Sincronizamos con el checkBox de la tabla
|
651 |
tablePointsPanel.getJTable().getTableModel().setValueAt(new Boolean(cb.isSelected()), |
652 |
tablePointsPanel.getJTable().getTable().getSelectedRow(), |
653 |
0);
|
654 |
|
655 |
if(cb.isSelected()){
|
656 |
this.setEnabled(true); |
657 |
getLyrPoints().setPointActive(getSelectedPoint(), true);
|
658 |
}else{
|
659 |
this.setEnabled(false); |
660 |
getLyrPoints().setPointActive(getSelectedPoint(), false);
|
661 |
} |
662 |
|
663 |
//Al activar y desactivar tenemos que recalcular errores
|
664 |
this.getPointManager().setErrors(getSelectedPoint());
|
665 |
|
666 |
theView.getMapControl().getMapContext().invalidate(); |
667 |
getZoomControlLeft().draw(); |
668 |
getZoomControlRight().draw(); |
669 |
} |
670 |
|
671 |
/**
|
672 |
* Recalcula el extent de la mini-imagen que corresponde a los puntos en coordenadas
|
673 |
* pixel.Para esto calcula el nuevo centro a partir de la capa y con la distancia entre
|
674 |
* el nuevo centro y el viejo desplaza el extent completo de la mini-imagen.
|
675 |
* @param theView
|
676 |
*/
|
677 |
private void calcNewMiniExtent(View theView){ |
678 |
|
679 |
ViewPort viewPort = theView.getMapControl().getMapContext().getViewPort(); |
680 |
for(int j = 0; j < getLyrPoints().getCountPoints(); j++){ |
681 |
//Calculamos el nuevo centro
|
682 |
Point2D oldCenter = getLyrPoints().getPoint(j).leftCenterPoint;
|
683 |
Point2D newCenter = new Point2D.Double(); |
684 |
newCenter.setLocation( lyrGeoRaster.img2World(getLyrPoints().getPoint(j).pixelPoint)); |
685 |
|
686 |
double diffX = oldCenter.getX() - newCenter.getX();
|
687 |
double diffY = oldCenter.getY() - newCenter.getY();
|
688 |
|
689 |
getLyrPoints().getPoint(j).leftCenterPoint = newCenter; |
690 |
|
691 |
ViewPort vpOld = getLyrPoints().getPoint(j).lvp; |
692 |
Rectangle2D newExtent = new Rectangle2D.Double( vpOld.getExtent().getMinX() - diffX, |
693 |
vpOld.getExtent().getMinY() - diffY, |
694 |
vpOld.getExtent().getWidth(), |
695 |
vpOld.getExtent().getHeight() ); |
696 |
ViewPort vpNew = new ViewPort(vpOld.getProjection());
|
697 |
vpNew.setExtent(newExtent); |
698 |
vpNew.setImageSize(vpOld.getImageSize()); |
699 |
vpNew.refreshExtent(); |
700 |
getLyrPoints().getPoint(j).setLeftViewPort(vpNew); |
701 |
} |
702 |
} |
703 |
|
704 |
/**
|
705 |
* This method initializes jButton
|
706 |
*
|
707 |
* @return javax.swing.JButton
|
708 |
*/
|
709 |
public JButton getBAccept() { |
710 |
if (bAceptar == null) { |
711 |
bAceptar = new JButton(); |
712 |
bAceptar.setText(PluginServices.getText(this,"aceptar")); |
713 |
bAceptar.setToolTipText(PluginServices.getText(this,"accept_tip")); |
714 |
bAceptar.addActionListener(this);
|
715 |
} |
716 |
return bAceptar;
|
717 |
} |
718 |
|
719 |
/**
|
720 |
* This method initializes bProcesar
|
721 |
*
|
722 |
* @return javax.swing.JButton
|
723 |
*/
|
724 |
public JButton getBProcess() { |
725 |
if (bProcesar == null) { |
726 |
bProcesar = new JButton(); |
727 |
bProcesar.setText(PluginServices.getText(this,"procesar")); |
728 |
bProcesar.setToolTipText(PluginServices.getText(this,"process_tip")); |
729 |
bProcesar.setEnabled(true);
|
730 |
bProcesar.addActionListener(this);
|
731 |
|
732 |
//TODO: Descomentar cuando se pueda procesar al vuelo la imagen
|
733 |
bProcesar.setVisible(false);
|
734 |
} |
735 |
return bProcesar;
|
736 |
} |
737 |
|
738 |
/**
|
739 |
* El bot?n cancelar restaura el extent con el que se carg? la imagen a georreferenciar
|
740 |
* y cierra la ventana.
|
741 |
*
|
742 |
* @return javax.swing.JButton
|
743 |
*/
|
744 |
public JButton getBCancel() { |
745 |
if (bCancelar == null) { |
746 |
bCancelar = new JButton(); |
747 |
bCancelar.setText(PluginServices.getText(this,"cancelar")); |
748 |
bCancelar.setToolTipText(PluginServices.getText(this,"cancel_tip")); |
749 |
bCancelar.addActionListener(this);
|
750 |
} |
751 |
return bCancelar;
|
752 |
} |
753 |
|
754 |
/**
|
755 |
* Asigna a las textbox el valor de pixel pasado
|
756 |
* @param x valor x
|
757 |
* @param y valor y
|
758 |
*/
|
759 |
public void setPixelText(double x, double y){ |
760 |
getSelectPointsPanel().getDataPointPanel().getTX().setText(String.valueOf(x));
|
761 |
getSelectPointsPanel().getDataPointPanel().getTY().setText(String.valueOf(y));
|
762 |
} |
763 |
|
764 |
/**
|
765 |
* Asigna a las textbox el valor de coordenadas pasado
|
766 |
* @param x valor x
|
767 |
* @param y valor y
|
768 |
*/
|
769 |
public void setMapCoordText(double x, double y){ |
770 |
getSelectPointsPanel().getDataPointPanel().getLongitud().setText(GeoUtils.tailDecimals(String.valueOf(x), 5)); |
771 |
getSelectPointsPanel().getDataPointPanel().getLatitud().setText(GeoUtils.tailDecimals(String.valueOf(y), 5)); |
772 |
} |
773 |
|
774 |
/**
|
775 |
* Esta funci?n resetea los controles del panel de info de un punto.
|
776 |
*/
|
777 |
public void resetControls(boolean active){ |
778 |
getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().setSaveToDisk(active); |
779 |
getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().resetControls(active); |
780 |
getConectorPanel().getAdjustGeorefPanel().getZoomLeft().clear(); |
781 |
getConectorPanel().getAdjustGeorefPanel().getZoomRight().clear(); |
782 |
setEnabled(active); |
783 |
} |
784 |
|
785 |
/* (non-Javadoc)
|
786 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
787 |
*/
|
788 |
public void componentHidden(ComponentEvent arg0) { |
789 |
|
790 |
} |
791 |
/* (non-Javadoc)
|
792 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
|
793 |
*/
|
794 |
public void componentMoved(ComponentEvent arg0) { |
795 |
|
796 |
} |
797 |
/* (non-Javadoc)
|
798 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
|
799 |
*/
|
800 |
public void componentResized(ComponentEvent ev) { |
801 |
|
802 |
if(frame.getWidth() <= this.normalWidth + 10) |
803 |
frame.setSize(this.normalWidth, frame.getHeight());
|
804 |
|
805 |
if(this.getConectorPanel().getDataPointsTabPanel().getTbPoints().getSelectedIndex() == 1){ |
806 |
tmpWidth = frame.getWidth(); |
807 |
this.newFrameSize(frame.getWidth(), frame.getHeight() - 10); |
808 |
} |
809 |
} |
810 |
/* (non-Javadoc)
|
811 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
|
812 |
*/
|
813 |
public void componentShown(ComponentEvent arg0) { |
814 |
|
815 |
} |
816 |
|
817 |
/**
|
818 |
*Inicializa el tama?o del dialogo
|
819 |
*/
|
820 |
public void resetSize(){ |
821 |
if(!enlarge){
|
822 |
frame.setSize(this.normalWidth + 12, this.normalHeight + 10); |
823 |
}else{
|
824 |
frame.setSize(this.normalWidth + 12, this.enlargeHeight + 10); |
825 |
} |
826 |
newFrameSize((int)Math.round(this.normalWidth / 0.98), this.normalHeight); |
827 |
} |
828 |
|
829 |
/**
|
830 |
* Calculo del nuevo tama?o a partir de un frame redimensionado
|
831 |
* @param w Ancho del frame
|
832 |
* @param h Alto del frame
|
833 |
*/
|
834 |
public void newFrameSize(int w, int h){ |
835 |
int newWidth = (int)Math.round(w * 0.98); |
836 |
|
837 |
this.setSize(new java.awt.Dimension(newWidth, normalHeight )); |
838 |
this.setPreferredSize(new java.awt.Dimension(newWidth, normalHeight )); |
839 |
this.getConectorPanel().newFrameSize(newWidth, h);
|
840 |
} |
841 |
|
842 |
/**
|
843 |
* Elimina un punto de la tabla de puntos
|
844 |
* @param pos Posici?n del punto a eliminar
|
845 |
*/
|
846 |
public void removeTableValueAt(int pos) throws ArrayIndexOutOfBoundsException{ |
847 |
((DefaultTableModel)getTable().getTable().getModel()).removeRow(pos);
|
848 |
} |
849 |
|
850 |
/**
|
851 |
* A partir de nuevas coordenadas actualiza la vista, minimagen, capa de puntos el
|
852 |
* dialogo y la tabla.
|
853 |
*
|
854 |
*/
|
855 |
public void updateData(int nPunto, Point2D pixel, Point2D map, View view){ |
856 |
getPointManager().updateData(nPunto, pixel, map, this, view);
|
857 |
} |
858 |
|
859 |
/**
|
860 |
* Esta funci?n deshabilita todos los controles y guarda sus valores
|
861 |
* de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue
|
862 |
* se vuelvan a quedar como estaba
|
863 |
*/
|
864 |
public void disableAllControls(){ |
865 |
if(!disableAllControls){
|
866 |
disableAllControls = true;
|
867 |
|
868 |
//Salvamos los estados
|
869 |
buttonsState[0] = getBProcess().isEnabled();
|
870 |
buttonsState[1] = getBAccept().isEnabled();
|
871 |
buttonsState[2] = getBCancel().isEnabled();
|
872 |
buttonsState[3] = getDialogButtons().getBExportToCSV().isEnabled();
|
873 |
buttonsState[4] = getDialogButtons().getBImportFromCSV().isEnabled();
|
874 |
buttonsState[5] = getDialogButtons().getBLoad().isEnabled();
|
875 |
buttonsState[6] = getDialogButtons().getBSave().isEnabled();
|
876 |
|
877 |
//Desactivamos controles
|
878 |
getBProcess().setEnabled(false);
|
879 |
getBAccept().setEnabled(false);
|
880 |
getBCancel().setEnabled(false);
|
881 |
|
882 |
getDialogButtons().getBExportToCSV().setEnabled(false);
|
883 |
getDialogButtons().getBImportFromCSV().setEnabled(false);
|
884 |
getDialogButtons().getBLoad().setEnabled(false);
|
885 |
getDialogButtons().getBSave().setEnabled(false);
|
886 |
} |
887 |
} |
888 |
|
889 |
/**
|
890 |
* Esta funci?n deja los controles como estaban al ejecutar la funci?n
|
891 |
* disableAllControls
|
892 |
*/
|
893 |
public void restoreControlsValue(){ |
894 |
if(disableAllControls){
|
895 |
disableAllControls = false;
|
896 |
getBProcess().setEnabled(buttonsState[0]);
|
897 |
getBAccept().setEnabled(buttonsState[1]);
|
898 |
getBCancel().setEnabled(buttonsState[2]);
|
899 |
getDialogButtons().getBExportToCSV().setEnabled(buttonsState[3]);
|
900 |
getDialogButtons().getBImportFromCSV().setEnabled(buttonsState[4]);
|
901 |
getDialogButtons().getBLoad().setEnabled(buttonsState[5]);
|
902 |
getDialogButtons().getBSave().setEnabled(buttonsState[6]);
|
903 |
} |
904 |
} |
905 |
//**********************End Methods***************************
|
906 |
|
907 |
//**********************Setters & Getters*********************
|
908 |
/**
|
909 |
* Obtiene la tabla de puntos
|
910 |
*/
|
911 |
public PointTable getTable(){
|
912 |
return this.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getJTable(); |
913 |
} |
914 |
|
915 |
/**
|
916 |
* Asigna un valor a una posici?n de la tabla
|
917 |
* @param value Valor a asignar
|
918 |
* @param row Fila en la que se asigna
|
919 |
* @param col Columna en la que se asigna
|
920 |
*/
|
921 |
public void setTableValueAt(String value, int row, int col)throws ArrayIndexOutOfBoundsException{ |
922 |
((DefaultTableModel)getTable().getTable().getModel()).setValueAt(value, row, col);
|
923 |
} |
924 |
|
925 |
/**
|
926 |
* Asigna un valor del checkBox para una fila de la tabla
|
927 |
* @param row Fila en la que se asigna
|
928 |
*/
|
929 |
public void setCheckValueAt(Boolean value, int row)throws ArrayIndexOutOfBoundsException{ |
930 |
((DefaultTableModel)getTable().getTable().getModel()).setValueAt(value, row, 0); |
931 |
} |
932 |
|
933 |
/**
|
934 |
* Obtiene el n?mero de filas de la tabla
|
935 |
* @return N?mero de filas de la tabla
|
936 |
*/
|
937 |
public int getTableRowCount(){ |
938 |
return getTable().getTable().getRowCount();
|
939 |
} |
940 |
|
941 |
/**
|
942 |
* A?ade una nueva fila a la tabla de puntos
|
943 |
*/
|
944 |
public void addTableNew(){ |
945 |
getTable().getTableModel().addNew(); |
946 |
} |
947 |
/**
|
948 |
* @return Returns the tmpWidth.
|
949 |
*/
|
950 |
public int getTmpWidth() { |
951 |
return tmpWidth;
|
952 |
} |
953 |
/**
|
954 |
* @param tmpWidth The tmpWidth to set.
|
955 |
*/
|
956 |
public void setTmpWidth(int tmpWidth) { |
957 |
this.tmpWidth = tmpWidth;
|
958 |
} |
959 |
/**
|
960 |
* @return Returns the enlargeHeight.
|
961 |
*/
|
962 |
public int getEnlargeHeight() { |
963 |
return enlargeHeight;
|
964 |
} |
965 |
/**
|
966 |
* @return Returns the normalHeight.
|
967 |
*/
|
968 |
public int getNormalHeight() { |
969 |
return normalHeight;
|
970 |
} |
971 |
|
972 |
/**
|
973 |
* @return Returns the normalWidth.
|
974 |
*/
|
975 |
public int getNormalWidth() { |
976 |
return normalWidth;
|
977 |
} |
978 |
|
979 |
/**
|
980 |
* Asigna el valor del campo RMS
|
981 |
* @param rms Cadena que representa el RMS
|
982 |
*/
|
983 |
public void setRMS(String rms){ |
984 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTRMS().setText(rms);
|
985 |
} |
986 |
|
987 |
/**
|
988 |
* Asigna el valor del campo de residuo en X
|
989 |
* @param rms Cadena que representa el RMS
|
990 |
*/
|
991 |
public void setResX(String resX){ |
992 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResX().setText(resX);
|
993 |
} |
994 |
|
995 |
/**
|
996 |
* Asigna el valor del campo de residuo en Y
|
997 |
* @param rms Cadena que representa el RMS
|
998 |
*/
|
999 |
public void setResY(String resY){ |
1000 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResY().setText(resY);
|
1001 |
} |
1002 |
|
1003 |
/**
|
1004 |
* Asigna el valor del campo RMS
|
1005 |
* @param rms Cadena que representa el RMS
|
1006 |
*/
|
1007 |
public void setTotal(String total){ |
1008 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTTotal().setText(total);
|
1009 |
} |
1010 |
|
1011 |
/**
|
1012 |
* @return Returns the lyrGeoRaster.
|
1013 |
*/
|
1014 |
public FLyrGeoRaster getLyrGeoRaster() {
|
1015 |
return lyrGeoRaster;
|
1016 |
} |
1017 |
|
1018 |
/**
|
1019 |
* @return Returns the lyrPoints.
|
1020 |
*/
|
1021 |
public FLyrPoints getLyrPoints() {
|
1022 |
try{
|
1023 |
return lyrGeoRaster.getFLyrPoints();
|
1024 |
}catch(ClassCastException exc){ |
1025 |
return null; |
1026 |
} |
1027 |
} |
1028 |
|
1029 |
/**
|
1030 |
* Selecciona un tab del cuadro
|
1031 |
* @param index
|
1032 |
*/
|
1033 |
public void setSelectedTab(int index){ |
1034 |
try{
|
1035 |
this.getConectorPanel().getDataPointsTabPanel().getTbPoints().setSelectedIndex(index);
|
1036 |
}catch(IllegalArgumentException ex){ |
1037 |
//Si peta al seleccionar un tab, pues nada.
|
1038 |
} |
1039 |
} |
1040 |
|
1041 |
/**
|
1042 |
* @param extended The extended to set.
|
1043 |
*/
|
1044 |
public void setEnlarge(boolean enlarge) { |
1045 |
this.enlarge = enlarge;
|
1046 |
if(!enlarge){
|
1047 |
frame.setSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10)); |
1048 |
frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10)); |
1049 |
this.setPreferredSize(new Dimension(this.normalWidth, this.normalHeight)); |
1050 |
this.setSize(new Dimension(this.normalWidth, this.normalHeight)); |
1051 |
this.getConectorPanel().setCanvasVisible(false); |
1052 |
}else{
|
1053 |
frame.setSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10)); |
1054 |
frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10)); |
1055 |
this.setPreferredSize(new Dimension(this.normalWidth, this.enlargeHeight)); |
1056 |
this.setSize(new Dimension(this.normalWidth, this.enlargeHeight)); |
1057 |
this.getConectorPanel().setCanvasVisible(true); |
1058 |
} |
1059 |
frame.pack(); |
1060 |
} |
1061 |
|
1062 |
/**
|
1063 |
* @return Returns the extended.
|
1064 |
*/
|
1065 |
public boolean isEnlarge() { |
1066 |
return enlarge;
|
1067 |
} |
1068 |
|
1069 |
/**
|
1070 |
* Obtiene el panel conector
|
1071 |
* @return
|
1072 |
*/
|
1073 |
public ConectorPanel getConectorPanel() {
|
1074 |
if (conectorPanel == null) { |
1075 |
conectorPanel = new ConectorPanel(this); |
1076 |
} |
1077 |
|
1078 |
return conectorPanel;
|
1079 |
} |
1080 |
|
1081 |
/**
|
1082 |
* This method initializes jPanel
|
1083 |
*
|
1084 |
* @return javax.swing.JPanel
|
1085 |
*/
|
1086 |
private JPanel getPBotones() { |
1087 |
if (pBotones == null) { |
1088 |
FlowLayout flowLayout1 = new FlowLayout(); |
1089 |
pBotones = new JPanel(); |
1090 |
pBotones.setLayout(flowLayout1); |
1091 |
flowLayout1.setHgap(2);
|
1092 |
flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT); |
1093 |
pBotones.add(getDialogButtons(), null);
|
1094 |
pBotones.add(getBProcess(), null);
|
1095 |
pBotones.add(getBAccept(), null);
|
1096 |
pBotones.add(getBCancel(), null);
|
1097 |
} |
1098 |
return pBotones;
|
1099 |
} |
1100 |
|
1101 |
public static IProjection getLastProjection() { |
1102 |
return proj;
|
1103 |
} |
1104 |
public static void setLastProjection(IProjection proj) { |
1105 |
GeoreferencingDialog.proj = proj; |
1106 |
} |
1107 |
|
1108 |
/**
|
1109 |
* @return Returns the GeoRedimBehavior.
|
1110 |
*/
|
1111 |
public GeoRedimBehavior getGeoRedimBehavior() {
|
1112 |
return rb;
|
1113 |
} |
1114 |
|
1115 |
/**
|
1116 |
* @param rb The GeoRedimBehavior to set.
|
1117 |
*/
|
1118 |
public void setGeoRedimBehavior(GeoRedimBehavior rb) { |
1119 |
this.rb = rb;
|
1120 |
} |
1121 |
|
1122 |
/**
|
1123 |
* @return Returns the GeoMoveBehavior
|
1124 |
*/
|
1125 |
public GeoMoveBehavior getGeoMoveBehavior() {
|
1126 |
return mb;
|
1127 |
} |
1128 |
|
1129 |
/**
|
1130 |
* @param mb The GeoMoveBehavior to set.
|
1131 |
*/
|
1132 |
public void setGeoMoveBehavior(GeoMoveBehavior mb) { |
1133 |
this.mb = mb;
|
1134 |
} |
1135 |
|
1136 |
|
1137 |
/**
|
1138 |
* Obtiene el punto de la lista que ha sido seleccionado
|
1139 |
* @return
|
1140 |
*/
|
1141 |
public int getSelectedPoint(){ |
1142 |
return getConectorPanel().getDataPointsTabPanel().
|
1143 |
getSelectPointsPanel().getTableControlerPanel().getSelectedIndex(); |
1144 |
} |
1145 |
|
1146 |
/**
|
1147 |
* Obtiene el control de la mini imagen que tiene los botones a la izquierda
|
1148 |
* @return ZoomControlPanel
|
1149 |
*/
|
1150 |
public ZoomControlPanel getZoomControlLeft(){
|
1151 |
return this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft(); |
1152 |
} |
1153 |
|
1154 |
/**
|
1155 |
* Obtiene el control de la mini imagen que tiene los botones a la derecha
|
1156 |
* @return ZoomControlPanel
|
1157 |
*/
|
1158 |
public ZoomControlPanel getZoomControlRight(){
|
1159 |
return this.getConectorPanel().getAdjustGeorefPanel().getZoomRight(); |
1160 |
} |
1161 |
|
1162 |
/**
|
1163 |
* Obtiene el panel de selecci?n de puntos
|
1164 |
* @return Panel de selecci?n de puntos
|
1165 |
*/
|
1166 |
public SelectPointsPanel getSelectPointsPanel(){
|
1167 |
return this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel(); |
1168 |
} |
1169 |
|
1170 |
/**
|
1171 |
* Obtiene el panel de opciones
|
1172 |
* @return OptionPanel
|
1173 |
*/
|
1174 |
public OptionsPanel getOptionsPanel(){
|
1175 |
return getConectorPanel().getAdjustGeorefPanel().getOptionsPanel();
|
1176 |
} |
1177 |
|
1178 |
/**
|
1179 |
* Asigna el frame
|
1180 |
* @param f
|
1181 |
*/
|
1182 |
public void setFrame(JInternalFrame f){ |
1183 |
frame = f; |
1184 |
frame.addComponentListener(this);
|
1185 |
} |
1186 |
|
1187 |
/**
|
1188 |
* Obtiene el frame
|
1189 |
* @return frame
|
1190 |
*/
|
1191 |
public JInternalFrame getFrame(){ |
1192 |
return frame;
|
1193 |
} |
1194 |
|
1195 |
/**
|
1196 |
* Obtiene el gestor de puntos
|
1197 |
* @return PointManager
|
1198 |
*/
|
1199 |
public PointManager getPointManager() {
|
1200 |
return pointManager;
|
1201 |
} |
1202 |
|
1203 |
/**
|
1204 |
* Activa o desactiva este panel y todos los que lo componen
|
1205 |
* @param enabled variable booleana para la activaci?n y/o desactivaci?n
|
1206 |
*/
|
1207 |
public void setEnabled(boolean enabled){ |
1208 |
conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().setEnabled(enabled); |
1209 |
conectorPanel.getAdjustGeorefPanel().setEnabled(enabled); |
1210 |
} |
1211 |
|
1212 |
/**
|
1213 |
* M?todo para notificar si se desea crear o no el fichero de coordenadas .tfw, .wld .jpgw ,...
|
1214 |
* @param createWorldFile
|
1215 |
*/
|
1216 |
public void setCreateWorldFile(boolean createWorldFile) { |
1217 |
this.createWorldFile = createWorldFile;
|
1218 |
} |
1219 |
|
1220 |
/**
|
1221 |
*
|
1222 |
*/
|
1223 |
public ViewPort getLeftInitViewport(ViewPort vp, Point2D center, ViewPort initVp, double zoom){ |
1224 |
return getZoomControlLeft().getCanvas().initViewPort(vp, center, initVp, zoom);
|
1225 |
} |
1226 |
|
1227 |
/**
|
1228 |
* Consulta si se desea incluir los errores cuando se exporta a fichero .csv
|
1229 |
* @param errorCVS true si se incluyen los errores dentro del fichero y false si no se incluyen
|
1230 |
*/
|
1231 |
public boolean isErrorCSV() { |
1232 |
return errorCSV;
|
1233 |
} |
1234 |
|
1235 |
/**
|
1236 |
* M?todo para notificar si se desea incluir los errores cuando se exporta a fichero .csv
|
1237 |
* @param errorCVS true si se incluyen los errores dentro del fichero y false si no se incluyen
|
1238 |
*/
|
1239 |
public void setErrorCSV(boolean errorCSV) { |
1240 |
this.errorCSV = errorCSV;
|
1241 |
} |
1242 |
|
1243 |
/**
|
1244 |
* Obtiene los errores en una matriz de Nx3 en la que cada fila es un punto y la
|
1245 |
* columna 0 es el error en X, la columna 1 es el error en Y y la columna 2 es el error RMS.
|
1246 |
* @return matriz de errores
|
1247 |
*/
|
1248 |
public double[][] getErrors(){ |
1249 |
return pointManager.getErrors();
|
1250 |
} |
1251 |
|
1252 |
/**
|
1253 |
* Pregunta si la capa a georreferenciar se desactiva cuando se introduce el
|
1254 |
* primer punto y devuelve true si lo hace.
|
1255 |
* @return true o false
|
1256 |
*/
|
1257 |
public boolean isOffLayer() { |
1258 |
return offLayer;
|
1259 |
} |
1260 |
|
1261 |
/**
|
1262 |
* Asigna el flag que dice si la capa a georreferenciar se desactiva cuando se introduce el
|
1263 |
* primer punto
|
1264 |
* @param offLayer true para desactivar la capa
|
1265 |
*/
|
1266 |
public void setOffLayer(boolean offLayer) { |
1267 |
this.offLayer = offLayer;
|
1268 |
} |
1269 |
|
1270 |
/**
|
1271 |
* Consulta si la vista ha de centrarse sobre el punto seleccionado o no.
|
1272 |
* @return true o false
|
1273 |
*/
|
1274 |
public boolean isCenterPoint() { |
1275 |
return centerPoint;
|
1276 |
} |
1277 |
|
1278 |
/**
|
1279 |
* Asigna el flag que dice si vista ha centrarse sobre el punto seleccionado o no
|
1280 |
* @param centerPoint true para centrar la vista y false no.
|
1281 |
*/
|
1282 |
public void setCenterPoint(boolean centerPoint) { |
1283 |
this.centerPoint = centerPoint;
|
1284 |
} |
1285 |
|
1286 |
/**
|
1287 |
* Pregunta si la capa de puntos se desactiva cuando se introduce el
|
1288 |
* primer punto y devuelve true si lo hace.
|
1289 |
* @return true o false
|
1290 |
*/
|
1291 |
public boolean isOffPoints() { |
1292 |
return offPoints;
|
1293 |
} |
1294 |
|
1295 |
/**
|
1296 |
* Asigna el flag que dice si la capa de puntos se desactiva cuando se introduce el
|
1297 |
* primer punto
|
1298 |
* @param offPoints true para desactivar la capa
|
1299 |
*/
|
1300 |
public void setOffPoints(boolean offPoints) { |
1301 |
this.offPoints = offPoints;
|
1302 |
} |
1303 |
|
1304 |
/**
|
1305 |
* Obtiene el bot?n de activar/desactivar la inserci?n de punto del panel del control de
|
1306 |
* tabla
|
1307 |
* @return JToggleButton
|
1308 |
*/
|
1309 |
public JToggleButton getBInsertPointOfTablePoints(){ |
1310 |
return tablePointsPanel.getPTablePanelButtons().getBInsertPoint();
|
1311 |
} |
1312 |
|
1313 |
/**
|
1314 |
* Obtiene el bot?n de activar/desactivar la inserci?n de punto del panel del control de
|
1315 |
* tabla
|
1316 |
* @return JToggleButton
|
1317 |
*/
|
1318 |
public JButton getBNewPointOfTablePoints(){ |
1319 |
return tablePointsPanel.getTableControlerPanel().getBNew();
|
1320 |
} |
1321 |
|
1322 |
/**
|
1323 |
* This method initializes jPanel
|
1324 |
*
|
1325 |
* @return javax.swing.JPanel
|
1326 |
*/
|
1327 |
public DialogButtons getDialogButtons() {
|
1328 |
if (dialogButtons == null) { |
1329 |
dialogButtons = new DialogButtons();
|
1330 |
} |
1331 |
return dialogButtons;
|
1332 |
} |
1333 |
|
1334 |
/**
|
1335 |
* Activa/desactiva los botones de la barra correspondientes al salvado
|
1336 |
* de datos a disco.
|
1337 |
* @param active true activa los controles y false los desactiva.
|
1338 |
*/
|
1339 |
public void setEnableSaveButtons(boolean active){ |
1340 |
getDialogButtons().getBSave().setEnabled(active); |
1341 |
getDialogButtons().getBExportToCSV().setEnabled(active); |
1342 |
} |
1343 |
//**********************End Setters & Getters*****************
|
1344 |
|
1345 |
} // @jve:decl-index=0:visual-constraint="10,10"
|
1346 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|
1347 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|