svn-gvsig-desktop / trunk / extensions / extJCRS / src / org / gvsig / crs / gui / panels / TransformationNadgridsPanel.java @ 20637
History | View | Annotate | Download (18.8 KB)
1 |
/* gvSIG. Sistema de Informacin Geogrfica de la Generalitat Valenciana
|
---|---|
2 |
*
|
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 |
* Av. Blasco Ibez, 50
|
24 |
* 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 |
import java.awt.BorderLayout; |
44 |
import java.awt.Component; |
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.io.File; |
51 |
import java.io.FileInputStream; |
52 |
import java.io.FileNotFoundException; |
53 |
import java.io.FileOutputStream; |
54 |
import java.io.IOException; |
55 |
import java.io.InputStream; |
56 |
import java.io.OutputStream; |
57 |
import java.io.RandomAccessFile; |
58 |
|
59 |
import javax.swing.BorderFactory; |
60 |
import javax.swing.JButton; |
61 |
import javax.swing.JComboBox; |
62 |
import javax.swing.JFileChooser; |
63 |
import javax.swing.JLabel; |
64 |
import javax.swing.JPanel; |
65 |
import javax.swing.JRadioButton; |
66 |
import javax.swing.JTextArea; |
67 |
import javax.swing.border.EmptyBorder; |
68 |
import javax.swing.filechooser.FileFilter; |
69 |
|
70 |
import org.cresques.cts.IProjection; |
71 |
import org.gvsig.crs.CrsException; |
72 |
import org.gvsig.crs.CrsFactory; |
73 |
import org.gvsig.crs.CrsWkt; |
74 |
import org.gvsig.crs.ICrs; |
75 |
import org.gvsig.crs.persistence.RecentCRSsPersistence; |
76 |
import org.gvsig.crs.persistence.RecentTrsPersistence; |
77 |
import org.gvsig.crs.persistence.TrData; |
78 |
|
79 |
import au.com.objectix.jgridshift.GridShiftFile; |
80 |
import au.com.objectix.jgridshift.SubGrid; |
81 |
|
82 |
import com.iver.andami.PluginServices; |
83 |
import com.iver.andami.ui.mdiManager.IWindow; |
84 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
85 |
import com.iver.utiles.XMLEntity; |
86 |
|
87 |
/**
|
88 |
* Clase para generar el panel de la tranformacin nadgrids y su
|
89 |
* manejo
|
90 |
*
|
91 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)
|
92 |
* @author Jos Luis Gmez Martnez (jolugomar@gmail.com)
|
93 |
* @author Luisa Marina Fernndez (luisam.fernandez@uclm.es)
|
94 |
*
|
95 |
*/
|
96 |
public class TransformationNadgridsPanel extends JPanel implements IWindow, ActionListener { |
97 |
|
98 |
private static final long serialVersionUID = 1L; |
99 |
|
100 |
private JPanel groupRadioButton = null; |
101 |
private JLabel jLabelChooser = null; |
102 |
private JRadioButton jRadioButtonSource = null; |
103 |
private JRadioButton jRadioButtonTarget = null; |
104 |
|
105 |
private IProjection firstProj;
|
106 |
private String nadFile = null; |
107 |
String[] targetAuthority; |
108 |
String targetAbrev = ""; |
109 |
String sourceAbrev = ""; |
110 |
|
111 |
private String cadWKT = ""; |
112 |
private String dataPath = "./gvSIG/extensiones/org.gvsig.crs/data/"; |
113 |
private int codeEpsg; |
114 |
|
115 |
private JPanel jPanelOpen; |
116 |
private JPanel jPanelSelectNad; |
117 |
private JLabel jLabelOpenGsb; |
118 |
private JFileChooser openFileChooser; |
119 |
private JButton jButtonOpen; |
120 |
private TreePanel treePanel = null; |
121 |
private JComboBox jComboNadFile = null; |
122 |
private JLabel jLabelSelectNad = null; |
123 |
|
124 |
|
125 |
private JTextArea jTextAreaInfo; |
126 |
|
127 |
private PluginServices ps = null; |
128 |
private XMLEntity xml = null; |
129 |
|
130 |
boolean targetNad = false; |
131 |
boolean setRadioButtons = false; |
132 |
|
133 |
public TransformationNadgridsPanel(boolean optional) { |
134 |
ps = PluginServices.getPluginServices("org.gvsig.crs");
|
135 |
xml = ps.getPersistentXML(); |
136 |
setRadioButtons = optional; |
137 |
initialize(); |
138 |
} |
139 |
|
140 |
private void initialize(){ |
141 |
|
142 |
this.setLayout(new BorderLayout()); |
143 |
this.setBorder(BorderFactory.createCompoundBorder( |
144 |
BorderFactory.createTitledBorder("+ "+PluginServices.getText(this,"nadgrids")), |
145 |
BorderFactory.createEmptyBorder(5,5,5,5))); |
146 |
JPanel pNorth=new JPanel(); |
147 |
pNorth.setBorder(new EmptyBorder(1,10,1,10)); |
148 |
pNorth.setLayout(new GridLayout(4,1)); |
149 |
|
150 |
pNorth.add(getJPanelOpen()); |
151 |
//label+combo
|
152 |
pNorth.add(getJPanelSelectNad()); |
153 |
JPanel lbl=new JPanel(new FlowLayout(FlowLayout.LEFT,0,10)); |
154 |
lbl.add(getJLabelChooser()); |
155 |
if (setRadioButtons) {
|
156 |
pNorth.add(lbl); |
157 |
//dos radio buttons
|
158 |
pNorth.add(getGroupRadioButton()); |
159 |
} |
160 |
this.add(pNorth,BorderLayout.NORTH); |
161 |
this.add(getTreePanel(),BorderLayout.CENTER); |
162 |
|
163 |
} |
164 |
|
165 |
private JPanel getGroupRadioButton() { |
166 |
if (groupRadioButton == null) { |
167 |
groupRadioButton = new JPanel(); |
168 |
groupRadioButton.setLayout(new GridLayout(1,0)); |
169 |
groupRadioButton.add(getJRadioButtonSource()); |
170 |
groupRadioButton.add(getJRadioButtonTarget()); |
171 |
} |
172 |
return groupRadioButton;
|
173 |
} |
174 |
|
175 |
private JRadioButton getJRadioButtonSource() { |
176 |
if (jRadioButtonSource == null) { |
177 |
jRadioButtonSource = new JRadioButton(); |
178 |
jRadioButtonSource.setSelected(true);
|
179 |
jRadioButtonSource.addActionListener(this);
|
180 |
} |
181 |
jRadioButtonSource.setText(PluginServices.getText(this,"aplicar_capa") + " " + "("+getSourceAbrev()+")" ); |
182 |
return jRadioButtonSource;
|
183 |
} |
184 |
|
185 |
|
186 |
private JRadioButton getJRadioButtonTarget() { |
187 |
if (jRadioButtonTarget == null) { |
188 |
jRadioButtonTarget = new JRadioButton(); |
189 |
jRadioButtonTarget.setSelected(false);
|
190 |
jRadioButtonTarget.addActionListener(this);
|
191 |
} |
192 |
jRadioButtonTarget.setText(PluginServices.getText(this,"aplicar_vista") + " " + "("+ getTargetAbrev()+")"); |
193 |
return jRadioButtonTarget;
|
194 |
} |
195 |
|
196 |
private JLabel getJLabelChooser(){ |
197 |
jLabelChooser = new JLabel(); |
198 |
jLabelChooser.setText(PluginServices.getText(this, "seleccion_nadgrids")+":"); |
199 |
return jLabelChooser;
|
200 |
} |
201 |
|
202 |
|
203 |
private JPanel getJPanelOpen() { |
204 |
if(jPanelOpen == null) { |
205 |
jPanelOpen = new JPanel(); |
206 |
jPanelOpen.setLayout(new FlowLayout(FlowLayout.LEFT,5,5)); |
207 |
jPanelOpen.add(getJLabelOpenGsb(), null);
|
208 |
jPanelOpen.add(getJButtonOpen(), null);
|
209 |
} |
210 |
return jPanelOpen;
|
211 |
} |
212 |
|
213 |
private JLabel getJLabelOpenGsb() { |
214 |
if(jLabelOpenGsb == null) { |
215 |
jLabelOpenGsb = new JLabel(); |
216 |
jLabelOpenGsb.setPreferredSize(new Dimension(130,20)); |
217 |
jLabelOpenGsb.setText(PluginServices.getText(this,"importarRejilla")); |
218 |
} |
219 |
return jLabelOpenGsb;
|
220 |
} |
221 |
|
222 |
private JFileChooser getOpenFileChooser(){ |
223 |
if(openFileChooser == null){ |
224 |
openFileChooser = new JFileChooser(); |
225 |
openFileChooser.setEnabled(false);
|
226 |
openFileChooser.addChoosableFileFilter(new FiltroNadgrids());
|
227 |
} |
228 |
return openFileChooser;
|
229 |
} |
230 |
|
231 |
private JButton getJButtonOpen() { |
232 |
if(jButtonOpen == null) { |
233 |
jButtonOpen = new JButton(); |
234 |
jButtonOpen.setText("");
|
235 |
jButtonOpen.setPreferredSize(new Dimension(20,20)); |
236 |
jButtonOpen.setText("...");
|
237 |
jButtonOpen.addActionListener(this);
|
238 |
} |
239 |
return jButtonOpen;
|
240 |
} |
241 |
|
242 |
public ICrs getProjection() {
|
243 |
ICrs crs; |
244 |
if (jRadioButtonSource.isSelected()){
|
245 |
try {
|
246 |
setNad(false);
|
247 |
//crs = new CrsFactory().getCRS(getSourceAbrev(), getWKT());
|
248 |
crs = new CrsFactory().getCRS(getSourceAbrev());
|
249 |
crs.setTransformationParams("+nadgrids="+getNadFile(),null);//nadFile); |
250 |
return crs;
|
251 |
} catch (org.gvsig.crs.CrsException e) {
|
252 |
e.printStackTrace(); |
253 |
} |
254 |
return null; |
255 |
} |
256 |
else {
|
257 |
setNad(true);
|
258 |
try {
|
259 |
//crs = new CrsFactory().getCRS(getSourceAbrev(), getWKT());
|
260 |
crs = new CrsFactory().getCRS(getSourceAbrev());
|
261 |
crs.setTransformationParams(null,"+nadgrids="+getNadFile());//nadFile); |
262 |
//crs.setParamsInTarget(true);
|
263 |
|
264 |
return crs;
|
265 |
} catch (CrsException e) {
|
266 |
e.printStackTrace(); |
267 |
} |
268 |
return null; |
269 |
} |
270 |
} |
271 |
|
272 |
public void setProjection(IProjection proj) { |
273 |
firstProj = proj; |
274 |
} |
275 |
|
276 |
public void setNad(boolean nadg){ |
277 |
targetNad = nadg; |
278 |
} |
279 |
|
280 |
public boolean getNad(){ |
281 |
return targetNad;
|
282 |
} |
283 |
|
284 |
public void setCode(int cod){ |
285 |
codeEpsg = cod; |
286 |
} |
287 |
|
288 |
public int getCode(){ |
289 |
return codeEpsg;
|
290 |
} |
291 |
|
292 |
public void setWKT(String cad){ |
293 |
cadWKT = cad; |
294 |
CrsWkt parser = new CrsWkt(cad);
|
295 |
//setSourceAbrev(parser.getAuthority()[0], parser.getAuthority()[1]);
|
296 |
//getJTextAreaInfo();
|
297 |
//getJRadioButtonSource();
|
298 |
} |
299 |
|
300 |
public String getWKT(){ |
301 |
return cadWKT;
|
302 |
} |
303 |
|
304 |
public void setTargetAuthority(String[] authority){ |
305 |
targetAuthority = authority; |
306 |
setTargetAbrev(targetAuthority[0], targetAuthority[1]); |
307 |
getJRadioButtonTarget(); |
308 |
} |
309 |
|
310 |
public String[] getTargetAuthority(){ |
311 |
return targetAuthority;
|
312 |
} |
313 |
|
314 |
public void setTargetAbrev(String fuente, String codigo){ |
315 |
targetAbrev = fuente + ":" + codigo;
|
316 |
} |
317 |
|
318 |
public String getTargetAbrev() { |
319 |
return targetAbrev;
|
320 |
} |
321 |
|
322 |
public void setSourceAbrev(String fuente, String codigo){ |
323 |
sourceAbrev = fuente + ":" + codigo;
|
324 |
getJRadioButtonSource(); |
325 |
} |
326 |
|
327 |
public String getSourceAbrev(){ |
328 |
return sourceAbrev;
|
329 |
} |
330 |
|
331 |
public WindowInfo getWindowInfo() {
|
332 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
333 |
m_viewinfo.setTitle(PluginServices.getText(this,"nadgrids")); |
334 |
return m_viewinfo;
|
335 |
} |
336 |
|
337 |
public void actionPerformed(ActionEvent e) { |
338 |
if (e.getSource() == this.getJRadioButtonSource()){ |
339 |
jRadioButtonSource.setSelected(true);
|
340 |
jRadioButtonTarget.setSelected(false);
|
341 |
} |
342 |
|
343 |
if (e.getSource() == this.getJRadioButtonTarget()){ |
344 |
jRadioButtonTarget.setSelected(true);
|
345 |
jRadioButtonSource.setSelected(false);
|
346 |
} |
347 |
|
348 |
if (e.getSource() == this.getJButtonOpen()){ |
349 |
jPanelOpen.add(getOpenFileChooser(), null);
|
350 |
//openChooser.setCurrentDirectory(f);
|
351 |
int returnVal = openFileChooser.showOpenDialog(TransformationNadgridsPanel.this);
|
352 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
353 |
File inFile = openFileChooser.getSelectedFile();
|
354 |
//jTextOpen.setText(file.getAbsolutePath());
|
355 |
|
356 |
String fileName = inFile.getName();
|
357 |
|
358 |
//Comprobar que el fichero existe y tiene formato valido
|
359 |
RandomAccessFile raFile = null; |
360 |
try {
|
361 |
raFile = new RandomAccessFile(inFile.getAbsolutePath(),"r"); |
362 |
} catch (FileNotFoundException ex) { |
363 |
ex.printStackTrace(); |
364 |
getJComboNadFile().setSelectedIndex(0);
|
365 |
getTreePanel().setRoot(PluginServices.getText(this,"nadfile_not_found")); |
366 |
setNadFile(null);//nadFile = null; |
367 |
return;
|
368 |
} |
369 |
GridShiftFile gsf = new GridShiftFile();
|
370 |
try {
|
371 |
gsf.loadGridShiftFile(raFile); |
372 |
} catch (IOException ex) { |
373 |
ex.printStackTrace(); |
374 |
getJComboNadFile().setSelectedIndex(0);
|
375 |
getTreePanel().setRoot(PluginServices.getText(this,"nadfile_bad_format")); |
376 |
setNadFile(null);//nadFile = null; |
377 |
return;
|
378 |
}catch (java.lang.Exception ex) {
|
379 |
ex.printStackTrace(); |
380 |
getJComboNadFile().setSelectedIndex(0);
|
381 |
getTreePanel().setRoot(PluginServices.getText(this,"nadfile_bad_format")); |
382 |
setNadFile(null);//nadFile = null; |
383 |
return;
|
384 |
} |
385 |
|
386 |
//Copiar el fichero seleccionado al directorio data de la extensin:
|
387 |
|
388 |
File outFile = new File(dataPath+fileName); |
389 |
InputStream in = null; |
390 |
OutputStream out = null; |
391 |
try {
|
392 |
in = new FileInputStream(inFile); |
393 |
out = new FileOutputStream(outFile); |
394 |
} catch (FileNotFoundException ex) { |
395 |
ex.printStackTrace(); |
396 |
} |
397 |
byte[] buf = new byte[1024]; |
398 |
int len;
|
399 |
try {
|
400 |
while ((len = in.read(buf)) > 0) { |
401 |
out.write(buf, 0, len);
|
402 |
} |
403 |
in.close(); |
404 |
out.close(); |
405 |
} catch (IOException ex) { |
406 |
ex.printStackTrace(); |
407 |
} |
408 |
|
409 |
//Incluir el fichero importado en el combo y seleccionarlo
|
410 |
boolean exists = false; |
411 |
for (int item=0; item<getJComboNadFile().getItemCount() && !exists;item++) |
412 |
if (getJComboNadFile().getItemAt(item).equals(fileName))
|
413 |
exists = true;
|
414 |
if(!exists)
|
415 |
getJComboNadFile().addItem(fileName); |
416 |
getJComboNadFile().setSelectedItem(fileName); |
417 |
setNadFile(fileName);//nadFile = fileName;
|
418 |
} |
419 |
} |
420 |
} |
421 |
|
422 |
public TreePanel getTreePanel() {
|
423 |
if (treePanel == null){ |
424 |
treePanel = new TreePanel(PluginServices.getText(this,"grids_en")+": "+nadFile); |
425 |
treePanel.getTree().expandRow(0);
|
426 |
treePanel.setPanelSize(530,150); |
427 |
} |
428 |
return treePanel;
|
429 |
} |
430 |
|
431 |
public void initializeTree(){ |
432 |
// leer el fichero nadgrids
|
433 |
RandomAccessFile raFile = null; |
434 |
try {
|
435 |
raFile = new RandomAccessFile("./gvSIG/extensiones/org.gvsig.crs/data/"+nadFile,"r"); |
436 |
} catch (FileNotFoundException e) { |
437 |
e.printStackTrace(); |
438 |
getTreePanel().setRoot(PluginServices.getText(this,"nadfile_not_found")); |
439 |
setNadFile(null);//nadFile = null; |
440 |
return;
|
441 |
} |
442 |
GridShiftFile gsf = new GridShiftFile();
|
443 |
try {
|
444 |
gsf.loadGridShiftFile(raFile); |
445 |
} catch (IOException e) { |
446 |
e.printStackTrace(); |
447 |
getTreePanel().setRoot(PluginServices.getText(this,"nadfile_bad_format")); |
448 |
setNadFile(null);//nadFile = null; |
449 |
return;
|
450 |
}catch (java.lang.Exception e) {
|
451 |
e.printStackTrace(); |
452 |
getTreePanel().setRoot(PluginServices.getText(this,"nadfile_bad_format")); |
453 |
setNadFile(null);//nadFile = null; |
454 |
return;
|
455 |
} |
456 |
|
457 |
SubGrid subGrid[] = gsf.getSubGridTree();
|
458 |
|
459 |
for (int i=0;i<subGrid.length;i++){ |
460 |
getTreePanel().addClass(subGrid[i].getSubGridName(),i); |
461 |
getTreePanel().addEntry(PluginServices.getText(this,"long_min")+": "+String.valueOf(subGrid[i].getMaxLon()/-3600)+"",subGrid[i].getSubGridName(), ""); |
462 |
getTreePanel().addEntry(PluginServices.getText(this,"lat_min")+": "+String.valueOf(subGrid[i].getMinLat()/3600)+"?",subGrid[i].getSubGridName(), ""); |
463 |
getTreePanel().addEntry(PluginServices.getText(this,"long_max")+": "+String.valueOf(subGrid[i].getMinLon()/-3600+"?"),subGrid[i].getSubGridName(), ""); |
464 |
getTreePanel().addEntry(PluginServices.getText(this,"lat_max")+": "+String.valueOf(subGrid[i].getMaxLat()/3600+""),subGrid[i].getSubGridName(), ""); |
465 |
getTreePanel().addEntry(PluginServices.getText(this,"node_count")+": "+String.valueOf(subGrid[i].getNodeCount()),subGrid[i].getSubGridName(), ""); |
466 |
getTreePanel().addEntry(PluginServices.getText(this,"detalles")+": "+String.valueOf(subGrid[i].getDetails()),subGrid[i].getSubGridName(), ""); |
467 |
} |
468 |
getTreePanel().getTree().expandRow(0);
|
469 |
getTreePanel().getList().setText(PluginServices.getText(this,"advertencia_nad")); |
470 |
} |
471 |
|
472 |
public JComboBox getJComboNadFile() { |
473 |
if (jComboNadFile == null){ |
474 |
jComboNadFile = new JComboBox(); |
475 |
jComboNadFile.setPreferredSize(new Dimension(200,25)); |
476 |
jComboNadFile.setEditable(false);
|
477 |
jComboNadFile.addItem(PluginServices.getText(this,"seleccionar")+"..."); |
478 |
//Aadir los al combo los nombres de los .gsb que hay en el directorio data
|
479 |
File dataDir = new File(dataPath); |
480 |
for (int i = 0; i<dataDir.list().length;i++) |
481 |
if (dataDir.list()[i].substring(dataDir.list()[i].lastIndexOf('.')+1).equals("gsb")){ |
482 |
jComboNadFile.addItem(dataDir.list()[i]); |
483 |
} |
484 |
if (getNadFile() != null)//nadFile != null) |
485 |
jComboNadFile.setSelectedItem(getNadFile());//nadFile);
|
486 |
|
487 |
} |
488 |
return jComboNadFile;
|
489 |
} |
490 |
|
491 |
public JLabel getJLabelSelectNad() { |
492 |
if (jLabelSelectNad == null){ |
493 |
jLabelSelectNad = new JLabel(PluginServices.getText(this,"seleccionarRejilla")+": "); |
494 |
jLabelSelectNad.setPreferredSize(new Dimension(130,25)); |
495 |
} |
496 |
return jLabelSelectNad;
|
497 |
} |
498 |
|
499 |
public JPanel getJPanelSelectNad() { |
500 |
if (jPanelSelectNad == null){ |
501 |
jPanelSelectNad = new JPanel(); |
502 |
jPanelSelectNad.setLayout(new FlowLayout(FlowLayout.LEFT,5,5)); |
503 |
jPanelSelectNad.add(getJLabelSelectNad()); |
504 |
jPanelSelectNad.add(getJComboNadFile()); |
505 |
} |
506 |
return jPanelSelectNad;
|
507 |
} |
508 |
|
509 |
public void setNadFile(String nad){ |
510 |
nadFile = nad; |
511 |
} |
512 |
|
513 |
public String getNadFile(){ |
514 |
return nadFile;
|
515 |
} |
516 |
|
517 |
/**
|
518 |
* Guarda el nombre del fichero nadgrids mediante el modelo de persistencia
|
519 |
* de Andami
|
520 |
* @param name Nombre del fichero nadgrids
|
521 |
*/
|
522 |
public void saveNadFileName(String name){ |
523 |
ps = PluginServices.getPluginServices("org.gvsig.crs");
|
524 |
xml = ps.getPersistentXML(); |
525 |
|
526 |
for (int child = 0; child<xml.getChildrenCount();child++) |
527 |
if (xml.getChild(child).getPropertyName(0).equals("nadFile")) |
528 |
xml.removeChild(child); |
529 |
|
530 |
|
531 |
XMLEntity xmlEnt = new XMLEntity();
|
532 |
xmlEnt.putProperty("nadFile",name);
|
533 |
xml.addChild(xmlEnt); |
534 |
ps.setPersistentXML(xml); |
535 |
} |
536 |
|
537 |
/**
|
538 |
* Obtiene el nombre del fichero nadgrids guardado mediante el
|
539 |
* modelo de persistencia de Andami.
|
540 |
*
|
541 |
* @return nombre del fichero nadgrids o null si no ha sido guardado.
|
542 |
*/
|
543 |
private String restoreNadFileName(){ |
544 |
String fileName;
|
545 |
for (int child = 0; child<xml.getChildrenCount();child++) |
546 |
if (xml.getChild(child).getPropertyName(0).equals("nadFile")){ |
547 |
fileName = xml.getChild(child).getPropertyValue(0);
|
548 |
File dataDir = new File(dataPath); |
549 |
for (int i = 0; i<dataDir.list().length;i++) |
550 |
if (dataDir.list()[i].equals(fileName)){
|
551 |
return fileName;
|
552 |
} |
553 |
} |
554 |
|
555 |
return null; |
556 |
} |
557 |
|
558 |
/**
|
559 |
* cuando utilizamos crs+transformacion, cargamos los paneles para que
|
560 |
* el usuario pueda consultar la transformacion utilizada...
|
561 |
* @param details
|
562 |
*/
|
563 |
public void fillData(String details) { |
564 |
RecentTrsPersistence trPersistence = new RecentTrsPersistence();
|
565 |
TrData crsTrDataArray[] = trPersistence.getArrayOfTrData();
|
566 |
|
567 |
for (int iRow = crsTrDataArray.length-1; iRow >= 0; iRow--) { |
568 |
if (details.equals(crsTrDataArray[iRow].getAuthority()+":"+crsTrDataArray[iRow].getCode()+" <--> "+crsTrDataArray[iRow].getDetails()) && crsTrDataArray[iRow].getAuthority().equals(PluginServices.getText(this, "NADGR"))) { |
569 |
String data[] = crsTrDataArray[iRow].getDetails().split(" "); |
570 |
String fichero = data[0]; |
571 |
String authority = data[1].substring(1,data[1].length()-1); |
572 |
for (int i = 0; i< getJComboNadFile().getItemCount(); i++) { |
573 |
if (fichero.equals((String)getJComboNadFile().getItemAt(i))) { |
574 |
getJComboNadFile().setSelectedIndex(i); |
575 |
break;
|
576 |
} |
577 |
} |
578 |
if (authority.equals(getSourceAbrev())) {
|
579 |
getJRadioButtonSource().setSelected(true);
|
580 |
getJRadioButtonTarget().setSelected(false);
|
581 |
} |
582 |
else {
|
583 |
getJRadioButtonSource().setSelected(false);
|
584 |
getJRadioButtonTarget().setSelected(true);
|
585 |
} |
586 |
|
587 |
break;
|
588 |
} |
589 |
} |
590 |
} |
591 |
|
592 |
public void resetData () { |
593 |
getJRadioButtonSource().setSelected(true);
|
594 |
getJRadioButtonTarget().setSelected(false);
|
595 |
getJComboNadFile().setSelectedIndex(0);
|
596 |
} |
597 |
|
598 |
} |
599 |
|
600 |
class FiltroNadgrids extends FileFilter { |
601 |
|
602 |
final static String gsb = "gsb"; |
603 |
public boolean accept(File f) { |
604 |
if (f.isDirectory()) {
|
605 |
return true; |
606 |
} |
607 |
String s = f.getName();
|
608 |
int i = s.lastIndexOf('.'); |
609 |
|
610 |
if (i > 0 && i < s.length() - 1) { |
611 |
String extension = s.substring(i+1).toLowerCase(); |
612 |
if (gsb.equals(extension)){
|
613 |
return true; |
614 |
} else {
|
615 |
return false; |
616 |
} |
617 |
} |
618 |
return false; |
619 |
} |
620 |
|
621 |
public String getDescription() { |
622 |
return "Archivos .gsb"; |
623 |
} |
624 |
|
625 |
} |