root / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / gui / selectPoints / SelectPointsPanel.java @ 4688
History | View | Annotate | Download (25.9 KB)
1 |
package com.iver.cit.gvsig.gui.selectPoints; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
import java.awt.FlowLayout; |
5 |
import java.awt.GridBagConstraints; |
6 |
import java.awt.GridBagLayout; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
import java.awt.event.FocusEvent; |
10 |
import java.awt.event.FocusListener; |
11 |
import java.awt.event.KeyEvent; |
12 |
import java.awt.event.KeyListener; |
13 |
import java.awt.geom.Point2D; |
14 |
|
15 |
import javax.swing.ImageIcon; |
16 |
import javax.swing.JButton; |
17 |
import javax.swing.JOptionPane; |
18 |
import javax.swing.JPanel; |
19 |
import javax.swing.JTextField; |
20 |
|
21 |
import com.iver.andami.PluginServices; |
22 |
import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
23 |
import com.iver.cit.gvsig.gui.View; |
24 |
import com.iver.cit.gvsig.gui.dialogs.GeoreferencingDialog; |
25 |
import com.iver.cit.gvsig.gui.listeners.GeorefPointSelectorListener; |
26 |
import com.iver.cit.gvsig.gui.pointsTable.TableControlerPanel; |
27 |
|
28 |
public class SelectPointsPanel extends JPanel implements ActionListener, KeyListener, FocusListener{ |
29 |
|
30 |
//**********************Vars**********************************
|
31 |
private String pathToImages = "/com/iver/cit/gvsig/gui/panels/images/"; |
32 |
private JPanel pGeneral = null; |
33 |
private JPanel pPointSelection = null; |
34 |
private JPanel pControlPoint = null; |
35 |
private JButton bSelectFromView = null; |
36 |
private FLyrPoints lyrPoints = null; |
37 |
private boolean disableEvent = false; |
38 |
private int lastIndexSelection = -1; |
39 |
private JButton bExtended = null; |
40 |
private JPanel pExtend = null; |
41 |
private TableControlerPanel tableControlerPanel = null; |
42 |
private DataPointPanel dataPointPanel = null; |
43 |
private ErrorPointPanel errorPointPanel = null; |
44 |
private GeoreferencingDialog grd = null; |
45 |
private boolean update = false; |
46 |
/**
|
47 |
* Valores ?ltimos que se han introducido en los JTextField para poder reponerlos.
|
48 |
*/
|
49 |
public String lastTx = "", lastTy = "", lastLong = "", lastLat = ""; |
50 |
//**********************End Vars********************************
|
51 |
|
52 |
//**********************Methods*********************************
|
53 |
/**
|
54 |
* Contructor. Inicializa el panel.
|
55 |
*/
|
56 |
public SelectPointsPanel() {
|
57 |
super();
|
58 |
initialize(); |
59 |
} |
60 |
|
61 |
/**
|
62 |
* This is the default constructor
|
63 |
*/
|
64 |
public SelectPointsPanel(GeoreferencingDialog grd) {
|
65 |
super();
|
66 |
initialize(); |
67 |
this.grd = grd;
|
68 |
} |
69 |
|
70 |
/**
|
71 |
* This method initializes this
|
72 |
*
|
73 |
* @return void
|
74 |
*/
|
75 |
private void initialize() { |
76 |
this.setPreferredSize(new java.awt.Dimension(390,165)); |
77 |
this.setSize(new java.awt.Dimension(390,165)); |
78 |
this.setLocation(new java.awt.Point(0,0)); |
79 |
this.add(getPGeneral(), null); |
80 |
} |
81 |
|
82 |
/**
|
83 |
* Actualiza el n?mero de puntos del combo a partir de los contenidos en
|
84 |
* la capa de puntos. Esta funci?n es usada desde otros paneles que cambien
|
85 |
* el punto seleccionado para comunicar al control la nueva selecci?n.
|
86 |
*/
|
87 |
public void updateComboPoint(int pointSelected){ |
88 |
disableEvent = true;
|
89 |
try{
|
90 |
loadLyrPoint(); |
91 |
}catch(InstantiationException exc){ |
92 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
93 |
PluginServices.getText(this, "error_capa_puntos")); |
94 |
return;
|
95 |
} |
96 |
|
97 |
tableControlerPanel.setNItems(lyrPoints.getCountPoints()); |
98 |
tableControlerPanel.getCPoint().setSelectedIndex(pointSelected); |
99 |
tableControlerPanel.checkArrows(); |
100 |
lyrPoints.loadVisualPoint(pointSelected, this.grd);
|
101 |
disableEvent = false;
|
102 |
} |
103 |
|
104 |
/**
|
105 |
* Comprueba si los valores de un punto en los campos de texto est?n
|
106 |
* vacios y lanza una excepci?n si hay alguno sin informaci?n.
|
107 |
* @throws NoSuchFieldException
|
108 |
*/
|
109 |
public void checkInfoPointText()throws NoSuchFieldException{ |
110 |
if( dataPointPanel.getTX().getText().equals("") || |
111 |
dataPointPanel.getTY().getText().equals("") ||
|
112 |
dataPointPanel.getLatitud().getText().equals("") ||
|
113 |
dataPointPanel.getLongitud().getText().equals("")){
|
114 |
disableEvent = true;
|
115 |
try{
|
116 |
tableControlerPanel.getCPoint().setSelectedIndex(lastIndexSelection); |
117 |
disableEvent = false;
|
118 |
}catch(IllegalArgumentException ex){ |
119 |
//Si el lastIndex tiene un valor erroneo no hacemos ninguna selecci?n
|
120 |
} |
121 |
throw new NoSuchFieldException(); |
122 |
} |
123 |
} |
124 |
|
125 |
/**
|
126 |
* Esta funci?n resetea los controles del panel de info de un punto.
|
127 |
*/
|
128 |
public void resetControls(boolean active){ |
129 |
dataPointPanel.resetControls(null);
|
130 |
getBSelectFromView().setEnabled(active); |
131 |
getTableControlerPanel().getBClear().setEnabled(active); |
132 |
getTableControlerPanel().getBDelPoint().setEnabled(active); |
133 |
if(!active)
|
134 |
getTableControlerPanel().resetControls(); |
135 |
} |
136 |
|
137 |
/**
|
138 |
* Cuando pasamos de un punto a otro o se va a crear uno nuevo
|
139 |
* <UL>
|
140 |
* <LI>Cargamos la capa FLyrPoint si no est? ya cargada.</LI>
|
141 |
* <LI>Comprobamos que los campos no esten vacios y lanzamos una excepci?n si hay alg?n campo vacio si lo est?n.</LI>
|
142 |
* <LI>Insertamos el nuevo punto seleccionado en los campos de informaci?n.</LI>
|
143 |
* <LI>Checkeamos las flechas para ver si tenemos que activarlas o desactivarlas.</LI>
|
144 |
* </UL>
|
145 |
* @param changeSelection Cambia la posici?n seleccionada del combo si es true
|
146 |
* @param pos Posici?n a la que cambia el combo si el parametro chageSelection es true
|
147 |
*/
|
148 |
public void changePoint(boolean changeSelection, int pos){ |
149 |
disableEvent = true;
|
150 |
try{
|
151 |
loadLyrPoint(); |
152 |
checkInfoPointText(); |
153 |
if(changeSelection){
|
154 |
lastIndexSelection = pos; |
155 |
tableControlerPanel.setSelectedIndex(pos); |
156 |
} |
157 |
lyrPoints.loadVisualPoint(tableControlerPanel.getSelectedIndex(), this.grd);
|
158 |
tableControlerPanel.checkArrows(); |
159 |
}catch(NoSuchFieldException exc){ |
160 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
161 |
PluginServices.getText(this, "coordenadas_vacias")); |
162 |
}catch(InstantiationException e){ |
163 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
164 |
PluginServices.getText(this, "error_capa_puntos")); |
165 |
} |
166 |
disableEvent = false;
|
167 |
} |
168 |
|
169 |
/**
|
170 |
* Limpia la lista de puntos y borra el dialogo.
|
171 |
*/
|
172 |
public void clearList(){ |
173 |
try{
|
174 |
loadLyrPoint(); |
175 |
if(lyrPoints != null) |
176 |
lyrPoints.clearVisualList(this,
|
177 |
grd.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel(), |
178 |
grd.getConectorPanel().getAdjustGeorefPanel()); |
179 |
}catch(InstantiationException e){ |
180 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
181 |
PluginServices.getText(this, "error_capa_puntos")); |
182 |
} |
183 |
} |
184 |
|
185 |
/**
|
186 |
* Obtiene una capa de puntos. Si no existe crea una.
|
187 |
* @return
|
188 |
*/
|
189 |
private void loadLyrPoint() throws InstantiationException{ |
190 |
if(lyrPoints == null){ |
191 |
lyrPoints = this.grd.getLyrPoints();
|
192 |
if(lyrPoints == null) |
193 |
throw new InstantiationException(); |
194 |
} |
195 |
} |
196 |
|
197 |
|
198 |
|
199 |
/**
|
200 |
* Este m?todo inicializa el bot?n seleccionar desde la vista. Cuando lo
|
201 |
* activamos se carga la herramienta de selecci?n de puntos desde la vista.
|
202 |
*
|
203 |
* @return javax.swing.JButton
|
204 |
*/
|
205 |
public JButton getBSelectFromView() { |
206 |
if (bSelectFromView == null) { |
207 |
bSelectFromView = new JButton(); |
208 |
bSelectFromView.setText("");
|
209 |
bSelectFromView.setPreferredSize(new java.awt.Dimension(22,22)); |
210 |
bSelectFromView.setIcon(new ImageIcon(getClass().getResource(pathToImages + "selectfromview.png"))); |
211 |
bSelectFromView.setEnabled(false);
|
212 |
bSelectFromView.setToolTipText(PluginServices.getText(this, "selectfromview")); |
213 |
bSelectFromView.addActionListener(new java.awt.event.ActionListener() {
|
214 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
215 |
View theView = (View) PluginServices.getMDIManager().getActiveView(); |
216 |
try{
|
217 |
loadLyrPoint(); |
218 |
lyrPoints.setLastTool(theView.getMapControl().getTool()); |
219 |
GeorefPointSelectorListener.posPoint = tableControlerPanel.getSelectedIndex(); |
220 |
GeorefPointSelectorListener.firstPoint = true;
|
221 |
theView.getMapControl().setTool("pointLyrSelection");
|
222 |
}catch(InstantiationException exc){ |
223 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
224 |
PluginServices.getText(this, "error_capa_puntos")); |
225 |
} |
226 |
} |
227 |
}); |
228 |
} |
229 |
return bSelectFromView;
|
230 |
} |
231 |
|
232 |
/**
|
233 |
* Checkea un textField para que contenga caracteres validos. Consideramos validos
|
234 |
* los caracteres del 0 al 9, el punto, DEL, Supr, flechas y Enter teniendo en cuenta que el
|
235 |
* c?digo ascii del teclado numerico es distinto.
|
236 |
*/
|
237 |
public boolean checkTextField(JTextField tf, int code, String lastText){ |
238 |
|
239 |
//Si el caracter es erroneo pasamos de el y reponemos el texto que habia
|
240 |
if( (code >= 0 && code <= 7) || |
241 |
code == 9 ||
|
242 |
(code >= 11 && code <= 36) || |
243 |
(code >= 41 && code <= 45) || |
244 |
code == 47 ||
|
245 |
(code >= 58 && code <= 95) || |
246 |
(code >= 106 && code <= 109) || |
247 |
(code >= 111 && code <= 126) || |
248 |
code >= 128){
|
249 |
tf.setText(lastText); |
250 |
return false; |
251 |
} |
252 |
|
253 |
return true; |
254 |
} |
255 |
|
256 |
/**
|
257 |
* Control de eventos de TableControlerPanel
|
258 |
*/
|
259 |
public void actionPerformed(ActionEvent e) { |
260 |
|
261 |
//Bot?n de ir al punto inicial
|
262 |
if(e.getSource() == tableControlerPanel.getBFirst()){
|
263 |
if(tableControlerPanel.getItemCount() >= 1) |
264 |
changePoint(true, 0); |
265 |
} |
266 |
|
267 |
//Bot?n de ir al punto anterior
|
268 |
if(e.getSource() == tableControlerPanel.getBPrev()){
|
269 |
if(tableControlerPanel.getSelectedIndex() != 0) |
270 |
changePoint(true, tableControlerPanel.getSelectedIndex() - 1); |
271 |
} |
272 |
|
273 |
//Bot?n de ir al punto siguiente
|
274 |
if(e.getSource() == tableControlerPanel.getBNext()){
|
275 |
if(tableControlerPanel.getSelectedIndex() != (tableControlerPanel.getItemCount() - 1)) |
276 |
changePoint(true, tableControlerPanel.getSelectedIndex() + 1); |
277 |
|
278 |
} |
279 |
|
280 |
//Bot?n de ir al punto final
|
281 |
if(e.getSource() == tableControlerPanel.getBLast()){
|
282 |
if(tableControlerPanel.getItemCount() >= 1) |
283 |
changePoint(true, tableControlerPanel.getItemCount() - 1); |
284 |
} |
285 |
|
286 |
//Combo de selecci?n de punto
|
287 |
if(e.getSource() == tableControlerPanel.getCPoint()){
|
288 |
if(tableControlerPanel.getSelectedIndex() != -1){ |
289 |
if(!disableEvent){
|
290 |
try{
|
291 |
loadLyrPoint(); |
292 |
}catch(InstantiationException exc){ |
293 |
return;
|
294 |
} |
295 |
lyrPoints.loadVisualPoint(tableControlerPanel.getSelectedIndex(), grd); |
296 |
tableControlerPanel.checkArrows(); |
297 |
} |
298 |
} |
299 |
} |
300 |
|
301 |
//Bot?n de nuevo punto
|
302 |
if(e.getSource() == tableControlerPanel.getBNew()){
|
303 |
try{
|
304 |
disableEvent = true;
|
305 |
loadLyrPoint(); |
306 |
if(this.getTableControlerPanel().getItemCount() > 0) |
307 |
checkInfoPointText(); |
308 |
lyrPoints.addPoint(null, null); |
309 |
tableControlerPanel.getCPoint().addItem("" + lyrPoints.getCountPoints());
|
310 |
tableControlerPanel.getLNumberOfPoints().setText(PluginServices.getText(this, "de ") + " " + lyrPoints.getCountPoints()); |
311 |
lastIndexSelection = lyrPoints.getCountPoints() - 1;
|
312 |
tableControlerPanel.setSelectedIndex(tableControlerPanel.getItemCount() - 1);
|
313 |
grd.resetControls(true);
|
314 |
tableControlerPanel.checkArrows(); |
315 |
}catch(NoSuchFieldException exc){ |
316 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
317 |
PluginServices.getText(this, "coordenadas_vacias")); |
318 |
}catch(InstantiationException exc){ |
319 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
320 |
PluginServices.getText(this, "error_capa_puntos")); |
321 |
} |
322 |
disableEvent = false;
|
323 |
} |
324 |
|
325 |
//Bot?n de eliminado de todos los puntos
|
326 |
if(e.getSource() == getTableControlerPanel().getBClear()){
|
327 |
int op = JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(), |
328 |
PluginServices.getText(this, "eliminar_todos_puntos")); |
329 |
if(op == JOptionPane.OK_OPTION) |
330 |
clearList(); |
331 |
} |
332 |
|
333 |
//Bot?n de eliminado de un punto
|
334 |
if(e.getSource() == getTableControlerPanel().getBDelPoint()){
|
335 |
int op = JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(), |
336 |
PluginServices.getText(this, "eliminar_punto")); |
337 |
if(op == JOptionPane.OK_OPTION){ |
338 |
if(lyrPoints.length() == 1) //Si solo hay un punto reseteamos |
339 |
clearList(); |
340 |
else{
|
341 |
disableEvent = true;
|
342 |
int posSelect = tableControlerPanel.getSelectedIndex();
|
343 |
if(posSelect == -1) |
344 |
return;
|
345 |
lyrPoints.deleteVisualPoint(posSelect, grd); |
346 |
|
347 |
if(posSelect == 0){ |
348 |
lastIndexSelection = posSelect; |
349 |
}else{
|
350 |
lastIndexSelection = posSelect -1 ;
|
351 |
} |
352 |
disableEvent = false;
|
353 |
} |
354 |
} |
355 |
} |
356 |
|
357 |
//Bot?n de extensi?n del cuadro de dialogo
|
358 |
if(e.getSource() == this.getBExtended()) |
359 |
this.setEnlarge(grd.isEnlarge());
|
360 |
|
361 |
} |
362 |
|
363 |
/* (non-Javadoc)
|
364 |
* @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
|
365 |
*/
|
366 |
public void keyPressed(KeyEvent e) { |
367 |
// TODO Auto-generated method stu
|
368 |
} |
369 |
|
370 |
/**
|
371 |
* Actualiza los valores del punto nuevo introducido desde el teclado llamando a la funci?n
|
372 |
* de la capa updataData que actualizar? los controles necesarios para que se refresquen la vista
|
373 |
* mini imagenes, textfields, tabla y capa de puntos.
|
374 |
* @param pixel Pixel de la imagen
|
375 |
* @param map Coordenadas de la vista.
|
376 |
*/
|
377 |
private void updatePointsValue(Point2D pixel, Point2D map){ |
378 |
|
379 |
//Si se modifica el pixel tenemos que controlar que no se salga de la imagen.
|
380 |
//Si se sale avisamos y reponemos su valor.
|
381 |
if( pixel != null && |
382 |
(pixel.getX() < 0 ||
|
383 |
pixel.getX() > grd.getLyrGeoRaster().getImageWidth() || |
384 |
pixel.getY() < 0 ||
|
385 |
pixel.getY() > grd.getLyrGeoRaster().getImageHeight())){ |
386 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
387 |
PluginServices.getText(this, "fuera_de_extent")); |
388 |
dataPointPanel.getTX().setText(lastTx); |
389 |
dataPointPanel.getTY().setText(lastTy); |
390 |
dataPointPanel.getLatitud().setText(lastLat); |
391 |
dataPointPanel.getLongitud().setText(lastLong); |
392 |
update = false;
|
393 |
return;
|
394 |
} |
395 |
|
396 |
//Capturamos los ?ltimos valores de los JtextField por si hay que reponerlos
|
397 |
if(pixel != null){ |
398 |
if( !lastTx.equals(dataPointPanel.getTX().getText()) )
|
399 |
lastTx = dataPointPanel.getTX().getText(); |
400 |
if( !lastTy.equals(dataPointPanel.getTY().getText()) )
|
401 |
lastTy = dataPointPanel.getTY().getText(); |
402 |
} |
403 |
|
404 |
if(map != null){ |
405 |
if( !lastLat.equals(dataPointPanel.getLatitud().getText()) )
|
406 |
lastLat = dataPointPanel.getLatitud().getText(); |
407 |
if( !lastLong.equals(dataPointPanel.getLongitud().getText()) )
|
408 |
lastLong = dataPointPanel.getLongitud().getText(); |
409 |
} |
410 |
|
411 |
View theView = null; |
412 |
try{
|
413 |
theView = (View)PluginServices.getMDIManager().getActiveView();
|
414 |
}catch(ClassCastException exc){ |
415 |
return;
|
416 |
} |
417 |
|
418 |
//Actualizamos los puntos
|
419 |
grd.getLyrGeoRaster().updateData(Integer.valueOf(this.grd.getSelectPointsPanel().getTableControlerPanel().getSelectedItem()).intValue(), |
420 |
pixel, |
421 |
map, |
422 |
this.grd,
|
423 |
theView); |
424 |
update = false;
|
425 |
|
426 |
} |
427 |
|
428 |
/**
|
429 |
* Control de eventos de las entradas de texto de los puntos
|
430 |
*/
|
431 |
public void keyReleased(KeyEvent e) { |
432 |
//Campo de texto de la coordenada X en pixeles
|
433 |
Point2D pixel = null; |
434 |
Point2D map = null; |
435 |
|
436 |
try{
|
437 |
if(e.getSource() == dataPointPanel.getTX()){
|
438 |
if(checkTextField(dataPointPanel.getTX(), e.getKeyCode(), lastTx)){
|
439 |
pixel = new Point2D.Double(); |
440 |
pixel.setLocation( Double.valueOf(dataPointPanel.getTX().getText()).doubleValue(),
|
441 |
Double.valueOf(dataPointPanel.getTY().getText()).doubleValue());
|
442 |
|
443 |
if(e.getKeyCode() == 10) |
444 |
update = true;
|
445 |
} |
446 |
} |
447 |
|
448 |
//Campo de texto de la coordenada Y en pixeles
|
449 |
if(e.getSource() == dataPointPanel.getTY()){
|
450 |
if(checkTextField(dataPointPanel.getTY(), e.getKeyCode(), lastTy)){
|
451 |
pixel = new Point2D.Double(); |
452 |
pixel.setLocation( Double.valueOf(dataPointPanel.getTX().getText()).doubleValue(),
|
453 |
Double.valueOf(dataPointPanel.getTY().getText()).doubleValue());
|
454 |
|
455 |
if(e.getKeyCode() == 10) |
456 |
update = true;
|
457 |
} |
458 |
} |
459 |
|
460 |
//Campo de texto de la coordenada X en coordenadas del mundo
|
461 |
if(e.getSource() == dataPointPanel.getLatitud()){
|
462 |
if(checkTextField(dataPointPanel.getLatitud(), e.getKeyCode(), lastLat)){
|
463 |
map = new Point2D.Double(); |
464 |
map.setLocation( Double.valueOf(dataPointPanel.getLongitud().getText()).doubleValue(),
|
465 |
Double.valueOf(dataPointPanel.getLatitud().getText()).doubleValue());
|
466 |
if(e.getKeyCode() == 10) |
467 |
update = true;
|
468 |
} |
469 |
} |
470 |
|
471 |
//Campo de texto de la coordenada Y en coordenadas del mundo
|
472 |
if(e.getSource() == dataPointPanel.getLongitud()){
|
473 |
if(checkTextField(dataPointPanel.getLongitud(), e.getKeyCode(), lastLong)){
|
474 |
map = new Point2D.Double(); |
475 |
map.setLocation( Double.valueOf(dataPointPanel.getLongitud().getText()).doubleValue(),
|
476 |
Double.valueOf(dataPointPanel.getLatitud().getText()).doubleValue());
|
477 |
if(e.getKeyCode() == 10) |
478 |
update = true;
|
479 |
} |
480 |
} |
481 |
|
482 |
if(update)
|
483 |
this.updatePointsValue(pixel, map);
|
484 |
|
485 |
this.abortSelectPoints();
|
486 |
|
487 |
}catch(NumberFormatException exc){ |
488 |
System.out.println("Formato numerico erroneo"); |
489 |
} |
490 |
|
491 |
} |
492 |
|
493 |
/* (non-Javadoc)
|
494 |
* @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
|
495 |
*/
|
496 |
public void keyTyped(KeyEvent e) { |
497 |
// TODO Auto-generated method stub
|
498 |
|
499 |
} |
500 |
|
501 |
/* (non-Javadoc)
|
502 |
* @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
|
503 |
*/
|
504 |
public void focusGained(FocusEvent arg0) { |
505 |
// TODO Auto-generated method stub
|
506 |
|
507 |
} |
508 |
|
509 |
/**
|
510 |
* Cancela la selecci?n de puntos sobre la vista de forma gr?fica. Esta acci?n
|
511 |
* conllevar? seleccionar la ?ltima herramienta del mapCtrl
|
512 |
*/
|
513 |
private void abortSelectPoints(){ |
514 |
String tx = dataPointPanel.getTX().getText();
|
515 |
String ty = dataPointPanel.getTY().getText();
|
516 |
String lon = dataPointPanel.getLongitud().getText();
|
517 |
String lat = dataPointPanel.getLatitud().getText();
|
518 |
|
519 |
if(!tx.equals("") && !ty.equals("") && !lon.equals("") && !lat.equals("")){ |
520 |
//Si todos los puntos est?n rellenos deseleccionamos la herramienta de selecci?n de puntos
|
521 |
GeorefPointSelectorListener.firstPoint = true;
|
522 |
com.iver.cit.gvsig.gui.View theView = null;
|
523 |
try{
|
524 |
theView = (com.iver.cit.gvsig.gui.View)PluginServices.getMDIManager().getActiveView(); |
525 |
theView.getMapControl().setTool(grd.getLyrPoints().getLastTool()); |
526 |
}catch(ClassCastException exc){ |
527 |
//No se selecciona la herramienta
|
528 |
} |
529 |
} |
530 |
} |
531 |
|
532 |
/**
|
533 |
* Los campos de texto de las coordenadas cuando pierden el foco actualizan el valor del pixel
|
534 |
* en la cap, vista, mini imagen y tabla
|
535 |
*/
|
536 |
public void focusLost(FocusEvent arg0) { |
537 |
String tx = dataPointPanel.getTX().getText();
|
538 |
String ty = dataPointPanel.getTY().getText();
|
539 |
String lon = dataPointPanel.getLongitud().getText();
|
540 |
String lat = dataPointPanel.getLatitud().getText();
|
541 |
|
542 |
if(!tx.equals("") && !ty.equals("") && !lon.equals("") && !lat.equals("")){ |
543 |
Point2D pixel = new Point2D.Double(); |
544 |
Point2D map = new Point2D.Double(); |
545 |
pixel.setLocation(Double.valueOf(tx).doubleValue(),
|
546 |
Double.valueOf(ty).doubleValue());
|
547 |
map.setLocation(Double.valueOf(lon).doubleValue(),
|
548 |
Double.valueOf(lat).doubleValue());
|
549 |
//Si update es true significa q se ha pulsado Enter por lo q ya se est? actualizando
|
550 |
//y no hace falta que se haga de nuevo pq podr?a salir un mensaje de error dos veces
|
551 |
if(!update)
|
552 |
this.updatePointsValue(pixel, map);
|
553 |
this.abortSelectPoints();
|
554 |
} |
555 |
} |
556 |
|
557 |
//**********************End Methods*******************************
|
558 |
|
559 |
//**********************Setters & Getters*************************
|
560 |
/**
|
561 |
* Extiende o pliega el panel inferior controlando el icono del bot?n. Si se
|
562 |
* asigna true quiere decir que el panel est? desplegado, en este caso lo plegar?.
|
563 |
* Si se asigna false quiere decir que el panel est? plegado, en este caso lo
|
564 |
* desplegar?.
|
565 |
* @param enlarge True para recogerlo y false para desplegarlo
|
566 |
*/
|
567 |
public void setEnlarge(boolean enlarge){ |
568 |
if(enlarge){
|
569 |
grd.setEnlarge(!enlarge); |
570 |
bExtended.setIcon(new ImageIcon(getClass().getResource(pathToImages + "down.png"))); |
571 |
}else{
|
572 |
grd.setEnlarge(!enlarge); |
573 |
bExtended.setIcon(new ImageIcon(getClass().getResource(pathToImages + "up.png"))); |
574 |
if(lyrPoints != null) |
575 |
lyrPoints.loadVisualPoint(tableControlerPanel.getSelectedIndex(), this.grd);
|
576 |
} |
577 |
} |
578 |
|
579 |
/**
|
580 |
* @return Returns the errorPointPanel.
|
581 |
*/
|
582 |
public ErrorPointPanel getErrorPointPanel() {
|
583 |
if(this.errorPointPanel == null) |
584 |
errorPointPanel = new ErrorPointPanel();
|
585 |
return errorPointPanel;
|
586 |
} |
587 |
/**
|
588 |
* @return Returns the lyrPoints.
|
589 |
*/
|
590 |
public FLyrPoints getLyrPoints() {
|
591 |
if(lyrPoints == null){ |
592 |
try{
|
593 |
loadLyrPoint(); |
594 |
}catch(InstantiationException exc){ |
595 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
596 |
PluginServices.getText(this, "error_capa_puntos")); |
597 |
} |
598 |
} |
599 |
return lyrPoints;
|
600 |
} |
601 |
|
602 |
/**
|
603 |
* This method initializes jButton
|
604 |
*
|
605 |
* @return javax.swing.JButton
|
606 |
*/
|
607 |
private JButton getBExtended() { |
608 |
if (bExtended == null) { |
609 |
bExtended = new JButton(); |
610 |
bExtended.setPreferredSize(new java.awt.Dimension(42,22)); |
611 |
bExtended.setIcon(new ImageIcon(getClass().getResource(pathToImages + "down.png"))); |
612 |
bExtended.addActionListener(this);
|
613 |
} |
614 |
return bExtended;
|
615 |
} |
616 |
|
617 |
/**
|
618 |
* This method initializes jPanel
|
619 |
*
|
620 |
* @return javax.swing.JPanel
|
621 |
*/
|
622 |
private JPanel getPExtend() { |
623 |
if (pExtend == null) { |
624 |
FlowLayout flowLayout21 = new FlowLayout(); |
625 |
pExtend = new JPanel(); |
626 |
pExtend.setLayout(flowLayout21); |
627 |
flowLayout21.setHgap(0);
|
628 |
flowLayout21.setVgap(1);
|
629 |
flowLayout21.setAlignment(java.awt.FlowLayout.LEFT); |
630 |
pExtend.setPreferredSize(new java.awt.Dimension(70,22)); |
631 |
pExtend.add(getBSelectFromView(), null);
|
632 |
pExtend.add(getBExtended(), null);
|
633 |
} |
634 |
return pExtend;
|
635 |
} |
636 |
|
637 |
/**
|
638 |
* @return Returns the dataPointPanel.
|
639 |
*/
|
640 |
public DataPointPanel getDataPointPanel() {
|
641 |
return dataPointPanel;
|
642 |
} |
643 |
|
644 |
/**
|
645 |
* @param dataPointPanel The dataPointPanel to set.
|
646 |
*/
|
647 |
public void setDataPointPanel(DataPointPanel dataPointPanel) { |
648 |
this.dataPointPanel = dataPointPanel;
|
649 |
} |
650 |
|
651 |
/**
|
652 |
* @return Returns the tableControlerPanel.
|
653 |
*/
|
654 |
public TableControlerPanel getTableControlerPanel() {
|
655 |
return tableControlerPanel;
|
656 |
} |
657 |
|
658 |
/**
|
659 |
* @param tableControlerPanel The tableControlerPanel to set.
|
660 |
*/
|
661 |
public void setTableControlerPanel(TableControlerPanel tableControlerPanel) { |
662 |
this.tableControlerPanel = tableControlerPanel;
|
663 |
} |
664 |
|
665 |
/**
|
666 |
* This method initializes pGeneral
|
667 |
*
|
668 |
* @return javax.swing.JPanel
|
669 |
*/
|
670 |
private JPanel getPGeneral() { |
671 |
if (pGeneral == null) { |
672 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
673 |
gridBagConstraints1.insets = new java.awt.Insets(0,0,0,0); |
674 |
gridBagConstraints1.gridy = 0;
|
675 |
gridBagConstraints1.gridx = 0;
|
676 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
677 |
gridBagConstraints.insets = new java.awt.Insets(5,0,5,0); |
678 |
gridBagConstraints.gridy = 1;
|
679 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; |
680 |
gridBagConstraints.gridheight = 1;
|
681 |
gridBagConstraints.gridx = 0;
|
682 |
pGeneral = new JPanel(); |
683 |
pGeneral.setLayout(new GridBagLayout()); |
684 |
pGeneral.setPreferredSize(new java.awt.Dimension(390,163)); |
685 |
gridBagConstraints.gridwidth = 1;
|
686 |
pGeneral.add(getPPointSelection(), gridBagConstraints); |
687 |
pGeneral.add(getPControlPoint(), gridBagConstraints1); |
688 |
} |
689 |
return pGeneral;
|
690 |
} |
691 |
|
692 |
/**
|
693 |
* This method initializes pFileSelection
|
694 |
*
|
695 |
* @return javax.swing.JPanel
|
696 |
*/
|
697 |
private JPanel getPPointSelection() { |
698 |
if (pPointSelection == null) { |
699 |
//jLabel = new JLabel();
|
700 |
FlowLayout flowLayout1 = new FlowLayout(); |
701 |
FlowLayout flowLayout = new FlowLayout(); |
702 |
flowLayout.setVgap(-3);
|
703 |
flowLayout.setAlignment(java.awt.FlowLayout.LEFT); |
704 |
pPointSelection = new JPanel(); |
705 |
pPointSelection.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.black)); |
706 |
pPointSelection.setName("");
|
707 |
pPointSelection.setLayout(flowLayout); |
708 |
pPointSelection.setPreferredSize(new java.awt.Dimension(375,27)); |
709 |
flowLayout.setHgap(0);
|
710 |
if(this.tableControlerPanel == null){ |
711 |
tableControlerPanel = new TableControlerPanel();
|
712 |
tableControlerPanel.setLayout(flowLayout1); |
713 |
flowLayout1.setVgap(1);
|
714 |
flowLayout1.setHgap(0);
|
715 |
//jLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER);
|
716 |
//tableControlerPanel.setLNumberOfPoints(jLabel);
|
717 |
tableControlerPanel.getBFirst().addActionListener(this);
|
718 |
tableControlerPanel.getBLast().addActionListener(this);
|
719 |
tableControlerPanel.getBNext().addActionListener(this);
|
720 |
tableControlerPanel.getBPrev().addActionListener(this);
|
721 |
tableControlerPanel.getBNew().addActionListener(this);
|
722 |
tableControlerPanel.getCPoint().addActionListener(this);
|
723 |
tableControlerPanel.getBClear().addActionListener(this);
|
724 |
tableControlerPanel.getBDelPoint().addActionListener(this);
|
725 |
} |
726 |
//pPointSelection.add(getPTableControl(), null);
|
727 |
pPointSelection.add(tableControlerPanel, null);
|
728 |
pPointSelection.add(getPExtend(), null);
|
729 |
} |
730 |
return pPointSelection;
|
731 |
} |
732 |
|
733 |
/**
|
734 |
* This method initializes pControls
|
735 |
*
|
736 |
*/
|
737 |
private JPanel getPControlPoint() { |
738 |
if (pControlPoint == null) { |
739 |
GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
740 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
741 |
gridBagConstraints2.gridx = 0;
|
742 |
gridBagConstraints2.insets = new java.awt.Insets(0,0,0,0); |
743 |
gridBagConstraints2.gridy = 0;
|
744 |
pControlPoint = new JPanel(); |
745 |
pControlPoint.setLayout(new GridBagLayout()); |
746 |
pControlPoint.setPreferredSize(new java.awt.Dimension(380,125)); |
747 |
pControlPoint.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0)); |
748 |
gridBagConstraints11.gridy = 0;
|
749 |
gridBagConstraints11.gridx = 1;
|
750 |
if(this.dataPointPanel == null){ |
751 |
dataPointPanel = new DataPointPanel();
|
752 |
dataPointPanel.getTX().addKeyListener(this);
|
753 |
dataPointPanel.getTY().addKeyListener(this);
|
754 |
dataPointPanel.getLatitud().addKeyListener(this);
|
755 |
dataPointPanel.getLongitud().addKeyListener(this);
|
756 |
dataPointPanel.getTX().addFocusListener(this);
|
757 |
dataPointPanel.getTY().addFocusListener(this);
|
758 |
dataPointPanel.getLatitud().addFocusListener(this);
|
759 |
dataPointPanel.getLongitud().addFocusListener(this);
|
760 |
} |
761 |
pControlPoint.add(dataPointPanel, gridBagConstraints2); |
762 |
|
763 |
getErrorPointPanel(); |
764 |
pControlPoint.add(errorPointPanel, gridBagConstraints11); |
765 |
} |
766 |
return pControlPoint;
|
767 |
} |
768 |
|
769 |
/**
|
770 |
* Asigna la ruta donde est?n las imagenes
|
771 |
* @param pathToImages
|
772 |
*/
|
773 |
public void setPathToImages(String pathToImages) { |
774 |
this.pathToImages = pathToImages;
|
775 |
} |
776 |
//**********************End Setters & Getters*********************
|
777 |
} |