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