Statistics
| Revision:

root / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / panels / EPSGpanel.java @ 8127

History | View | Annotate | Download (20.3 KB)

1
package org.gvsig.crs.gui.panels;
2
import java.awt.Color;
3
import java.awt.Dimension;
4
import java.awt.FlowLayout;
5
import java.awt.GridLayout;
6
import java.awt.event.ActionEvent;
7
import java.awt.event.ActionListener;
8
import java.awt.event.KeyEvent;
9
import java.awt.event.KeyListener;
10
import java.sql.ResultSet;
11
import java.sql.SQLException;
12

    
13
import javax.swing.BorderFactory;
14
import javax.swing.JButton;
15
import javax.swing.JLabel;
16
import javax.swing.JOptionPane;
17
import javax.swing.JPanel;
18
import javax.swing.JRadioButton;
19
import javax.swing.JScrollPane;
20
import javax.swing.JTable;
21
import javax.swing.JTextField;
22
import javax.swing.ListSelectionModel;
23
import javax.swing.table.DefaultTableModel;
24
import javax.swing.table.TableColumn;
25

    
26
import org.cresques.cts.IProjection;
27
import org.gvsig.crs.CrsException;
28
import org.gvsig.crs.CrsFactory;
29
import org.gvsig.crs.EpsgConnection;
30
import org.gvsig.crs.ICrs;
31
import org.gvsig.crs.Query;
32
import org.gvsig.crs.gui.InfoCRSPanel;
33
import org.gvsig.crs.ogr.Epsg2wkt;
34
import org.gvsig.crs.ogr.GetCRSepsg;
35

    
36
import com.iver.andami.PluginServices;
37
import com.iver.cit.gvsig.gui.TableSorter;
38

    
39
public class EPSGpanel extends JPanel implements KeyListener, ActionListener{
40

    
41
        /**
42
         * 
43
         */
44
        private static final long serialVersionUID = 1L;
45
        public JPanel EPSGpanel = null;
46
        
47
        JLabel jLabel = null;
48
        JTextField crsTextFld = null;        
49
        
50
        String cadWKT = "";
51
        
52
        int transf = 0;
53
        public int epsg_code  = 0;
54
        boolean source_yn = false;
55
        int source_cod = 0;
56
        int method_code = 0;
57
        int datum_code = 0;
58
        int projection_conv_code = 0;
59
        public String crs_kind = null;
60
        int[] valid_method_code = {9800, 9801, 9802, 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810, 
61
                        9811, 9812, 9813, 9814, 9815, 9816, 9817, 9602, 9659};
62
        boolean select = false;
63
        
64
        String[] soported_crs = {"projected","geographic 2D","geographic 3D", "engineering", "vertical", "compound", "geocentric"};
65
        String[] not_soported_crs = {};
66
        
67
        private JRadioButton codeRadioButton = null;
68
        private JRadioButton nameRadioButton = null;
69
        private JRadioButton areaRadioButton = null;
70
        private JPanel groupRadioButton = null;
71
        
72
        boolean inAnApplet = true;
73
        
74
        public EpsgConnection connect = null;
75
        
76
        private JButton infoCrs = null;
77
        private JButton searchButton = null;
78
        private JTextField searchTextField = null;
79
        public JTable jTable = null;
80
        private JScrollPane jScrollPane = null;
81
        public DefaultTableModel dtm = null;
82
        public DefaultTableModel dtm2 = null;
83
        public String key;
84
        public int selectedRowTable = -1;
85
        public int selectedRowTable2 = -1;        
86
        
87
        private int codeCRS = -1;        
88
        
89
        TransformationManualPanel manual = null;
90
        
91
        public EPSGpanel(){
92
                initialize();
93
        }
94
        
95
        private void initialize(){
96
                this.setLayout(new GridLayout(3,3));
97
                this.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
98
                                
99
                this.add(getGroupRadioButton(), null);                        
100
                this.add(getSearchButton(), null);
101
                this.add(getSearchTextField(), null);
102
                this.add(getInfoCrs(), null);
103
                this.add(getJScrollPane(), null);                
104
        }
105
        
106
        public void connection(){
107
                connect = new EpsgConnection();
108
                connect.setConnectionEPSG();                
109
        }
110
        
111
/*        public JPanel getJPanelEPSG() {         //TODO Eliminar esta funci?n.
112
                if (EPSGpanel == null){
113
                        EPSGpanel = new JPanel();
114
                        EPSGpanel.setLayout(new GridLayout(3,3));
115
                        EPSGpanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
116
                                        
117
                        EPSGpanel.add(getGroupRadioButton(), null);                        
118
                        EPSGpanel.add(getSearchButton(), null);
119
                        EPSGpanel.add(getSearchTextField(), null);
120
                        EPSGpanel.add(getInfoCrs(), null);
121
                        EPSGpanel.add(getJScrollPane(), null);                        
122
                }        
123
                return EPSGpanel;
124
        }*/
125
        
126
        
127
            
128
        private JRadioButton getCodeRadioButton() {
129
                if (codeRadioButton == null) {
130
                        codeRadioButton = new JRadioButton();
131
                        codeRadioButton.setText(PluginServices.getText(this,"Por c?digo"));//setText("By Code EPSG");
132
                        codeRadioButton.setSelected(true);
133
                        codeRadioButton.addActionListener(this);
134
                }
135
                return codeRadioButton;
136
        }
137
                  
138
        private JRadioButton getNameRadioButton() {
139
                if (nameRadioButton == null) {
140
                        nameRadioButton = new JRadioButton();
141
                        nameRadioButton.setText(PluginServices.getText(this,"Por nombre"));
142
                        nameRadioButton.addActionListener(this);
143
                }
144
                return nameRadioButton;
145
        }
146
        
147
        private JRadioButton getAreaRadioButton() {
148
                if (areaRadioButton == null) {
149
                        areaRadioButton = new JRadioButton();
150
                        areaRadioButton.setText(PluginServices.getText(this,"Por ?rea"));
151
                        areaRadioButton.addActionListener(this);
152
                }
153
                return areaRadioButton;
154
        }
155
         
156
        private JPanel getGroupRadioButton() {
157
                if (groupRadioButton == null) {
158
                        groupRadioButton = new JPanel();
159
                        groupRadioButton.setLayout(new GridLayout(1,0));
160
                        groupRadioButton.setPreferredSize(new Dimension(500,30));
161
                        groupRadioButton.add(getLabel());
162
                        groupRadioButton.add(getCodeRadioButton());
163
                        groupRadioButton.add(getNameRadioButton());
164
                        groupRadioButton.add(getAreaRadioButton());
165
                }
166
                return groupRadioButton;
167
        }
168
        
169
        private JLabel getLabel(){
170
                JLabel criterio = new JLabel();
171
                criterio.setPreferredSize(new Dimension(100, 20));
172
                criterio.setText(PluginServices.getText(this, "Criterio de b?squeda: "));
173
                return criterio;
174
        }
175

    
176
        private void searchButton() {
177
                boolean not_valid = false;
178
                searchTextField.setBackground(Color.white);
179
                
180
                if (searchTextField.getText().equals("")) {
181
                        searchTextField.setBackground(new Color(255,204,204));
182
                        JOptionPane.showMessageDialog(this, "Fill the name of CRS.", "Warning...", JOptionPane.WARNING_MESSAGE);
183
                }
184
                
185
                else {
186
            //Eliminar filas en cada nueva bsqueda
187
                        int numRow = dtm.getRowCount();
188
                        while (numRow != 0) {
189
                                numRow = numRow - 1;
190
                                dtm.removeRow(numRow);
191
                        }
192
                        
193
                        //Dependiendo de la opcion se realizada una busqueda
194
                        ResultSet result = null;
195
                        ResultSet result2 = null;
196
                        /*
197
                         * variable que indicara si la busqueda se hace primero en epsg_coordinatereferencesystem
198
                         * o en epsg_area; esto es debido a que HSQLDB no soporta la b?squeda simult?nea en ambas
199
                         * tablas, por lo cual hay que separar la b?squeda
200
                         */
201
                        int bus = 2;                          
202
                        if (codeRadioButton.isSelected()) {
203
                                bus=0;
204
                                key = searchTextField.getText();
205
                                int code = Integer.parseInt(key);
206
                                String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, area_of_use_code, " +
207
                                                                  "source_geogcrs_code, projection_conv_code  " +
208
                                                                  "FROM epsg_coordinatereferencesystem " +                                      
209
                                      "WHERE coord_ref_sys_code = " + code;
210
                                result = Query.select(sentence,connect.getConnection());        
211
                        }
212
                        
213
                        else if (nameRadioButton.isSelected()) {
214
                                bus=0;
215
                                key = searchTextField.getText();
216
                                String key2 = key.substring(0,1);
217
                                String key3 = key.substring(1,key.length());
218
                                key2 = key2.toUpperCase();
219
                                
220
                                String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, " +
221
                                                                        "area_of_use_code, source_geogcrs_code, projection_conv_code " +
222
                                                                          "FROM epsg_coordinatereferencesystem " +                                      
223
                                                                          "WHERE (coord_ref_sys_name LIKE '%" + key + "%') OR (coord_ref_sys_name LIKE '%"+ 
224
                                                                          key.toUpperCase() +"%') " +
225
                                                                          "OR (coord_ref_sys_name LIKE '%" + key2+key3 +"%')";
226
                                result = Query.select(sentence,connect.getConnection());
227
                        }
228
                        
229
                        else {
230
                                bus=1;
231
                                key = searchTextField.getText();
232
                                String key2 = key.substring(0,1);
233
                                String key3 = key.substring(1,key.length());
234
                                key2 = key2.toUpperCase();                                
235
                                
236
                                String sentence = "SELECT area_name, area_of_use, area_code " +
237
                                      "FROM epsg_area " +
238
                                      "WHERE (area_name LIKE '%" + key + "%') OR (area_of_use LIKE '%" + key + "%') "+
239
                                      "OR (area_name LIKE '%" + key.toUpperCase() + "%') OR (area_of_use LIKE '%" + key.toUpperCase() + "%') "+
240
                                      "OR (area_name LIKE '%" + key2+key3 + "%') OR (area_of_use LIKE '%" + key2+key3 + "%') ";
241
                                result = Query.select(sentence,connect.getConnection());                                
242
                        }
243
                        
244
                        if (bus==0){
245
                                try {
246
                                        while(result.next()) {
247
                                                Object[]data = new Object[5];
248
                                                data[0] = String.valueOf(result.getInt("coord_ref_sys_code"));
249
                                                data[1] = result.getString("coord_ref_sys_name");
250
                                                crs_kind = result.getString("coord_ref_sys_kind");
251
                                                data[2] = crs_kind;
252
                                                projection_conv_code = result.getInt("projection_conv_code");
253
                                                
254
                                                int area_of_use_code = Integer.parseInt(result.getString("area_of_use_code"));
255
                                                                                
256
                                                String sentence = "SELECT area_name, area_of_use FROM epsg_area " +
257
                                                                                "WHERE area_code = "+ area_of_use_code ;
258
                                                
259
                                                result2 = Query.select(sentence,connect.getConnection());
260
                                                while(result2.next()){
261
                                                        data[3] = result2.getString("area_name");
262
                                                        data[4] = result2.getString("area_of_use");                                        
263
                                                }
264
                                                if (data[0]!=null && validCRS(projection_conv_code) && valid(crs_kind)){
265
                                                        dtm.addRow(data);
266
                                                }
267
                                        }
268
                                }
269
                                
270
                                catch (SQLException e1) {
271
                                        e1.printStackTrace();
272
                                }
273
                        }
274
                        else if (bus==1){
275
                                try {
276
                                        while(result.next()) {
277
                                                Object[]data = new Object[5];
278
                                                data[3] = result.getString("area_name");
279
                                                data[4] = result.getString("area_of_use");        
280
                                                                                        
281
                                                int area_of_use_code = Integer.parseInt(result.getString("area_code"));
282
                                                                                
283
                                                String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, " +
284
                                                                                "coord_ref_sys_kind, source_geogcrs_code, projection_conv_code " +
285
                                                                                "FROM epsg_coordinatereferencesystem " +
286
                                                                                "WHERE area_of_use_code = "+ area_of_use_code ;
287
                                                
288
                                                result2 = Query.select(sentence,connect.getConnection());
289
                                                while(result2.next()){
290
                                                        data[0] = String.valueOf(result2.getInt("coord_ref_sys_code"));
291
                                                        data[1] = result2.getString("coord_ref_sys_name");
292
                                                        data[2] = result2.getString("coord_ref_sys_kind");
293
                                                        crs_kind = (String)data[2];
294
                                                        projection_conv_code = result2.getInt("projection_conv_code");
295
                                                                                
296
                                                }
297
                                                /*
298
                                                 * Buscaremos solo aquellos CRS cuyas proyecciones esten entre las
299
                                                 * 16 soportadas por proj4 para ello creamos un metodo para validar
300
                                                 * si esta entre estas proyecciones
301
                                                 */                                                
302
                                                if (data[0]!=null && validCRS(projection_conv_code) && valid(crs_kind)){
303
                                                        dtm.addRow(data);
304
                                                }        
305
                                                if (notValid(crs_kind)){
306
                                                        not_valid = true;
307
                                                }
308
                                        }
309
                                } 
310
                                
311
                                catch (SQLException e1) {
312
                                        e1.printStackTrace();
313
                                }
314
                        }
315
                        int numr = dtm.getRowCount();
316
                        if (not_valid){
317
                                JOptionPane.showMessageDialog(this, "CRS no soportado.", "Warning...",
318
                                                JOptionPane.WARNING_MESSAGE);
319
                                not_valid = false;
320
                        }
321
                        else if (numr == 0 ){
322
                        JOptionPane.showMessageDialog(this, "Not Results found.", "Warning...",
323
                                        JOptionPane.WARNING_MESSAGE);
324
                        }
325
                        else{
326
                                this.getJTable().setRowSelectionInterval(0,0);                                
327
                        }
328
                }                
329
        }        
330
        
331
        /*
332
         * metodo auxiliar que hara la comprobacion de si el CRS buscado pertenecera
333
         * a los no soportados por proj4
334
         */
335
        private boolean notValid(String kind){                
336
                for (int i = 0; i< not_soported_crs.length; i++){
337
                        if (kind.equals(not_soported_crs[i])){
338
                                return true;
339
                        }
340
                }
341
                return false;
342
        }
343
        
344
        /*
345
         * Metodo que comprueba si el CRS buscado pertenece a algun tipo de los que soporta
346
         * la aplicacion
347
         */
348
        private boolean valid(String kind){                
349
                for (int i = 0; i< soported_crs.length; i++){
350
                        if (kind.equals(soported_crs[i])){
351
                                return true;
352
                        }
353
                }
354
                return false;
355
        }
356
        
357
        /*
358
         * metodo auxiliar que nos servira para comprobar si la proyeccion del CRS seleccionado
359
         * esta entre las 16 con las que trabaja proj4
360
         */
361
        private boolean validCRS(int projection_conv_code2) {
362
                if (projection_conv_code2 == 0) return true;
363
                String sentence = "SELECT coord_op_method_code " +
364
                                                        "FROM epsg_coordoperation " +
365
                                                        "WHERE coord_op_code = " + projection_conv_code;
366
                ResultSet result = Query.select(sentence,connect.getConnection());
367
                try {
368
                        while (result.next()){
369
                                method_code = result.getInt("coord_op_method_code");
370
                        }
371
                } catch (SQLException e) {
372
                        e.printStackTrace();
373
                }
374
                
375
                for (int i = 0; i< valid_method_code.length; i++){
376
                        if (method_code == valid_method_code[i] ){
377
                                return true;
378
                        }
379
                }                
380
                return false;
381
        }
382

    
383

    
384
        private JButton getSearchButton() {
385
                if (searchButton == null) {
386
                        searchButton = new JButton();
387
                        searchButton.setPreferredSize(new Dimension(75,20));
388
                        searchButton.setText(PluginServices.getText(this,"Buscar"));
389
                        searchButton.setMnemonic('S');
390
                        searchButton.setToolTipText("Search of a CRS by selected criterion");
391
                        searchButton.addActionListener(this);                        
392
                }
393
                return searchButton;
394
        }        
395
        
396
        private JTextField getSearchTextField() {
397
                if (searchTextField == null) {
398
                        searchTextField = new JTextField();
399
                        searchTextField.setPreferredSize(new Dimension(300,20));
400
                        searchTextField.addKeyListener(this);
401
                }
402
                
403
                return searchTextField;
404
        }
405
        
406
        public JTable getJTable() {
407
                if (jTable == null) {
408
                        String[] columnNames= {"Code of CRS","Name of CRS","Type of CRS","Name of Area","Description of Area"};
409
                        Object[][]data = {};                        
410
                        dtm = new DefaultTableModel(data, columnNames)
411
                         {
412
                                public boolean isCellEditable(int row, int column) {
413
                                        return false;
414
                                }
415
                                };
416
                        TableSorter sorter = new TableSorter(dtm);                        
417

    
418
                        jTable = new JTable(sorter);
419
                        sorter.setTableHeader(jTable.getTableHeader());                        
420
                        jTable.setCellSelectionEnabled(false);
421
                        jTable.setRowSelectionAllowed(true);
422
                        jTable.setColumnSelectionAllowed(false);
423
                        jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
424
                        TableColumn column = null;
425
                        for (int i = 0; i < 5; i++) {
426
                            column = jTable.getColumnModel().getColumn(i);
427
                            if (i == 0) {
428
                                column.setPreferredWidth(40); //code column is shorter                                     
429
                            }else if (i == 2) {
430
                                    column.setPreferredWidth(80);
431
                            }
432
                            else {                            
433
                                column.setPreferredWidth(160);
434
                            }
435
                        }                        
436
        }
437
                return jTable;
438
                
439
        }
440
        
441
        public void setCodeCRS(int code) {
442
                codeCRS = code;
443
        }
444
        
445
        public int getCodeCRS() {
446
                return codeCRS;
447
        }        
448
        
449
        private JScrollPane getJScrollPane() {
450
                if (jScrollPane == null) {
451
                        jScrollPane = new JScrollPane();
452
                        jScrollPane.setPreferredSize(new Dimension(500,150));
453
                        jScrollPane.setBorder(
454
                                    BorderFactory.createCompoundBorder(
455
                                        BorderFactory.createCompoundBorder(
456
                                                        BorderFactory.createTitledBorder(PluginServices.getText(this,"Coordinate Reference Systems")),
457
                                                        BorderFactory.createEmptyBorder(5,5,5,5)),
458
                                                        jScrollPane.getBorder()));
459
                        jScrollPane.setViewportView(getJTable());
460
                }
461
                return jScrollPane;
462
        }
463
        
464
        public JButton getInfoCrs() {
465
                if(infoCrs == null) {
466
                        infoCrs = new JButton();
467
                        infoCrs.setPreferredSize(new Dimension(75,20));
468
                        infoCrs.setText(PluginServices.getText(this,"InfoCrs"));                        
469
                        infoCrs.setMnemonic('I');
470
                        infoCrs.setEnabled(false);
471
                        infoCrs.setToolTipText("Mostrar la informacion del Crs selecionado");
472
                        infoCrs.addActionListener(this);
473
                }
474
                return infoCrs;
475
        }
476
        
477
        
478
        public ICrs getProjection() {
479
                try {
480
                        String txt = getWKT();                        
481
                        ICrs crs = new CrsFactory().getCRS(epsg_code, txt); 
482
                        return crs ;
483
                } catch (CrsException e) {
484
                        e.printStackTrace();
485
                }
486
                return null;
487
        }
488
        
489
        
490
        public void setWKT(){
491
                Epsg2wkt wkt = null;
492
                                                
493
                epsg_code = getCodeCRS();
494
                if (epsg_code != -1){                
495
                        /*
496
                         * ahora que he escogido, recojo toda la informacion que me va a hacer falta
497
                         */
498
                        String sentence = "SELECT source_geogcrs_code, projection_conv_code, " +
499
                                        "coord_ref_sys_kind, datum_code " +
500
                                                        "FROM epsg_coordinatereferencesystem " +
501
                                                        "WHERE coord_ref_sys_code = "+ epsg_code ;
502
                        ResultSet result = Query.select(sentence,connect.getConnection());
503
                        
504
                        try {
505
                                result.next();
506
                                source_cod = result.getInt("source_geogcrs_code");
507
                                projection_conv_code = result.getInt("projection_conv_code");
508
                                crs_kind = result.getString("coord_ref_sys_kind");
509
                                datum_code = result.getInt("datum_code");
510
                        } catch (SQLException e1) {
511
                                e1.printStackTrace();
512
                        }
513
                        
514
                        if (datum_code != 0){
515
                                source_yn = true;
516
                                GetCRSepsg ep = new GetCRSepsg(epsg_code, source_yn, source_cod, projection_conv_code, connect);
517
                                ep.Getepsgdata();
518
                        }
519
                        else if (source_cod != 0){
520
                                source_yn = false;
521
                        }
522
                        else source_yn = true;
523
                        
524
                        GetCRSepsg ep = new GetCRSepsg(epsg_code, source_yn, source_cod, projection_conv_code, connect);
525
                        ep.Getepsgdata();
526
                        
527
                        if (crs_kind.equals("geographic 2D") || crs_kind.equals("geographic 3D")){
528
                                wkt = new Epsg2wkt(ep , "geog");                        
529
                        }
530
                        else if (crs_kind.equals("projected")){
531
                                wkt = new Epsg2wkt(ep, "proj");
532
                        }
533
                        else if (crs_kind.equals("compound")){
534
                                wkt = new Epsg2wkt(ep,"comp");
535
                        }
536
                        else if (crs_kind.equals("geocentric")){
537
                                wkt = new Epsg2wkt(ep,"geoc");
538
                        }
539
                }
540
                else {
541
                        JOptionPane.showMessageDialog(this, 
542
                                        "No CRS selected.", 
543
                                        "Warning...", JOptionPane.WARNING_MESSAGE);
544
                        
545
                }
546
                cadWKT = wkt.getWKT();
547
        }
548
                
549
        public String getWKT(){
550
                return cadWKT;
551
        }
552
        
553
        public void setProjection(IProjection crs) {
554
                //setCrs((ICrs) crs);
555
        }
556
        
557
        /*
558
         * Metodo para cargar en el CRS de la capa el CRS de la vista.
559
         * Se utilizar? a la hora de arrancar la definici?n del CRS de la nueva capa
560
         */
561
        public void loadViewCRS(int code){
562
                connection();
563
                String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, area_of_use_code, " +
564
                                                  "source_geogcrs_code, projection_conv_code  " +
565
                                                  "FROM epsg_coordinatereferencesystem " +                                      
566
                                        "WHERE coord_ref_sys_code = " + code;
567
                ResultSet result = Query.select(sentence,connect.getConnection());
568
                
569
                try {
570
                        result.next();
571
                        Object[]data = new Object[5];
572
                        data[0] = String.valueOf(result.getInt("coord_ref_sys_code"));
573
                        data[1] = result.getString("coord_ref_sys_name");
574
                        crs_kind = result.getString("coord_ref_sys_kind");
575
                        data[2] = crs_kind;
576
                        projection_conv_code = result.getInt("projection_conv_code");
577
                        
578
                        int area_of_use_code = Integer.parseInt(result.getString("area_of_use_code"));
579
                                                        
580
                        sentence = "SELECT area_name, area_of_use FROM epsg_area " +
581
                                                        "WHERE area_code = "+ area_of_use_code ;
582
                        
583
                        ResultSet result2 = Query.select(sentence,connect.getConnection());
584
                        result2.next();
585
                        data[3] = result2.getString("area_name");
586
                        data[4] = result2.getString("area_of_use");                                        
587
                        
588
                        dtm.addRow(data);                                        
589
                }
590
                
591
                catch (SQLException e1) {
592
                        e1.printStackTrace();
593
                }
594
        }
595

    
596
        public void keyPressed(KeyEvent e) {
597
                // TODO Auto-generated method stub
598
                if (e.getSource() == this.getSearchTextField()) {
599
                        if (e.getKeyCode() == 10) {
600
                                searchButton();
601
                        }
602
                        if (codeRadioButton.isSelected()){
603
                                if ((e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || 
604
                                                (e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){                                                
605
                                }
606
                                else {
607
                                        JOptionPane.showMessageDialog(EPSGpanel.this, 
608
                                                        "Only number format.", 
609
                                                        "Warning...", JOptionPane.WARNING_MESSAGE);
610
                                        String aux = searchTextField.getText();
611
                                        if (aux.length() == 1 || aux.length() == 0){
612
                                                searchTextField.setText("");
613
                                        }
614
                                        else {
615
                                                searchTextField.setText(aux.substring(0, aux.length()-1));
616
                                        }
617
                                }
618
                        }
619
                }
620
                
621
        }
622

    
623
        public void keyReleased(KeyEvent e) {
624
                // TODO Auto-generated method stub
625
                
626
        }
627

    
628
        public void keyTyped(KeyEvent e) {
629
                // TODO Auto-generated method stub
630
                
631
        }
632

    
633
        public void actionPerformed(ActionEvent e) {
634
                // TODO Auto-generated method stub
635
                if (e.getSource() == this.getCodeRadioButton()) {
636
                        searchTextField.setText("");
637
                        codeRadioButton.setSelected(true);
638
                        nameRadioButton.setSelected(false);
639
                        areaRadioButton.setSelected(false);
640
                }
641
                
642
                if (e.getSource() == this.getNameRadioButton()) {
643
                        searchTextField.setText("");
644
                        nameRadioButton.setSelected(true);
645
                        codeRadioButton.setSelected(false);
646
                        areaRadioButton.setSelected(false);
647
                }
648

    
649
                if (e.getSource() == this.getAreaRadioButton()) {
650
                        searchTextField.setText("");
651
                        areaRadioButton.setSelected(true);
652
                        codeRadioButton.setSelected(false);
653
                        nameRadioButton.setSelected(false);
654
                }
655
                
656
                if (e.getSource() == this.getSearchButton()) {
657
                        searchTextField.setBackground(Color.white);
658
                        if (searchTextField.getText().equals("")) {
659
                                searchTextField.setBackground(new Color(255,204,204));
660
                                JOptionPane.showMessageDialog(EPSGpanel.this, 
661
                                                "Fill the key-word of the search.", 
662
                                                "Warning...", JOptionPane.WARNING_MESSAGE);
663
                        }
664
                        else {
665
                                searchButton();
666
                        }
667
                }
668
                
669
                if (e.getSource() == this.getInfoCrs()) {
670
                        InfoCRSPanel info = new InfoCRSPanel(getProjection());
671
                        info.setSize(new Dimension(550,350));
672
                        info.setLayout(new GridLayout(0,1));
673
                        info.setLayout(new FlowLayout(FlowLayout.LEFT,10,5));
674
                        PluginServices.getMDIManager().addWindow(info);
675
                }
676
        }
677

    
678
}