svn-gvsig-desktop / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / gui / dialogs / GeoreferencingDialog.java @ 4734
History | View | Annotate | Download (26.8 KB)
1 |
package com.iver.cit.gvsig.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.beans.PropertyVetoException; |
11 |
import java.io.File; |
12 |
|
13 |
import javax.swing.JButton; |
14 |
import javax.swing.JCheckBox; |
15 |
import javax.swing.JFileChooser; |
16 |
import javax.swing.JInternalFrame; |
17 |
import javax.swing.JOptionPane; |
18 |
import javax.swing.JPanel; |
19 |
import javax.swing.filechooser.FileFilter; |
20 |
import javax.swing.table.DefaultTableModel; |
21 |
|
22 |
import org.cresques.cts.IProjection; |
23 |
|
24 |
import com.iver.andami.PluginServices; |
25 |
import com.iver.cit.gvsig.fmap.MapControl; |
26 |
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
27 |
import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
28 |
import com.iver.cit.gvsig.fmap.tools.ZoomOutRightButtonListener; |
29 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
30 |
import com.iver.cit.gvsig.fmap.tools.Behavior.DraggedBehavior; |
31 |
import com.iver.cit.gvsig.fmap.tools.Behavior.GeoMoveBehavior; |
32 |
import com.iver.cit.gvsig.fmap.tools.Behavior.GeoRedimBehavior; |
33 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
34 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
35 |
import com.iver.cit.gvsig.gui.listeners.GeorefMovePointListener; |
36 |
import com.iver.cit.gvsig.gui.listeners.GeorefPanListener; |
37 |
import com.iver.cit.gvsig.gui.listeners.GeorefPointSelectorListener; |
38 |
import com.iver.cit.gvsig.gui.listeners.ZoomGeorefListener; |
39 |
import com.iver.cit.gvsig.gui.panels.ConectorPanel; |
40 |
import com.iver.cit.gvsig.gui.panels.OptionsPanel; |
41 |
import com.iver.cit.gvsig.gui.panels.ZoomControlPanel; |
42 |
import com.iver.cit.gvsig.gui.pointsTable.TablePointsPanel; |
43 |
import com.iver.cit.gvsig.gui.pointsTable.TablePointsPanel.PointTable; |
44 |
import com.iver.cit.gvsig.gui.selectPoints.SelectPointsPanel; |
45 |
import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener; |
46 |
import com.iver.cit.gvsig.gui.wizards.WizardListener; |
47 |
import com.iver.cit.gvsig.project.Project; |
48 |
import com.iver.cit.gvsig.utils.MathUtils; |
49 |
import com.iver.cit.gvsig.utils.PointManager; |
50 |
|
51 |
/**
|
52 |
* Panel que contiene el Wizard de georeferenciaci?n con los tabs
|
53 |
* interiores
|
54 |
*
|
55 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
56 |
*/
|
57 |
public class GeoreferencingDialog extends JPanel implements ActionListener, ComponentListener { |
58 |
|
59 |
//**********************Vars**********************************
|
60 |
static private IProjection proj = Project.getProjection(); |
61 |
private JPanel pBotones = null; // @jve:decl-index=0: |
62 |
private JButton bProcesar = null; // @jve:decl-index=0: |
63 |
private JButton bCancelar = null; // @jve:decl-index=0: |
64 |
private WizardListener wizardListener = new DialogWizardListener(); |
65 |
private JButton bLoadPoints = null; // @jve:decl-index=0: |
66 |
private GeoRedimBehavior rb = null; |
67 |
private GeoMoveBehavior mb = null; |
68 |
private boolean loadTools = false; |
69 |
private JInternalFrame frame = null; |
70 |
/**
|
71 |
* Lista de formatos soportados
|
72 |
*/
|
73 |
private String[] fileFilters = {"grf"}; |
74 |
/**
|
75 |
* Recuerda la ?ltima ruta seleccionada por el usuario
|
76 |
*/
|
77 |
private String lastPathLoad = "./"; |
78 |
private String lastPathSave = "./"; |
79 |
private ConectorPanel conectorPanel = null; |
80 |
|
81 |
private boolean enlarge = false; |
82 |
private int normalWidth = 400; |
83 |
private int normalHeight = 263; |
84 |
private int enlargeHeight = 428; |
85 |
private int tmpWidth = normalWidth; |
86 |
|
87 |
private JButton bAceptar = null; |
88 |
|
89 |
private JButton bSavePoints = null; |
90 |
private FLyrGeoRaster lyrGeoRaster = null; |
91 |
private TablePointsPanel tablePointsPanel = null; |
92 |
private PointManager pointManager = null; |
93 |
//**********************End Vars******************************
|
94 |
|
95 |
//**********************Classes*******************************
|
96 |
/**
|
97 |
* Filtro para selecci?n de ficheros.
|
98 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
99 |
*/
|
100 |
class SelectFileFilter extends javax.swing.filechooser.FileFilter { |
101 |
|
102 |
private JFileChooser chooser = null; |
103 |
private String file = null; |
104 |
|
105 |
public SelectFileFilter(JFileChooser ch, String file){ |
106 |
this.chooser = ch;
|
107 |
this.file = file;
|
108 |
} |
109 |
|
110 |
public boolean accept(File f) { |
111 |
|
112 |
return f.isDirectory() || f.getName().toLowerCase().endsWith("."+file); |
113 |
} |
114 |
|
115 |
public String getDescription() { |
116 |
return file;
|
117 |
} |
118 |
|
119 |
} |
120 |
|
121 |
/**
|
122 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
123 |
*/
|
124 |
public class DialogWizardListener implements WizardListener { |
125 |
|
126 |
/**
|
127 |
* @see com.iver.cit.gvsig.gui.wms.WizardListener#error(java.lang.Exception)
|
128 |
*/
|
129 |
public void error(Exception e) { |
130 |
} |
131 |
|
132 |
/**
|
133 |
* @see com.iver.cit.gvsig.gui.wms.WizardListener#wizardStateChanged(boolean)
|
134 |
*/
|
135 |
public void wizardStateChanged(boolean finishable) { |
136 |
getBProcesar().setEnabled(finishable); |
137 |
} |
138 |
|
139 |
} |
140 |
//**********************End Classes***************************
|
141 |
|
142 |
//**********************Methods*******************************
|
143 |
/**
|
144 |
* Constructor.
|
145 |
*/
|
146 |
public GeoreferencingDialog(JInternalFrame f, FLyrGeoRaster lyr) { |
147 |
frame = f; |
148 |
lyrGeoRaster = lyr; |
149 |
|
150 |
frame.addComponentListener(this);
|
151 |
initialize(); |
152 |
|
153 |
//Creamos el pointManager y lo asignamos a la capa de puntos
|
154 |
pointManager = new PointManager(this, lyrGeoRaster.getFLyrPoints()); |
155 |
this.lyrGeoRaster.getFLyrPoints().setPointManager(pointManager);
|
156 |
} |
157 |
|
158 |
/**
|
159 |
* En la inicializaci?n de la ventana a?adimos los tags de est? y cargamos
|
160 |
* ls herramientas para manejar las imagenes a georeferenciar.
|
161 |
*/
|
162 |
private void initialize() { |
163 |
//Cargamos las herramientas la primera vez que abrimos la ventana
|
164 |
if(!loadTools){
|
165 |
loadTools = true;
|
166 |
com.iver.cit.gvsig.gui.View vista = null;
|
167 |
try{
|
168 |
vista = (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView(); |
169 |
}catch(ClassCastException exc){ |
170 |
return;
|
171 |
} |
172 |
MapControl mapCtrl = vista.getMapControl(); |
173 |
|
174 |
StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
175 |
|
176 |
ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(mapCtrl);
|
177 |
ZoomGeorefListener zigl = new ZoomGeorefListener(mapCtrl);
|
178 |
rb = new GeoRedimBehavior(zigl, this); |
179 |
mapCtrl.addMapTool("geoZoom", new Behavior[]{rb, |
180 |
new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
181 |
|
182 |
GeorefPanListener pl = new GeorefPanListener(mapCtrl);
|
183 |
mb = new GeoMoveBehavior(pl, this); |
184 |
mapCtrl.addMapTool("geoPan", new Behavior[]{mb, new MouseMovementBehavior(sbl)}); |
185 |
|
186 |
//Seleccion de un punto sobre la vista
|
187 |
GeorefPointSelectorListener psl = new GeorefPointSelectorListener(this); |
188 |
mapCtrl.addMapTool("pointLyrSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)}); |
189 |
|
190 |
GeorefMovePointListener mpl = new GeorefMovePointListener(this); |
191 |
mapCtrl.addMapTool("geoMovePoint", new Behavior[]{new DraggedBehavior(mpl), new MouseMovementBehavior(sbl)}); |
192 |
|
193 |
} |
194 |
|
195 |
this.setLayout(new BorderLayout()); |
196 |
if(!enlarge){
|
197 |
this.setPreferredSize(new java.awt.Dimension(normalWidth, normalHeight)); |
198 |
this.setSize(new java.awt.Dimension(normalWidth, normalHeight)); |
199 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().setVisible(false); |
200 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomRight().setVisible(false); |
201 |
}else{
|
202 |
this.setPreferredSize(new java.awt.Dimension(normalWidth, enlargeHeight)); |
203 |
this.setSize(new java.awt.Dimension(normalWidth, enlargeHeight)); |
204 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().setVisible(true); |
205 |
this.getConectorPanel().getAdjustGeorefPanel().getZoomRight().setVisible(true); |
206 |
} |
207 |
this.setLocation(new java.awt.Point(0,0)); |
208 |
|
209 |
this.add(this.getPBotones(), BorderLayout.SOUTH); |
210 |
this.add(this.getConectorPanel(), BorderLayout.NORTH); |
211 |
|
212 |
//A?adimos los listener de los botones de la tabla
|
213 |
//Los botones de borrado los gestiona SelectPointsPanel
|
214 |
//Los botones de cargar y exportar los gestiona GeoreferencigDialog
|
215 |
tablePointsPanel = getConectorPanel().getDataPointsTabPanel().getTablePointsPanel(); |
216 |
tablePointsPanel.getTableControlerPanel().getBClear().addActionListener(this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel());
|
217 |
tablePointsPanel.getTableControlerPanel().getBDelPoint().addActionListener(this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel());
|
218 |
tablePointsPanel.getPButtonsExportImportPanel().getBLoad().addActionListener(this);
|
219 |
tablePointsPanel.getPButtonsExportImportPanel().getBSave().addActionListener(this);
|
220 |
tablePointsPanel.getPButtonsExportImportPanel().getBExportToAscii().addActionListener(this);
|
221 |
conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel().getCbActive().addActionListener(this);
|
222 |
} |
223 |
|
224 |
/**
|
225 |
* This method initializes jButton
|
226 |
*
|
227 |
* @return javax.swing.JButton
|
228 |
*/
|
229 |
private JButton getBAceptar() { |
230 |
if (bAceptar == null) { |
231 |
bAceptar = new JButton(); |
232 |
bAceptar.setText(PluginServices.getText(this,"aceptar")); |
233 |
bAceptar.addActionListener(this);
|
234 |
} |
235 |
return bAceptar;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* Comprueba si existe el fichero pasado por par?metro existe solicitando confirmaci?n
|
240 |
* de sobreescritura. Si el usuario acepta devolver? true y si no acepta devuelve false.
|
241 |
* Si se acepta la sobreescritura el fichero es borrado.
|
242 |
* @param file Cadena con el nombre del fichero a comprobar su existencia.
|
243 |
* @return Devuelve true si el fichero existe y va a ser sobreescrito
|
244 |
*/
|
245 |
private boolean checkFileExists(String file){ |
246 |
File f = new File(file); |
247 |
if(f.exists()){
|
248 |
String string1 = PluginServices.getText(this, "yes"); |
249 |
String string2 = PluginServices.getText(this, "no"); |
250 |
Object[] options = {string1, string2}; |
251 |
int n = JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(), |
252 |
PluginServices.getText(this, "file_exists"), |
253 |
PluginServices.getText(this, "confirmacion"), |
254 |
JOptionPane.YES_NO_OPTION,
|
255 |
JOptionPane.QUESTION_MESSAGE,
|
256 |
null,
|
257 |
options, |
258 |
string1); |
259 |
if (n == JOptionPane.YES_OPTION){ |
260 |
f.delete(); |
261 |
return true; |
262 |
}else
|
263 |
return false; |
264 |
} |
265 |
return true; |
266 |
} |
267 |
|
268 |
/**
|
269 |
* Acci?n cuando se pulsa el bot?n de aceptar en el dialogo.
|
270 |
* <UL>
|
271 |
* <LI>Cambiamos el nombre a la capa georraster</LI>
|
272 |
* <LI>A la capa Georraster le asignamos la capa de puntos para poder recuperarla</LI>
|
273 |
* <LI>Cerramos la ventana</LI>
|
274 |
* </UL>
|
275 |
*/
|
276 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
277 |
com.iver.cit.gvsig.gui.View theView = null;
|
278 |
try{
|
279 |
theView = (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView(); |
280 |
}catch(ClassCastException exc){ |
281 |
return;
|
282 |
} |
283 |
|
284 |
//ACEPTAR
|
285 |
if(e.getSource() == bAceptar){
|
286 |
if(getLyrPoints() == null) |
287 |
return;
|
288 |
|
289 |
if(lyrGeoRaster != null){ |
290 |
getLyrPoints().setVisible(false);
|
291 |
lyrGeoRaster.setName(lyrGeoRaster.getName().substring(1, lyrGeoRaster.getName().length()));
|
292 |
lyrGeoRaster.setActive(false);
|
293 |
theView.getMapControl().getMapContext().invalidate(); |
294 |
} |
295 |
|
296 |
try{
|
297 |
frame.setClosed(true);
|
298 |
}catch(PropertyVetoException exc){} |
299 |
} |
300 |
|
301 |
//CANCELAR
|
302 |
if(e.getSource() == bCancelar){
|
303 |
if(getLyrPoints() == null) |
304 |
return;
|
305 |
|
306 |
//Cerramos la ventana
|
307 |
//(se ejecuta el evento internalFrameClosing de GeoRasterFrameListener)
|
308 |
try{
|
309 |
frame.setClosed(true);
|
310 |
}catch(PropertyVetoException exc){} |
311 |
} |
312 |
|
313 |
//CARGAR PUNTOS
|
314 |
if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBLoad()){
|
315 |
JFileChooser chooser = new JFileChooser(lastPathLoad); |
316 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
317 |
FileFilter f = null; |
318 |
for(int i=0; i<this.fileFilters.length;i++){ |
319 |
f = new SelectFileFilter(chooser, this.fileFilters[i]); |
320 |
chooser.addChoosableFileFilter(f); |
321 |
} |
322 |
int returnVal = chooser.showOpenDialog(this); |
323 |
if(returnVal == JFileChooser.APPROVE_OPTION){ |
324 |
String fName = chooser.getSelectedFile().toString();
|
325 |
FileFilter filter = chooser.getFileFilter();
|
326 |
lastPathLoad = chooser.getCurrentDirectory().getAbsolutePath(); |
327 |
|
328 |
if(getLyrPoints() == null) |
329 |
return;
|
330 |
|
331 |
lyrGeoRaster.getFLyrPoints().saveState(); |
332 |
getLyrPoints().XML2PointList(fName); |
333 |
} |
334 |
} |
335 |
|
336 |
//SALVAR PUNTOS
|
337 |
if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBSave()){
|
338 |
JFileChooser chooser = new JFileChooser(lastPathSave); |
339 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
340 |
|
341 |
FileFilter f = null; |
342 |
for(int i=0; i<this.fileFilters.length;i++){ |
343 |
f = new SelectFileFilter(chooser, this.fileFilters[i]); |
344 |
chooser.addChoosableFileFilter(f); |
345 |
} |
346 |
int returnVal = chooser.showOpenDialog(this); |
347 |
if(returnVal == JFileChooser.APPROVE_OPTION){ |
348 |
String fName = chooser.getSelectedFile().toString();
|
349 |
lastPathSave = chooser.getCurrentDirectory().getAbsolutePath(); |
350 |
if(!fName.endsWith(".grf")) |
351 |
fName = fName + ".grf";
|
352 |
if(this.checkFileExists(fName)){ |
353 |
if(getLyrPoints() != null) |
354 |
getLyrPoints().PointList2XML(fName); |
355 |
} |
356 |
} |
357 |
|
358 |
} |
359 |
|
360 |
//EXPORTAR A ASCII
|
361 |
if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBExportToAscii()){
|
362 |
JFileChooser chooser = new JFileChooser(lastPathSave); |
363 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero")); |
364 |
|
365 |
FileFilter f = null; |
366 |
for(int i=0; i<this.fileFilters.length;i++){ |
367 |
f = new SelectFileFilter(chooser, this.fileFilters[i]); |
368 |
chooser.addChoosableFileFilter(f); |
369 |
} |
370 |
int returnVal = chooser.showOpenDialog(this); |
371 |
if(returnVal == JFileChooser.APPROVE_OPTION){ |
372 |
String fName = chooser.getSelectedFile().toString();
|
373 |
lastPathSave = chooser.getCurrentDirectory().getAbsolutePath(); |
374 |
if(this.checkFileExists(fName)){ |
375 |
if(getLyrPoints() != null) |
376 |
getLyrPoints().PointList2Ascii(fName); |
377 |
} |
378 |
} |
379 |
|
380 |
} |
381 |
|
382 |
//DESACTIVAR PANELES
|
383 |
JCheckBox cb = this.conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel().getCbActive(); |
384 |
if(e.getSource() == cb){
|
385 |
if(cb.isSelected()){
|
386 |
this.setEnabled(true); |
387 |
getLyrPoints().setPointActive(getSelectedPoint(), true);
|
388 |
}else{
|
389 |
this.setEnabled(false); |
390 |
getLyrPoints().setPointActive(getSelectedPoint(), false);
|
391 |
} |
392 |
theView.getMapControl().getMapContext().invalidate(); |
393 |
getZoomControlLeft().draw(); |
394 |
getZoomControlRight().draw(); |
395 |
} |
396 |
} |
397 |
|
398 |
/**
|
399 |
* This method initializes bProcesar
|
400 |
*
|
401 |
* @return javax.swing.JButton
|
402 |
*/
|
403 |
private JButton getBProcesar() { |
404 |
if (bProcesar == null) { |
405 |
bProcesar = new JButton(); |
406 |
bProcesar.setText(PluginServices.getText(this,"procesar")); |
407 |
bProcesar.setEnabled(false);
|
408 |
bProcesar.addActionListener(new java.awt.event.ActionListener() {
|
409 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
410 |
/*if (PluginServices.getMainFrame() == null) {
|
411 |
((JDialog) (getParent().getParent().getParent()
|
412 |
.getParent())).dispose();
|
413 |
} else {
|
414 |
PluginServices.getMDIManager().closeView((com.iver.andami.ui.mdiManager.View) GeoreferencingDialog.this);
|
415 |
}*/
|
416 |
} |
417 |
}); |
418 |
} |
419 |
return bProcesar;
|
420 |
} |
421 |
|
422 |
/**
|
423 |
* El bot?n cancelar restaura el extent con el que se carg? la imagen a georreferenciar
|
424 |
* y cierra la ventana.
|
425 |
*
|
426 |
* @return javax.swing.JButton
|
427 |
*/
|
428 |
private JButton getBCancelar() { |
429 |
if (bCancelar == null) { |
430 |
bCancelar = new JButton(); |
431 |
bCancelar.setText(PluginServices.getText(this,"cancelar")); |
432 |
bCancelar.addActionListener(this);
|
433 |
} |
434 |
return bCancelar;
|
435 |
} |
436 |
|
437 |
/**
|
438 |
* This method initializes jButton
|
439 |
*
|
440 |
* @return javax.swing.JButton
|
441 |
*/
|
442 |
private JButton getBLoadPoints() { |
443 |
if (bLoadPoints == null) { |
444 |
bLoadPoints = new JButton(); |
445 |
bLoadPoints.setText(PluginServices.getText(this,"cargar")); |
446 |
bLoadPoints.setEnabled(true);
|
447 |
bLoadPoints.addActionListener(this);
|
448 |
} |
449 |
return bLoadPoints;
|
450 |
} |
451 |
|
452 |
/**
|
453 |
* Asigna a las textbox el valor de pixel pasado
|
454 |
* @param x valor x
|
455 |
* @param y valor y
|
456 |
*/
|
457 |
public void setPixelText(double x, double y){ |
458 |
getSelectPointsPanel().getDataPointPanel().getTX().setText(String.valueOf(x));
|
459 |
getSelectPointsPanel().getDataPointPanel().getTY().setText(String.valueOf(y));
|
460 |
} |
461 |
|
462 |
/**
|
463 |
* Asigna a las textbox el valor de coordenadas pasado
|
464 |
* @param x valor x
|
465 |
* @param y valor y
|
466 |
*/
|
467 |
public void setMapCoordText(double x, double y){ |
468 |
getSelectPointsPanel().getDataPointPanel().getLongitud().setText(MathUtils.tailDecimals(String.valueOf(x), 5)); |
469 |
getSelectPointsPanel().getDataPointPanel().getLatitud().setText(MathUtils.tailDecimals(String.valueOf(y), 5)); |
470 |
} |
471 |
|
472 |
/**
|
473 |
* Esta funci?n resetea los controles del panel de info de un punto.
|
474 |
*/
|
475 |
public void resetControls(boolean active){ |
476 |
getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().setSaveToDisk(active); |
477 |
getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().resetControls(active); |
478 |
getConectorPanel().getAdjustGeorefPanel().getZoomLeft().clear(); |
479 |
setEnabled(active); |
480 |
} |
481 |
|
482 |
/* (non-Javadoc)
|
483 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
484 |
*/
|
485 |
public void componentHidden(ComponentEvent arg0) { |
486 |
// TODO Auto-generated method stub
|
487 |
|
488 |
} |
489 |
/* (non-Javadoc)
|
490 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
|
491 |
*/
|
492 |
public void componentMoved(ComponentEvent arg0) { |
493 |
// TODO Auto-generated method stub
|
494 |
|
495 |
} |
496 |
/* (non-Javadoc)
|
497 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
|
498 |
*/
|
499 |
public void componentResized(ComponentEvent ev) { |
500 |
|
501 |
if(frame.getWidth() <= this.normalWidth + 10) |
502 |
frame.setSize(this.normalWidth, frame.getHeight());
|
503 |
|
504 |
if(this.getConectorPanel().getDataPointsTabPanel().getTbPoints().getSelectedIndex() == 1){ |
505 |
tmpWidth = frame.getWidth(); |
506 |
this.newFrameSize(frame.getWidth(), frame.getHeight() - 10); |
507 |
} |
508 |
} |
509 |
/* (non-Javadoc)
|
510 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
|
511 |
*/
|
512 |
public void componentShown(ComponentEvent arg0) { |
513 |
// TODO Auto-generated method stub
|
514 |
|
515 |
} |
516 |
|
517 |
/**
|
518 |
*Inicializa el tama?o del dialogo
|
519 |
*/
|
520 |
public void resetSize(){ |
521 |
if(!enlarge){
|
522 |
frame.setSize(this.normalWidth + 12, this.normalHeight + 10); |
523 |
}else{
|
524 |
frame.setSize(this.normalWidth + 12, this.enlargeHeight + 10); |
525 |
} |
526 |
newFrameSize((int)Math.round(this.normalWidth / 0.98), this.normalHeight); |
527 |
} |
528 |
|
529 |
/**
|
530 |
* Calculo del nuevo tama?o a partir de un frame redimensionado
|
531 |
* @param w Ancho del frame
|
532 |
* @param h Alto del frame
|
533 |
*/
|
534 |
public void newFrameSize(int w, int h){ |
535 |
int newWidth = (int)Math.round(w * 0.98); |
536 |
|
537 |
this.setSize(new java.awt.Dimension(newWidth, normalHeight )); |
538 |
this.setPreferredSize(new java.awt.Dimension(newWidth, normalHeight )); |
539 |
this.getConectorPanel().newFrameSize(newWidth, h);
|
540 |
} |
541 |
|
542 |
/**
|
543 |
* Elimina un punto de la tabla de puntos
|
544 |
* @param pos Posici?n del punto a eliminar
|
545 |
*/
|
546 |
public void removeTableValueAt(int pos) throws ArrayIndexOutOfBoundsException{ |
547 |
((DefaultTableModel)this.getTable().getTable().getModel()).removeRow(pos); |
548 |
} |
549 |
|
550 |
|
551 |
//**********************End Methods***************************
|
552 |
|
553 |
//**********************Setters & Getters*********************
|
554 |
/**
|
555 |
* Obtiene la tabla de puntos
|
556 |
*/
|
557 |
public PointTable getTable(){
|
558 |
return this.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getJTable(); |
559 |
} |
560 |
|
561 |
/**
|
562 |
* Asigna un valor a una posici?n de la tabla
|
563 |
* @param value Valor a asignar
|
564 |
* @param row Fila en la que se asigna
|
565 |
* @param col Columna en la que se asigna
|
566 |
*/
|
567 |
public void setTableValueAt(String value, int row, int col)throws ArrayIndexOutOfBoundsException{ |
568 |
((DefaultTableModel)this.getTable().getTable().getModel()).setValueAt(value, row, col); |
569 |
} |
570 |
|
571 |
/**
|
572 |
* Obtiene el n?mero de filas de la tabla
|
573 |
* @return N?mero de filas de la tabla
|
574 |
*/
|
575 |
public int getTableRowCount(){ |
576 |
return this.getTable().getTable().getRowCount(); |
577 |
} |
578 |
|
579 |
/**
|
580 |
* A?ade una nueva fila a la tabla de puntos
|
581 |
*/
|
582 |
public void addTableNew(){ |
583 |
this.getTable().getTableModel().addNew();
|
584 |
} |
585 |
/**
|
586 |
* @return Returns the tmpWidth.
|
587 |
*/
|
588 |
public int getTmpWidth() { |
589 |
return tmpWidth;
|
590 |
} |
591 |
/**
|
592 |
* @param tmpWidth The tmpWidth to set.
|
593 |
*/
|
594 |
public void setTmpWidth(int tmpWidth) { |
595 |
this.tmpWidth = tmpWidth;
|
596 |
} |
597 |
/**
|
598 |
* @return Returns the enlargeHeight.
|
599 |
*/
|
600 |
public int getEnlargeHeight() { |
601 |
return enlargeHeight;
|
602 |
} |
603 |
/**
|
604 |
* @return Returns the normalHeight.
|
605 |
*/
|
606 |
public int getNormalHeight() { |
607 |
return normalHeight;
|
608 |
} |
609 |
|
610 |
/**
|
611 |
* @return Returns the normalWidth.
|
612 |
*/
|
613 |
public int getNormalWidth() { |
614 |
return normalWidth;
|
615 |
} |
616 |
|
617 |
/**
|
618 |
* This method initializes jButton
|
619 |
*
|
620 |
* @return javax.swing.JButton
|
621 |
*/
|
622 |
private JButton getBSavePoints() { |
623 |
if (bSavePoints == null) { |
624 |
bSavePoints = new JButton(); |
625 |
bSavePoints.setText(PluginServices.getText(this,"salvar")); |
626 |
//bSavePoints.setPreferredSize(new java.awt.Dimension(41,25));
|
627 |
bSavePoints.addActionListener(this);
|
628 |
} |
629 |
return bSavePoints;
|
630 |
} |
631 |
|
632 |
/**
|
633 |
* Asigna el valor del campo RMS
|
634 |
* @param rms Cadena que representa el RMS
|
635 |
*/
|
636 |
public void setRMS(String rms){ |
637 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTRMS().setText(rms);
|
638 |
} |
639 |
|
640 |
/**
|
641 |
* Asigna el valor del campo de residuo en X
|
642 |
* @param rms Cadena que representa el RMS
|
643 |
*/
|
644 |
public void setResX(String resX){ |
645 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResX().setText(resX);
|
646 |
} |
647 |
|
648 |
/**
|
649 |
* Asigna el valor del campo de residuo en Y
|
650 |
* @param rms Cadena que representa el RMS
|
651 |
*/
|
652 |
public void setResY(String resY){ |
653 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResY().setText(resY);
|
654 |
} |
655 |
|
656 |
/**
|
657 |
* Asigna el valor del campo RMS
|
658 |
* @param rms Cadena que representa el RMS
|
659 |
*/
|
660 |
public void setTotal(String total){ |
661 |
this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTTotal().setText(total);
|
662 |
} |
663 |
|
664 |
/**
|
665 |
* @return Returns the lyrGeoRaster.
|
666 |
*/
|
667 |
public FLyrGeoRaster getLyrGeoRaster() {
|
668 |
return lyrGeoRaster;
|
669 |
} |
670 |
|
671 |
/**
|
672 |
* @return Returns the lyrPoints.
|
673 |
*/
|
674 |
public FLyrPoints getLyrPoints() {
|
675 |
try{
|
676 |
return lyrGeoRaster.getFLyrPoints();
|
677 |
}catch(ClassCastException exc){ |
678 |
return null; |
679 |
} |
680 |
} |
681 |
|
682 |
/**
|
683 |
* Selecciona un tab del cuadro
|
684 |
* @param index
|
685 |
*/
|
686 |
public void setSelectedTab(int index){ |
687 |
this.getConectorPanel().getDataPointsTabPanel().getTbPoints().setSelectedIndex(index);
|
688 |
} |
689 |
|
690 |
/**
|
691 |
* @param extended The extended to set.
|
692 |
*/
|
693 |
public void setEnlarge(boolean enlarge) { |
694 |
this.enlarge = enlarge;
|
695 |
if(!enlarge){
|
696 |
frame.setSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10)); |
697 |
frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10)); |
698 |
this.setPreferredSize(new Dimension(this.normalWidth, this.normalHeight)); |
699 |
this.setSize(new Dimension(this.normalWidth, this.normalHeight)); |
700 |
this.getConectorPanel().setCanvasVisible(false); |
701 |
}else{
|
702 |
frame.setSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10)); |
703 |
frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10)); |
704 |
this.setPreferredSize(new Dimension(this.normalWidth, this.enlargeHeight)); |
705 |
this.setSize(new Dimension(this.normalWidth, this.enlargeHeight)); |
706 |
this.getConectorPanel().setCanvasVisible(true); |
707 |
} |
708 |
frame.pack(); |
709 |
} |
710 |
|
711 |
/**
|
712 |
* @return Returns the extended.
|
713 |
*/
|
714 |
public boolean isEnlarge() { |
715 |
return enlarge;
|
716 |
} |
717 |
|
718 |
/**
|
719 |
* Obtiene el panel conector
|
720 |
* @return
|
721 |
*/
|
722 |
public ConectorPanel getConectorPanel() {
|
723 |
if (conectorPanel == null) { |
724 |
conectorPanel = new ConectorPanel(this); |
725 |
} |
726 |
|
727 |
return conectorPanel;
|
728 |
} |
729 |
|
730 |
/**
|
731 |
* This method initializes jPanel
|
732 |
*
|
733 |
* @return javax.swing.JPanel
|
734 |
*/
|
735 |
private JPanel getPBotones() { |
736 |
if (pBotones == null) { |
737 |
FlowLayout flowLayout1 = new FlowLayout(); |
738 |
pBotones = new JPanel(); |
739 |
pBotones.setLayout(flowLayout1); |
740 |
flowLayout1.setHgap(10);
|
741 |
flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT); |
742 |
pBotones.add(getBProcesar(), null);
|
743 |
pBotones.add(getBAceptar(), null);
|
744 |
pBotones.add(getBCancelar(), null);
|
745 |
} |
746 |
return pBotones;
|
747 |
} |
748 |
|
749 |
public static IProjection getLastProjection() { |
750 |
return proj;
|
751 |
} |
752 |
public static void setLastProjection(IProjection proj) { |
753 |
GeoreferencingDialog.proj = proj; |
754 |
} |
755 |
|
756 |
/**
|
757 |
* @return Returns the GeoRedimBehavior.
|
758 |
*/
|
759 |
public GeoRedimBehavior getGeoRedimBehavior() {
|
760 |
return rb;
|
761 |
} |
762 |
|
763 |
/**
|
764 |
* @param rb The GeoRedimBehavior to set.
|
765 |
*/
|
766 |
public void setGeoRedimBehavior(GeoRedimBehavior rb) { |
767 |
this.rb = rb;
|
768 |
} |
769 |
|
770 |
/**
|
771 |
* @return Returns the GeoMoveBehavior
|
772 |
*/
|
773 |
public GeoMoveBehavior getGeoMoveBehavior() {
|
774 |
return mb;
|
775 |
} |
776 |
|
777 |
/**
|
778 |
* @param mb The GeoMoveBehavior to set.
|
779 |
*/
|
780 |
public void setGeoMoveBehavior(GeoMoveBehavior mb) { |
781 |
this.mb = mb;
|
782 |
} |
783 |
|
784 |
|
785 |
/**
|
786 |
* Obtiene el punto de la lista que ha sido seleccionado
|
787 |
* @return
|
788 |
*/
|
789 |
public int getSelectedPoint(){ |
790 |
return getConectorPanel().getDataPointsTabPanel().
|
791 |
getSelectPointsPanel().getTableControlerPanel().getSelectedIndex(); |
792 |
} |
793 |
|
794 |
/**
|
795 |
* Obtiene el control de la mini imagen que tiene los botones a la izquierda
|
796 |
* @return ZoomControlPanel
|
797 |
*/
|
798 |
public ZoomControlPanel getZoomControlLeft(){
|
799 |
return this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft(); |
800 |
} |
801 |
|
802 |
/**
|
803 |
* Obtiene el control de la mini imagen que tiene los botones a la derecha
|
804 |
* @return ZoomControlPanel
|
805 |
*/
|
806 |
public ZoomControlPanel getZoomControlRight(){
|
807 |
return this.getConectorPanel().getAdjustGeorefPanel().getZoomRight(); |
808 |
} |
809 |
|
810 |
/**
|
811 |
* Obtiene el panel de selecci?n de puntos
|
812 |
* @return Panel de selecci?n de puntos
|
813 |
*/
|
814 |
public SelectPointsPanel getSelectPointsPanel(){
|
815 |
return this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel(); |
816 |
} |
817 |
|
818 |
/**
|
819 |
* Obtiene el panel de opciones
|
820 |
* @return OptionPanel
|
821 |
*/
|
822 |
public OptionsPanel getOptionsPanel(){
|
823 |
return getConectorPanel().getAdjustGeorefPanel().getOptionsPanel();
|
824 |
} |
825 |
|
826 |
/**
|
827 |
* Asigna el frame
|
828 |
* @param f
|
829 |
*/
|
830 |
public void setFrame(JInternalFrame f){ |
831 |
frame = f; |
832 |
frame.addComponentListener(this);
|
833 |
} |
834 |
|
835 |
/**
|
836 |
* Obtiene el frame
|
837 |
* @return frame
|
838 |
*/
|
839 |
public JInternalFrame getFrame(){ |
840 |
return frame;
|
841 |
} |
842 |
|
843 |
/**
|
844 |
* Obtiene el gestor de puntos
|
845 |
* @return PointManager
|
846 |
*/
|
847 |
public PointManager getPointManager() {
|
848 |
return pointManager;
|
849 |
} |
850 |
|
851 |
/**
|
852 |
* Activa o desactiva este panel y todos los que lo componen
|
853 |
* @param enabled variable booleana para la activaci?n y/o desactivaci?n
|
854 |
*/
|
855 |
public void setEnabled(boolean enabled){ |
856 |
this.conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().setEnabled(enabled);
|
857 |
this.conectorPanel.getAdjustGeorefPanel().setEnabled(enabled);
|
858 |
} |
859 |
//**********************End Setters & Getters*****************
|
860 |
|
861 |
} // @jve:decl-index=0:visual-constraint="10,10"
|
862 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|
863 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|