svn-gvsig-desktop / trunk / libraries / libJCRS / src / org / gvsig / crs / ui / CRSSelectionPanel.java @ 7020
History | View | Annotate | Download (19.7 KB)
1 |
package org.gvsig.crs.ui; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.FlowLayout; |
6 |
import java.awt.GridLayout; |
7 |
import java.awt.event.ActionEvent; |
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.ICrs; |
30 |
import org.gvsig.crs.Query; |
31 |
import org.gvsig.crs.ogr.Epsg2wkt; |
32 |
import org.gvsig.crs.ogr.GetCRSepsg; |
33 |
|
34 |
import com.iver.andami.PluginServices; |
35 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanel; |
36 |
|
37 |
public class CRSSelectionPanel extends JPanel { |
38 |
/**
|
39 |
*
|
40 |
*/
|
41 |
private static final long serialVersionUID = 1L; |
42 |
JLabel jLabel = null; |
43 |
JTextField crsTextFld = null; |
44 |
|
45 |
ProjChooserPanel pcp; |
46 |
|
47 |
String cadWKT = ""; |
48 |
|
49 |
int transf = 0; |
50 |
int epsg_code = 0; |
51 |
boolean source_yn = false; |
52 |
int source_cod = 0; |
53 |
int method_code = 0; |
54 |
int projection_conv_code = 0; |
55 |
int[] valid_method_code = {9800, 9801, 9802, 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810, |
56 |
9811, 9812, 9813, 9814, 9815, 9816, 9817}; |
57 |
boolean select = false; |
58 |
|
59 |
private JRadioButton codeRadioButton = null; |
60 |
private JRadioButton nameRadioButton = null; |
61 |
private JRadioButton areaRadioButton = null; |
62 |
private JPanel groupRadioButton = null; |
63 |
|
64 |
private JButton infoCrs = null; |
65 |
private JButton searchButton = null; |
66 |
private JTextField searchTextField = null; |
67 |
private JTable jTable = null; |
68 |
private JScrollPane jScrollPane = null; |
69 |
public DefaultTableModel dtm = null; |
70 |
public DefaultTableModel dtm2 = null; |
71 |
public String key; |
72 |
public int selectedRowTable = -1; |
73 |
public int selectedRowTable2 = -1; |
74 |
|
75 |
private int codeCRS = -1; |
76 |
|
77 |
/*
|
78 |
* distinguira entre si es el panel para seleccion solo de CRS o para el de CRS y
|
79 |
* transformacion
|
80 |
*/
|
81 |
|
82 |
public CRSSelectionPanel() {
|
83 |
super();
|
84 |
pcp = new ProjChooserPanel();
|
85 |
initialize(); |
86 |
} |
87 |
|
88 |
private void initialize() { |
89 |
getJPanel(); |
90 |
} |
91 |
|
92 |
private void getJPanel() { |
93 |
this.add(getSearchButton(), null); |
94 |
this.add(getSearchTextField(), null); |
95 |
this.add(getInfoCrs(), null); |
96 |
this.add(getGroupRadioButton(), null); |
97 |
this.add(getJScrollPane(), null); |
98 |
} |
99 |
|
100 |
private void codeRadioButton_actionPerformed(ActionEvent e) { |
101 |
searchTextField.setText("");
|
102 |
nameRadioButton.setSelected(false);
|
103 |
areaRadioButton.setSelected(false);
|
104 |
} |
105 |
|
106 |
private JRadioButton getCodeRadioButton() { |
107 |
if (codeRadioButton == null) { |
108 |
codeRadioButton = new JRadioButton(); |
109 |
codeRadioButton.setText("By Code EPSG");
|
110 |
codeRadioButton.setSelected(true);
|
111 |
codeRadioButton.addActionListener(new java.awt.event.ActionListener() {
|
112 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
113 |
codeRadioButton_actionPerformed(e); |
114 |
} |
115 |
}); |
116 |
} |
117 |
return codeRadioButton;
|
118 |
} |
119 |
|
120 |
private void nameRadioButton_actionPerformed(ActionEvent e) { |
121 |
searchTextField.setText("");
|
122 |
codeRadioButton.setSelected(false);
|
123 |
areaRadioButton.setSelected(false);
|
124 |
} |
125 |
|
126 |
private JRadioButton getNameRadioButton() { |
127 |
if (nameRadioButton == null) { |
128 |
nameRadioButton = new JRadioButton(); |
129 |
nameRadioButton.setText("By CRS Name");
|
130 |
nameRadioButton.addActionListener(new java.awt.event.ActionListener() {
|
131 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
132 |
nameRadioButton_actionPerformed(e); |
133 |
} |
134 |
}); |
135 |
} |
136 |
return nameRadioButton;
|
137 |
} |
138 |
|
139 |
private void areaRadioButton_actionPerformed(ActionEvent e) { |
140 |
searchTextField.setText("");
|
141 |
codeRadioButton.setSelected(false);
|
142 |
nameRadioButton.setSelected(false);
|
143 |
} |
144 |
|
145 |
private JRadioButton getAreaRadioButton() { |
146 |
if (areaRadioButton == null) { |
147 |
areaRadioButton = new JRadioButton(); |
148 |
areaRadioButton.setText("By Area of Use");
|
149 |
areaRadioButton.addActionListener(new java.awt.event.ActionListener() {
|
150 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
151 |
areaRadioButton_actionPerformed(e); |
152 |
} |
153 |
}); |
154 |
} |
155 |
return areaRadioButton;
|
156 |
} |
157 |
|
158 |
private JPanel getGroupRadioButton() { |
159 |
if (groupRadioButton == null) { |
160 |
groupRadioButton = new JPanel(); |
161 |
groupRadioButton.setLayout(new GridLayout(1,0)); |
162 |
groupRadioButton.setPreferredSize(new Dimension(400,50)); |
163 |
groupRadioButton.add(getCodeRadioButton()); |
164 |
groupRadioButton.add(getNameRadioButton()); |
165 |
groupRadioButton.add(getAreaRadioButton()); |
166 |
} |
167 |
return groupRadioButton;
|
168 |
} |
169 |
|
170 |
private void searchButton_actionPerformed(ActionEvent e) { |
171 |
searchTextField.setBackground(Color.white);
|
172 |
|
173 |
if (searchTextField.getText().equals("")) { |
174 |
searchTextField.setBackground(new Color(255,204,204)); |
175 |
JOptionPane.showMessageDialog(this, "Fill the name of CRS.", "Warning...", JOptionPane.WARNING_MESSAGE); |
176 |
} |
177 |
|
178 |
else {
|
179 |
//Eliminar filas en cada nueva bsqueda
|
180 |
int numRow = dtm.getRowCount();
|
181 |
while (numRow != 0) { |
182 |
numRow = numRow - 1;
|
183 |
dtm.removeRow(numRow); |
184 |
} |
185 |
|
186 |
//Dependiendo de la opcion se realizada una busqueda
|
187 |
ResultSet result = null; |
188 |
ResultSet result2 = null; |
189 |
/*
|
190 |
* variable que indicara si la busqueda se hace primero en epsg_coordinatereferencesystem
|
191 |
* o en epsg_area; esto es debido a que HSQLDB no soporta la b?squeda simult?nea en ambas
|
192 |
* tablas, por lo cual hay que separar la b?squeda
|
193 |
*/
|
194 |
int bus = 2; |
195 |
if (codeRadioButton.isSelected()) {
|
196 |
bus=0;
|
197 |
key = searchTextField.getText(); |
198 |
int code = Integer.parseInt(key); |
199 |
String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, area_of_use_code, " + |
200 |
"source_geogcrs_code, projection_conv_code " +
|
201 |
"FROM epsg_coordinatereferencesystem " +
|
202 |
"WHERE coord_ref_sys_code = " + code;
|
203 |
result = Query.select(sentence,pcp.connect.getConnection());
|
204 |
} |
205 |
|
206 |
else if (nameRadioButton.isSelected()) { |
207 |
bus=0;
|
208 |
key = searchTextField.getText(); |
209 |
String key2 = key.substring(0,1); |
210 |
String key3 = key.substring(1,key.length()); |
211 |
key2 = key2.toUpperCase(); |
212 |
|
213 |
String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, " + |
214 |
"area_of_use_code, source_geogcrs_code, projection_conv_code " +
|
215 |
"FROM epsg_coordinatereferencesystem " +
|
216 |
"WHERE (coord_ref_sys_name LIKE '%" + key + "%') OR (coord_ref_sys_name LIKE '%"+ |
217 |
key.toUpperCase() +"%') " +
|
218 |
"OR (coord_ref_sys_name LIKE '%" + key2+key3 +"%')"; |
219 |
result = Query.select(sentence,pcp.connect.getConnection());
|
220 |
} |
221 |
|
222 |
else {
|
223 |
bus=1;
|
224 |
key = searchTextField.getText(); |
225 |
String key2 = key.substring(0,1); |
226 |
String key3 = key.substring(1,key.length()); |
227 |
key2 = key2.toUpperCase(); |
228 |
|
229 |
String sentence = "SELECT area_name, area_of_use, area_code " + |
230 |
"FROM epsg_area " +
|
231 |
"WHERE (area_name LIKE '%" + key + "%') OR (area_of_use LIKE '%" + key + "%') "+ |
232 |
"OR (area_name LIKE '%" + key.toUpperCase() + "%') OR (area_of_use LIKE '%" + key.toUpperCase() + "%') "+ |
233 |
"OR (area_name LIKE '%" + key2+key3 + "%') OR (area_of_use LIKE '%" + key2+key3 + "%') "; |
234 |
result = Query.select(sentence,pcp.connect.getConnection());
|
235 |
} |
236 |
String crs_kind = null; |
237 |
if (bus==0){ |
238 |
try {
|
239 |
while(result.next()) {
|
240 |
Object[]data = new Object[5]; |
241 |
data[0] = String.valueOf(result.getInt("coord_ref_sys_code")); |
242 |
data[1] = result.getString("coord_ref_sys_name"); |
243 |
crs_kind = result.getString("coord_ref_sys_kind");
|
244 |
data[2] = crs_kind;
|
245 |
projection_conv_code = result.getInt("projection_conv_code");
|
246 |
|
247 |
int area_of_use_code = Integer.parseInt(result.getString("area_of_use_code")); |
248 |
|
249 |
String sentence = "SELECT area_name, area_of_use FROM epsg_area " + |
250 |
"WHERE area_code = "+ area_of_use_code ;
|
251 |
|
252 |
result2 = Query.select(sentence,pcp.connect.getConnection());
|
253 |
while(result2.next()){
|
254 |
data[3] = result2.getString("area_name"); |
255 |
data[4] = result2.getString("area_of_use"); |
256 |
} |
257 |
if (data[0]!=null && validCRS(projection_conv_code) && (crs_kind.equals("projected") |
258 |
|| crs_kind.equals("geographic 2D"))){
|
259 |
dtm.addRow(data); |
260 |
} |
261 |
} |
262 |
} |
263 |
|
264 |
catch (SQLException e1) { |
265 |
e1.printStackTrace(); |
266 |
} |
267 |
} |
268 |
else if (bus==1){ |
269 |
try {
|
270 |
while(result.next()) {
|
271 |
Object[]data = new Object[5]; |
272 |
data[3] = result.getString("area_name"); |
273 |
data[4] = result.getString("area_of_use"); |
274 |
|
275 |
int area_of_use_code = Integer.parseInt(result.getString("area_code")); |
276 |
|
277 |
String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, " + |
278 |
"coord_ref_sys_kind, source_geogcrs_code, projection_conv_code " +
|
279 |
"FROM epsg_coordinatereferencesystem " +
|
280 |
"WHERE area_of_use_code = "+ area_of_use_code ;
|
281 |
|
282 |
result2 = Query.select(sentence,pcp.connect.getConnection());
|
283 |
while(result2.next()){
|
284 |
data[0] = String.valueOf(result2.getInt("coord_ref_sys_code")); |
285 |
data[1] = result2.getString("coord_ref_sys_name"); |
286 |
data[2] = result2.getString("coord_ref_sys_kind"); |
287 |
crs_kind = (String)data[2]; |
288 |
projection_conv_code = result2.getInt("projection_conv_code");
|
289 |
|
290 |
} |
291 |
/*
|
292 |
* Buscaremos solo aquellos CRS cuyas proyecciones esten entre las
|
293 |
* 16 soportadas por proj4 para ello creamos un metodo para validar
|
294 |
* si esta entre estas proyecciones
|
295 |
*/
|
296 |
if (data[0]!=null && validCRS(projection_conv_code) && (crs_kind.equals("projected") |
297 |
|| crs_kind.equals("geographic 2D"))){
|
298 |
dtm.addRow(data); |
299 |
} |
300 |
} |
301 |
} |
302 |
|
303 |
catch (SQLException e1) { |
304 |
e1.printStackTrace(); |
305 |
} |
306 |
} |
307 |
int numr = dtm.getRowCount();
|
308 |
if (numr == 0 ){ |
309 |
JOptionPane.showMessageDialog(this, "Not results find.", "Warning...", |
310 |
JOptionPane.WARNING_MESSAGE);
|
311 |
} |
312 |
} |
313 |
} |
314 |
|
315 |
/*
|
316 |
* metodo auxiliar que nos servira para comprobar si la proyeccion del CRS seleccionado
|
317 |
* esta entre las 16 con las que trabaja proj4
|
318 |
*/
|
319 |
private boolean validCRS(int projection_conv_code2) { |
320 |
if (projection_conv_code2 == 0) return true; |
321 |
String sentence = "SELECT coord_op_method_code " + |
322 |
"FROM epsg_coordoperation " +
|
323 |
"WHERE coord_op_code = " + projection_conv_code;
|
324 |
ResultSet result = Query.select(sentence,pcp.connect.getConnection()); |
325 |
try {
|
326 |
while (result.next()){
|
327 |
method_code = result.getInt("coord_op_method_code");
|
328 |
} |
329 |
} catch (SQLException e) { |
330 |
e.printStackTrace(); |
331 |
} |
332 |
|
333 |
for (int i = 0; i< valid_method_code.length; i++){ |
334 |
if (method_code == valid_method_code[i] ){
|
335 |
return true; |
336 |
} |
337 |
} |
338 |
return false; |
339 |
} |
340 |
|
341 |
private JButton getSearchButton() { |
342 |
if (searchButton == null) { |
343 |
searchButton = new JButton(); |
344 |
searchButton.setPreferredSize(new Dimension(75,20)); |
345 |
searchButton.setText("Search");
|
346 |
searchButton.setMnemonic('S');
|
347 |
searchButton.setToolTipText("Search of a CRS by selected criterion");
|
348 |
searchButton.addActionListener(new java.awt.event.ActionListener() {
|
349 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
350 |
searchTextField.setBackground(Color.white);
|
351 |
if (searchTextField.getText().equals("")) { |
352 |
searchTextField.setBackground(new Color(255,204,204)); |
353 |
JOptionPane.showMessageDialog(CRSSelectionPanel.this,
|
354 |
"Fill the key-word of the search.",
|
355 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
356 |
} |
357 |
else {
|
358 |
searchButton_actionPerformed(e); |
359 |
} |
360 |
} |
361 |
}); |
362 |
} |
363 |
return searchButton;
|
364 |
} |
365 |
|
366 |
private JTextField getSearchTextField() { |
367 |
if (searchTextField == null) { |
368 |
searchTextField = new JTextField(); |
369 |
searchTextField.setPreferredSize(new Dimension(300,20)); |
370 |
} |
371 |
searchTextField.addKeyListener(new KeyListener() { |
372 |
public void keyPressed(KeyEvent e) { |
373 |
if (e.getKeyCode() == 10) { |
374 |
searchButton_actionPerformed(null);
|
375 |
} |
376 |
if (codeRadioButton.isSelected()){
|
377 |
if ((e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || |
378 |
(e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){ |
379 |
} |
380 |
else {
|
381 |
JOptionPane.showMessageDialog(CRSSelectionPanel.this,
|
382 |
"Only number format.",
|
383 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
384 |
String aux = searchTextField.getText();
|
385 |
if (aux.length() == 1){ |
386 |
searchTextField.setText("");
|
387 |
} |
388 |
else {
|
389 |
searchTextField.setText(aux.substring(0, aux.length()-1)); |
390 |
} |
391 |
} |
392 |
} |
393 |
} |
394 |
|
395 |
public void keyReleased(KeyEvent arg0) { |
396 |
} |
397 |
|
398 |
public void keyTyped(KeyEvent arg0) { |
399 |
} |
400 |
}); |
401 |
return searchTextField;
|
402 |
} |
403 |
|
404 |
public JTable getJTable() { |
405 |
if (jTable == null) { |
406 |
String[] columnNames= {"Code of CRS","Name of CRS","Type of CRS","Name of Area","Description of Area"}; |
407 |
Object[][]data = {}; |
408 |
dtm = new DefaultTableModel(data, columnNames); |
409 |
jTable = new JTable(dtm); |
410 |
jTable.setCellSelectionEnabled(false);
|
411 |
jTable.setRowSelectionAllowed(true);
|
412 |
jTable.setColumnSelectionAllowed(false);
|
413 |
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
414 |
TableColumn column = null; |
415 |
for (int i = 0; i < 5; i++) { |
416 |
column = jTable.getColumnModel().getColumn(i); |
417 |
if (i == 0) { |
418 |
column.setPreferredWidth(40); //code column is shorter |
419 |
}else if (i == 2) { |
420 |
column.setPreferredWidth(80);
|
421 |
} |
422 |
else {
|
423 |
column.setPreferredWidth(160);
|
424 |
} |
425 |
} |
426 |
/*ListSelectionModel rowSM = jTable.getSelectionModel();
|
427 |
rowSM.addListSelectionListener(new ListSelectionListener() {
|
428 |
public void valueChanged(ListSelectionEvent e) {
|
429 |
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
|
430 |
if (lsm.isSelectionEmpty()) {
|
431 |
selectedRowTable = -1;
|
432 |
setCodeCRS(-1);
|
433 |
if (transfPanel){
|
434 |
si = false;
|
435 |
CrsView.withOutTrans.setEnabled(false);
|
436 |
CrsView.nadgrids.setEnabled(false);
|
437 |
CrsView.epsgTrans.setEnabled(false);
|
438 |
CrsView.manualTrans.setEnabled(false);
|
439 |
CrsView.next.setVisible(false);
|
440 |
CrsView.accept.setVisible(true);
|
441 |
}
|
442 |
}
|
443 |
else {
|
444 |
selectedRowTable = lsm.getMinSelectionIndex();
|
445 |
setCodeCRS(Integer.parseInt((String)dtm.getValueAt(selectedRowTable,0)));
|
446 |
setWKT();
|
447 |
|
448 |
if (transfPanel){
|
449 |
compareCRS();
|
450 |
}
|
451 |
}
|
452 |
infoCrs.setEnabled(true);
|
453 |
}
|
454 |
|
455 |
private void compareCRS() {
|
456 |
int base = getCodeCRS();
|
457 |
String datum = "";
|
458 |
int datum_code = -1;
|
459 |
String sentence = "SELECT source_geogcrs_code " +
|
460 |
"FROM epsg_coordinatereferencesystem " +
|
461 |
"WHERE coord_ref_sys_code = "+ base ;
|
462 |
ResultSet result = Query.select(sentence,pcp.connect.getConnection());
|
463 |
int source = 0;
|
464 |
try {
|
465 |
result.next();
|
466 |
source = result.getInt("source_geogcrs_code");
|
467 |
} catch (SQLException e1) {
|
468 |
e1.printStackTrace();
|
469 |
}
|
470 |
|
471 |
if (source != 0){
|
472 |
base = source;
|
473 |
}
|
474 |
|
475 |
sentence = "SELECT datum_code " +
|
476 |
"FROM epsg_coordinatereferencesystem " +
|
477 |
"WHERE coord_ref_sys_code = "+ base ;
|
478 |
result = Query.select(sentence,pcp.connect.getConnection());
|
479 |
|
480 |
try {
|
481 |
result.next();
|
482 |
datum_code = result.getInt("datum_code");
|
483 |
} catch (SQLException e1) {
|
484 |
e1.printStackTrace();
|
485 |
}
|
486 |
|
487 |
sentence = "SELECT datum_name " +
|
488 |
"FROM epsg_datum " +
|
489 |
"WHERE datum_code = "+ datum_code ;
|
490 |
result = Query.select(sentence,pcp.connect.getConnection());
|
491 |
|
492 |
try {
|
493 |
result.next();
|
494 |
datum = result.getString("datum_name");
|
495 |
} catch (SQLException e1) {
|
496 |
e1.printStackTrace();
|
497 |
}
|
498 |
|
499 |
if (!((ICrs) View.m_MapControl.getProjection()).getCrsWkt().getDatumName().equals(datum.replaceAll(" ",""))){
|
500 |
si = true;
|
501 |
CrsView.withOutTrans.setEnabled(true);
|
502 |
CrsView.nadgrids.setEnabled(true);
|
503 |
CrsView.epsgTrans.setEnabled(true);
|
504 |
CrsView.manualTrans.setEnabled(true);
|
505 |
CrsView.next.setVisible(true);
|
506 |
CrsView.accept.setVisible(false);
|
507 |
|
508 |
* logica necesaria para comprobar si los crs bases son iguales
|
509 |
* y en ese caso deshabilitar opcion transformacion de
|
510 |
* TransformationEpsgPanel
|
511 |
|
512 |
}
|
513 |
else {
|
514 |
si = false;
|
515 |
CrsView.withOutTrans.setEnabled(false);
|
516 |
CrsView.nadgrids.setEnabled(false);
|
517 |
CrsView.epsgTrans.setEnabled(false);
|
518 |
CrsView.manualTrans.setEnabled(false);
|
519 |
CrsView.next.setVisible(false);
|
520 |
CrsView.accept.setVisible(true);
|
521 |
}
|
522 |
}
|
523 |
});*/
|
524 |
} |
525 |
return jTable;
|
526 |
|
527 |
} |
528 |
|
529 |
public void setCodeCRS(int code) { |
530 |
codeCRS = code; |
531 |
} |
532 |
|
533 |
public int getCodeCRS() { |
534 |
return codeCRS;
|
535 |
} |
536 |
|
537 |
private JScrollPane getJScrollPane() { |
538 |
if (jScrollPane == null) { |
539 |
jScrollPane = new JScrollPane(); |
540 |
jScrollPane.setPreferredSize(new Dimension(605,250)); |
541 |
jScrollPane.setBorder( |
542 |
BorderFactory.createCompoundBorder(
|
543 |
BorderFactory.createCompoundBorder(
|
544 |
BorderFactory.createTitledBorder("Coordinate Reference Systems"), |
545 |
BorderFactory.createEmptyBorder(5,5,5,5)), |
546 |
jScrollPane.getBorder())); |
547 |
jScrollPane.setViewportView(getJTable()); |
548 |
} |
549 |
return jScrollPane;
|
550 |
} |
551 |
|
552 |
public JButton getInfoCrs() { |
553 |
if(infoCrs == null) { |
554 |
infoCrs = new JButton(); |
555 |
infoCrs.setText("InfoCrs");
|
556 |
infoCrs.setPreferredSize(new Dimension(75,20)); |
557 |
infoCrs.setMnemonic('I');
|
558 |
infoCrs.setEnabled(false);
|
559 |
infoCrs.setToolTipText("Mostrar la informacion del Crs selecionado");
|
560 |
infoCrs.addActionListener(new java.awt.event.ActionListener() {
|
561 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
562 |
infoCrs_actionPerformed(e); |
563 |
} |
564 |
}); |
565 |
} |
566 |
return infoCrs;
|
567 |
} |
568 |
|
569 |
private void infoCrs_actionPerformed(ActionEvent e) { |
570 |
InfoCrs info = new InfoCrs(getCrs());
|
571 |
info.setSize(new Dimension(550,350)); |
572 |
info.setLayout(new GridLayout(0,1)); |
573 |
info.setLayout(new FlowLayout(FlowLayout.LEFT,10,5)); |
574 |
PluginServices.getMDIManager().addWindow(info); |
575 |
} |
576 |
|
577 |
public ICrs getProjection() {
|
578 |
return getCrs();
|
579 |
} |
580 |
public ICrs getCrs() {
|
581 |
try {
|
582 |
String txt = getWKT();
|
583 |
ICrs crs = new CrsFactory().getCRS(epsg_code, txt);
|
584 |
return crs ;
|
585 |
} catch (CrsException e) {
|
586 |
e.printStackTrace(); |
587 |
} |
588 |
return null; |
589 |
} |
590 |
|
591 |
public void setWKT(){ |
592 |
Epsg2wkt wkt = null;
|
593 |
|
594 |
epsg_code = getCodeCRS(); |
595 |
if (epsg_code != -1){ |
596 |
/*
|
597 |
* ahora que he escogido, recojo toda la informacion que me va a hacer falta
|
598 |
*/
|
599 |
String sentence = "SELECT source_geogcrs_code, projection_conv_code " + |
600 |
"FROM epsg_coordinatereferencesystem " +
|
601 |
"WHERE coord_ref_sys_code = "+ epsg_code ;
|
602 |
ResultSet result = Query.select(sentence,pcp.connect.getConnection()); |
603 |
|
604 |
try {
|
605 |
result.next(); |
606 |
source_cod = result.getInt("source_geogcrs_code");
|
607 |
projection_conv_code = result.getInt("projection_conv_code");
|
608 |
} catch (SQLException e1) { |
609 |
e1.printStackTrace(); |
610 |
} |
611 |
|
612 |
if (source_cod != 0){ |
613 |
source_yn = false;
|
614 |
} |
615 |
else source_yn = true; |
616 |
|
617 |
GetCRSepsg ep = new GetCRSepsg(epsg_code, source_yn, source_cod, projection_conv_code, pcp);
|
618 |
ep.Getepsgdata(); |
619 |
|
620 |
if (source_yn){
|
621 |
wkt = new Epsg2wkt(ep ,0); |
622 |
} |
623 |
else {
|
624 |
wkt = new Epsg2wkt(ep);
|
625 |
} |
626 |
} |
627 |
else {
|
628 |
JOptionPane.showMessageDialog(this, |
629 |
"No CRS selected.",
|
630 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
631 |
|
632 |
} |
633 |
cadWKT = wkt.getWKT(); |
634 |
} |
635 |
|
636 |
public String getWKT(){ |
637 |
return cadWKT;
|
638 |
} |
639 |
|
640 |
public void setProjection(IProjection crs) { |
641 |
//setCrs((ICrs) crs);
|
642 |
} |
643 |
} |