Revision 11699
branches/F2/extensions/extJCRS/src/org/gvsig/crs/gui/panels/wizard/DefCrsUsr.java | ||
---|---|---|
263 | 263 |
System.out.println("boton Crs Existente"); |
264 | 264 |
ImportNewCrsDialog newCrs = new ImportNewCrsDialog("crs"); |
265 | 265 |
PluginServices.getMDIManager().addWindow(newCrs); |
266 |
getLblCrs().setText("EPSG:"+newCrs.getCode()); |
|
267 |
setCrs(newCrs.getCode()); |
|
266 |
if (newCrs.getCode() != -1) { |
|
267 |
getLblCrs().setText("EPSG:"+newCrs.getCode()); |
|
268 |
setCrs(newCrs.getCode()); |
|
269 |
} |
|
268 | 270 |
|
269 | 271 |
}else if(e.getSource().equals(getBtnImportarWkt())){ |
270 | 272 |
System.out.println("Boton Importar Wkt"); |
branches/F2/extensions/extJCRS/src/org/gvsig/crs/gui/panels/wizard/DefSistCoordenadas.java | ||
---|---|---|
83 | 83 |
//agregar cardPanel en el this |
84 | 84 |
this.add(cardPanel,BorderLayout.CENTER); |
85 | 85 |
|
86 |
|
|
87 | 86 |
} |
88 | 87 |
/** |
89 | 88 |
* Inicializa el radio button Geogr�fico 2D |
... | ... | |
182 | 181 |
|
183 | 182 |
if(tableParametros==null){ |
184 | 183 |
tableParametros = new JTable(); |
185 |
model = (DefaultTableModel)tableParametros.getModel(); |
|
184 |
model = (DefaultTableModel)tableParametros.getModel();
|
|
186 | 185 |
//Crea la tabla con 7 filas |
187 | 186 |
Object[][] data = { |
188 | 187 |
{"", "", "Metros"}, |
... | ... | |
196 | 195 |
String col1=PluginServices.getText(this,"SistCoor_Parametro"); |
197 | 196 |
String col2=PluginServices.getText(this,"SistCoor_Valor"); |
198 | 197 |
String col3=PluginServices.getText(this,"SistCoor_Unidades"); |
199 |
Object[] headers = {col1, col2, col3};
|
|
200 |
model.setDataVector(data,headers); |
|
198 |
Object[] headers = {col1, col2, col3}; |
|
199 |
|
|
201 | 200 |
/*Agrega otra fila |
202 | 201 |
model.addRow(new Object[]{"fila","","Metros"});*/ |
203 | 202 |
//TODO: Agregar los items "Unidades" al combo |
... | ... | |
207 | 206 |
for (int i=0;i<units.size();i++){ |
208 | 207 |
items[i] = units.get(i).toString(); |
209 | 208 |
} |
209 |
|
|
210 |
model = new DefaultTableModel(data, headers) { |
|
211 |
private static final long serialVersionUID = 1L; |
|
212 |
public boolean isCellEditable(int row, int column) { |
|
213 |
if (column == 0) |
|
214 |
return false; |
|
215 |
else return true; |
|
216 |
} |
|
217 |
}; |
|
218 |
tableParametros.setModel(model); |
|
210 | 219 |
//String[] items = new String[] { "Metros", "Grados", "Kilometros", "Decimetros", "Hect�metros" }; |
211 | 220 |
TableColumn col = tableParametros.getColumnModel().getColumn(2); |
221 |
|
|
212 | 222 |
ComboBoxEditor editor = new ComboBoxEditor(items); |
213 | 223 |
col.setCellEditor(editor); |
214 | 224 |
col.setCellRenderer(new ComboBoxRenderer(items)); |
225 |
|
|
226 |
|
|
215 | 227 |
//Define el tama�o de la tabla |
216 | 228 |
tableParametros.setPreferredScrollableViewportSize(new Dimension(twidth,theigth)); |
217 | 229 |
//la posicion de las columnas es fija |
218 | 230 |
tableParametros.getTableHeader().setReorderingAllowed( false ); |
219 | 231 |
//Ajustar ancho y alto de las filas y columnas |
220 | 232 |
ajustarTamanoTabla(); |
221 |
fillTable(cbProyeccion.getItemAt(0).toString()); |
|
222 |
}
|
|
233 |
fillTable(cbProyeccion.getItemAt(0).toString());
|
|
234 |
} |
|
223 | 235 |
|
224 | 236 |
return tableParametros; |
225 | 237 |
} |
... | ... | |
478 | 490 |
} |
479 | 491 |
} |
480 | 492 |
model.addRow(data); |
481 |
System.out.println(getTableParametros().getValueAt(i, 2)); |
|
482 | 493 |
TableColumn col = getTableParametros().getColumnModel().getColumn(2); |
483 | 494 |
ComboBoxEditor editor = new ComboBoxEditor(items); |
484 | 495 |
col.setCellEditor(editor); |
... | ... | |
496 | 507 |
String op = (String)e.getItem(); |
497 | 508 |
fillTable(op); |
498 | 509 |
} |
510 |
|
|
511 |
public void cleanData() { |
|
512 |
getCbProyeccion().setSelectedIndex(0); |
|
513 |
} |
|
514 |
|
|
515 |
public double convert2Meters(String unit, double value) { |
|
516 |
double factor_b = 0; |
|
517 |
double factor_c = 0; |
|
518 |
String sentence = "SELECT factor_b, factor_c " + |
|
519 |
"FROM epsg_unitofmeasure " + |
|
520 |
"WHERE unit_of_meas_name = '" +unit + "'"; |
|
521 |
EpsgConnection connect = new EpsgConnection(); |
|
522 |
connect.setConnectionEPSG(); |
|
523 |
ResultSet result = Query.select(sentence,connect.getConnection()); |
|
524 |
try { |
|
525 |
result.next(); |
|
526 |
factor_b = result.getDouble("factor_b"); |
|
527 |
factor_c = result.getDouble("factor_c"); |
|
528 |
} catch (SQLException e) { |
|
529 |
// TODO Auto-generated catch block |
|
530 |
e.printStackTrace(); |
|
531 |
} |
|
532 |
return ((value*factor_b)/factor_c); |
|
533 |
} |
|
534 |
|
|
535 |
public double convert2Unitless(String unit, double value) { |
|
536 |
double factor_b = 0; |
|
537 |
double factor_c = 0; |
|
538 |
String sentence = "SELECT factor_b, factor_c " + |
|
539 |
"FROM epsg_unitofmeasure " + |
|
540 |
"WHERE unit_of_meas_name = '" +unit + "'"; |
|
541 |
EpsgConnection connect = new EpsgConnection(); |
|
542 |
connect.setConnectionEPSG(); |
|
543 |
ResultSet result = Query.select(sentence,connect.getConnection()); |
|
544 |
try { |
|
545 |
result.next(); |
|
546 |
factor_b = result.getDouble("factor_b"); |
|
547 |
factor_c = result.getDouble("factor_c"); |
|
548 |
} catch (SQLException e) { |
|
549 |
// TODO Auto-generated catch block |
|
550 |
e.printStackTrace(); |
|
551 |
} |
|
552 |
return ((value*factor_b)/factor_c); |
|
553 |
} |
|
554 |
|
|
555 |
public double convert2Degree(String unit, double value) { |
|
556 |
double factor_b = 0; |
|
557 |
double factor_c = 0; |
|
558 |
String sentence = "SELECT factor_b, factor_c " + |
|
559 |
"FROM epsg_unitofmeasure " + |
|
560 |
"WHERE unit_of_meas_name = '" +unit + "'"; |
|
561 |
EpsgConnection connect = new EpsgConnection(); |
|
562 |
connect.setConnectionEPSG(); |
|
563 |
ResultSet result = Query.select(sentence,connect.getConnection()); |
|
564 |
try { |
|
565 |
result.next(); |
|
566 |
factor_b = result.getDouble("factor_b"); |
|
567 |
factor_c = result.getDouble("factor_c"); |
|
568 |
} catch (SQLException e) { |
|
569 |
// TODO Auto-generated catch block |
|
570 |
e.printStackTrace(); |
|
571 |
} |
|
572 |
value = ((value*factor_b)/factor_c); |
|
573 |
return ((value * 180.0) / 200.0); |
|
574 |
} |
|
575 |
|
|
576 |
public double convertFromMeters(String unitSource, String unitTarget, double value) { |
|
577 |
double factor_b = 0; |
|
578 |
double factor_c = 0; |
|
579 |
String sentence = "SELECT factor_b, factor_c " + |
|
580 |
"FROM epsg_unitofmeasure " + |
|
581 |
"WHERE unit_of_meas_name = '" +unitSource + "'"; |
|
582 |
EpsgConnection connect = new EpsgConnection(); |
|
583 |
connect.setConnectionEPSG(); |
|
584 |
ResultSet result = Query.select(sentence,connect.getConnection()); |
|
585 |
try { |
|
586 |
result.next(); |
|
587 |
factor_b = result.getDouble("factor_b"); |
|
588 |
factor_c = result.getDouble("factor_c"); |
|
589 |
} catch (SQLException e) { |
|
590 |
// TODO Auto-generated catch block |
|
591 |
e.printStackTrace(); |
|
592 |
} |
|
593 |
value = ((value*factor_b)/factor_c); |
|
594 |
|
|
595 |
sentence = "SELECT factor_b, factor_c " + |
|
596 |
"FROM epsg_unitofmeasure " + |
|
597 |
"WHERE unit_of_meas_name = '" +unitSource + "'"; |
|
598 |
connect = new EpsgConnection(); |
|
599 |
connect.setConnectionEPSG(); |
|
600 |
result = Query.select(sentence,connect.getConnection()); |
|
601 |
try { |
|
602 |
result.next(); |
|
603 |
factor_b = result.getDouble("factor_b"); |
|
604 |
factor_c = result.getDouble("factor_c"); |
|
605 |
} catch (SQLException e) { |
|
606 |
// TODO Auto-generated catch block |
|
607 |
e.printStackTrace(); |
|
608 |
} |
|
609 |
return ((value*factor_c)/factor_b); |
|
610 |
} |
|
611 |
|
|
612 |
public double convertFromUnitless(String unitSource, String unitTarget, double value) { |
|
613 |
double factor_b = 0; |
|
614 |
double factor_c = 0; |
|
615 |
String sentence = "SELECT factor_b, factor_c " + |
|
616 |
"FROM epsg_unitofmeasure " + |
|
617 |
"WHERE unit_of_meas_name = '" +unitSource + "'"; |
|
618 |
EpsgConnection connect = new EpsgConnection(); |
|
619 |
connect.setConnectionEPSG(); |
|
620 |
ResultSet result = Query.select(sentence,connect.getConnection()); |
|
621 |
try { |
|
622 |
result.next(); |
|
623 |
factor_b = result.getDouble("factor_b"); |
|
624 |
factor_c = result.getDouble("factor_c"); |
|
625 |
} catch (SQLException e) { |
|
626 |
// TODO Auto-generated catch block |
|
627 |
e.printStackTrace(); |
|
628 |
} |
|
629 |
value = ((value*factor_b)/factor_c); |
|
630 |
|
|
631 |
sentence = "SELECT factor_b, factor_c " + |
|
632 |
"FROM epsg_unitofmeasure " + |
|
633 |
"WHERE unit_of_meas_name = '" +unitSource + "'"; |
|
634 |
connect = new EpsgConnection(); |
|
635 |
connect.setConnectionEPSG(); |
|
636 |
result = Query.select(sentence,connect.getConnection()); |
|
637 |
try { |
|
638 |
result.next(); |
|
639 |
factor_b = result.getDouble("factor_b"); |
|
640 |
factor_c = result.getDouble("factor_c"); |
|
641 |
} catch (SQLException e) { |
|
642 |
// TODO Auto-generated catch block |
|
643 |
e.printStackTrace(); |
|
644 |
} |
|
645 |
return ((value*factor_c)/factor_b); |
|
646 |
} |
|
647 |
|
|
648 |
public double convertFromDegree(String unitSource, String unitTarget, double value) { |
|
649 |
double factor_b = 0; |
|
650 |
double factor_c = 0; |
|
651 |
String sentence = "SELECT factor_b, factor_c " + |
|
652 |
"FROM epsg_unitofmeasure " + |
|
653 |
"WHERE unit_of_meas_name = '" +unitSource + "'"; |
|
654 |
EpsgConnection connect = new EpsgConnection(); |
|
655 |
connect.setConnectionEPSG(); |
|
656 |
ResultSet result = Query.select(sentence,connect.getConnection()); |
|
657 |
try { |
|
658 |
result.next(); |
|
659 |
factor_b = result.getDouble("factor_b"); |
|
660 |
factor_c = result.getDouble("factor_c"); |
|
661 |
} catch (SQLException e) { |
|
662 |
// TODO Auto-generated catch block |
|
663 |
e.printStackTrace(); |
|
664 |
} |
|
665 |
value = ((value*factor_b)/factor_c); |
|
666 |
|
|
667 |
sentence = "SELECT factor_b, factor_c " + |
|
668 |
"FROM epsg_unitofmeasure " + |
|
669 |
"WHERE unit_of_meas_name = '" +unitSource + "'"; |
|
670 |
connect = new EpsgConnection(); |
|
671 |
connect.setConnectionEPSG(); |
|
672 |
result = Query.select(sentence,connect.getConnection()); |
|
673 |
try { |
|
674 |
result.next(); |
|
675 |
factor_b = result.getDouble("factor_b"); |
|
676 |
factor_c = result.getDouble("factor_c"); |
|
677 |
} catch (SQLException e) { |
|
678 |
// TODO Auto-generated catch block |
|
679 |
e.printStackTrace(); |
|
680 |
} |
|
681 |
return ((value*factor_c)/factor_b); |
|
682 |
} |
|
499 | 683 |
|
500 | 684 |
} |
501 | 685 |
|
branches/F2/extensions/extJCRS/src/org/gvsig/crs/gui/panels/wizard/MainPanel.java | ||
---|---|---|
5 | 5 |
import java.awt.FlowLayout; |
6 | 6 |
import java.awt.event.ActionEvent; |
7 | 7 |
import java.awt.event.ActionListener; |
8 |
import java.sql.ResultSet; |
|
8 | 9 |
import java.sql.SQLException; |
9 | 10 |
|
10 | 11 |
import javax.swing.JButton; |
12 |
import javax.swing.JOptionPane; |
|
11 | 13 |
import javax.swing.JPanel; |
12 | 14 |
|
13 | 15 |
import org.gvsig.crs.ICrs; |
16 |
import org.gvsig.crs.gui.panels.EPSGpanel; |
|
14 | 17 |
|
15 | 18 |
import com.iver.andami.PluginServices; |
16 | 19 |
import com.iver.andami.ui.mdiManager.IWindow; |
17 | 20 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
18 | 21 |
|
19 | 22 |
import es.idr.teledeteccion.connection.EpsgConnection; |
23 |
import es.idr.teledeteccion.connection.Query; |
|
20 | 24 |
|
21 | 25 |
|
22 | 26 |
/** |
... | ... | |
178 | 182 |
} |
179 | 183 |
else fillData(getCrs()); |
180 | 184 |
} |
185 |
else if (getPCrsUsr().isShowing() && getPCrsUsr().getRbNuevoCrs().isSelected() ){ |
|
186 |
cleanData(); |
|
187 |
} |
|
181 | 188 |
cl.next(pCard); |
182 | 189 |
getBtnAnterior().setVisible(true); |
183 | 190 |
//Si aparece el ultimo panel visualizar el botn finalizar |
... | ... | |
190 | 197 |
|
191 | 198 |
}else if(e.getSource().equals(getBtnFinalizar())){ |
192 | 199 |
//Realizar las acciones de fin del Wizard |
193 |
getDataAndUpdate(); |
|
194 |
System.out.println("Finalizar el Asistente"); |
|
195 |
System.out.println("Cerrar el Asistente"); |
|
196 |
PluginServices.getMDIManager().closeWindow(this); |
|
197 |
|
|
200 |
getDataAndUpdate(); |
|
198 | 201 |
}else if(e.getSource().equals(getBtnCancelar())){ |
199 | 202 |
//Cerrar el asistente |
200 | 203 |
PluginServices.getMDIManager().closeWindow(this); |
... | ... | |
224 | 227 |
getPSistCoord().fillData(crs); |
225 | 228 |
} |
226 | 229 |
|
230 |
private void cleanData() { |
|
231 |
getPDatum().cleanData(); |
|
232 |
getPSistCoord().cleanData(); |
|
233 |
} |
|
234 |
|
|
227 | 235 |
private void getDataAndUpdate() { |
236 |
EpsgConnection conn = new EpsgConnection(); |
|
237 |
conn.setConnectionUsr(); |
|
228 | 238 |
String[] spheroid = {getPDatum().getTxtElipsoide().getText(), |
229 | 239 |
getPDatum().getTxtSemMay().getText(), |
230 | 240 |
getPDatum().getTxtInvF().getText()}; |
... | ... | |
232 | 242 |
getPDatum().getTxtLong().getText()}; |
233 | 243 |
|
234 | 244 |
String[] authority = {"\"USR\"", "2001"}; |
245 |
String sentence = "SELECT usr_code FROM USR WHERE usr_code = " +authority[1]; |
|
246 |
ResultSet result = Query.select(sentence, conn.getConnection()); |
|
247 |
try { |
|
248 |
if (result.next()) { |
|
249 |
JOptionPane.showMessageDialog(MainPanel.this, |
|
250 |
PluginServices.getText(this,"crsRepeat")+": "+authority[1], |
|
251 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
|
252 |
return; |
|
253 |
} |
|
254 |
} catch (SQLException e1) { |
|
255 |
// TODO Auto-generated catch block |
|
256 |
e1.printStackTrace(); |
|
257 |
} |
|
235 | 258 |
String datum = getPDatum().getTxtDatum().getText(); |
236 |
String sentence; |
|
237 | 259 |
|
260 |
|
|
238 | 261 |
if (getPSistCoord().getRbGeografico().isSelected()) { |
239 | 262 |
cadWkt = "GEOGCS[\"" + "Nombre crs usuario" + "\", DATUM[\""+ datum + |
240 | 263 |
"\", SPHEROID[\""+ spheroid[0] + "\", "+ spheroid[1] + ", "+ spheroid[2] +"]], " + |
... | ... | |
266 | 289 |
sentence = "INSERT INTO USR VALUES("+authority[1]+",'" + |
267 | 290 |
cadWkt +"','crs proyectado usuario','Nombre crs usuario','"+datum+"')"; |
268 | 291 |
|
269 |
} |
|
270 |
EpsgConnection conn = new EpsgConnection(); |
|
271 |
conn.setConnectionUsr(); |
|
292 |
} |
|
272 | 293 |
|
273 | 294 |
try { |
274 | 295 |
conn.update(sentence); |
... | ... | |
276 | 297 |
} catch (SQLException e) { |
277 | 298 |
// TODO Auto-generated catch block |
278 | 299 |
e.printStackTrace(); |
279 |
} |
|
280 |
|
|
300 |
} |
|
281 | 301 |
setNewCrsCode(Integer.parseInt(authority[1])); |
302 |
PluginServices.getMDIManager().closeWindow(this); |
|
282 | 303 |
} |
283 | 304 |
|
284 | 305 |
public void setNewCrsCode(int code) { |
branches/F2/extensions/extJCRS/src/org/gvsig/crs/gui/panels/wizard/DefinirDatum.java | ||
---|---|---|
568 | 568 |
System.out.println("Importar Datum"); |
569 | 569 |
ImportNewCrsDialog newCrs = new ImportNewCrsDialog("datum"); |
570 | 570 |
PluginServices.getMDIManager().addWindow(newCrs); |
571 |
setCrs(newCrs.getCode()); |
|
572 |
fillData(getCrs()); |
|
571 |
if (newCrs.getCode() != -1) { |
|
572 |
setCrs(newCrs.getCode()); |
|
573 |
fillData(getCrs()); |
|
574 |
} |
|
573 | 575 |
}else if(e.getSource().equals(getBtnImportElipsoide())){ |
574 | 576 |
System.out.println("Importar Elipsoide"); |
575 | 577 |
ImportNewCrsDialog newCrs = new ImportNewCrsDialog("ellips"); |
576 | 578 |
PluginServices.getMDIManager().addWindow(newCrs); |
577 |
setCrs(newCrs.getCode()); |
|
578 |
fillEllipsoid(getCrs()); |
|
579 |
if (newCrs.getCode() != -1) { |
|
580 |
setCrs(newCrs.getCode()); |
|
581 |
fillEllipsoid(getCrs()); |
|
582 |
} |
|
579 | 583 |
}else if(e.getSource().equals(getBtnImportMeridian())){ |
580 | 584 |
System.out.println("Importar Meridiano"); |
581 | 585 |
ImportNewCrsDialog newCrs = new ImportNewCrsDialog("primem"); |
582 | 586 |
PluginServices.getMDIManager().addWindow(newCrs); |
583 |
setCrs(newCrs.getCode()); |
|
584 |
fillPrimeMeridian(getCrs()); |
|
587 |
if (newCrs.getCode() != -1) { |
|
588 |
setCrs(newCrs.getCode()); |
|
589 |
fillPrimeMeridian(getCrs()); |
|
590 |
} |
|
585 | 591 |
}else if(e.getSource().equals(getRbInvF())){ |
586 | 592 |
System.out.println("opcion Inverse Flat"); |
587 | 593 |
/*Si selecciona esta opcin se fija este |
... | ... | |
650 | 656 |
return crs; |
651 | 657 |
} |
652 | 658 |
|
659 |
public void cleanData() { |
|
660 |
txtDatum.setText(""); |
|
661 |
txtElipsoide.setText(""); |
|
662 |
txtInvF.setText(""); |
|
663 |
txtLong.setText(""); |
|
664 |
txtMeridian.setText(""); |
|
665 |
txtSemMay.setText(""); |
|
666 |
txtSemMen.setText(""); |
|
667 |
} |
|
668 |
|
|
653 | 669 |
} |
branches/F2/extensions/extJCRS/src/org/gvsig/crs/gui/listeners/ImportNewCrsDialogListener.java | ||
---|---|---|
21 | 21 |
public class ImportNewCrsDialogListener implements ActionListener, |
22 | 22 |
ListSelectionListener, MouseListener { |
23 | 23 |
|
24 |
ImportNewCrsDialog dialog = null; |
|
24 |
ImportNewCrsDialog dialog = null;
|
|
25 | 25 |
|
26 | 26 |
public ImportNewCrsDialogListener(ImportNewCrsDialog d) { |
27 | 27 |
dialog = d; |
... | ... | |
64 | 64 |
else { |
65 | 65 |
JOptionPane.showMessageDialog(dialog, PluginServices.getText(this,"crs_not_soported"), "Warning...", |
66 | 66 |
JOptionPane.WARNING_MESSAGE); |
67 |
dialog.setCode(0);
|
|
67 |
dialog.setCode(-1);
|
|
68 | 68 |
dialog.getJButtonAccept().setEnabled(false); |
69 | 69 |
dialog.getEpsgPanel().getInfoCrs().setEnabled(false); |
70 | 70 |
} |
Also available in: Unified diff