svn-gvsig-desktop / tags / v1_1_Build_1002 / extensions / extGeoreferencing / src / org / gvsig / georeferencing / gui / dialog / GeoreferencingDialog.java @ 12070
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 = true; |
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 |
|
440 |
double[] begin = go.transformPoint(0, 0, go.getAffine()); |
441 |
double[] end = go.transformPoint((int)lyrGeoRaster.getImageWidth(), (int)lyrGeoRaster.getImageHeight(), go.getAffine()); |
442 |
Extent ext = new Extent(begin[0], begin[1], end[0], end[1]); |
443 |
|
444 |
//Asignamos el extent temporal a la capa de georreferenciaci?n
|
445 |
ViewPort vp = theView.getMapControl().getMapContext().getViewPort(); |
446 |
((FLyrGeoRaster)theView.getMapControl().getMapContext().getLayers().getLayer(lyrGeoRaster.getName())).setAssignExtent(ext); |
447 |
|
448 |
//Si la capa tiene puntos de control hacemos un update de estos
|
449 |
//a su posici?n para que se actualicen los controles
|
450 |
|
451 |
for(int i=0; i<lyrGeoRaster.getFLyrPoints().getCountPoints(); i++){ |
452 |
Point2D center = lyrGeoRaster.img2World(lyrGeoRaster.getFLyrPoints().getPoint(i).pixelPoint);
|
453 |
lyrGeoRaster.getFLyrPoints().setMiniExtent( i, |
454 |
center, |
455 |
GeoUtils.shiftExtent(oldCenter[i], center, getLyrPoints().getMiniExtent(i, false)),
|
456 |
false);
|
457 |
if(i == getSelectedPoint())
|
458 |
updateData(i + 1, lyrGeoRaster.getFLyrPoints().getPoint(i).pixelPoint, null, null); |
459 |
} |
460 |
theView.getMapControl().getMapContext().invalidate(); |
461 |
} |
462 |
} |
463 |
|
464 |
/**
|
465 |
* Funci?n que se ejecuta al pulsar el bot?n aceptar. Este procesamiento calcula a partir de
|
466 |
* los puntos de control la georreferenciaci?n de la imagen, crear el fichero .rmf de georreferenciaci?n
|
467 |
* y descarga la capa del TOC. A continuaci?n vuelve a cargar la capa como FLyrRaster dando
|
468 |
* por finalizada la georreferenciaci?n.
|
469 |
* @param theView
|
470 |
*/
|
471 |
private void accept(View theView)throws Exception{ |
472 |
if(getLyrPoints() == null) |
473 |
throw new Exception("LyrPoints not loaded."); |
474 |
|
475 |
if(this.getLyrPoints().getCountPoints() > 0){ |
476 |
savePoints(); |
477 |
|
478 |
//Creamos el fichero de georreferenciaci?n
|
479 |
GeoOperations go = new GeoOperations(getLyrPoints());
|
480 |
go.setCreateWorldFile(this.createWorldFile);
|
481 |
go.createGeorefFile( (int)getLyrGeoRaster().getImageWidth(),
|
482 |
(int)getLyrGeoRaster().getImageHeight(),
|
483 |
getLyrGeoRaster().getSource().getFiles()[0].getName());
|
484 |
|
485 |
FLayers lyrs = this.getLyrGeoRaster().getParentLayer();
|
486 |
|
487 |
for(int i = 0; i < lyrs.getLayersCount();i++){ |
488 |
if(this.getLyrGeoRaster().getName().equals(lyrs.getLayer(i).getName())){ |
489 |
|
490 |
//Eliminamos la capa
|
491 |
lyrs.removeLayer(i); |
492 |
File fich = new File(getLyrGeoRaster().getSource().getFiles()[0].getName()); |
493 |
try{
|
494 |
//Creamos la nueva capa GeoRaster y la a?adimos al TOC.
|
495 |
FLyrRaster lyrRaster = GeoLayerFactory.createLayer(getLyrGeoRaster().getName().substring(1, getLyrGeoRaster().getName().length()),
|
496 |
(RasterDriver)getLyrGeoRaster().getSource().getDriver(), |
497 |
fich, |
498 |
getLyrGeoRaster().getProjection()); |
499 |
lyrs.addLayer(lyrRaster); |
500 |
theView.getMapControl().getMapContext().invalidate(); |
501 |
}catch(DriverException exc){
|
502 |
|
503 |
} |
504 |
break;
|
505 |
} |
506 |
} |
507 |
} |
508 |
//Cerramos la ventana
|
509 |
try{
|
510 |
frame.setClosed(true);
|
511 |
}catch(PropertyVetoException exc){} |
512 |
|
513 |
} |
514 |
|
515 |
/**
|
516 |
* Funci?n que se ejecuta al pulsar el bot?n cancelar
|
517 |
* @param theView
|
518 |
*/
|
519 |
private void cancel(View theView)throws Exception{ |
520 |
if(getLyrPoints() == null) |
521 |
throw new Exception("LyrPoints not loaded."); |
522 |
|
523 |
//Cerramos la ventana
|
524 |
//(se ejecuta el evento internalFrameClosing de GeoRasterFrameListener)
|
525 |
try{
|
526 |
frame.setClosed(true);
|
527 |
theView.getMapControl().getMapContext().invalidate(); |
528 |
}catch(PropertyVetoException exc){} |
529 |
} |
530 |
|
531 |
/**
|
532 |
* Funci?n que se ejecuta al pulsar el bot?n de cargar puntos
|
533 |
* @param theView
|
534 |
*/
|
535 |
private void loadPoints(View theView)throws Exception{ |
536 |
if(getLyrPoints() == null) |
537 |
throw new Exception("LyrPoints not loaded."); |
538 |
|
539 |
if(messageBoxYesOrNot("cargar_puntos")){ |
540 |
String name = lyrGeoRaster.getName().substring(lyrGeoRaster.getName().indexOf("*") + 1, lyrGeoRaster.getName().lastIndexOf(".")); |
541 |
String path = ((RasterFileAdapter)lyrGeoRaster.getSource()).getFile().getAbsolutePath();
|
542 |
String nameRmf = path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".rmf"; |
543 |
|
544 |
//Antes de cargar puntos plegamos el cuadro
|
545 |
getSelectPointsPanel().setEnlarge(true);
|
546 |
|
547 |
getLyrPoints().saveState(); |
548 |
getLyrPoints().XML2PointList(nameRmf); |
549 |
|
550 |
//Esto es por si el panel ha sido estirado cuando cargamos los puntos
|
551 |
frame.pack(); |
552 |
frame.show(); |
553 |
|
554 |
//Por problemas con repaint e hilos concurrentes tenemos que poner esto explicitamente
|
555 |
//ya que es posible que se haga un paint de las miniimagenes antes de que cleanCanvas vuelva a valer false
|
556 |
this.getZoomControlLeft().getCanvas().setCleanCanvas(false); |
557 |
this.getZoomControlRight().getCanvas().setCleanCanvas(false); |
558 |
|
559 |
if(getLyrPoints().getCountPoints() > 0) |
560 |
setEnableSaveButtons(true);
|
561 |
} |
562 |
} |
563 |
|
564 |
/**
|
565 |
* Funci?n usada para salvar puntos
|
566 |
* @param theView
|
567 |
*/
|
568 |
public void savePoints()throws Exception{ |
569 |
if(getLyrPoints() == null) |
570 |
throw new Exception("LyrPoints not loaded."); |
571 |
String name = lyrGeoRaster.getName().substring(lyrGeoRaster.getName().indexOf("*") + 1, lyrGeoRaster.getName().lastIndexOf(".")); |
572 |
String path = ((RasterFileAdapter)lyrGeoRaster.getSource()).getFile().getAbsolutePath();
|
573 |
String nameRmf = path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".rmf"; |
574 |
|
575 |
File f = new File(nameRmf); |
576 |
if(f.exists()){
|
577 |
if (messageBoxYesOrNot(PluginServices.getText(this, "gcps_exist"))){ |
578 |
if(getLyrPoints() != null) |
579 |
getLyrPoints().PointList2XML( path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".grf"); |
580 |
} |
581 |
}else
|
582 |
getLyrPoints().PointList2XML( path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".grf"); |
583 |
} |
584 |
|
585 |
/**
|
586 |
* Funci?n que se ejecuta al pulsar el bot?n de export a ascii
|
587 |
* @param theView
|
588 |
*/
|
589 |
private void exportToCSV(View theView)throws Exception{ |
590 |
if(getLyrPoints() == null) |
591 |
throw new Exception("LyrPoints not loaded."); |
592 |
|
593 |
JFileChooser chooser = new JFileChooser(lastPathSave); |
594 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
595 |
|
596 |
FileFilter f = null; |
597 |
for(int i=0; i<this.fileFilters.length;i++){ |
598 |
f = new SelectFileFilter(chooser, this.fileFilters[i]); |
599 |
chooser.addChoosableFileFilter(f); |
600 |
} |
601 |
int returnVal = chooser.showOpenDialog(this); |
602 |
if(returnVal == JFileChooser.APPROVE_OPTION){ |
603 |
String fName = chooser.getSelectedFile().toString();
|
604 |
if(!fName.endsWith(".csv")) |
605 |
fName = fName + ".csv";
|
606 |
lastPathSave = chooser.getCurrentDirectory().getAbsolutePath(); |
607 |
if(checkFileExists(fName, true)){ |
608 |
if(getLyrPoints() != null) |
609 |
getLyrPoints().PointList2CSV(fName); |
610 |
} |
611 |
} |
612 |
} |
613 |
|
614 |
/**
|
615 |
* Funci?n que se ejecuta al pulsar el bot?n de importar desde CSV
|
616 |
* @param theView
|
617 |
*/
|
618 |
private void importFromCSV(View theView)throws Exception{ |
619 |
if(getLyrPoints() == null) |
620 |
throw new Exception("LyrPoints not loaded."); |
621 |
|
622 |
JFileChooser chooser = new JFileChooser(lastPathSave); |
623 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
624 |
|
625 |
FileFilter f = null; |
626 |
for(int i=0; i<this.fileFilters.length;i++){ |
627 |
f = new SelectFileFilter(chooser, this.fileFilters[i]); |
628 |
chooser.addChoosableFileFilter(f); |
629 |
} |
630 |
int returnVal = chooser.showOpenDialog(this); |
631 |
if(returnVal == JFileChooser.APPROVE_OPTION){ |
632 |
String fName = chooser.getSelectedFile().toString();
|
633 |
lastPathSave = chooser.getCurrentDirectory().getAbsolutePath(); |
634 |
getLyrPoints().PointListFromCSV(fName); |
635 |
|
636 |
//Antes de cargar puntos plegamos el cuadro
|
637 |
getSelectPointsPanel().setEnlarge(true);
|
638 |
|
639 |
//Por problemas con repaint e hilos concurrentes tenemos que poner esto explicitamente
|
640 |
//ya que es posible que se haga un paint de las miniimagenes antes de que cleanCanvas vuelva a valer false
|
641 |
this.getZoomControlLeft().getCanvas().setCleanCanvas(false); |
642 |
this.getZoomControlRight().getCanvas().setCleanCanvas(false); |
643 |
|
644 |
//Si se han cargado puntos desde el CSV se activan los controles
|
645 |
if(getLyrPoints().getCountPoints() > 0) |
646 |
setEnableSaveButtons(true);
|
647 |
} |
648 |
} |
649 |
|
650 |
/**
|
651 |
* Funci?n que se ejecuta al pulsar el bot?n desactivar panel
|
652 |
* @param theView
|
653 |
*/
|
654 |
public void deactivatePanel(View theView, JCheckBox cb)throws Exception{ |
655 |
if(getLyrPoints() == null) |
656 |
throw new Exception("LyrPoints not loaded."); |
657 |
|
658 |
//Sincronizamos con el checkBox de la tabla
|
659 |
tablePointsPanel.getJTable().getTableModel().setValueAt(new Boolean(cb.isSelected()), |
660 |
tablePointsPanel.getJTable().getTable().getSelectedRow(), |
661 |
0);
|
662 |
|
663 |
if(cb.isSelected()){
|
664 |
this.setEnabled(true); |
665 |
getLyrPoints().setPointActive(getSelectedPoint(), true);
|
666 |
}else{
|
667 |
this.setEnabled(false); |
668 |
getLyrPoints().setPointActive(getSelectedPoint(), false);
|
669 |
} |
670 |
|
671 |
//Al activar y desactivar tenemos que recalcular errores
|
672 |
this.getPointManager().setErrors(getSelectedPoint());
|
673 |
|
674 |
theView.getMapControl().getMapContext().invalidate(); |
675 |
getZoomControlLeft().draw(); |
676 |
getZoomControlRight().draw(); |
677 |
} |
678 |
|
679 |
/**
|
680 |
* Recalcula el extent de la mini-imagen que corresponde a los puntos en coordenadas
|
681 |
* pixel.Para esto calcula el nuevo centro a partir de la capa y con la distancia entre
|
682 |
* el nuevo centro y el viejo desplaza el extent completo de la mini-imagen.
|
683 |
* @param theView
|
684 |
*/
|
685 |
private void calcNewMiniExtent(View theView){ |
686 |
|
687 |
ViewPort viewPort = theView.getMapControl().getMapContext().getViewPort(); |
688 |
for(int j = 0; j < getLyrPoints().getCountPoints(); j++){ |
689 |
//Calculamos el nuevo centro
|
690 |
Point2D oldCenter = getLyrPoints().getPoint(j).leftCenterPoint;
|
691 |
Point2D newCenter = new Point2D.Double(); |
692 |
newCenter.setLocation( lyrGeoRaster.img2World(getLyrPoints().getPoint(j).pixelPoint)); |
693 |
|
694 |
double diffX = oldCenter.getX() - newCenter.getX();
|
695 |
double diffY = oldCenter.getY() - newCenter.getY();
|
696 |
|
697 |
getLyrPoints().getPoint(j).leftCenterPoint = newCenter; |
698 |
|
699 |
ViewPort vpOld = getLyrPoints().getPoint(j).leftViewPort; |
700 |
Rectangle2D newExtent = new Rectangle2D.Double( vpOld.getExtent().getMinX() - diffX, |
701 |
vpOld.getExtent().getMinY() - diffY, |
702 |
vpOld.getExtent().getWidth(), |
703 |
vpOld.getExtent().getHeight() ); |
704 |
ViewPort vpNew = new ViewPort(vpOld.getProjection());
|
705 |
vpNew.setExtent(newExtent); |
706 |
vpNew.setImageSize(vpOld.getImageSize()); |
707 |
vpNew.refreshExtent(); |
708 |
getLyrPoints().getPoint(j).leftViewPort = vpNew; |
709 |
} |
710 |
} |
711 |
|
712 |
/**
|
713 |
* This method initializes jButton
|
714 |
*
|
715 |
* @return javax.swing.JButton
|
716 |
*/
|
717 |
public JButton getBAccept() { |
718 |
if (bAceptar == null) { |
719 |
bAceptar = new JButton(); |
720 |
bAceptar.setText(PluginServices.getText(this,"aceptar")); |
721 |
bAceptar.setToolTipText(PluginServices.getText(this,"accept_tip")); |
722 |
bAceptar.addActionListener(this);
|
723 |
} |
724 |
return bAceptar;
|
725 |
} |
726 |
|
727 |
/**
|
728 |
* This method initializes bProcesar
|
729 |
*
|
730 |
* @return javax.swing.JButton
|
731 |
*/
|
732 |
public JButton getBProcess() { |
733 |
if (bProcesar == null) { |
734 |
bProcesar = new JButton(); |
735 |
bProcesar.setText(PluginServices.getText(this,"procesar")); |
736 |
bProcesar.setToolTipText(PluginServices.getText(this,"process_tip")); |
737 |
bProcesar.setEnabled(true);
|
738 |
bProcesar.addActionListener(this);
|
739 |
|
740 |
//TODO: Descomentar cuando se pueda procesar al vuelo la imagen
|
741 |
bProcesar.setVisible(false);
|
742 |
} |
743 |
return bProcesar;
|
744 |
} |
745 |
|
746 |
/**
|
747 |
* El bot?n cancelar restaura el extent con el que se carg? la imagen a georreferenciar
|
748 |
* y cierra la ventana.
|
749 |
*
|
750 |
* @return javax.swing.JButton
|
751 |
*/
|
752 |
public JButton getBCancel() { |
753 |
if (bCancelar == null) { |
754 |
bCancelar = new JButton(); |
755 |
bCancelar.setText(PluginServices.getText(this,"cancelar")); |
756 |
bCancelar.setToolTipText(PluginServices.getText(this,"cancel_tip")); |
757 |
bCancelar.addActionListener(this);
|
758 |
} |
759 |
return bCancelar;
|
760 |
} |
761 |
|
762 |
/**
|
763 |
* Asigna a las textbox el valor de pixel pasado
|
764 |
* @param x valor x
|
765 |
* @param y valor y
|
766 |
*/
|
767 |
public void setPixelText(double x, double y){ |
768 |
getSelectPointsPanel().getDataPointPanel().getTX().setText(String.valueOf(x));
|
769 |
getSelectPointsPanel().getDataPointPanel().getTY().setText(String.valueOf(y));
|
770 |
} |
771 |
|
772 |
/**
|
773 |
* Asigna a las textbox el valor de coordenadas pasado
|
774 |
* @param x valor x
|
775 |
* @param y valor y
|
776 |
*/
|
777 |
public void setMapCoordText(double x, double y){ |
778 |
getSelectPointsPanel().getDataPointPanel().getLongitud().setText(GeoUtils.tailDecimals(String.valueOf(x), 5)); |
779 |
getSelectPointsPanel().getDataPointPanel().getLatitud().setText(GeoUtils.tailDecimals(String.valueOf(y), 5)); |
780 |
} |
781 |
|
782 |
/**
|
783 |
* Esta funci?n resetea los controles del panel de info de un punto.
|
784 |
*/
|
785 |
public void resetControls(boolean active){ |
786 |
getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().setSaveToDisk(active); |
787 |
getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().resetControls(active); |
788 |
getConectorPanel().getAdjustGeorefPanel().getZoomLeft().clear(); |
789 |
getConectorPanel().getAdjustGeorefPanel().getZoomRight().clear(); |
790 |
setEnabled(active); |
791 |
} |
792 |
|
793 |
/* (non-Javadoc)
|
794 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
795 |
*/
|
796 |
public void componentHidden(ComponentEvent arg0) { |
797 |
|
798 |
} |
799 |
/* (non-Javadoc)
|
800 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
|
801 |
*/
|
802 |
public void componentMoved(ComponentEvent arg0) { |
803 |
|
804 |
} |
805 |
/* (non-Javadoc)
|
806 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
|
807 |
*/
|
808 |
public void componentResized(ComponentEvent ev) { |
809 |
|
810 |
if(frame.getWidth() <= this.normalWidth + 10) |
811 |
frame.setSize(this.normalWidth, frame.getHeight());
|
812 |
|
813 |
if(this.getConectorPanel().getDataPointsTabPanel().getTbPoints().getSelectedIndex() == 1){ |
814 |
tmpWidth = frame.getWidth(); |
815 |
this.newFrameSize(frame.getWidth(), frame.getHeight() - 10); |
816 |
} |
817 |
} |
818 |
/* (non-Javadoc)
|
819 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
|
820 |
*/
|
821 |
public void componentShown(ComponentEvent arg0) { |
822 |
|
823 |
} |
824 |
|
825 |
/**
|
826 |
*Inicializa el tama?o del dialogo
|
827 |
*/
|
828 |
public void resetSize(){ |
829 |
if(!enlarge){
|
830 |
frame.setSize(this.normalWidth + 12, this.normalHeight + 10); |
831 |
}else{
|
832 |
frame.setSize(this.normalWidth + 12, this.enlargeHeight + 10); |
833 |
} |
834 |
newFrameSize((int)Math.round(this.normalWidth / 0.98), this.normalHeight); |
835 |
} |
836 |
|
837 |
/**
|
838 |
* Calculo del nuevo tama?o a partir de un frame redimensionado
|
839 |
* @param w Ancho del frame
|
840 |
* @param h Alto del frame
|
841 |
*/
|
842 |
public void newFrameSize(int w, int h){ |
843 |
int newWidth = (int)Math.round(w * 0.98); |
844 |
|
845 |
this.setSize(new java.awt.Dimension(newWidth, normalHeight )); |
846 |
this.setPreferredSize(new java.awt.Dimension(newWidth, normalHeight )); |
847 |
this.getConectorPanel().newFrameSize(newWidth, h);
|
848 |
} |
849 |
|
850 |
/**
|
851 |
* Elimina un punto de la tabla de puntos
|
852 |
* @param pos Posici?n del punto a eliminar
|
853 |
*/
|
854 |
public void removeTableValueAt(int pos) throws ArrayIndexOutOfBoundsException{ |
855 |
((DefaultTableModel)getTable().getTable().getModel()).removeRow(pos);
|
856 |
} |
857 |
|
858 |
/**
|
859 |
* A partir de nuevas coordenadas actualiza la vista, minimagen, capa de puntos el
|
860 |
* dialogo y la tabla.
|
861 |
*
|
862 |
*/
|
863 |
public void updateData(int nPunto, Point2D pixel, Point2D map, View view){ |
864 |
getPointManager().updateData(nPunto, pixel, map, this, view);
|
865 |
} |
866 |
|
867 |
/**
|
868 |
* Esta funci?n deshabilita todos los controles y guarda sus valores
|
869 |
* de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue
|
870 |
* se vuelvan a quedar como estaba
|
871 |
*/
|
872 |
public void disableAllControls(){ |
873 |
if(!disableAllControls){
|
874 |
disableAllControls = true;
|
875 |
|
876 |
//Salvamos los estados
|
877 |
buttonsState[0] = getBProcess().isEnabled();
|
878 |
buttonsState[1] = getBAccept().isEnabled();
|
879 |
buttonsState[2] = getBCancel().isEnabled();
|
880 |
buttonsState[3] = getDialogButtons().getBExportToCSV().isEnabled();
|
881 |
buttonsState[4] = getDialogButtons().getBImportFromCSV().isEnabled();
|
882 |
buttonsState[5] = getDialogButtons().getBLoad().isEnabled();
|
883 |
buttonsState[6] = getDialogButtons().getBSave().isEnabled();
|
884 |
|
885 |
//Desactivamos controles
|
886 |
getBProcess().setEnabled(false);
|
887 |
getBAccept().setEnabled(false);
|
888 |
getBCancel().setEnabled(false);
|
889 |
|
890 |
getDialogButtons().getBExportToCSV().setEnabled(false);
|
891 |
getDialogButtons().getBImportFromCSV().setEnabled(false);
|
892 |
getDialogButtons().getBLoad().setEnabled(false);
|
893 |
getDialogButtons().getBSave().setEnabled(false);
|
894 |
} |
895 |
} |
896 |
|
897 |
/**
|
898 |
* Esta funci?n deja los controles como estaban al ejecutar la funci?n
|
899 |
* disableAllControls
|
900 |
*/
|
901 |
public void restoreControlsValue(){ |
902 |
if(disableAllControls){
|
903 |
disableAllControls = false;
|
904 |
getBProcess().setEnabled(buttonsState[0]);
|
905 |
getBAccept().setEnabled(buttonsState[1]);
|
906 |
getBCancel().setEnabled(buttonsState[2]);
|
907 |
getDialogButtons().getBExportToCSV().setEnabled(buttonsState[3]);
|
908 |
getDialogButtons().getBImportFromCSV().setEnabled(buttonsState[4]);
|
909 |
getDialogButtons().getBLoad().setEnabled(buttonsState[5]);
|
910 |
getDialogButtons().getBSave().setEnabled(buttonsState[6]);
|
911 |
} |
912 |
} |
913 |
//**********************End Methods***************************
|
914 |
|
915 |
//**********************Setters & Getters*********************
|
916 |
/**
|
917 |
* Obtiene la tabla de puntos
|
918 |
*/
|
919 |
public PointTable getTable(){
|
920 |
return this.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getJTable(); |
921 |
} |
922 |
|
923 |
/**
|
924 |
* Asigna un valor a una posici?n de la tabla
|
925 |
* @param value Valor a asignar
|
926 |
* @param row Fila en la que se asigna
|
927 |
* @param col Columna en la que se asigna
|
928 |
*/
|
929 |
public void setTableValueAt(String value, int row, int col)throws ArrayIndexOutOfBoundsException{ |
930 |
((DefaultTableModel)getTable().getTable().getModel()).setValueAt(value, row, col);
|
931 |
} |
932 |
|
933 |
/**
|
934 |
* Asigna un valor del checkBox para una fila de la tabla
|
935 |
* @param row Fila en la que se asigna
|
936 |
*/
|
937 |
public void setCheckValueAt(Boolean value, int row)throws ArrayIndexOutOfBoundsException{ |
938 |
((DefaultTableModel)getTable().getTable().getModel()).setValueAt(value, row, 0); |
939 |
} |
940 |
|
941 |
/**
|
942 |
* Obtiene el n?mero de filas de la tabla
|
943 |
* @return N?mero de filas de la tabla
|
944 |
*/
|
945 |
public int getTableRowCount(){ |
946 |
return getTable().getTable().getRowCount();
|
947 |
} |
948 |
|
949 |
/**
|
950 |
* A?ade una nueva fila a la tabla de puntos
|
951 |
*/
|
952 |
public void addTableNew(){ |
953 |
getTable().getTableModel().addNew(); |
954 |
} |
955 |
/**
|
956 |
* @return Returns the tmpWidth.
|
957 |
*/
|
958 |
public int getTmpWidth() { |
959 |
return tmpWidth;
|
960 |
} |
961 |
/**
|
962 |
* @param tmpWidth The tmpWidth to set.
|
963 |
*/
|
964 |
public void setTmpWidth(int tmpWidth) { |
965 |
this.tmpWidth = tmpWidth;
|
966 |
} |
967 |
/**
|
968 |
* @return Returns the enlargeHeight.
|
969 |
*/
|
970 |
public int getEnlargeHeight() { |
971 |
return enlargeHeight;
|
972 |
} |
973 |
/**
|
974 |
* @return Returns the normalHeight.
|
975 |
*/
|
976 |
public int getNormalHeight() { |
977 |
return normalHeight;
|
978 |
} |
979 |
|
980 |
/**
|
981 |
* @return Returns the normalWidth.
|
982 |
*/
|
983 |
public int getNormalWidth() { |
984 |
return normalWidth;
|
985 |
} |
986 |
|
987 |
/**
|
988 |
* Asigna el valor del campo RMS
|
989 |
* @param rms Cadena que representa el RMS
|
990 |
*/
|
991 |
public void setRMS(String rms){ |
992 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTRMS().setText(rms);
|
993 |
} |
994 |
|
995 |
/**
|
996 |
* Asigna el valor del campo de residuo en X
|
997 |
* @param rms Cadena que representa el RMS
|
998 |
*/
|
999 |
public void setResX(String resX){ |
1000 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResX().setText(resX);
|
1001 |
} |
1002 |
|
1003 |
/**
|
1004 |
* Asigna el valor del campo de residuo en Y
|
1005 |
* @param rms Cadena que representa el RMS
|
1006 |
*/
|
1007 |
public void setResY(String resY){ |
1008 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResY().setText(resY);
|
1009 |
} |
1010 |
|
1011 |
/**
|
1012 |
* Asigna el valor del campo RMS
|
1013 |
* @param rms Cadena que representa el RMS
|
1014 |
*/
|
1015 |
public void setTotal(String total){ |
1016 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTTotal().setText(total);
|
1017 |
} |
1018 |
|
1019 |
/**
|
1020 |
* @return Returns the lyrGeoRaster.
|
1021 |
*/
|
1022 |
public FLyrGeoRaster getLyrGeoRaster() {
|
1023 |
return lyrGeoRaster;
|
1024 |
} |
1025 |
|
1026 |
/**
|
1027 |
* @return Returns the lyrPoints.
|
1028 |
*/
|
1029 |
public FLyrPoints getLyrPoints() {
|
1030 |
try{
|
1031 |
return lyrGeoRaster.getFLyrPoints();
|
1032 |
}catch(ClassCastException exc){ |
1033 |
return null; |
1034 |
} |
1035 |
} |
1036 |
|
1037 |
/**
|
1038 |
* Selecciona un tab del cuadro
|
1039 |
* @param index
|
1040 |
*/
|
1041 |
public void setSelectedTab(int index){ |
1042 |
try{
|
1043 |
this.getConectorPanel().getDataPointsTabPanel().getTbPoints().setSelectedIndex(index);
|
1044 |
}catch(IllegalArgumentException ex){ |
1045 |
//Si peta al seleccionar un tab, pues nada.
|
1046 |
} |
1047 |
} |
1048 |
|
1049 |
/**
|
1050 |
* @param extended The extended to set.
|
1051 |
*/
|
1052 |
public void setEnlarge(boolean enlarge) { |
1053 |
this.enlarge = enlarge;
|
1054 |
if(!enlarge){
|
1055 |
frame.setSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10)); |
1056 |
frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10)); |
1057 |
this.setPreferredSize(new Dimension(this.normalWidth, this.normalHeight)); |
1058 |
this.setSize(new Dimension(this.normalWidth, this.normalHeight)); |
1059 |
this.getConectorPanel().setCanvasVisible(false); |
1060 |
}else{
|
1061 |
frame.setSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10)); |
1062 |
frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10)); |
1063 |
this.setPreferredSize(new Dimension(this.normalWidth, this.enlargeHeight)); |
1064 |
this.setSize(new Dimension(this.normalWidth, this.enlargeHeight)); |
1065 |
this.getConectorPanel().setCanvasVisible(true); |
1066 |
} |
1067 |
frame.pack(); |
1068 |
} |
1069 |
|
1070 |
/**
|
1071 |
* @return Returns the extended.
|
1072 |
*/
|
1073 |
public boolean isEnlarge() { |
1074 |
return enlarge;
|
1075 |
} |
1076 |
|
1077 |
/**
|
1078 |
* Obtiene el panel conector
|
1079 |
* @return
|
1080 |
*/
|
1081 |
public ConectorPanel getConectorPanel() {
|
1082 |
if (conectorPanel == null) { |
1083 |
conectorPanel = new ConectorPanel(this); |
1084 |
} |
1085 |
|
1086 |
return conectorPanel;
|
1087 |
} |
1088 |
|
1089 |
/**
|
1090 |
* This method initializes jPanel
|
1091 |
*
|
1092 |
* @return javax.swing.JPanel
|
1093 |
*/
|
1094 |
private JPanel getPBotones() { |
1095 |
if (pBotones == null) { |
1096 |
FlowLayout flowLayout1 = new FlowLayout(); |
1097 |
pBotones = new JPanel(); |
1098 |
pBotones.setLayout(flowLayout1); |
1099 |
flowLayout1.setHgap(2);
|
1100 |
flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT); |
1101 |
pBotones.add(getDialogButtons(), null);
|
1102 |
pBotones.add(getBProcess(), null);
|
1103 |
pBotones.add(getBAccept(), null);
|
1104 |
pBotones.add(getBCancel(), null);
|
1105 |
} |
1106 |
return pBotones;
|
1107 |
} |
1108 |
|
1109 |
public static IProjection getLastProjection() { |
1110 |
return proj;
|
1111 |
} |
1112 |
public static void setLastProjection(IProjection proj) { |
1113 |
GeoreferencingDialog.proj = proj; |
1114 |
} |
1115 |
|
1116 |
/**
|
1117 |
* @return Returns the GeoRedimBehavior.
|
1118 |
*/
|
1119 |
public GeoRedimBehavior getGeoRedimBehavior() {
|
1120 |
return rb;
|
1121 |
} |
1122 |
|
1123 |
/**
|
1124 |
* @param rb The GeoRedimBehavior to set.
|
1125 |
*/
|
1126 |
public void setGeoRedimBehavior(GeoRedimBehavior rb) { |
1127 |
this.rb = rb;
|
1128 |
} |
1129 |
|
1130 |
/**
|
1131 |
* @return Returns the GeoMoveBehavior
|
1132 |
*/
|
1133 |
public GeoMoveBehavior getGeoMoveBehavior() {
|
1134 |
return mb;
|
1135 |
} |
1136 |
|
1137 |
/**
|
1138 |
* @param mb The GeoMoveBehavior to set.
|
1139 |
*/
|
1140 |
public void setGeoMoveBehavior(GeoMoveBehavior mb) { |
1141 |
this.mb = mb;
|
1142 |
} |
1143 |
|
1144 |
|
1145 |
/**
|
1146 |
* Obtiene el punto de la lista que ha sido seleccionado
|
1147 |
* @return
|
1148 |
*/
|
1149 |
public int getSelectedPoint(){ |
1150 |
return getConectorPanel().getDataPointsTabPanel().
|
1151 |
getSelectPointsPanel().getTableControlerPanel().getSelectedIndex(); |
1152 |
} |
1153 |
|
1154 |
/**
|
1155 |
* Obtiene el control de la mini imagen que tiene los botones a la izquierda
|
1156 |
* @return ZoomControlPanel
|
1157 |
*/
|
1158 |
public ZoomControlPanel getZoomControlLeft(){
|
1159 |
return this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft(); |
1160 |
} |
1161 |
|
1162 |
/**
|
1163 |
* Obtiene el control de la mini imagen que tiene los botones a la derecha
|
1164 |
* @return ZoomControlPanel
|
1165 |
*/
|
1166 |
public ZoomControlPanel getZoomControlRight(){
|
1167 |
return this.getConectorPanel().getAdjustGeorefPanel().getZoomRight(); |
1168 |
} |
1169 |
|
1170 |
/**
|
1171 |
* Obtiene el panel de selecci?n de puntos
|
1172 |
* @return Panel de selecci?n de puntos
|
1173 |
*/
|
1174 |
public SelectPointsPanel getSelectPointsPanel(){
|
1175 |
return this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel(); |
1176 |
} |
1177 |
|
1178 |
/**
|
1179 |
* Obtiene el panel de opciones
|
1180 |
* @return OptionPanel
|
1181 |
*/
|
1182 |
public OptionsPanel getOptionsPanel(){
|
1183 |
return getConectorPanel().getAdjustGeorefPanel().getOptionsPanel();
|
1184 |
} |
1185 |
|
1186 |
/**
|
1187 |
* Asigna el frame
|
1188 |
* @param f
|
1189 |
*/
|
1190 |
public void setFrame(JInternalFrame f){ |
1191 |
frame = f; |
1192 |
frame.addComponentListener(this);
|
1193 |
} |
1194 |
|
1195 |
/**
|
1196 |
* Obtiene el frame
|
1197 |
* @return frame
|
1198 |
*/
|
1199 |
public JInternalFrame getFrame(){ |
1200 |
return frame;
|
1201 |
} |
1202 |
|
1203 |
/**
|
1204 |
* Obtiene el gestor de puntos
|
1205 |
* @return PointManager
|
1206 |
*/
|
1207 |
public PointManager getPointManager() {
|
1208 |
return pointManager;
|
1209 |
} |
1210 |
|
1211 |
/**
|
1212 |
* Activa o desactiva este panel y todos los que lo componen
|
1213 |
* @param enabled variable booleana para la activaci?n y/o desactivaci?n
|
1214 |
*/
|
1215 |
public void setEnabled(boolean enabled){ |
1216 |
conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().setEnabled(enabled); |
1217 |
conectorPanel.getAdjustGeorefPanel().setEnabled(enabled); |
1218 |
} |
1219 |
|
1220 |
/**
|
1221 |
* M?todo para notificar si se desea crear o no el fichero de coordenadas .tfw, .wld .jpgw ,...
|
1222 |
* @param createWorldFile
|
1223 |
*/
|
1224 |
public void setCreateWorldFile(boolean createWorldFile) { |
1225 |
this.createWorldFile = createWorldFile;
|
1226 |
} |
1227 |
|
1228 |
/**
|
1229 |
*
|
1230 |
*/
|
1231 |
public ViewPort getLeftInitViewport(ViewPort vp, Point2D center, ViewPort initVp, double zoom){ |
1232 |
return getZoomControlLeft().getCanvas().initViewPort(vp, center, initVp, zoom);
|
1233 |
} |
1234 |
|
1235 |
/**
|
1236 |
* Consulta 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 boolean isErrorCSV() { |
1240 |
return errorCSV;
|
1241 |
} |
1242 |
|
1243 |
/**
|
1244 |
* M?todo para notificar si se desea incluir los errores cuando se exporta a fichero .csv
|
1245 |
* @param errorCVS true si se incluyen los errores dentro del fichero y false si no se incluyen
|
1246 |
*/
|
1247 |
public void setErrorCSV(boolean errorCSV) { |
1248 |
this.errorCSV = errorCSV;
|
1249 |
} |
1250 |
|
1251 |
/**
|
1252 |
* Obtiene los errores en una matriz de Nx3 en la que cada fila es un punto y la
|
1253 |
* columna 0 es el error en X, la columna 1 es el error en Y y la columna 2 es el error RMS.
|
1254 |
* @return matriz de errores
|
1255 |
*/
|
1256 |
public double[][] getErrors(){ |
1257 |
return pointManager.getErrors();
|
1258 |
} |
1259 |
|
1260 |
/**
|
1261 |
* Pregunta si la capa a georreferenciar se desactiva cuando se introduce el
|
1262 |
* primer punto y devuelve true si lo hace.
|
1263 |
* @return true o false
|
1264 |
*/
|
1265 |
public boolean isOffLayer() { |
1266 |
return offLayer;
|
1267 |
} |
1268 |
|
1269 |
/**
|
1270 |
* Asigna el flag que dice si la capa a georreferenciar se desactiva cuando se introduce el
|
1271 |
* primer punto
|
1272 |
* @param offLayer true para desactivar la capa
|
1273 |
*/
|
1274 |
public void setOffLayer(boolean offLayer) { |
1275 |
this.offLayer = offLayer;
|
1276 |
} |
1277 |
|
1278 |
/**
|
1279 |
* Consulta si la vista ha de centrarse sobre el punto seleccionado o no.
|
1280 |
* @return true o false
|
1281 |
*/
|
1282 |
public boolean isCenterPoint() { |
1283 |
return centerPoint;
|
1284 |
} |
1285 |
|
1286 |
/**
|
1287 |
* Asigna el flag que dice si vista ha centrarse sobre el punto seleccionado o no
|
1288 |
* @param centerPoint true para centrar la vista y false no.
|
1289 |
*/
|
1290 |
public void setCenterPoint(boolean centerPoint) { |
1291 |
this.centerPoint = centerPoint;
|
1292 |
} |
1293 |
|
1294 |
/**
|
1295 |
* Pregunta si la capa de puntos se desactiva cuando se introduce el
|
1296 |
* primer punto y devuelve true si lo hace.
|
1297 |
* @return true o false
|
1298 |
*/
|
1299 |
public boolean isOffPoints() { |
1300 |
return offPoints;
|
1301 |
} |
1302 |
|
1303 |
/**
|
1304 |
* Asigna el flag que dice si la capa de puntos se desactiva cuando se introduce el
|
1305 |
* primer punto
|
1306 |
* @param offPoints true para desactivar la capa
|
1307 |
*/
|
1308 |
public void setOffPoints(boolean offPoints) { |
1309 |
this.offPoints = offPoints;
|
1310 |
} |
1311 |
|
1312 |
/**
|
1313 |
* Obtiene el bot?n de activar/desactivar la inserci?n de punto del panel del control de
|
1314 |
* tabla
|
1315 |
* @return JToggleButton
|
1316 |
*/
|
1317 |
public JToggleButton getBInsertPointOfTablePoints(){ |
1318 |
return tablePointsPanel.getPTablePanelButtons().getBInsertPoint();
|
1319 |
} |
1320 |
|
1321 |
/**
|
1322 |
* Obtiene el bot?n de activar/desactivar la inserci?n de punto del panel del control de
|
1323 |
* tabla
|
1324 |
* @return JToggleButton
|
1325 |
*/
|
1326 |
public JButton getBNewPointOfTablePoints(){ |
1327 |
return tablePointsPanel.getTableControlerPanel().getBNew();
|
1328 |
} |
1329 |
|
1330 |
/**
|
1331 |
* This method initializes jPanel
|
1332 |
*
|
1333 |
* @return javax.swing.JPanel
|
1334 |
*/
|
1335 |
public DialogButtons getDialogButtons() {
|
1336 |
if (dialogButtons == null) { |
1337 |
dialogButtons = new DialogButtons();
|
1338 |
} |
1339 |
return dialogButtons;
|
1340 |
} |
1341 |
|
1342 |
/**
|
1343 |
* Activa/desactiva los botones de la barra correspondientes al salvado
|
1344 |
* de datos a disco.
|
1345 |
* @param active true activa los controles y false los desactiva.
|
1346 |
*/
|
1347 |
public void setEnableSaveButtons(boolean active){ |
1348 |
getDialogButtons().getBSave().setEnabled(active); |
1349 |
getDialogButtons().getBExportToCSV().setEnabled(active); |
1350 |
} |
1351 |
//**********************End Setters & Getters*****************
|
1352 |
|
1353 |
} // @jve:decl-index=0:visual-constraint="10,10"
|
1354 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|
1355 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|