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