root / branches / F2 / extensions / extJCRS / src / org / gvsig / crs / gui / panels / IAU2000panel.java @ 12202
History | View | Annotate | Download (17.1 KB)
1 | 11458 | jlgomez | /* gvSIG. Sistema de Informacin Geogrfica de la Generalitat Valenciana
|
---|---|---|---|
2 | 10301 | dguerrero | *
|
3 | * Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | 11458 | jlgomez | * Av. Blasco Ibez, 50
|
24 | 10301 | dguerrero | * 46010 VALENCIA
|
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
|
||
34 | * Campus Universitario s/n
|
||
35 | * 02071 Alabacete
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 967 599 200
|
||
39 | */
|
||
40 | |||
41 | package org.gvsig.crs.gui.panels; |
||
42 | |||
43 | 10786 | lmfernandez | import java.awt.BorderLayout; |
44 | 10301 | dguerrero | import java.awt.Color; |
45 | import java.awt.Dimension; |
||
46 | import java.awt.FlowLayout; |
||
47 | import java.awt.GridLayout; |
||
48 | import java.awt.event.ActionEvent; |
||
49 | import java.awt.event.ActionListener; |
||
50 | import java.awt.event.KeyEvent; |
||
51 | import java.awt.event.KeyListener; |
||
52 | import java.sql.ResultSet; |
||
53 | import java.sql.SQLException; |
||
54 | |||
55 | import javax.swing.BorderFactory; |
||
56 | 10786 | lmfernandez | import javax.swing.ButtonGroup; |
57 | 10301 | dguerrero | import javax.swing.JButton; |
58 | import javax.swing.JLabel; |
||
59 | import javax.swing.JOptionPane; |
||
60 | import javax.swing.JPanel; |
||
61 | import javax.swing.JRadioButton; |
||
62 | import javax.swing.JScrollPane; |
||
63 | import javax.swing.JTable; |
||
64 | import javax.swing.JTextField; |
||
65 | import javax.swing.ListSelectionModel; |
||
66 | import javax.swing.table.DefaultTableModel; |
||
67 | import javax.swing.table.TableColumn; |
||
68 | |||
69 | import org.cresques.cts.IProjection; |
||
70 | import org.gvsig.crs.CrsException; |
||
71 | import org.gvsig.crs.CrsFactory; |
||
72 | import org.gvsig.crs.ICrs; |
||
73 | import org.gvsig.crs.ogr.Iau2wkt; |
||
74 | |||
75 | import com.iver.andami.PluginServices; |
||
76 | import com.iver.cit.gvsig.gui.TableSorter; |
||
77 | |||
78 | 11458 | jlgomez | import es.idr.teledeteccion.connection.EpsgConnection; |
79 | import es.idr.teledeteccion.connection.Query; |
||
80 | |||
81 | 10301 | dguerrero | /**
|
82 | 11458 | jlgomez | * Clase que genera el panel para la bsqueda de CRS del repositorio
|
83 | 10301 | dguerrero | * de la IAU2000
|
84 | *
|
||
85 | 11458 | jlgomez | * @author Jos Luis Gmez Martnez (jolugomar@gmail.com)
|
86 | * @author Luisa Marina Fernndez (luisam.fernandez@uclm.es)
|
||
87 | 10301 | dguerrero | *
|
88 | */
|
||
89 | public class IAU2000panel extends JPanel implements KeyListener, ActionListener { |
||
90 | |||
91 | private static final long serialVersionUID = 1L; |
||
92 | public JPanel IAU2000panel = null; |
||
93 | |||
94 | private JRadioButton codeRadioButton = null; |
||
95 | private JRadioButton nameRadioButton = null; |
||
96 | private JPanel groupRadioButton = null; |
||
97 | 12194 | lmfernandez | private JButton infoCrs=null; |
98 | 10301 | dguerrero | |
99 | JLabel jLabel = null; |
||
100 | 10786 | lmfernandez | private JLabel lblCriterio=null; |
101 | 10301 | dguerrero | JTextField crsTextFld = null; |
102 | |||
103 | String cadWKT = ""; |
||
104 | |||
105 | int transf = 0; |
||
106 | boolean source_yn = false; |
||
107 | int source_cod = 0; |
||
108 | int method_code = 0; |
||
109 | int datum_code = 0; |
||
110 | int projection_conv_code = 0; |
||
111 | public String crs_kind = null; |
||
112 | 10786 | lmfernandez | |
113 | 10301 | dguerrero | public TableSorter sorter = null; |
114 | |||
115 | public EpsgConnection connect = null; |
||
116 | |||
117 | 10786 | lmfernandez | |
118 | 10301 | dguerrero | private JButton searchButton = null; |
119 | private JTextField searchTextField = null; |
||
120 | public JTable jTable = null; |
||
121 | private JScrollPane jScrollPane = null; |
||
122 | public DefaultTableModel dtm = null; |
||
123 | 10786 | lmfernandez | |
124 | 10301 | dguerrero | public String key; |
125 | public int selectedRowTable = -1; |
||
126 | private int codeCRS = -1; |
||
127 | |||
128 | public IAU2000panel() {
|
||
129 | initialize(); |
||
130 | } |
||
131 | 10786 | lmfernandez | /*
|
132 | * Establece las propiedades y los componentes del panel de la IAU2000
|
||
133 | */
|
||
134 | 10301 | dguerrero | private void initialize(){ |
135 | 10786 | lmfernandez | this.setLayout(new BorderLayout()); |
136 | JPanel pNorth=new JPanel(); |
||
137 | JPanel pInNorth=new JPanel(); |
||
138 | 12194 | lmfernandez | JPanel pSouth=new JPanel(); |
139 | 11458 | jlgomez | //Agregar las opciones de bsqueda
|
140 | 10786 | lmfernandez | pInNorth.setLayout(new FlowLayout(FlowLayout.CENTER,10,1)); |
141 | pInNorth.add(getSearchButton()); |
||
142 | pInNorth.add(getSearchTextField()); |
||
143 | |||
144 | pNorth.setLayout(new GridLayout(0,1)); |
||
145 | pNorth.add(getGroupRadioButton()); |
||
146 | pNorth.add(pInNorth); |
||
147 | 12194 | lmfernandez | |
148 | pSouth.setLayout(new FlowLayout(FlowLayout.RIGHT,5,5)); |
||
149 | pSouth.add(getInfoCrs()); |
||
150 | 10786 | lmfernandez | //Agregar estos elementos al panel principal
|
151 | this.add(pNorth,BorderLayout.NORTH); |
||
152 | this.add(getJScrollPane(),BorderLayout.CENTER); |
||
153 | 12194 | lmfernandez | this.add(pSouth,BorderLayout.SOUTH); |
154 | 10301 | dguerrero | } |
155 | |||
156 | public void connection(){ |
||
157 | connect = new EpsgConnection();
|
||
158 | connect.setConnectionIAU2000(); |
||
159 | |||
160 | } |
||
161 | 10786 | lmfernandez | /**
|
162 | 11458 | jlgomez | * Inicializa el Radio Button 'Cdigo'
|
163 | 10786 | lmfernandez | * @return
|
164 | */
|
||
165 | 10301 | dguerrero | private JRadioButton getCodeRadioButton() { |
166 | if (codeRadioButton == null) { |
||
167 | codeRadioButton = new JRadioButton(); |
||
168 | codeRadioButton.setText(PluginServices.getText(this,"por_codigo"));//setText("By Code EPSG"); |
||
169 | codeRadioButton.setSelected(true);
|
||
170 | codeRadioButton.addActionListener(this);
|
||
171 | } |
||
172 | return codeRadioButton;
|
||
173 | } |
||
174 | 10786 | lmfernandez | /**
|
175 | * Inicializa el Radio Button 'Nombre'
|
||
176 | * @return
|
||
177 | */
|
||
178 | 10301 | dguerrero | private JRadioButton getNameRadioButton() { |
179 | if (nameRadioButton == null) { |
||
180 | nameRadioButton = new JRadioButton(); |
||
181 | nameRadioButton.setText(PluginServices.getText(this,"por_nombre")); |
||
182 | nameRadioButton.addActionListener(this);
|
||
183 | } |
||
184 | return nameRadioButton;
|
||
185 | } |
||
186 | 10786 | lmfernandez | /**
|
187 | * Agrega todos los Radio Buttons a un panel
|
||
188 | * @return
|
||
189 | */
|
||
190 | 10301 | dguerrero | private JPanel getGroupRadioButton() { |
191 | if (groupRadioButton == null) { |
||
192 | groupRadioButton = new JPanel(); |
||
193 | groupRadioButton.setLayout(new GridLayout(1,0)); |
||
194 | groupRadioButton.setPreferredSize(new Dimension(500,30)); |
||
195 | 10786 | lmfernandez | groupRadioButton.add(getLblCriterio()); |
196 | 10301 | dguerrero | groupRadioButton.add(getCodeRadioButton()); |
197 | 10786 | lmfernandez | groupRadioButton.add(getNameRadioButton()); |
198 | //Agrupar los Radio Buttons
|
||
199 | ButtonGroup group=new ButtonGroup(); |
||
200 | group.add(getCodeRadioButton()); |
||
201 | group.add(getNameRadioButton()); |
||
202 | 10301 | dguerrero | } |
203 | return groupRadioButton;
|
||
204 | } |
||
205 | 10786 | lmfernandez | /**
|
206 | 11458 | jlgomez | * Inicializa el Label que nombra el Criterio de Bsqueda
|
207 | 10786 | lmfernandez | * @return
|
208 | */
|
||
209 | private JLabel getLblCriterio(){ |
||
210 | if(lblCriterio==null){ |
||
211 | lblCriterio = new JLabel(); |
||
212 | lblCriterio.setPreferredSize(new Dimension(100, 20)); |
||
213 | lblCriterio.setText(PluginServices.getText(this, "criterio_busqueda")); |
||
214 | } |
||
215 | return lblCriterio;
|
||
216 | 10301 | dguerrero | } |
217 | |||
218 | /**
|
||
219 | 11458 | jlgomez | * Mtodo que controla la bsqueda de CRS del repositorio de IAU2000.
|
220 | 12194 | lmfernandez | * Tambien maneja los errores en caso de que los parmetros de bsqueda
|
221 | 11458 | jlgomez | * sean errneos, o que no se encuentren resultados.
|
222 | 10301 | dguerrero | *
|
223 | */
|
||
224 | private void searchButton() { |
||
225 | searchTextField.setBackground(Color.white);
|
||
226 | boolean not_numeric = false; |
||
227 | |||
228 | if (searchTextField.getText().equals("")) { |
||
229 | searchTextField.setBackground(new Color(255,204,204)); |
||
230 | JOptionPane.showMessageDialog(this, PluginServices.getText(this,"fill_name"), "Warning...", JOptionPane.WARNING_MESSAGE); |
||
231 | } |
||
232 | |||
233 | else {
|
||
234 | //Eliminar filas en cada nueva bsqueda
|
||
235 | int numRow = dtm.getRowCount();
|
||
236 | while (numRow != 0) { |
||
237 | numRow = numRow - 1;
|
||
238 | dtm.removeRow(numRow); |
||
239 | } |
||
240 | |||
241 | if (codeRadioButton.isSelected() && (searchTextField.getText().length()!=searchTextField.getText().replaceAll("[^0-9]", "").length())){ |
||
242 | not_numeric = true;
|
||
243 | } |
||
244 | |||
245 | //Dependiendo de la opcion se realizada una busqueda
|
||
246 | ResultSet result = null; |
||
247 | |||
248 | if (codeRadioButton.isSelected() && !not_numeric) {
|
||
249 | |||
250 | key = searchTextField.getText(); |
||
251 | int code = Integer.parseInt(key); |
||
252 | String sentence = "SELECT iau_code, iau_wkt, iau_proj, iau_geog, iau_datum " + |
||
253 | "FROM IAU2000 " +
|
||
254 | "WHERE iau_code = " + code;
|
||
255 | |||
256 | result = Query.select(sentence,connect.getConnection());
|
||
257 | |||
258 | |||
259 | Object[] data = new Object[4]; |
||
260 | try {
|
||
261 | while (result.next()){
|
||
262 | data[0] = result.getString("iau_code"); |
||
263 | data[1] = result.getString("iau_wkt"); |
||
264 | String proj = result.getString("iau_proj"); |
||
265 | if (!proj.equals("")){ |
||
266 | data[1] = proj;
|
||
267 | data[2] = PluginServices.getText(this,"si"); |
||
268 | } |
||
269 | else
|
||
270 | { |
||
271 | data[1] = result.getString("iau_geog"); |
||
272 | data[2] = PluginServices.getText(this,"no"); |
||
273 | } |
||
274 | |||
275 | data[3] = result.getString("iau_datum"); |
||
276 | dtm.addRow(data); |
||
277 | } |
||
278 | } catch (SQLException e1) { |
||
279 | e1.printStackTrace(); |
||
280 | } |
||
281 | } |
||
282 | else if (nameRadioButton.isSelected()) { |
||
283 | key = searchTextField.getText(); |
||
284 | String key2 = key.substring(0,1); |
||
285 | String key3 = key.substring(1,key.length()); |
||
286 | key2 = key2.toUpperCase(); |
||
287 | |||
288 | String sentence = "SELECT iau_code, iau_wkt, iau_proj, iau_geog, iau_datum " + |
||
289 | "FROM IAU2000 " +
|
||
290 | "WHERE (iau_proj LIKE '%" + key + "%') OR (iau_proj LIKE '%"+ |
||
291 | key.toUpperCase() +"%') " +
|
||
292 | "OR (iau_proj LIKE '%" + key2+key3 +"%') OR " + |
||
293 | "(iau_geog LIKE '%" + key + "%') OR (iau_geog LIKE '%"+ |
||
294 | key.toUpperCase() +"%') " +
|
||
295 | "OR (iau_geog LIKE '%" + key2+key3 +"%')"; |
||
296 | |||
297 | result = Query.select(sentence,connect.getConnection());
|
||
298 | |||
299 | Object[] data = new Object[4]; |
||
300 | try {
|
||
301 | while (result.next()){
|
||
302 | data[0] = result.getString("iau_code"); |
||
303 | data[1] = result.getString("iau_wkt"); |
||
304 | String proj = result.getString("iau_proj"); |
||
305 | if (!proj.equals("")){ |
||
306 | data[1] = proj;
|
||
307 | data[2] = PluginServices.getText(this,"si"); |
||
308 | } |
||
309 | else
|
||
310 | { |
||
311 | data[1] = result.getString("iau_geog"); |
||
312 | data[2] = PluginServices.getText(this,"no"); |
||
313 | } |
||
314 | |||
315 | data[3] = result.getString("iau_datum"); |
||
316 | dtm.addRow(data); |
||
317 | } |
||
318 | } catch (SQLException e1) { |
||
319 | e1.printStackTrace(); |
||
320 | } |
||
321 | } |
||
322 | |||
323 | int numr = dtm.getRowCount();
|
||
324 | if (not_numeric) {
|
||
325 | JOptionPane.showMessageDialog(IAU2000panel.this,
|
||
326 | PluginServices.getText(this,"numeric_format"), |
||
327 | "Warning...", JOptionPane.WARNING_MESSAGE); |
||
328 | searchTextField.setText("");
|
||
329 | } |
||
330 | else if (numr == 0){ |
||
331 | JOptionPane.showMessageDialog(this, PluginServices.getText(this,"no_results"), "Warning...", |
||
332 | JOptionPane.WARNING_MESSAGE);
|
||
333 | } |
||
334 | else{
|
||
335 | this.getJTable().setRowSelectionInterval(0,0); |
||
336 | } |
||
337 | } |
||
338 | } |
||
339 | |||
340 | private JButton getSearchButton() { |
||
341 | if (searchButton == null) { |
||
342 | searchButton = new JButton(); |
||
343 | searchButton.setPreferredSize(new Dimension(75,20)); |
||
344 | searchButton.setText(PluginServices.getText(this,"buscar")); |
||
345 | 10789 | lmfernandez | searchButton.setMnemonic('S');
|
346 | searchButton.setToolTipText(PluginServices.getText(this,"buscar_por_criterio_seleccion")); |
||
347 | 10301 | dguerrero | searchButton.addActionListener(this);
|
348 | } |
||
349 | return searchButton;
|
||
350 | } |
||
351 | |||
352 | 12194 | lmfernandez | /**
|
353 | 12202 | jlgomez | * Inicializa el botn que obtiene la informacin del CRS
|
354 | 12194 | lmfernandez | * @return
|
355 | */
|
||
356 | public JButton getInfoCrs() { |
||
357 | if(infoCrs == null) { |
||
358 | infoCrs = new JButton(); |
||
359 | infoCrs.setPreferredSize(new Dimension(85,20)); |
||
360 | infoCrs.setText(PluginServices.getText(this,"infocrs")); |
||
361 | infoCrs.setMnemonic('I');
|
||
362 | infoCrs.setEnabled(false);
|
||
363 | infoCrs.setToolTipText(PluginServices.getText(this,"more_info")); |
||
364 | infoCrs.addActionListener(this);
|
||
365 | } |
||
366 | return infoCrs;
|
||
367 | } |
||
368 | 10301 | dguerrero | private JTextField getSearchTextField() { |
369 | if (searchTextField == null) { |
||
370 | searchTextField = new JTextField(); |
||
371 | searchTextField.setPreferredSize(new Dimension(300,20)); |
||
372 | searchTextField.addKeyListener(this);
|
||
373 | } |
||
374 | return searchTextField;
|
||
375 | } |
||
376 | |||
377 | public JTable getJTable() { |
||
378 | if (jTable == null) { |
||
379 | String[] columnNames= {PluginServices.getText(this,"codigo"), |
||
380 | PluginServices.getText(this,"nombre"), |
||
381 | PluginServices.getText(this,"projected"), |
||
382 | PluginServices.getText(this,"datum")}; |
||
383 | Object[][]data = {}; |
||
384 | dtm = new DefaultTableModel(data, columnNames) |
||
385 | { |
||
386 | 10786 | lmfernandez | private static final long serialVersionUID = 1L; |
387 | 10301 | dguerrero | public boolean isCellEditable(int row, int column) { |
388 | return false; |
||
389 | } |
||
390 | /*
|
||
391 | * metodo necesario para cuando utilizamos tablas ordenadas
|
||
392 | * ya que sino al ordenar por algun campo no se queda con el orden
|
||
393 | * actual al seleccionar una fila (non-Javadoc)
|
||
394 | * @see javax.swing.table.TableModel#getColumnClass(int)
|
||
395 | */
|
||
396 | public Class getColumnClass(int column) |
||
397 | { |
||
398 | return getValueAt(0, column).getClass(); |
||
399 | } |
||
400 | }; |
||
401 | sorter = new TableSorter(dtm);
|
||
402 | |||
403 | jTable = new JTable(sorter); |
||
404 | sorter.setTableHeader(jTable.getTableHeader()); |
||
405 | jTable.setCellSelectionEnabled(false);
|
||
406 | jTable.setRowSelectionAllowed(true);
|
||
407 | jTable.setColumnSelectionAllowed(false);
|
||
408 | jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||
409 | TableColumn column = null; |
||
410 | 11543 | jlgomez | for (int i = 0; i < columnNames.length; i++) { |
411 | 10301 | dguerrero | column = jTable.getColumnModel().getColumn(i); |
412 | if (i == 0) { |
||
413 | column.setPreferredWidth(80); //code column is shorter |
||
414 | }else if (i ==2) { |
||
415 | column.setPreferredWidth(50);
|
||
416 | } else {
|
||
417 | column.setPreferredWidth(175);
|
||
418 | } |
||
419 | |||
420 | } |
||
421 | } |
||
422 | return jTable;
|
||
423 | |||
424 | } |
||
425 | |||
426 | public void setCodeCRS(int code) { |
||
427 | codeCRS = code; |
||
428 | } |
||
429 | |||
430 | public int getCodeCRS() { |
||
431 | return codeCRS;
|
||
432 | } |
||
433 | |||
434 | private JScrollPane getJScrollPane() { |
||
435 | if (jScrollPane == null) { |
||
436 | jScrollPane = new JScrollPane(); |
||
437 | jScrollPane.setPreferredSize(new Dimension(500,150)); |
||
438 | 10786 | lmfernandez | /*jScrollPane.setBorder(
|
439 | 10301 | dguerrero | BorderFactory.createCompoundBorder(
|
440 | BorderFactory.createCompoundBorder(
|
||
441 | BorderFactory.createTitledBorder(PluginServices.getText(this,"IAU2000")),
|
||
442 | BorderFactory.createEmptyBorder(5,5,5,5)),
|
||
443 | 10786 | lmfernandez | jScrollPane.getBorder()));*/
|
444 | jScrollPane.setBorder( |
||
445 | BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(3,3,3,3),jScrollPane.getBorder())); |
||
446 | |||
447 | 10301 | dguerrero | jScrollPane.setViewportView(getJTable()); |
448 | } |
||
449 | return jScrollPane;
|
||
450 | } |
||
451 | |||
452 | public ICrs getProjection() {
|
||
453 | try {
|
||
454 | String txt = getWKT();
|
||
455 | 11458 | jlgomez | //ICrs crs = new CrsFactory().getCRS("IAU2000:"+getCodeCRS(), txt);
|
456 | ICrs crs = new CrsFactory().getCRS("IAU2000:"+getCodeCRS()); |
||
457 | 10301 | dguerrero | return crs ;
|
458 | } catch (CrsException e) {
|
||
459 | e.printStackTrace(); |
||
460 | } |
||
461 | return null; |
||
462 | } |
||
463 | |||
464 | /**
|
||
465 | 11458 | jlgomez | * Consigue la cadena wkt del CRS seleccionado, y genera la cadena que ms
|
466 | * tarde volver a ser tratada para la consecucin de una cadena wkt
|
||
467 | 10301 | dguerrero | * legible por la proj4.
|
468 | *
|
||
469 | */
|
||
470 | public void setWKT(){ |
||
471 | int code = getCodeCRS();
|
||
472 | String sentence = "SELECT iau_code, iau_wkt, iau_proj, iau_geog, iau_datum " + |
||
473 | "FROM IAU2000 " +
|
||
474 | "WHERE iau_code = " + code;
|
||
475 | |||
476 | |||
477 | ResultSet result = Query.select(sentence,connect.getConnection()); |
||
478 | |||
479 | try {
|
||
480 | result.next(); |
||
481 | cadWKT = result.getString("iau_wkt");
|
||
482 | } catch (SQLException e1) { |
||
483 | e1.printStackTrace(); |
||
484 | } |
||
485 | cadWKT = cadWKT.substring(0, cadWKT.length()-1) + ", AUTHORITY[\"IAU2000\","+ getCodeCRS()+"]]"; |
||
486 | if (cadWKT.charAt(0) == 'P'){ |
||
487 | Iau2wkt wk = new Iau2wkt(cadWKT);
|
||
488 | cadWKT = wk.getWkt(); |
||
489 | } |
||
490 | } |
||
491 | |||
492 | public String getWKT(){ |
||
493 | return cadWKT;
|
||
494 | } |
||
495 | |||
496 | public void setProjection(IProjection crs) { |
||
497 | //setCrs((ICrs) crs);
|
||
498 | } |
||
499 | |||
500 | /**
|
||
501 | * Metodo para cargar en el CRS de la capa el CRS de la vista.
|
||
502 | 11458 | jlgomez | * Se utilizar a la hora de arrancar la definicin del CRS de la nueva capa
|
503 | 10301 | dguerrero | */
|
504 | public void loadViewCRS(int code){ |
||
505 | connection(); |
||
506 | String sentence = "SELECT iau_code, iau_wkt, iau_proj, iau_geog, iau_datum " + |
||
507 | "FROM IAU2000 " +
|
||
508 | "WHERE iau_code = " + code;
|
||
509 | |||
510 | ResultSet result = Query.select(sentence,connect.getConnection()); |
||
511 | |||
512 | Object[] data = new Object[4]; |
||
513 | try {
|
||
514 | while (result.next()){
|
||
515 | data[0] = result.getString("iau_code"); |
||
516 | data[1] = result.getString("iau_wkt"); |
||
517 | String proj = result.getString("iau_proj"); |
||
518 | if (!proj.equals("")){ |
||
519 | data[1] = proj;
|
||
520 | data[2] = PluginServices.getText(this,"si"); |
||
521 | } |
||
522 | else
|
||
523 | { |
||
524 | data[1] = result.getString("iau_geog"); |
||
525 | data[2] = PluginServices.getText(this,"no"); |
||
526 | } |
||
527 | |||
528 | data[3] = result.getString("iau_datum"); |
||
529 | dtm.addRow(data); |
||
530 | } |
||
531 | } catch (SQLException e1) { |
||
532 | e1.printStackTrace(); |
||
533 | } |
||
534 | } |
||
535 | |||
536 | public void keyPressed(KeyEvent e) { |
||
537 | if (e.getSource() == this.getSearchTextField()){ |
||
538 | if (e.getKeyCode() == 10) { |
||
539 | 11543 | jlgomez | searchTextField.setBackground(Color.white);
|
540 | if (searchTextField.getText().equals("")) { |
||
541 | searchTextField.setBackground(new Color(255,204,204)); |
||
542 | JOptionPane.showMessageDialog(IAU2000panel.this,
|
||
543 | PluginServices.getText(this,"fill_name"), |
||
544 | "Warning...", JOptionPane.WARNING_MESSAGE); |
||
545 | } |
||
546 | else {
|
||
547 | searchButton(); |
||
548 | } |
||
549 | 10301 | dguerrero | } |
550 | } |
||
551 | } |
||
552 | |||
553 | public void keyReleased(KeyEvent arg0) { |
||
554 | 10786 | lmfernandez | |
555 | 10301 | dguerrero | } |
556 | |||
557 | public void keyTyped(KeyEvent arg0) { |
||
558 | 10786 | lmfernandez | |
559 | 10301 | dguerrero | } |
560 | |||
561 | /**
|
||
562 | * Maneja los eventos de los botones y los radioButtons del panel
|
||
563 | * del repositorio IAU2000.
|
||
564 | */
|
||
565 | public void actionPerformed(ActionEvent e) { |
||
566 | if (e.getSource() == this.getSearchButton()){ |
||
567 | searchTextField.setBackground(Color.white);
|
||
568 | if (searchTextField.getText().equals("")) { |
||
569 | searchTextField.setBackground(new Color(255,204,204)); |
||
570 | JOptionPane.showMessageDialog(IAU2000panel.this,
|
||
571 | PluginServices.getText(this,"fill_name"), |
||
572 | "Warning...", JOptionPane.WARNING_MESSAGE); |
||
573 | } |
||
574 | else {
|
||
575 | searchButton(); |
||
576 | } |
||
577 | } |
||
578 | if (e.getSource() == this.getCodeRadioButton()) { |
||
579 | searchTextField.setText("");
|
||
580 | } |
||
581 | |||
582 | if (e.getSource() == this.getNameRadioButton()) { |
||
583 | searchTextField.setText("");
|
||
584 | 10786 | lmfernandez | |
585 | 12202 | jlgomez | } |
586 | |||
587 | /*Si el objeto que genera el evento es el JButton 'InfoCrs'
|
||
588 | se muestra la informacin ralicionada con el Crs seleccionado en la tabla*/
|
||
589 | if (e.getSource() == this.getInfoCrs()) { |
||
590 | InfoCRSPanel info = new InfoCRSPanel("IAU2000", getCodeCRS()); |
||
591 | PluginServices.getMDIManager().addWindow(info); |
||
592 | } |
||
593 | 10301 | dguerrero | } |
594 | |||
595 | } |