Revision 10786 branches/F2/extensions/extJCRS/src/org/gvsig/crs/gui/panels/EPSGpanel.java
EPSGpanel.java | ||
---|---|---|
40 | 40 |
|
41 | 41 |
package org.gvsig.crs.gui.panels; |
42 | 42 |
|
43 |
import java.awt.BorderLayout; |
|
43 | 44 |
import java.awt.Color; |
44 |
import java.awt.Component; |
|
45 | 45 |
import java.awt.Dimension; |
46 | 46 |
import java.awt.FlowLayout; |
47 | 47 |
import java.awt.GridLayout; |
... | ... | |
49 | 49 |
import java.awt.event.ActionListener; |
50 | 50 |
import java.awt.event.KeyEvent; |
51 | 51 |
import java.awt.event.KeyListener; |
52 |
import java.awt.event.MouseAdapter; |
|
53 |
import java.awt.event.MouseEvent; |
|
54 | 52 |
import java.sql.ResultSet; |
55 | 53 |
import java.sql.SQLException; |
56 |
import java.util.ArrayList; |
|
57 | 54 |
|
58 | 55 |
import javax.swing.BorderFactory; |
56 |
import javax.swing.ButtonGroup; |
|
59 | 57 |
import javax.swing.JButton; |
60 | 58 |
import javax.swing.JLabel; |
61 | 59 |
import javax.swing.JOptionPane; |
62 | 60 |
import javax.swing.JPanel; |
63 | 61 |
import javax.swing.JRadioButton; |
64 |
import javax.swing.JScrollBar; |
|
65 | 62 |
import javax.swing.JScrollPane; |
66 | 63 |
import javax.swing.JTable; |
67 | 64 |
import javax.swing.JTextField; |
68 | 65 |
import javax.swing.ListSelectionModel; |
69 |
import javax.swing.event.DocumentEvent; |
|
70 |
import javax.swing.event.DocumentListener; |
|
71 | 66 |
import javax.swing.table.DefaultTableModel; |
72 | 67 |
import javax.swing.table.TableColumn; |
73 | 68 |
|
... | ... | |
88 | 83 |
* EPSG, realiza la b?squeda y filtra los v?lidos. |
89 | 84 |
* |
90 | 85 |
* @author Jos? Luis G?mez Mart?nez (jolugomar@gmail.com) |
86 |
* @author Luisa Marina Fern?ndez (luisam.fernandez@uclm.es) |
|
91 | 87 |
* |
92 | 88 |
*/ |
93 | 89 |
public class EPSGpanel extends JPanel implements KeyListener, ActionListener{ |
94 | 90 |
|
95 |
/** |
|
96 |
* |
|
97 |
*/ |
|
98 | 91 |
private static final long serialVersionUID = 1L; |
99 |
public JPanel EPSGpanel = null; |
|
100 |
|
|
92 |
|
|
101 | 93 |
String cadWKT = ""; |
94 |
String cad_valida = ""; |
|
95 |
public String key; |
|
96 |
public String crs_kind = null; |
|
97 |
String[] soported_crs = {"projected","geographic 2D","geographic 3D", "engineering", "vertical", "compound", "geocentric"}; |
|
98 |
String[] not_soported_crs = {}; |
|
102 | 99 |
|
103 | 100 |
int iteracion = 0; |
104 |
boolean tecla_valida = false; |
|
105 |
String cad_valida = ""; |
|
106 |
|
|
107 | 101 |
int transf = 0; |
108 |
public int epsg_code = 0; |
|
109 |
boolean source_yn = false; |
|
110 | 102 |
int source_cod = 0; |
111 | 103 |
int method_code = 0; |
112 | 104 |
int datum_code = 0; |
113 | 105 |
int projection_conv_code = 0; |
114 |
public String crs_kind = null; |
|
106 |
public int epsg_code = 0; |
|
107 |
public int selectedRowTable = -1; |
|
108 |
private int codeCRS = -1; |
|
115 | 109 |
int[] valid_method_code = {9800, 9801, 9802, 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810, |
116 | 110 |
9811, 9812, 9813, 9814, 9815, 9816, 9817, 9602, 9659, 9818, 9819, 9820, 9822, |
117 | 111 |
9827}; |
118 | 112 |
|
119 |
String[] soported_crs = {"projected","geographic 2D","geographic 3D", "engineering", "vertical", "compound", "geocentric"}; |
|
120 |
String[] not_soported_crs = {}; |
|
121 | 113 |
|
114 |
boolean tecla_valida = false; |
|
115 |
boolean source_yn = false; |
|
116 |
|
|
117 |
|
|
122 | 118 |
private JRadioButton codeRadioButton = null; |
123 | 119 |
private JRadioButton nameRadioButton = null; |
124 | 120 |
private JRadioButton areaRadioButton = null; |
121 |
private ButtonGroup optGroup; |
|
125 | 122 |
private JPanel groupRadioButton = null; |
126 | 123 |
|
127 | 124 |
public EpsgConnection connect = null; |
128 |
|
|
125 |
public JPanel EPSGpanel = null; |
|
126 |
private JLabel lblCriterio; |
|
129 | 127 |
private JButton infoCrs = null; |
130 | 128 |
private JButton searchButton = null; |
131 | 129 |
private JTextField searchTextField = null; |
132 | 130 |
public JTable jTable = null; |
133 | 131 |
private JScrollPane jScrollPane = null; |
134 | 132 |
public DefaultTableModel dtm = null; |
135 |
public String key; |
|
136 |
public int selectedRowTable = -1; |
|
137 |
|
|
138 |
private int codeCRS = -1; |
|
139 | 133 |
public TableSorter sorter = null; |
140 |
|
|
134 |
|
|
135 |
/** |
|
136 |
* Construye el Objeto EpsgPanel |
|
137 |
* |
|
138 |
*/ |
|
141 | 139 |
public EPSGpanel(){ |
142 | 140 |
initialize(); |
143 | 141 |
} |
144 |
|
|
142 |
/* |
|
143 |
* Define las propiedades y agrega los componentes del EPSGPanel |
|
144 |
*/ |
|
145 | 145 |
private void initialize(){ |
146 |
this.setLayout(new GridLayout(3,3)); |
|
147 |
this.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
|
148 |
|
|
149 |
this.add(getGroupRadioButton(), null); |
|
150 |
this.add(getSearchButton(), null); |
|
151 |
this.add(getSearchTextField(), null); |
|
152 |
this.add(getInfoCrs(), null); |
|
153 |
this.add(getJScrollPane(), null); |
|
146 |
this.setLayout(new BorderLayout()); |
|
147 |
JPanel pNorth=new JPanel(); |
|
148 |
pNorth.setLayout(new GridLayout(2,1)); |
|
149 |
pNorth.setBorder(BorderFactory.createEmptyBorder(3,3,3,3)); |
|
150 |
pNorth.add(getGroupRadioButton()); |
|
151 |
JPanel pInNorth = new JPanel(); |
|
152 |
pInNorth.setLayout(new FlowLayout(FlowLayout.LEFT,10,1)); |
|
153 |
pInNorth.add(getSearchButton()); |
|
154 |
pInNorth.add(getSearchTextField()); |
|
155 |
pNorth.add(pInNorth); |
|
156 |
this.add(pNorth,BorderLayout.NORTH); |
|
157 |
this.add(getJScrollPane(), BorderLayout.CENTER); |
|
158 |
JPanel pSouth=new JPanel(new FlowLayout(FlowLayout.RIGHT,10,3)); |
|
159 |
pSouth.add(getInfoCrs()); |
|
160 |
this.add(pSouth,BorderLayout.SOUTH); |
|
154 | 161 |
} |
155 |
|
|
162 |
/** |
|
163 |
* Establece la conexi?n con la Base de Datos de la Epsg |
|
164 |
* |
|
165 |
*/ |
|
156 | 166 |
public void connection(){ |
157 | 167 |
connect = new EpsgConnection(); |
158 | 168 |
connect.setConnectionEPSG(); |
159 | 169 |
} |
160 |
|
|
170 |
/** |
|
171 |
* Inicializa el bot?n de opci?n 'c?digo' |
|
172 |
* @return |
|
173 |
*/ |
|
161 | 174 |
private JRadioButton getCodeRadioButton() { |
162 | 175 |
if (codeRadioButton == null) { |
163 | 176 |
codeRadioButton = new JRadioButton(); |
... | ... | |
167 | 180 |
} |
168 | 181 |
return codeRadioButton; |
169 | 182 |
} |
170 |
|
|
183 |
/** |
|
184 |
* Inicializa el bot?n de opci?n 'nombre' |
|
185 |
* @return |
|
186 |
*/ |
|
171 | 187 |
private JRadioButton getNameRadioButton() { |
172 | 188 |
if (nameRadioButton == null) { |
173 | 189 |
nameRadioButton = new JRadioButton(); |
... | ... | |
176 | 192 |
} |
177 | 193 |
return nameRadioButton; |
178 | 194 |
} |
179 |
|
|
195 |
/** |
|
196 |
* Inicializa el bot?n de opci?n 'Area' |
|
197 |
* @return |
|
198 |
*/ |
|
180 | 199 |
private JRadioButton getAreaRadioButton() { |
181 | 200 |
if (areaRadioButton == null) { |
182 | 201 |
areaRadioButton = new JRadioButton(); |
... | ... | |
185 | 204 |
} |
186 | 205 |
return areaRadioButton; |
187 | 206 |
} |
188 |
|
|
207 |
/** |
|
208 |
* Obtiene el panel con todos los botones de opci?n |
|
209 |
* @return |
|
210 |
*/ |
|
189 | 211 |
private JPanel getGroupRadioButton() { |
190 | 212 |
if (groupRadioButton == null) { |
191 | 213 |
groupRadioButton = new JPanel(); |
192 |
groupRadioButton.setLayout(new GridLayout(1,0)); |
|
193 |
groupRadioButton.setPreferredSize(new Dimension(500,30)); |
|
194 |
groupRadioButton.add(getLabel()); |
|
214 |
groupRadioButton.setLayout(new GridLayout(1,4)); |
|
215 |
groupRadioButton.add(getLblCriterio()); |
|
195 | 216 |
groupRadioButton.add(getCodeRadioButton()); |
196 | 217 |
groupRadioButton.add(getNameRadioButton()); |
197 | 218 |
groupRadioButton.add(getAreaRadioButton()); |
219 |
//agrupar los botones |
|
220 |
getOptGroup(); |
|
198 | 221 |
} |
199 | 222 |
return groupRadioButton; |
200 | 223 |
} |
201 |
|
|
202 |
private JLabel getLabel(){ |
|
203 |
JLabel criterio = new JLabel(); |
|
204 |
criterio.setPreferredSize(new Dimension(100, 20)); |
|
205 |
criterio.setText(PluginServices.getText(this, "criterio_busqueda")+":"); |
|
206 |
return criterio; |
|
224 |
/** |
|
225 |
* Inicializa el laber 'Criterio de b?squeda' |
|
226 |
* @return |
|
227 |
*/ |
|
228 |
private JLabel getLblCriterio(){ |
|
229 |
lblCriterio = new JLabel(); |
|
230 |
lblCriterio.setText(PluginServices.getText(this, "criterio_busqueda")+":"); |
|
231 |
return lblCriterio; |
|
207 | 232 |
} |
208 | 233 |
|
209 | 234 |
/** |
... | ... | |
434 | 459 |
return false; |
435 | 460 |
} |
436 | 461 |
|
437 |
|
|
462 |
/** |
|
463 |
* Inicializa el bot?n de b?squeda |
|
464 |
* @return |
|
465 |
*/ |
|
438 | 466 |
private JButton getSearchButton() { |
439 | 467 |
if (searchButton == null) { |
440 | 468 |
searchButton = new JButton(); |
441 | 469 |
searchButton.setPreferredSize(new Dimension(75,20)); |
442 | 470 |
searchButton.setText(PluginServices.getText(this,"buscar")); |
443 | 471 |
searchButton.setMnemonic('S'); |
472 |
//TODO: Poner el tooltip text con Plugin Services |
|
444 | 473 |
searchButton.setToolTipText("Search of a CRS by selected criterion"); |
445 | 474 |
searchButton.addActionListener(this); |
446 | 475 |
} |
447 | 476 |
return searchButton; |
448 | 477 |
} |
449 |
|
|
478 |
/** |
|
479 |
* Inicializa el cuadro de texto en el que se introduce el dato a buscar |
|
480 |
* @return |
|
481 |
*/ |
|
450 | 482 |
private JTextField getSearchTextField() { |
451 | 483 |
if (searchTextField == null) { |
452 | 484 |
searchTextField = new JTextField(); |
453 |
searchTextField.setPreferredSize(new Dimension(300,20));
|
|
485 |
searchTextField.setPreferredSize(new Dimension(350,20));
|
|
454 | 486 |
searchTextField.addKeyListener(this); |
455 | 487 |
} |
456 |
|
|
457 | 488 |
return searchTextField; |
458 | 489 |
} |
459 |
|
|
490 |
/** |
|
491 |
* Inicializa la tabla que se utiliza para mostrar |
|
492 |
* los resultados de la b?squeda |
|
493 |
* @return |
|
494 |
*/ |
|
460 | 495 |
public JTable getJTable() { |
461 | 496 |
if (jTable == null) { |
462 | 497 |
String[] columnNames= {PluginServices.getText(this,"codigo"), |
... | ... | |
467 | 502 |
Object[][]data = {}; |
468 | 503 |
dtm = new DefaultTableModel(data, columnNames) |
469 | 504 |
{ |
505 |
private static final long serialVersionUID = 1L; |
|
470 | 506 |
public boolean isCellEditable(int row, int column) { |
471 | 507 |
return false; |
472 | 508 |
} |
... | ... | |
512 | 548 |
return jTable; |
513 | 549 |
|
514 | 550 |
} |
515 |
|
|
551 |
/** |
|
552 |
* Establece el c?digo se CRS |
|
553 |
* @param code |
|
554 |
*/ |
|
516 | 555 |
public void setCodeCRS(int code) { |
517 | 556 |
codeCRS = code; |
518 | 557 |
} |
519 |
|
|
558 |
/** |
|
559 |
* Obtiene el c?digo de CRS |
|
560 |
* @return |
|
561 |
*/ |
|
520 | 562 |
public int getCodeCRS() { |
521 | 563 |
return codeCRS; |
522 | 564 |
} |
523 |
|
|
565 |
/** |
|
566 |
* Inicializa el panel que contiene la tabla de resultados |
|
567 |
* @return |
|
568 |
*/ |
|
524 | 569 |
private JScrollPane getJScrollPane() { |
525 | 570 |
if (jScrollPane == null) { |
526 | 571 |
jScrollPane = new JScrollPane(getJTable(),JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); |
527 | 572 |
jScrollPane.setPreferredSize(new Dimension(500,150)); |
528 | 573 |
jScrollPane.setBorder( |
529 |
BorderFactory.createCompoundBorder( |
|
530 |
BorderFactory.createCompoundBorder( |
|
531 |
BorderFactory.createTitledBorder(PluginServices.getText(this,"coordinate_reference_systems")), |
|
532 |
BorderFactory.createEmptyBorder(5,5,5,5)), |
|
533 |
jScrollPane.getBorder())); |
|
574 |
BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(3,3,3,3),jScrollPane.getBorder())); |
|
575 |
|
|
534 | 576 |
jScrollPane.setViewportView(getJTable()); |
535 | 577 |
} |
536 | 578 |
return jScrollPane; |
537 | 579 |
} |
538 |
|
|
580 |
/** |
|
581 |
* Inicializa el bot?n que muestra la informaci?n de CRS seleccionado |
|
582 |
* @return |
|
583 |
*/ |
|
539 | 584 |
public JButton getInfoCrs() { |
540 | 585 |
if(infoCrs == null) { |
541 | 586 |
infoCrs = new JButton(); |
542 |
infoCrs.setPreferredSize(new Dimension(75,20));
|
|
587 |
infoCrs.setPreferredSize(new Dimension(85,20));
|
|
543 | 588 |
infoCrs.setText(PluginServices.getText(this,"infocrs")); |
544 | 589 |
infoCrs.setMnemonic('I'); |
545 | 590 |
infoCrs.setEnabled(false); |
591 |
//TODO Poner el tooltipText con Plugin Services |
|
546 | 592 |
infoCrs.setToolTipText("Mostrar la informacion del Crs selecionado"); |
547 | 593 |
infoCrs.addActionListener(this); |
548 | 594 |
} |
... | ... | |
673 | 719 |
e1.printStackTrace(); |
674 | 720 |
} |
675 | 721 |
} |
676 |
|
|
677 |
public void keyPressed(KeyEvent e) { |
|
678 |
// TODO Auto-generated method stub |
|
722 |
/** |
|
723 |
* Controla si se pulsa intro en el cuadro de texto, |
|
724 |
* en ese caso se interpreta como si hubiese pulsado el bot?n 'Buscar' |
|
725 |
*/ |
|
726 |
public void keyPressed(KeyEvent e) { |
|
679 | 727 |
if (e.getSource() == this.getSearchTextField()) { |
680 | 728 |
if (e.getKeyCode() == 10) { |
681 | 729 |
searchButton(); |
... | ... | |
684 | 732 |
} |
685 | 733 |
|
686 | 734 |
public void keyReleased(KeyEvent e) { |
687 |
// TODO Auto-generated method stub |
|
735 |
|
|
688 | 736 |
} |
689 | 737 |
|
690 | 738 |
public void keyTyped(KeyEvent e) { |
691 |
// TODO Auto-generated method stub |
|
692 | 739 |
|
693 | 740 |
} |
694 | 741 |
|
... | ... | |
697 | 744 |
* de la EPSG. |
698 | 745 |
*/ |
699 | 746 |
public void actionPerformed(ActionEvent e) { |
700 |
// TODO Auto-generated method stub |
|
747 |
/*Si el objeto que genera el evento es el RadioButton 'Codigo'--> |
|
748 |
resetea el texto de b?squeda*/ |
|
701 | 749 |
if (e.getSource() == this.getCodeRadioButton()) { |
702 | 750 |
searchTextField.setText(""); |
703 |
codeRadioButton.setSelected(true); |
|
704 |
nameRadioButton.setSelected(false); |
|
705 |
areaRadioButton.setSelected(false); |
|
706 | 751 |
} |
707 |
|
|
752 |
/*Si el objeto que genera el evento es el RadioButton 'Nombre'--> |
|
753 |
resetea el texto de b?squeda*/ |
|
708 | 754 |
if (e.getSource() == this.getNameRadioButton()) { |
709 | 755 |
searchTextField.setText(""); |
710 |
nameRadioButton.setSelected(true); |
|
711 |
codeRadioButton.setSelected(false); |
|
712 |
areaRadioButton.setSelected(false); |
|
713 | 756 |
} |
714 |
|
|
757 |
/*Si el objeto que genera el evento es el RadioButton 'Area'--> |
|
758 |
resetea el texto de b?squeda*/ |
|
715 | 759 |
if (e.getSource() == this.getAreaRadioButton()) { |
716 | 760 |
searchTextField.setText(""); |
717 |
areaRadioButton.setSelected(true); |
|
718 |
codeRadioButton.setSelected(false); |
|
719 |
nameRadioButton.setSelected(false); |
|
720 | 761 |
} |
721 |
|
|
762 |
/*Si el objeto que genera el evento es el JButton 'Buscar'--> |
|
763 |
Comprueba que no est? vacio*/ |
|
722 | 764 |
if (e.getSource() == this.getSearchButton()) { |
723 | 765 |
searchTextField.setBackground(Color.white); |
724 | 766 |
if (searchTextField.getText().equals("")) { |
... | ... | |
731 | 773 |
searchButton(); |
732 | 774 |
} |
733 | 775 |
} |
734 |
|
|
776 |
/*Si el objeto que genera el evento es el JButton 'InfoCrs' |
|
777 |
se muestra la informaci?n ralicionada con el Crs seleccionado en la tabla*/ |
|
735 | 778 |
if (e.getSource() == this.getInfoCrs()) { |
736 | 779 |
InfoCRSPanel info = new InfoCRSPanel(getProjection()); |
737 |
info.setSize(new Dimension(550,350)); |
|
738 |
info.setLayout(new GridLayout(0,1)); |
|
739 |
info.setLayout(new FlowLayout(FlowLayout.LEFT,10,5)); |
|
740 | 780 |
PluginServices.getMDIManager().addWindow(info); |
741 | 781 |
} |
742 | 782 |
} |
783 |
/** |
|
784 |
* Agrupa los botones de opci?n |
|
785 |
* @return |
|
786 |
*/ |
|
787 |
public ButtonGroup getOptGroup() { |
|
788 |
if (optGroup==null){ |
|
789 |
optGroup=new ButtonGroup(); |
|
790 |
optGroup.add(getCodeRadioButton()); |
|
791 |
optGroup.add(getNameRadioButton()); |
|
792 |
optGroup.add(getAreaRadioButton()); |
|
793 |
} |
|
794 |
return optGroup; |
|
795 |
} |
|
743 | 796 |
} |
Also available in: Unified diff