Statistics
| Revision:

root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSAreaPanel.java @ 10071

History | View | Annotate | Download (44.1 KB)

1
package com.iver.cit.gvsig.gui.panels;
2

    
3
import java.awt.Color;
4
import java.awt.Dimension;
5
import java.awt.GridBagLayout;
6
import java.awt.Rectangle;
7
import java.awt.event.ActionEvent;
8
import java.awt.event.ActionListener;
9
import java.awt.event.FocusAdapter;
10
import java.awt.event.FocusEvent;
11
import java.awt.event.FocusListener;
12
import java.awt.geom.Rectangle2D;
13
import java.io.Serializable;
14

    
15
import javax.swing.ImageIcon;
16
import javax.swing.JComboBox;
17
import javax.swing.JLabel;
18
import javax.swing.JOptionPane;
19
import javax.swing.JPanel;
20
import javax.swing.JRadioButton;
21
import javax.swing.JTextField;
22
import javax.swing.SwingConstants;
23

    
24
import com.iver.andami.PluginServices;
25
import com.iver.cit.gvsig.fmap.MapControl;
26
import com.iver.cit.gvsig.gui.wizards.WFSWizardData;
27
import com.iver.cit.gvsig.project.documents.view.gui.View;
28
import com.iver.utiles.stringNumberUtilities.StringNumberUtilities;
29

    
30
import javax.swing.JButton;
31

    
32
import org.gvsig.gui.beans.comboBoxItemsSeeker.JComboBoxItemsSeekerConfigurable;
33
import org.gvsig.gui.beans.swing.jTextFieldWithSpecificCaretPosition.JTextFieldWithSpecificCaretPosition;
34

    
35

    
36

    
37
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
38
 *
39
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
40
 *
41
 * This program is free software; you can redistribute it and/or
42
 * modify it under the terms of the GNU General Public License
43
 * as published by the Free Software Foundation; either version 2
44
 * of the License, or (at your option) any later version.
45
 *
46
 * This program is distributed in the hope that it will be useful,
47
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
48
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
49
 * GNU General Public License for more details.
50
 *
51
 * You should have received a copy of the GNU General Public License
52
 * along with this program; if not, write to the Free Software
53
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
54
 *
55
 * For more information, contact:
56
 *
57
 *  Generalitat Valenciana
58
 *   Conselleria d'Infraestructures i Transport
59
 *   Av. Blasco Ib??ez, 50
60
 *   46010 VALENCIA
61
 *   SPAIN
62
 *
63
 *      +34 963862235
64
 *   gvsig@gva.es
65
 *      www.gvsig.gva.es
66
 *
67
 *    or
68
 *
69
 *   IVER T.I. S.A
70
 *   Salamanca 50
71
 *   46005 Valencia
72
 *   Spain
73
 *
74
 *   +34 963163400
75
 *   dac@iver.es
76
 */
77
/* CVS MESSAGES:
78
 *
79
 * $Id: WFSAreaPanel.java 10071 2007-02-02 12:22:03Z ppiqueras $
80
 * $Log$
81
 * Revision 1.9  2007-02-02 12:22:03  ppiqueras
82
 * Mejorada la interfaz.
83
 *
84
 * Revision 1.8  2007/01/26 14:23:56  ppiqueras
85
 * Mejorada la interfaz
86
 *
87
 * Revision 1.7  2007/01/25 14:37:16  ppiqueras
88
 * Utiliza JTextFieldWithSpecificCaretPosition
89
 *
90
 * Revision 1.6  2007/01/25 09:31:09  ppiqueras
91
 * Mejorada la interfaz.
92
 *
93
 * Revision 1.5  2007/01/19 14:24:30  ppiqueras
94
 * + Avanzada.
95
 *
96
 * Revision 1.4  2007/01/12 13:09:41  jorpiell
97
 * added searches by area
98
 *
99
 * Revision 1.3  2007/01/10 09:01:25  jorpiell
100
 * The coordinates panel is opened with the view coordinates
101
 *
102
 * Revision 1.2  2006/12/22 11:45:53  jorpiell
103
 * Actualizado el driver del WFS
104
 *
105
 * Revision 1.1  2006/10/10 12:55:06  jorpiell
106
 * Se ha a?adido el soporte de features complejas
107
 *
108
 *
109
 */
110
/**
111
 * This panel allows user to select the area he/she wants to get in the view.
112
 * There are two options to do this:
113
 *  - Indicating the coordinates of the top-left and down-right corners
114
 *  - Selecting the area with the mouse
115
 * 
116
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
117
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
118
 */
119
public class WFSAreaPanel extends JPanel {
120
        private final Rectangle DEFAULT_BOUNDS = new Rectangle(10, 5, 490, 380);
121
        private final Rectangle DEFAULT_AREA_COORDINATES_PANEL_RECTANGLE = new Rectangle(8, 20, 481, 60);
122
        private final Rectangle DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE = new Rectangle(8, 115, 481, 265);
123

    
124
//        private final Rectangle DEFAULT_COORDINATES_CHECKBOX_RECTANGLE = new Rectangle(6, 19, 445, 20);
125
        private final Rectangle DEFAULT_ERASER_ICON_BUTTON_RECTANGLE = new Rectangle (270, 85, 25 , 25);
126
        private final Rectangle DEFAULT_PAN_ICON_BUTTON_RECTANGLE = new Rectangle(270, 85, 25, 25);
127
        private final Rectangle DEFAULT_ZOOMINANDOUT_JCOMBOBOX_RECTANGLE = new Rectangle(297, 85, 32 , 25);
128
        private final Rectangle DEFAULT_TOOL_JCOMBOBOX_RECTANGLE = new Rectangle(10, 87, 250, 21);
129
//        private final Rectangle DEFAULT_ZOOMIN_ICON_BUTTON_RECTANGLE = new Rectangle(297,100,25,25);
130
//        private final Rectangle DEFAULT_ZOOMOUT_ICON_BUTTON_RECTANGLE = new Rectangle(324,100,25,25);
131
        private final Rectangle DEFAULT_ZOOMRECTANGLESELECTION_ICON_BUTTON_RECTANGLE = new Rectangle(331, 85, 25, 25);
132
        private final Rectangle DEFAULT_ZOOMPREVIOUS_ICON_BUTTON_RECTANGLE = new Rectangle(358, 85, 25, 25);
133
        private final Rectangle DEFAULT_ZOOMCOMPLETE_ICON_BUTTON_RECTANGLE = new Rectangle(385, 85, 25, 25);
134
        private final Rectangle DEFAULT_ZOOMINANDOUTVIEWCENTERED_COMBOBOX_RECTANGLE = new Rectangle(412, 85, 32, 25);
135
        //        private final Rectangle DEFAULT_ZOOMINVIEWCENTERED_ICON_BUTTON_RECTANGLE = new Rectangle(378,100,25,25);
136
//        private final Rectangle DEFAULT_ZOOMOUTVIEWCENTERED_ICON_BUTTON_RECTANGLE = new Rectangle(405,100,25,25);
137
        private final Rectangle DEFAULT_INFO_ICON_BUTTON_RECTANGLE_V1 = new Rectangle(297, 85, 25, 25);
138
        private final Rectangle DEFAULT_INFO_ICON_BUTTON_RECTANGLE_V2 = new Rectangle(446, 85, 25, 25);
139
//        private final Rectangle DEFAULT_TOOLS_ICON_BUTTON_RECTANGLE = new Rectangle(459,100,25,25);
140
        
141
        private final int DISABLED_OPERATION = 0;
142
        private final int SELECTION_BY_COORDINATES_OPERATION = 1;
143
        private final int SELECTION_BY_AREA_OPERATION = 2;
144
        
145
        private WFSWizardData data = null;
146
        private WFSParamsPanel parent = null;
147
        private AreaCoordinatesPanel coordinatesPanel = null;
148
        private AreaMapControlPanel areaMapControlPanel = null;
149
        private JComboBox jComboBoxToolSelection = null;
150
        private JButton jButtonEraser = null;
151
        private JButton jButtonPan = null;
152
//        private JButton jButtonZoomIn = null;
153
//        private JButton jButtonZoomOut = null;
154
        private JButton jButtonZoomRectangleSelection = null;
155
        private JButton jButtonZoomPrevious = null;
156
        private JButton jButtonZoomComplete = null;
157
//        private JButton jButtonZoomInViewCentered = null;
158
//        private JButton jButtonZoomOutViewCentered = null;
159
        private JButton jButtonInfo = null;
160
//        private JButton jButtonTools = null;
161
        private JComboBox jComboBoxZoomInAndOut = null;
162
        private JComboBox jComboBoxZoomInAndOutViewCentered = null;
163
                
164
        /**
165
         * This method initializes
166
         */
167
        public WFSAreaPanel(WFSParamsPanel parent) {
168
                super();
169
                this.parent = parent;
170
                initialize();
171
        }
172

    
173
        /**
174
         * This method initializes this
175
         */
176
        private void initialize() {
177
                this.setLayout(null);
178
                this.setBounds(DEFAULT_BOUNDS);
179
                this.setBorder(javax.swing.BorderFactory.createTitledBorder(
180
                                null, PluginServices.getText(this, "select_by_area"),
181
                                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
182
                                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
183
                
184
                // Adds JPanel with the coordinates
185
                this.add(getCoordinatesPanel(), null);
186

    
187
                // Adds JComboBox to select a part of the graphical interface 
188
                this.add(getJComboBoxToolSelection(), null);
189
                this.getJComboBoxToolSelection().setSelectedIndex(0); // By default select first element
190

    
191
                // Adds Icons
192
//                this.add(getJButtonPan(), null);
193
////                this.add(getJButtonZoomIn(), null);
194
////                this.add(getJButtonZoomOut(), null);
195
//                this.add(getJComboBoxZoomInAndOut(), null);
196
//                this.add(getJButtonZoomRectangleSelection(), null);
197
//                this.add(getJButtonZoomPrevious(), null);
198
//                this.add(getJButtonZoomComplete(), null);
199
//                this.add(getJComboBoxZoomInAndOutViewCentered(), null);
200
//                this.add(getJButtonInfo(), null);
201
                
202
                // Adds Jpanel with the view
203
                this.add(getAreaMapControlPanel(), null);
204
//                this.add(get, null);
205
                
206
                initCoordinates();
207
        }        
208

    
209
        /**
210
         * Write the view coordinates into the coordinates panel
211
         */
212
        private void initCoordinates(){
213
                View activeView = 
214
                        (View) PluginServices.getMDIManager().getActiveWindow();
215
                Rectangle2D r2d= activeView.getMapControl().getViewPort().getAdjustedExtent();
216
                if (r2d != null){
217
                        getCoordinatesPanel().setExtent(r2d);
218
                }
219
        }
220

    
221
        /**
222
         * This method initializes coordinatesPanel        
223
         *         
224
         * @return javax.swing.JPanel        
225
         */
226
        private AreaCoordinatesPanel getCoordinatesPanel() {
227
                if (coordinatesPanel == null) {
228
                        coordinatesPanel = new AreaCoordinatesPanel();
229
                }
230
                return coordinatesPanel;
231
        }
232

    
233
        /**
234
         * This method initializes jComboBoxToolSelection
235
         * 
236
         * @return  javax.swing.JComboBox
237
         */
238
        private JComboBox getJComboBoxToolSelection() {
239
                if (jComboBoxToolSelection == null) {
240
                        jComboBoxToolSelection = new JComboBox();
241
                        jComboBoxToolSelection.setBounds(DEFAULT_TOOL_JCOMBOBOX_RECTANGLE);
242
                        jComboBoxToolSelection.setEditable(false);
243
                        jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "disabled"), this.DISABLED_OPERATION));
244
                        jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_absolute_coordinates"), this.SELECTION_BY_COORDINATES_OPERATION));
245
                        jComboBoxToolSelection.addItem(new ItemOperation(PluginServices.getText(this, "define_coordinates_using_view"), this.SELECTION_BY_AREA_OPERATION));
246
                        
247
                        jComboBoxToolSelection.addActionListener(new ActionListener() {
248
                                /*
249
                                 * (non-Javadoc)
250
                                 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
251
                                 */
252
                                public void actionPerformed(ActionEvent e) {
253
                                         JComboBox cb = (JComboBox)e.getSource();
254
                                         switch(((ItemOperation)cb.getSelectedItem()).getOperation()) {
255
                                                 case DISABLED_OPERATION:
256
                                                         disableCoorderatesRegionOperation();
257
                                                         disableAreaRegionOperation();
258
//                                                        getJButtonInfo().setEnabled(false);
259
                                                         break;
260
                                                 case SELECTION_BY_COORDINATES_OPERATION:
261
                                                         disableAreaRegionOperation();
262
                                                         enableCoorderatesRegionOperation();
263
//                                                        getJButtonInfo().setEnabled(true);
264
                                                         break;
265
                                                 case SELECTION_BY_AREA_OPERATION:
266
                                                         disableCoorderatesRegionOperation();
267
                                                         enableAreaRegionOperation();
268
//                                                        getJButtonInfo().setEnabled(true);
269
                                                         break;
270
                                                 }
271
                                }                                
272
                        });
273
                }
274
                return jComboBoxToolSelection;
275
        }
276

    
277
        /**
278
         * Enables the components associated to the selection of area by coordinates
279
         */
280
        private void enableCoorderatesRegionOperation() {
281
                // Adds associated icons
282
                this.add(getJButtonEraser(), null);
283
                this.add(getJButtonInfo(), null);
284
                
285
                getCoordinatesPanel().setAllTextFieldsEnabled(true);
286
        }
287

    
288
        /**
289
         * Enables the components associated to the selection of area by view
290
         */
291
        private void enableAreaRegionOperation() {
292
                // Adds associated icons
293
                this.add(getJButtonPan(), null);
294
//                this.add(getJButtonZoomIn(), null);
295
//                this.add(getJButtonZoomOut(), null);
296
                this.add(getJComboBoxZoomInAndOut(), null);
297
                this.add(getJButtonZoomRectangleSelection(), null);
298
                this.add(getJButtonZoomPrevious(), null);
299
                this.add(getJButtonZoomComplete(), null);
300
                this.add(getJComboBoxZoomInAndOutViewCentered(), null);
301
                this.add(getJButtonInfo(), null);        
302
                
303
                // Enables the icons
304
//                getJButtonPan().setEnabled(true);
305
//                getJComboBoxZoomInAndOut().setEnabled(true);
306
//                getJButtonZoomRectangleSelection().setEnabled(true);
307
//                getJButtonZoomPrevious().setEnabled(true);
308
//                getJButtonZoomComplete().setEnabled(true);
309
//                getJComboBoxZoomInAndOutViewCentered().setEnabled(true);
310
                
311
                // Enables the MapControl area
312
                getAreaMapControlPanel().setEnabled(true);
313
        }
314

    
315
        /**
316
         * Disables the components associated to the selection of area by coordinates
317
         */
318
        private void disableCoorderatesRegionOperation() {
319
                // Removes associated icons
320
                this.remove(getJButtonEraser());
321
                
322
                if (jButtonInfo != null)
323
                        this.remove(jButtonInfo);        
324

    
325
                getCoordinatesPanel().setAllTextFieldsEnabled(false);
326
        }
327

    
328
        /**
329
         * Disables the components associated to the selection of area by view
330
         */
331
        private void disableAreaRegionOperation() {
332
                // Removes associated icons
333
                this.remove(getJButtonPan());
334
//                this.add(getJButtonZoomIn(), null);
335
//                this.add(getJButtonZoomOut(), null);
336
                this.remove(getJComboBoxZoomInAndOut());
337
                this.remove(getJButtonZoomRectangleSelection());
338
                this.remove(getJButtonZoomPrevious());
339
                this.remove(getJButtonZoomComplete());
340
                this.remove(getJComboBoxZoomInAndOutViewCentered());
341
                
342
                if (jButtonInfo != null)
343
                        this.remove(jButtonInfo);        
344

    
345
                
346
                // Disables the icons
347
//                getJButtonPan().setEnabled(false);
348
//                getJComboBoxZoomInAndOut().setEnabled(false);
349
//                getJButtonZoomRectangleSelection().setEnabled(false);
350
//                getJButtonZoomPrevious().setEnabled(false);
351
//                getJButtonZoomComplete().setEnabled(false);
352
//                getJComboBoxZoomInAndOutViewCentered().setEnabled(false);
353
                
354
                // Disables the MapControl area
355
                getAreaMapControlPanel().setEnabled(false);
356
        }
357

    
358
        /**
359
         * This method initializes areaMapControlPanel
360
         * 
361
         * @return A reference to an object of AreaMapControlPanel
362
         */
363
        private AreaMapControlPanel getAreaMapControlPanel() {
364
                if (areaMapControlPanel == null) {
365
                        areaMapControlPanel = new AreaMapControlPanel();
366
                }
367

    
368
                return areaMapControlPanel;
369
        }
370

    
371
        /**
372
         * This method initializes jButtonEraser        
373
         *         
374
         * @return javax.swing.JButton        
375
         */
376
        private JButton getJButtonEraser() {
377
                if (jButtonEraser == null) {
378
                        jButtonEraser = new JButton();
379
                        jButtonEraser.setBounds(DEFAULT_ERASER_ICON_BUTTON_RECTANGLE);
380
                        jButtonEraser.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/eraser.png")));
381
                        jButtonEraser.setToolTipText(PluginServices.getText(this, "erases_coordinates"));
382
                }
383
                return jButtonEraser;
384
        }
385

    
386
        /**
387
         * This method initializes jButtonPan        
388
         *         
389
         * @return javax.swing.JButton        
390
         */
391
        private JButton getJButtonPan() {
392
                if (jButtonPan == null) {
393
                        jButtonPan = new JButton();
394
                        jButtonPan.setBounds(DEFAULT_PAN_ICON_BUTTON_RECTANGLE);
395
                        jButtonPan.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/Pan.png")));
396
                        jButtonPan.setToolTipText(PluginServices.getText(this, "Desplazamiento"));
397
                }
398
                return jButtonPan;
399
        }
400

    
401
        /**
402
         * This method initializes jComboBoxZoomInAndOut        
403
         *         
404
         * @return javax.swing.JComboBox        
405
         */
406
        private JComboBox getJComboBoxZoomInAndOut() {
407
                if (jComboBoxZoomInAndOut == null) {
408
                        jComboBoxZoomInAndOut = new JComboBox();
409
                        jComboBoxZoomInAndOut.setBounds(DEFAULT_ZOOMINANDOUT_JCOMBOBOX_RECTANGLE);
410
//                        jComboBoxZoomInAndOut.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/Pan.png")));
411
                }
412
                return jComboBoxZoomInAndOut;
413
        }
414
        
415
//        /**
416
//         * This method initializes jButtonZoomOut        
417
//         *         
418
//         * @return javax.swing.JButton        
419
//         */
420
//        private JButton getJButtonZoomOut() {
421
//                if (jButtonZoomOut == null) {
422
//                        jButtonZoomOut = new JButton();
423
//                        jButtonZoomOut.setBounds(DEFAULT_ZOOMOUT_ICON_BUTTON_RECTANGLE);
424
//                        jButtonZoomOut.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/ZoomOut.png")));
425
//                }
426
//                return jButtonZoomOut;
427
//        }
428
//
429
//        /**
430
//         * This method initializes jButtonZoomIn        
431
//         *         
432
//         * @return javax.swing.JButton        
433
//         */
434
//        private JButton getJButtonZoomIn() {
435
//                if (jButtonZoomIn == null) {
436
//                        jButtonZoomIn = new JButton();
437
//                        jButtonZoomIn.setBounds(DEFAULT_ZOOMIN_ICON_BUTTON_RECTANGLE);
438
//                        jButtonZoomIn.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/ZoomIn.png")));
439
//                }
440
//                return jButtonZoomIn;
441
//        }
442

    
443
        /**
444
         * This method initializes jButtonZoomRectangleSelection        
445
         *         
446
         * @return javax.swing.JButton        
447
         */
448
        private JButton getJButtonZoomRectangleSelection() {
449
                if (jButtonZoomRectangleSelection == null) {
450
                        jButtonZoomRectangleSelection = new JButton();
451
                        jButtonZoomRectangleSelection.setBounds(DEFAULT_ZOOMRECTANGLESELECTION_ICON_BUTTON_RECTANGLE);
452
                        jButtonZoomRectangleSelection.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/ZoomSeleccion.png")));
453
                        jButtonZoomRectangleSelection.setToolTipText(PluginServices.getText(this, "seleccionar_por_rectangulo"));
454
                }
455
                return jButtonZoomRectangleSelection;
456
        }
457

    
458
        /**
459
         * This method initializes jButtonZoomPrevious        
460
         *         
461
         * @return javax.swing.JButton        
462
         */
463
        private JButton getJButtonZoomPrevious() {
464
                if (jButtonZoomPrevious == null) {
465
                        jButtonZoomPrevious = new JButton();
466
                        jButtonZoomPrevious.setBounds(DEFAULT_ZOOMPREVIOUS_ICON_BUTTON_RECTANGLE);
467
                        jButtonZoomPrevious.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/ZoomPrevio.png")));
468
                        jButtonZoomPrevious.setToolTipText(PluginServices.getText(this, "Zoom_Previo"));
469
                }
470
                return jButtonZoomPrevious;
471
        }
472

    
473
        /**
474
         * This method initializes jButtonZoomComplete        
475
         *         
476
         * @return javax.swing.JButton        
477
         */
478
        private JButton getJButtonZoomComplete() {
479
                if (jButtonZoomComplete == null) {
480
                        jButtonZoomComplete = new JButton();
481
                        jButtonZoomComplete.setBounds(DEFAULT_ZOOMCOMPLETE_ICON_BUTTON_RECTANGLE);
482
                        jButtonZoomComplete.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/MapContents.png")));
483
                        jButtonZoomComplete.setToolTipText(PluginServices.getText(this, "Zoom_Completo"));
484
                }
485
                return jButtonZoomComplete;
486
        }
487

    
488
//        /**
489
//         * This method initializes jButtonZoomInViewCentered        
490
//         *         
491
//         * @return javax.swing.JButton        
492
//         */
493
//        private JButton getJButtonZoomInViewCentered() {
494
//                if (jButtonZoomInViewCentered == null) {
495
//                        jButtonZoomInViewCentered = new JButton();
496
//                        jButtonZoomInViewCentered.setBounds(DEFAULT_ZOOMINVIEWCENTERED_ICON_BUTTON_RECTANGLE);
497
//                        jButtonZoomInViewCentered.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/zoommas.png")));
498
//                }
499
//                return jButtonZoomInViewCentered;
500
//        }
501
//
502
//        /**
503
//         * This method initializes jButtonZoomOutViewCentered
504
//         *         
505
//         * @return javax.swing.JButton        
506
//         */
507
//        private JButton getJButtonZoomOutViewCentered() {
508
//                if (jButtonZoomOutViewCentered == null) {
509
//                        jButtonZoomOutViewCentered = new JButton();
510
//                        jButtonZoomOutViewCentered.setBounds(DEFAULT_ZOOMOUTVIEWCENTERED_ICON_BUTTON_RECTANGLE);
511
//                        jButtonZoomOutViewCentered.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/zoommenos.png")));
512
//                }
513
//                return jButtonZoomOutViewCentered;
514
//        }
515

    
516
        /**
517
         * This method initializes jComboBoxZoomInAndOut        
518
         *         
519
         * @return javax.swing.JComboBox        
520
         */
521
        private JComboBox getJComboBoxZoomInAndOutViewCentered() {
522
                if (jComboBoxZoomInAndOutViewCentered == null) {
523
                        jComboBoxZoomInAndOutViewCentered = new JComboBoxItemsSeekerConfigurable();
524
                        jComboBoxZoomInAndOutViewCentered.setBounds(DEFAULT_ZOOMINANDOUTVIEWCENTERED_COMBOBOX_RECTANGLE);
525
//                        jComboBoxZoomInAndOut.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/Pan.png")));
526
                }
527
                return jComboBoxZoomInAndOutViewCentered;
528
        }
529

    
530
        /**
531
         * This method initializes jButtonInfo        
532
         *         
533
         * @return javax.swing.JButton        
534
         */
535
        private JButton getJButtonInfo() {
536
                switch (((ItemOperation)getJComboBoxToolSelection().getSelectedItem()).getOperation()) {
537
                        case SELECTION_BY_COORDINATES_OPERATION:
538
                                jButtonInfo = new JButton();
539
                                jButtonInfo.setBounds(DEFAULT_INFO_ICON_BUTTON_RECTANGLE_V1);
540
                                jButtonInfo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/Identify.png")));
541
                                jButtonInfo.setToolTipText(PluginServices.getText(this, "informacion"));
542
                                break;
543
                        case SELECTION_BY_AREA_OPERATION:
544
                                jButtonInfo = new JButton();
545
                                jButtonInfo.setBounds(DEFAULT_INFO_ICON_BUTTON_RECTANGLE_V2);
546
                                jButtonInfo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/Identify.png")));
547
                                jButtonInfo.setToolTipText(PluginServices.getText(this, "informacion"));
548
                                break;
549
                        case DISABLED_OPERATION: // Do nothing
550
                                break;                                        
551
                }
552

    
553
                return jButtonInfo;
554
        }
555

    
556
//        /**
557
//         * This method initializes jButtonTools        
558
//         *         
559
//         * @return javax.swing.JButton        
560
//         */
561
//        private JButton getJButtonTools() {
562
//                if (jButtonTools == null) {
563
//                        jButtonTools = new JButton();
564
//                        jButtonTools.setBounds(DEFAULT_TOOLS_ICON_BUTTON_RECTANGLE);
565
//                        jButtonTools.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/ZoomOut.png")));
566
//                }
567
//                return jButtonTools;
568
//        }
569
        
570
        /**
571
         * Represents an object that stores the necessary information for know each operation of the 'jComboBoxToolSelection'
572
         * 
573
         * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
574
         */
575
        private class ItemOperation {
576
                String _name;
577
                int _operation;
578
                
579
                /**
580
                 * Default constructor with two parameters
581
                 * 
582
                 * @param name Name of the operation
583
                 * @param operation A code that identifies the operation
584
                 */
585
                public ItemOperation(String name, int operation) {
586
                        _name = new String(name);
587
                        _operation = operation;
588
                }
589
                
590
                /**
591
                 * Returns the name of the operation
592
                 * 
593
                 * @return An String
594
                 */
595
                public String getName() {
596
                        return _name;
597
                }
598
                
599
                /**
600
                 * Returns the code that identifies the operation
601
                 * 
602
                 * @return An integer value
603
                 */
604
                public int getOperation() {
605
                        return _operation;
606
                }
607
                
608
                /**
609
                 * The name of the operation that will use JComboBox
610
                 */
611
                public String toString() {
612
                        return _name;
613
                }
614
        }
615
        
616
        /**
617
         * This class is a panel width four fields for indicate the coordinates of two points:
618
         *   One for the ritgh-up point and another for the left-down point of a rectangle area
619
         * 
620
         * @author Pablo Piqueras Bartolom? (p_queras_pab@hotmail.com)
621
         * @author Jorge Piera Llodr? (piera_jor@gva.es) 
622
         */
623
        private class AreaCoordinatesPanel extends JPanel implements Serializable {
624
                private final Rectangle DEFAULT_JRADIOBUTTON_GO_TO_AREA_RECTANGLE = new Rectangle(412, 5, 67, 50);  //  @jve:decl-index=0:
625
                private final int DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT = 20;
626
                private final int DEFAULT_COORDIANTE_LABEL_WIDTH = 20;
627
                private final int DEFAULT_TEXT_FIELDS_WIDTH = 132;
628
                private final int DEFAULT_X_LOCATION = 8;
629
                private final int DEFAULT_Y_LEFT_UP_CORNER_LOCATION = 6;
630
                private final int DEFAULT_COORDINATE_WIDTH = DEFAULT_COORDIANTE_LABEL_WIDTH + DEFAULT_TEXT_FIELDS_WIDTH + 10;
631
                private final int DEFAULT_COORDINATE_HEIGHT = 25;
632
                private final Dimension DEFAULT_JLABEL_VERTEX_DIMENSION = new Dimension(60, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT);  //  @jve:decl-index=0:
633
                private final int DEFAULT_XY_COORDINATES_WIDTH = 2 * DEFAULT_COORDINATE_WIDTH + DEFAULT_JLABEL_VERTEX_DIMENSION.width + 10 ;
634

    
635
                private JPanel jPanelVertex1 = null;
636
                private JPanel jPanelVertex2 = null;
637
                private JPanel jPanelVertex1X = null;
638
                private JPanel jPanelVertex1Y = null;
639
                private JPanel jPanelVertex2X = null;
640
                private JPanel jPanelVertex2Y = null;
641
                
642
                private JLabel jLabelVertex1 = null;
643
                private JLabel jLabelVertex2 = null;
644
                private JLabel jLabelVertex1X = null;
645
                private JLabel jLabelVertex1Y = null;
646
                private JLabel jLabelVertex2X = null;
647
                private JLabel jLabelVertex2Y = null;
648
                private JTextFieldWithSpecificCaretPosition jTextFieldVertex1X = null;
649
                private JTextFieldWithSpecificCaretPosition jTextFieldVertex1Y = null;
650
                private JTextFieldWithSpecificCaretPosition jTextFieldVertex2X = null;
651
                private JTextFieldWithSpecificCaretPosition jTextFieldVertex2Y = null;
652
                private JRadioButton jRadioButtonGoToArea = null;
653
                
654
                private FocusListener focusListenerForCoordinateValidation = null;
655

    
656
                /**
657
                 * This is the default constructor
658
                 */
659
                public AreaCoordinatesPanel() {
660
                        super();
661
                        initialize();
662
                }
663

    
664
                /**
665
                 * This method initializes this
666
                 * 
667
                 * @return void
668
                 */
669
                private void initialize() {
670
                        this.setLayout(null);
671
                        this.setBounds(DEFAULT_AREA_COORDINATES_PANEL_RECTANGLE);
672
                        this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
673
                        this.setToolTipText(PluginServices.getText(this, "select_by_vertexes_coordinates"));
674
//                        this.setBorder(javax.swing.BorderFactory.createTitledBorder(
675
//                        null, PluginServices.getText(this, "select_by_vertexes_coordinates"),
676
//                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
677
//                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
678
                        this.add(getJPanelVertex1());
679
                        this.add(getJPanelVertex2());
680
                        this.add(getJRadioButtonGoToArea());
681
                }
682
                
683
                /**
684
                 * Returns the default width of this component
685
                 * 
686
                 * @return The default width
687
                 */
688
                public int getDefaultWidth() {
689
                        return DEFAULT_COORDINATE_WIDTH * 2;
690
                }
691
                
692
                /**
693
                 * Returns the default height of this component
694
                 * 
695
                 * @return The default height
696
                 */
697
                public int getDefaultHeight() {
698
                        return DEFAULT_COORDINATE_HEIGHT * 2;
699
                }
700
                
701
                /**
702
                 * This method initializes jPanelVertex1
703
                 * 
704
                 * @return javax.swing.JPanel
705
                 */
706
                private JPanel getJPanelVertex1() {
707
                        if (jPanelVertex1 == null) {
708
                                jPanelVertex1 = new JPanel();
709
                                jPanelVertex1.setBounds(DEFAULT_X_LOCATION, DEFAULT_Y_LEFT_UP_CORNER_LOCATION, DEFAULT_XY_COORDINATES_WIDTH, DEFAULT_COORDINATE_HEIGHT);
710
                                jPanelVertex1.setLayout(new GridBagLayout());
711
                                jPanelVertex1.add(getJLabelVertex1(), null);
712
                                jPanelVertex1.add(getJPanelVertex1X(), null);
713
                                jPanelVertex1.add(getJPanelVertex1Y(), null);
714
                        }
715
                        
716
                        return jPanelVertex1;
717
                }
718
                
719
                /**
720
                 * This method initializes jPanelVertex2
721
                 * 
722
                 * @return javax.swing.JPanel
723
                 */
724
                private JPanel getJPanelVertex2() {
725
                        if (jPanelVertex2 == null) {
726
                                jPanelVertex2 = new JPanel();
727
                                jPanelVertex2.setBounds(DEFAULT_X_LOCATION, DEFAULT_Y_LEFT_UP_CORNER_LOCATION + DEFAULT_COORDINATE_HEIGHT, DEFAULT_XY_COORDINATES_WIDTH, DEFAULT_COORDINATE_HEIGHT);
728
                                jPanelVertex2.setLayout(new GridBagLayout());
729
                                jPanelVertex2.add(getJLabelVertex2(), null);
730
                                jPanelVertex2.add(getJPanelVertex2X(), null);
731
                                jPanelVertex2.add(getJPanelVertex2Y(), null);
732
                        }
733
                        
734
                        return jPanelVertex2;
735
                }
736
                
737
                /**
738
                 * This method initializes jLabelVertex1
739
                 * 
740
                 * @return javax.swing.JPanel
741
                 */
742
                private JLabel getJLabelVertex1() {
743
                        if (jLabelVertex1 == null) {
744
                                jLabelVertex1 = new JLabel();
745
                                jLabelVertex1.setPreferredSize(DEFAULT_JLABEL_VERTEX_DIMENSION);
746
                                jLabelVertex1.setToolTipText(PluginServices.getText(this, "coordinates_from_area_left_up_vertex"));
747
                                jLabelVertex1.setText(PluginServices.getText(this, "vertex") + " 1:");
748
                                jLabelVertex1.setHorizontalAlignment(SwingConstants.LEFT);
749
                                jLabelVertex1.setVerticalAlignment(SwingConstants.CENTER);
750
                                jLabelVertex1.setForeground(new Color(0, 0, 255)); // Blue color for text
751
                        }
752
                        return jLabelVertex1;
753
                }
754

    
755
                /**
756
                 * This method initializes jLabelVertex2
757
                 * 
758
                 * @return javax.swing.JPanel
759
                 */
760
                private JLabel getJLabelVertex2() {
761
                        if (jLabelVertex2 == null) {
762
                                jLabelVertex2 = new JLabel();
763
                                jLabelVertex2.setPreferredSize(DEFAULT_JLABEL_VERTEX_DIMENSION);
764
                                jLabelVertex2.setToolTipText(PluginServices.getText(this, "coordinates_from_area_right_bottom_vertex"));
765
                                jLabelVertex2.setText(PluginServices.getText(this, "vertex") + " 2:");
766
                                jLabelVertex2.setHorizontalAlignment(SwingConstants.LEFT);
767
                                jLabelVertex2.setVerticalAlignment(SwingConstants.CENTER);
768
                                jLabelVertex2.setForeground(new Color(128, 64, 0)); // Brown color for text
769
                        }
770
                        return jLabelVertex2;
771
                }
772

    
773
                /**
774
                 * This method initializes jPanelVertex1X
775
                 * 
776
                 * @return javax.swing.JPanel
777
                 */
778
                private JPanel getJPanelVertex1X() {
779
                        if (jPanelVertex1X == null) {
780
                                jPanelVertex1X = new JPanel();
781
                                jPanelVertex1X.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
782
                                jPanelVertex1X.setLayout(new GridBagLayout());
783
                                jPanelVertex1X.add(getJLabelVertex1X(), null);
784
                                jPanelVertex1X.add(getJTextFieldVertex1X(), null);
785
                        }
786
                        
787
                        return jPanelVertex1X;
788
                }
789

    
790
                /**
791
                 * This method initializes jPanelVertex1Y
792
                 * 
793
                 * @return javax.swing.JPanel
794
                 */
795
                private JPanel getJPanelVertex1Y() {
796
                        if (jPanelVertex1Y == null) {
797
                                jPanelVertex1Y = new JPanel();
798
                                jPanelVertex1Y.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
799
                                jPanelVertex1Y.setLayout(new GridBagLayout());
800
                                jPanelVertex1Y.add(getJLabelVertex1Y(), null);
801
                                jPanelVertex1Y.add(getJTextFieldVertex1Y(), null);
802
                        }
803
                        
804
                        return jPanelVertex1Y;
805
                }
806

    
807
                /**
808
                 * This method initializes jPanelVertex2X
809
                 * 
810
                 * @return javax.swing.JPanel
811
                 */
812
                private JPanel getJPanelVertex2X() {
813
                        if (jPanelVertex2X == null) {
814
                                jPanelVertex2X = new JPanel();
815
                                jPanelVertex2X.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
816
                                jPanelVertex2X.setLayout(new GridBagLayout());
817
                                jPanelVertex2X.add(getJLabelVertex2X(), null);
818
                                jPanelVertex2X.add(getJTextFieldVertex2X(), null);
819
                        }
820
                        
821
                        return jPanelVertex2X;
822
                }
823
                
824
                /**
825
                 * This method initializes jPanelVertex2Y
826
                 * 
827
                 * @return javax.swing.JPanel
828
                 */
829
                private JPanel getJPanelVertex2Y() {
830
                        if (jPanelVertex2Y == null) {
831
                                jPanelVertex2Y = new JPanel();
832
                                jPanelVertex2Y.setPreferredSize(new Dimension(new Dimension(DEFAULT_COORDINATE_WIDTH, DEFAULT_COORDINATE_HEIGHT)));
833
                                jPanelVertex2Y.setLayout(new GridBagLayout());
834
                                jPanelVertex2Y.add(getJLabelVertex2Y(), null);
835
                                jPanelVertex2Y.add(getJTextFieldVertex2Y(), null);
836
                        }
837
                        
838
                        return jPanelVertex2Y;
839
                }
840

    
841
                /**
842
                 * This method initializes jLabelVertex1X
843
                 * 
844
                 * @return  javax.swing.JLabel
845
                 */
846
                private JLabel getJLabelVertex1X() {
847
                        if (jLabelVertex1X == null) {
848
                                jLabelVertex1X = new JLabel();
849
                                jLabelVertex1X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
850
                                jLabelVertex1X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_left_up_vertex"));
851
                                jLabelVertex1X.setText(PluginServices.getText(this, "x") + ":");
852
                                jLabelVertex1X.setHorizontalAlignment(SwingConstants.CENTER);
853
                                jLabelVertex1X.setVerticalAlignment(SwingConstants.CENTER);
854
                                jLabelVertex1X.setForeground(new Color(0, 0, 255)); // Blue color for text
855
                        }
856
                        
857
                        return jLabelVertex1X;
858
                }
859
                
860
                /**
861
                 * This method initializes jLabelVertex2X
862
                 * 
863
                 * @return  javax.swing.JLabel
864
                 */
865
                private JLabel getJLabelVertex2X() {
866
                        if (jLabelVertex2X == null) {
867
                                jLabelVertex2X = new JLabel();
868
                                jLabelVertex2X.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
869
                                jLabelVertex2X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_right_bottom_vertex"));
870
                                jLabelVertex2X.setText(PluginServices.getText(this, "x") + ":");
871
                                jLabelVertex2X.setHorizontalAlignment(SwingConstants.CENTER);
872
                                jLabelVertex2X.setVerticalAlignment(SwingConstants.CENTER);
873
                                jLabelVertex2X.setForeground(new Color(128, 64, 0)); // Brown color for text
874
                        }
875
                        
876
                        return jLabelVertex2X;
877
                }
878
                
879
                /**
880
                 * This method initializes jLabelVertex1Y
881
                 * 
882
                 * @return  javax.swing.JLabel
883
                 */
884
                private JLabel getJLabelVertex1Y() {
885
                        if (jLabelVertex1Y == null) {
886
                                jLabelVertex1Y = new JLabel();
887
                                jLabelVertex1Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
888
                                jLabelVertex1Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_up_vertex"));
889
                                jLabelVertex1Y.setText(PluginServices.getText(this, "y") + ":");
890
                                jLabelVertex1Y.setHorizontalAlignment(SwingConstants.CENTER);
891
                                jLabelVertex1Y.setVerticalAlignment(SwingConstants.CENTER);
892
                                jLabelVertex1Y.setForeground(new Color(0, 0, 255)); // Blue color for text
893
                        }
894
                        
895
                        return jLabelVertex1Y;
896
                }
897
                
898
                /**
899
                 * This method initializes jLabelVertex2Y
900
                 * 
901
                 * @return  javax.swing.JLabel
902
                 */
903
                private JLabel getJLabelVertex2Y() {
904
                        if (jLabelVertex2Y == null) {
905
                                jLabelVertex2Y = new JLabel();                        
906
                                jLabelVertex2Y.setPreferredSize(new java.awt.Dimension(DEFAULT_COORDIANTE_LABEL_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
907
                                jLabelVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_right_bottom_vertex"));
908
                                jLabelVertex2Y.setText(PluginServices.getText(this, "y") + ":");
909
                                jLabelVertex2Y.setHorizontalAlignment(SwingConstants.CENTER);
910
                                jLabelVertex2Y.setVerticalAlignment(SwingConstants.CENTER);
911
                                jLabelVertex2Y.setForeground(new Color(128, 64, 0)); // Brown color for text
912
                        }
913
                        
914
                        return jLabelVertex2Y;
915
                }
916
//                
917
//                /**
918
//                 * This method initializes a FocusAdapter event adapter, it's 'focusLost()' method for set the caret position of
919
//                 *   the JTextField (source which generates the event of focusLost), to the first position.
920
//                 * This adapter is done for use only with the JTextFields of the coordinates
921
//                 * 
922
//                 * @return java.awt.event.FocusAdapter
923
//                 */
924
//                private FocusAdapter getJFocusAdapterForJTextFields() {
925
//                        if (focusAdapterForJTextFields == null) {
926
//                                focusAdapterForJTextFields = new FocusAdapter() {
927
//                                        /*
928
//                                         *  (non-Javadoc)
929
//                                         * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
930
//                                         */
931
//                                        public void focusLost(FocusEvent e) {
932
//                                                ((JTextField)e.getSource()).setCaretPosition(0);
933
//                                        }                                        
934
//                                };
935
//                        }
936
//                        return focusAdapterForJTextFields;
937
//                }
938
                
939
                /**
940
                 * Returns a focus listener for validate the text of a JTextField when that component loses its focus
941
                 * 
942
                 * @return java.awt.event.FocusListener
943
                 */
944
                private FocusListener getFocusListenerForCoordinateValidation() {
945
                        if (focusListenerForCoordinateValidation == null) {
946
                                focusListenerForCoordinateValidation = new FocusAdapter() {
947
                                        /*
948
                                         *  (non-Javadoc)
949
                                         * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
950
                                         */
951
                                        public void focusLost(FocusEvent e) {
952
                                                validateCoordinate((JTextField)e.getSource());
953
                                        }                                        
954
                                };
955
                        }
956
                        
957
                        return focusListenerForCoordinateValidation;
958
                }
959

    
960
                /**
961
                 * This method initializes jTextFieldVertex1X        
962
                 *         
963
                 * @return javax.swing.JTextField        
964
                 */
965
                private JTextField getJTextFieldVertex1X() {
966
                        if (jTextFieldVertex1X == null) {
967
                                jTextFieldVertex1X = new JTextFieldWithSpecificCaretPosition();
968
                                jTextFieldVertex1X.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
969
                                jTextFieldVertex1X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_left_up_vertex"));
970
                                jTextFieldVertex1X.addFocusListener(getFocusListenerForCoordinateValidation());
971
                        }
972
                        return jTextFieldVertex1X;
973
                }
974

    
975
                /**
976
                 * This method initializes jTextFieldVertex1Y        
977
                 *         
978
                 * @return javax.swing.JTextField        
979
                 */
980
                private JTextField getJTextFieldVertex1Y() {
981
                        if (jTextFieldVertex1Y == null) {
982
                                jTextFieldVertex1Y = new JTextFieldWithSpecificCaretPosition();
983
                                jTextFieldVertex1Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
984
                                jTextFieldVertex1Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_left_up_vertex"));
985
                                jTextFieldVertex1Y.addFocusListener(getFocusListenerForCoordinateValidation());
986
                        }
987
                        return jTextFieldVertex1Y;
988
                }
989

    
990
                /**
991
                 * This method initializes jTextFieldVertex2X        
992
                 *         
993
                 * @return javax.swing.JTextField        
994
                 */
995
                private JTextField getJTextFieldVertex2X() {
996
                        if (jTextFieldVertex2X == null) {
997
                                jTextFieldVertex2X = new JTextFieldWithSpecificCaretPosition();
998
                                jTextFieldVertex2X.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));
999
                                jTextFieldVertex2X.setToolTipText(PluginServices.getText(this, "x_coordinate_from_area_right_bottom_vertex"));
1000
                                jTextFieldVertex2X.addFocusListener(getFocusListenerForCoordinateValidation());
1001
                        }
1002
                        return jTextFieldVertex2X;
1003
                }
1004

    
1005
                /**
1006
                 * This method initializes jTextFieldVertex2Y        
1007
                 *         
1008
                 * @return javax.swing.JTextField        
1009
                 */
1010
                private JTextField getJTextFieldVertex2Y() {
1011
                        if (jTextFieldVertex2Y == null) {
1012
                                jTextFieldVertex2Y = new JTextFieldWithSpecificCaretPosition();
1013
                                jTextFieldVertex2Y.setPreferredSize(new Dimension(DEFAULT_TEXT_FIELDS_WIDTH, DEFAULT_LABELS_AND_TEXT_FIELDS_HEIGHT));                        
1014
                                jTextFieldVertex2Y.setToolTipText(PluginServices.getText(this, "y_coordinate_from_area_right_bottom_vertex"));
1015
                                jTextFieldVertex2Y.addFocusListener(getFocusListenerForCoordinateValidation());
1016
                        }
1017
                        return jTextFieldVertex2Y;
1018
                }
1019
                
1020
                /**
1021
                 * Validates the coordinate of a JTextField
1022
                 * 
1023
                 * @param coordinate javax.swing.JTextField
1024
                 */
1025
                private void validateCoordinate(JTextField coordinate) {
1026
                        if (coordinate != null) {
1027
                                // If the format of the coordinate is incorrect, shows a message warning the user that problem and resets the coordinate text 
1028
                                if ((coordinate.getText().compareTo("") != 0) &&(! StringNumberUtilities.isExponentialRealNumber(coordinate.getText()))) {
1029
                                        JOptionPane.showMessageDialog(this, PluginServices.getText(null, "incorrect_coordinate_format"), PluginServices.getText(null, "error"), JOptionPane.ERROR_MESSAGE);
1030
                                        coordinate.setText(""); // Reset text
1031
                                }
1032
                        }
1033
                }
1034

    
1035
                /**
1036
                 * This method initializes jbuttonGoToArea
1037
                 * 
1038
                 * @return javax.swing.JRadioButton
1039
                 */
1040
                private JRadioButton getJRadioButtonGoToArea() {
1041
                        if (jRadioButtonGoToArea == null) {
1042
                                jRadioButtonGoToArea = new JRadioButton();
1043
                                jRadioButtonGoToArea.setBounds(DEFAULT_JRADIOBUTTON_GO_TO_AREA_RECTANGLE);
1044
                                jRadioButtonGoToArea.setToolTipText(PluginServices.getText(this, "to_previsualize"));
1045
                                jRadioButtonGoToArea.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/to_previsualize_area.png")));
1046
                        }                
1047
                        return jRadioButtonGoToArea;
1048
                }
1049

    
1050
                /**
1051
                 * Sets the extent
1052
                 * @param extent
1053
                 */
1054
                public void setExtent(Rectangle2D extent){
1055
                        getJTextFieldVertex1X().setText(String.valueOf(extent.getMaxX()));
1056
                        getJTextFieldVertex1Y().setText(String.valueOf(extent.getMaxY()));
1057
                        getJTextFieldVertex2X().setText(String.valueOf(extent.getMinX()));
1058
                        getJTextFieldVertex2Y().setText(String.valueOf(extent.getMinY()));
1059
                }
1060
                
1061
                /**
1062
                 * Gets the extent
1063
                 * @return
1064
                 */
1065
                public Rectangle2D getExtent(){
1066
                        if ((!getJTextFieldVertex1X().getText().equals("")) &&
1067
                                        (!getJTextFieldVertex1Y().getText().equals("")) &&
1068
                                        (!getJTextFieldVertex2X().getText().equals("")) &&
1069
                                        (!getJTextFieldVertex2Y().getText().equals(""))){
1070
                                Rectangle2D r2d = new Rectangle2D.Double(new Double(getJTextFieldVertex1X().getText()).doubleValue(),
1071
                                                new Double(getJTextFieldVertex1Y().getText()).doubleValue(),
1072
                                                new Double(getJTextFieldVertex2X().getText()).doubleValue(),
1073
                                                new Double(getJTextFieldVertex2Y().getText()).doubleValue());
1074
                                return r2d;
1075
                        }
1076
                        return null;
1077
                }
1078
                
1079
                /**
1080
                 * Enables or disables all inner JTextField
1081
                 * 
1082
                 * @param b A boolean value
1083
                 */
1084
                public void setAllTextFieldsEnabled(boolean b) {
1085
                        getJTextFieldVertex1X().setEnabled(b);
1086
                        getJTextFieldVertex1Y().setEnabled(b);
1087
                        getJTextFieldVertex2X().setEnabled(b);
1088
                        getJTextFieldVertex2Y().setEnabled(b);
1089
                }
1090
        }
1091
        
1092
        /**
1093
         * DOCUMENTAR!!
1094
         * 
1095
         * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
1096
         */
1097
        public class AreaMapControlPanel extends MapControl {
1098
//                private final Rectangle DEFAULT_AREA_MAPCONTROL_RECTANGLE = new Rectangle(0, 0, DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE.width, DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE.height);
1099
                
1100
//                private MapControl m_MapControl = null;
1101
                
1102
                /**
1103
                 * Default constructor
1104
                 */
1105
                public AreaMapControlPanel() {
1106
                        this.initialize();
1107
                }
1108
                
1109
                /**
1110
                 * This method initializes this
1111
                 */
1112
                private void initialize() {
1113
                        this.setLayout(null);
1114
                        this.setBounds(DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE);
1115
                        this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
1116
//                        this.setBorder(javax.swing.BorderFactory.createTitledBorder(
1117
//                        null, PluginServices.getText(this, "select_by_graphical_area"),
1118
//                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
1119
//                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
1120
//                        this.add(this.getMapControl(DEFAULT_AREA_MAPCONTROL_PANEL_RECTANGLE.getSize()));
1121
                }
1122
                
1123
//                /*
1124
//                 *  (non-Javadoc)
1125
//                 * @see java.awt.Component#setEnabled(boolean)
1126
//                 */
1127
//                public void setEnabled(boolean enabled) {
1128
//                        this.setEnabled(false);
1129
//                        this.getMapControl().setEnabled(false);
1130
//                }
1131
                
1132
//                /*
1133
//                 *  (non-Javadoc)
1134
//                 * @see com.iver.cit.gvsig.project.documents.view.gui.IView#getMapControl()
1135
//                 */
1136
//                public MapControl getMapControl() {
1137
//                        return this.m_MapControl;
1138
//                }
1139
                
1140

    
1141
                /**
1142
                 * Adds listeners to the inner MapControl of the inner area JPanel ??
1143
                 * (SOBRAR?N ALGUNOS)
1144
                 */
1145
                private void addListeneresToAreaPanel() {
1146
//                    //Listener de eventos de movimiento que pone las coordenadas del rat?n en la barra de estado
1147
//                StatusBarListener sbl = new StatusBarListener(this.areaMapControlPanel.getMapControl());
1148
        //
1149
//                // Zoom out (pinchas y el mapa se centra y te muestra m?s).
1150
//                // No es dibujando un rect?ngulo, es solo pinchando.
1151
//                ZoomOutListener zol = new ZoomOutListener(this.areaMapControlPanel.getMapControl());
1152
//                this.areaMapControlPanel.getMapControl().addMapTool("zoomOut", new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)});
1153
        //
1154
//                // Pan
1155
//                PanListener pl = new PanListener(this.areaMapControlPanel.getMapControl());
1156
//                this.areaMapControlPanel.getMapControl().addMapTool("pan", new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)});
1157
        //
1158
//                // Medir
1159
//                MeasureListener mli = new MeasureListener(this.areaMapControlPanel.getMapControl());
1160
//                this.areaMapControlPanel.getMapControl().addMapTool("medicion", new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)});
1161
        //
1162
//                // Area
1163
//                AreaListener ali = new AreaListener(this.areaMapControlPanel.getMapControl());
1164
//                this.areaMapControlPanel.getMapControl().addMapTool("area", new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)});
1165
        //
1166
//                // Seleccion por punto
1167
//                PointSelectListener psl = new PointSelectListener(this.areaMapControlPanel.getMapControl());
1168
//                this.areaMapControlPanel.getMapControl().addMapTool("pointSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)});
1169
        //
1170
//                // Info por punto
1171
//                InfoListener il = new InfoListener(this.areaMapControlPanel.getMapControl());
1172
//                this.areaMapControlPanel.getMapControl().addMapTool("info", new Behavior[]{new PointBehavior(il), new MouseMovementBehavior(sbl)});
1173
        //
1174
//                // Link por punto
1175
//                LinkListener ll = new LinkListener(this.areaMapControlPanel.getMapControl());
1176
//                this.areaMapControlPanel.getMapControl().addMapTool("link", new Behavior[]{new PointBehavior(ll), new MouseMovementBehavior(sbl)});
1177
        //
1178
//                // Selecci?n por rect?ngulo
1179
//                RectangleSelectListener rsl = new RectangleSelectListener(this.areaMapControlPanel.getMapControl());
1180
//                this.areaMapControlPanel.getMapControl().addMapTool("rectSelection", new Behavior[]{new RectangleBehavior(rsl), new MouseMovementBehavior(sbl)});
1181
        //
1182
//                // Selecci?n por pol?gono
1183
//                PolygonSelectListener poligSel = new PolygonSelectListener(this.areaMapControlPanel.getMapControl());
1184
//                this.areaMapControlPanel.getMapControl().addMapTool("polSelection", new Behavior[]{new PolygonBehavior(poligSel), new MouseMovementBehavior(sbl)});
1185
        //
1186
//                // Zoom por rect?ngulo
1187
//                ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(this.areaMapControlPanel.getMapControl());
1188
//                ZoomInListener zil = new ZoomInListener(this.areaMapControlPanel.getMapControl());
1189
//                this.areaMapControlPanel.getMapControl().addMapTool("zoomIn", new Behavior[]{new RectangleBehavior(zil),
1190
//                                                new PointBehavior(zoil), new MouseMovementBehavior(sbl)});
1191
        //
1192
//                SelectImageListener sil = new SelectImageListener(this.areaMapControlPanel.getMapControl());
1193
//                this.areaMapControlPanel.getMapControl().addMapTool("selectImage", new Behavior[]{
1194
//                                        new PointBehavior(sil), new MouseMovementBehavior(sbl)});
1195
        //
1196
//                ZoomPixelCursorListener zp = new ZoomPixelCursorListener(this.areaMapControlPanel.getMapControl());
1197
//                this.areaMapControlPanel.getMapControl().addMapTool("zoom_pixel_cursor", new Behavior[]{new PointBehavior(zp), new MouseMovementBehavior(sbl)});
1198
        //
1199
//                this.areaMapControlPanel.getMapControl().setTool("zoomIn"); // Por defecto
1200
//                // m_MapControl.setPaintEnabled(true);
1201
                }
1202
                
1203
//                /**
1204
//                 * This method initializes m_MapControl        
1205
//                 *         
1206
//                 * @return com.iver.cit.gvsig.fmap.MapControl
1207
//                 */
1208
//                private MapControl getMapControl(Dimension d) {
1209
//                        if (m_MapControl == null) {
1210
//                        m_MapControl = new MapControl(); // Default is paintEnabled = false.
1211
//                        m_MapControl.setBounds(DEFAULT_AREA_MAPCONTROL_RECTANGLE);
1212
//                        }
1213
//
1214
//                        return m_MapControl;
1215
//                }
1216

    
1217
                /**
1218
                 * @see MapControl#drawMap(boolean)
1219
                 */
1220
                public void repaintMap() {
1221
                        this.drawMap(false);
1222
                }
1223
//                
1224
//                /**
1225
//                 * @see MapControl#getImage()
1226
//                 */
1227
//                public BufferedImage getImage() {
1228
//                        return getMapControl().getImage();
1229
//                }
1230
//                
1231
//                /**
1232
//                 * @see MapControl#setProjection(IProjection)
1233
//                 */
1234
//                public void setProjection(IProjection proj)
1235
//                {
1236
//                        getMapControl().setProjection(proj);
1237
//                }
1238
//                
1239
//                /**
1240
//                 * @see MapControl#getProjection()
1241
//                 */
1242
//                public IProjection getProjection()
1243
//                {
1244
//                        return getMapControl().getProjection();
1245
//                }
1246
        }
1247
}