svn-gvsig-desktop / branches / F2 / extensions / extJCRS / src / org / gvsig / crs / gui / CRSMainTrPanel.java @ 11570
History | View | Annotate | Download (15.2 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; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.CardLayout; |
45 |
import java.awt.Dimension; |
46 |
import java.awt.FlowLayout; |
47 |
|
48 |
import javax.swing.JButton; |
49 |
import javax.swing.JComboBox; |
50 |
import javax.swing.JLabel; |
51 |
import javax.swing.JPanel; |
52 |
import javax.swing.ListSelectionModel; |
53 |
import javax.swing.border.EmptyBorder; |
54 |
|
55 |
import org.cresques.cts.IProjection; |
56 |
import org.gvsig.crs.CrsException; |
57 |
import org.gvsig.crs.CrsFactory; |
58 |
import org.gvsig.crs.CrsWkt; |
59 |
import org.gvsig.crs.ICrs; |
60 |
import org.gvsig.crs.gui.listeners.CRSMainTrPanelListener; |
61 |
import org.gvsig.crs.gui.panels.TransformationEpsgPanel; |
62 |
import org.gvsig.crs.gui.panels.TransformationManualPanel; |
63 |
import org.gvsig.crs.gui.panels.TransformationNadgridsPanel; |
64 |
import org.gvsig.crs.gui.panels.TransformationRecentsPanel; |
65 |
|
66 |
import com.iver.andami.PluginServices; |
67 |
import com.iver.andami.ui.mdiManager.IWindow; |
68 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
69 |
|
70 |
/**
|
71 |
* Clase que genera el panel de transformacin, en el que se incluye la
|
72 |
* eleccin del CRS de la capa, as como el de la posibilidad de poder
|
73 |
* asignarle una transformacin.
|
74 |
*
|
75 |
* @author Jos Luis Gmez Martnez (jolugomar@gmail.com)
|
76 |
* @author Luisa Marina Fernandez (luisam.fernandez@uclm.es)
|
77 |
*
|
78 |
*/
|
79 |
|
80 |
public class CRSMainTrPanel extends JPanel implements IWindow{ |
81 |
|
82 |
private static final long serialVersionUID = 1L; |
83 |
|
84 |
/*
|
85 |
* Para mostrar los parametros si tenemos seleccionada transformacion
|
86 |
*/
|
87 |
boolean tra = false; |
88 |
boolean inAnApplet = true; |
89 |
private boolean cancelYes = false; |
90 |
private JButton jButtonCancel = null; |
91 |
private JButton jButtonNext = null; |
92 |
private JButton jButtonAccept = null; |
93 |
private JButton jButtonBefore = null; |
94 |
private JPanel jPanelButtons = null; |
95 |
private JLabel jLabelTrans=null; |
96 |
|
97 |
boolean targetNad = false; |
98 |
|
99 |
int crs_target = -1; |
100 |
CrsWkt crsWkt_target = null;
|
101 |
|
102 |
int transformation_code = 0; |
103 |
|
104 |
//**private JPanel panel = null;
|
105 |
CRSMainPanel viewPan = null;
|
106 |
|
107 |
private JPanel jPanelMain = null; |
108 |
private TransformationManualPanel manualTrPanel = null; |
109 |
private boolean manual_tr = false; |
110 |
private TransformationEpsgPanel epsgTrPanel = null; |
111 |
private boolean epsg_tr = false; |
112 |
private TransformationNadgridsPanel nadsTrPanel = null; |
113 |
private boolean nads_tr = false; |
114 |
private TransformationRecentsPanel recentsTrPanel = null; |
115 |
private boolean recents_tr = false; |
116 |
|
117 |
private boolean sin_tr = false; |
118 |
private JPanel jPanelCombo = null; |
119 |
private JComboBox jComboOptions = null; |
120 |
|
121 |
private IProjection crsfirst;
|
122 |
|
123 |
private CRSMainPanel crsMainPanel;
|
124 |
private String newSelection; |
125 |
String dataSource = ""; |
126 |
ICrs curProj = null;
|
127 |
|
128 |
public CRSMainTrPanel(int target, CrsWkt crsWkttarget, ICrs proj) { |
129 |
curProj = proj; |
130 |
crsMainPanel = new CRSMainPanel(target, (ICrs) crsfirst);
|
131 |
viewPan = crsMainPanel; |
132 |
|
133 |
crs_target = target; |
134 |
setCrsWkt_target(crsWkttarget); |
135 |
|
136 |
manualTrPanel = new TransformationManualPanel();
|
137 |
epsgTrPanel = new TransformationEpsgPanel(crs_target);
|
138 |
nadsTrPanel = new TransformationNadgridsPanel();
|
139 |
recentsTrPanel = new TransformationRecentsPanel();
|
140 |
|
141 |
/*
|
142 |
* esta variable contendr tanto el panel utilizado en CRSViewPanel, como los paneles
|
143 |
* que seran necesarios para realizar las transformaciones
|
144 |
*/
|
145 |
jPanelMain = new JPanel(); |
146 |
jPanelMain.setLayout(new CardLayout()); |
147 |
jPanelMain.add("primero", viewPanel());
|
148 |
jPanelMain.add("manual", manualTrPanel);
|
149 |
jPanelMain.add("epsg", epsgTrPanel);
|
150 |
jPanelMain.add("nad", nadsTrPanel);
|
151 |
jPanelMain.add("recents", recentsTrPanel);
|
152 |
|
153 |
this.setLayout(new BorderLayout()); |
154 |
this.add(jPanelMain, BorderLayout.CENTER); |
155 |
this.add(getButtons(), BorderLayout.SOUTH); |
156 |
|
157 |
setListeners(); |
158 |
|
159 |
setDataSource(crsMainPanel.getDataSource()); |
160 |
|
161 |
crsMainPanel.getRecentsPanel().loadRecents(); |
162 |
} |
163 |
|
164 |
/**
|
165 |
* Este mtodo cargar todo el panel utilizado en dicho panel el
|
166 |
* CRSViewPanel y el combobox de las transformaciones
|
167 |
*/
|
168 |
private JPanel viewPanel(){ |
169 |
JPanel integro = new JPanel(); |
170 |
integro.setLayout(new BorderLayout()); |
171 |
integro.setBorder(new EmptyBorder(5,5,5,5)); |
172 |
|
173 |
integro.add(viewPan.capa(),BorderLayout.CENTER);
|
174 |
//**integro.add(getJPanel(), null);
|
175 |
integro.add(getCombopanel(),BorderLayout.SOUTH);
|
176 |
return integro;
|
177 |
} |
178 |
|
179 |
/**
|
180 |
* Define el panel en el que se integran el label y el combobox
|
181 |
* de transformaciones
|
182 |
*/
|
183 |
public JPanel getCombopanel(){ |
184 |
if (jPanelCombo == null){ |
185 |
jPanelCombo = new JPanel(); |
186 |
jPanelCombo.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
187 |
jPanelCombo.add(getJLabelTrans()); |
188 |
jPanelCombo.add(getJComboOptions()); |
189 |
} |
190 |
|
191 |
return jPanelCombo;
|
192 |
} |
193 |
/**
|
194 |
* Inicializa la etiqueta 'Seleccione Transformacin'
|
195 |
* @return
|
196 |
*/
|
197 |
private JLabel getJLabelTrans(){ |
198 |
if (jLabelTrans==null){ |
199 |
jLabelTrans = new JLabel(); |
200 |
jLabelTrans.setPreferredSize(new Dimension(180, 25)); |
201 |
jLabelTrans.setText(PluginServices.getText(this, "seleccione_transformacion")+":"); |
202 |
} |
203 |
return jLabelTrans;
|
204 |
} |
205 |
/**
|
206 |
* Inicializa el comboBox de Tansformaciones
|
207 |
* @return
|
208 |
*/
|
209 |
public JComboBox getJComboOptions(){ |
210 |
if (jComboOptions == null){ |
211 |
String[] selection = {PluginServices.getText(this, "sin_transformacion"), |
212 |
PluginServices.getText(this, "recents_transformation"), |
213 |
PluginServices.getText(this, "transformacion_epsg"), |
214 |
PluginServices.getText(this, "transformacion_manual"), |
215 |
PluginServices.getText(this, "nadgrids")}; |
216 |
jComboOptions = new JComboBox(selection); |
217 |
jComboOptions.setPreferredSize(new Dimension(180,25)); |
218 |
jComboOptions.setEnabled(false);
|
219 |
jComboOptions.setEditable(false);
|
220 |
jComboOptions.setSelectedIndex(0);
|
221 |
newSelection = (String) jComboOptions.getSelectedItem();
|
222 |
} |
223 |
return jComboOptions;
|
224 |
} |
225 |
/**
|
226 |
* Agrega los botones: Aceptar, cancelar, siguiente y finalizar
|
227 |
* @return
|
228 |
*/
|
229 |
private JPanel getButtons() { |
230 |
if(jPanelButtons == null) { |
231 |
jPanelButtons = new JPanel(); |
232 |
jPanelButtons.setLayout(new FlowLayout(FlowLayout.RIGHT,10,10)); |
233 |
jPanelButtons.add(getJButtonCancel()); |
234 |
jPanelButtons.add(getJButtonBefore()); |
235 |
jPanelButtons.add(getJButtonNext()); |
236 |
jPanelButtons.add(getJButtonAccept()); |
237 |
} |
238 |
return jPanelButtons;
|
239 |
} |
240 |
/**
|
241 |
* Inicializa el botn 'Anterior'
|
242 |
* @return
|
243 |
*/
|
244 |
public JButton getJButtonBefore(){ |
245 |
if(jButtonBefore == null) { |
246 |
jButtonBefore = new JButton(); |
247 |
jButtonBefore.setText(PluginServices.getText(this,"anterior")); |
248 |
jButtonBefore.setMnemonic('B');
|
249 |
jButtonBefore.setPreferredSize(new Dimension(100,25)); |
250 |
jButtonBefore.setEnabled(false);
|
251 |
} |
252 |
return jButtonBefore;
|
253 |
} |
254 |
/**
|
255 |
* Inicializa el botn 'Finalizar'
|
256 |
* @return
|
257 |
*/
|
258 |
public JButton getJButtonAccept() { |
259 |
if(jButtonAccept == null) { |
260 |
jButtonAccept = new JButton(); |
261 |
jButtonAccept.setText(PluginServices.getText(this,"finalizar")); |
262 |
jButtonAccept.setMnemonic('O');
|
263 |
jButtonAccept.setVisible(true);
|
264 |
jButtonAccept.setEnabled(false);
|
265 |
jButtonAccept.setPreferredSize(new Dimension(100,25)); |
266 |
} |
267 |
return jButtonAccept;
|
268 |
} |
269 |
/**
|
270 |
* Inicializa el botn 'Siguiente'
|
271 |
* @return
|
272 |
*/
|
273 |
public JButton getJButtonNext() { |
274 |
if(jButtonNext == null) { |
275 |
jButtonNext = new JButton(); |
276 |
jButtonNext.setText(PluginServices.getText(this,"siguiente")); |
277 |
jButtonNext.setMnemonic('S');
|
278 |
jButtonNext.setVisible(false);
|
279 |
jButtonNext.setPreferredSize(new Dimension(100,25)); |
280 |
} |
281 |
return jButtonNext;
|
282 |
} |
283 |
/**
|
284 |
* Inicializa el botn 'Cancelar'
|
285 |
* @return
|
286 |
*/
|
287 |
public JButton getJButtonCancel() { |
288 |
if(jButtonCancel == null) { |
289 |
jButtonCancel = new JButton(); |
290 |
jButtonCancel.setText(PluginServices.getText(this,"cancel")); |
291 |
jButtonCancel.setMnemonic('C');
|
292 |
jButtonCancel.setPreferredSize(new Dimension(100,25)); |
293 |
} |
294 |
return jButtonCancel;
|
295 |
} |
296 |
|
297 |
public void setTargetNad(boolean tarNad){ |
298 |
targetNad = tarNad; |
299 |
} |
300 |
|
301 |
public boolean getTargetNad(){ |
302 |
return targetNad;
|
303 |
} |
304 |
|
305 |
/*
|
306 |
* revisar esta solucion
|
307 |
*/
|
308 |
public ICrs getProjection() {
|
309 |
if (sin_tr) {
|
310 |
ICrs crs; |
311 |
try {
|
312 |
if (getDataSource().equals(PluginServices.getText(this,"EPSG"))){ |
313 |
//crs = new CrsFactory().getCRS(crsMainPanel.getEpsgPanel().getCodeCRS(),crsMainPanel.getEpsgPanel().getWKT());
|
314 |
crs = new CrsFactory().getCRS("EPSG:"+crsMainPanel.getEpsgPanel().getCodeCRS()); |
315 |
} |
316 |
else if (getDataSource().equals(PluginServices.getText(this,"IAU2000"))){ |
317 |
//crs = new CrsFactory().getCRS(crsMainPanel.getIauPanel().getCodeCRS(),crsMainPanel.getIauPanel().getWKT());
|
318 |
crs = new CrsFactory().getCRS("IAU2000:"+crsMainPanel.getIauPanel().getCodeCRS()); |
319 |
} |
320 |
else if (getDataSource().equals(PluginServices.getText(this,"recientes"))){ |
321 |
//crs = new CrsFactory().getCRS(crsMainPanel.getRecentsPanel().getCodeCRS(),crsMainPanel.getRecentsPanel().getCrs().getWKT());
|
322 |
crs = new CrsFactory().getCRS(crsMainPanel.getRecentsPanel().getAuthority());
|
323 |
} |
324 |
else if (getDataSource().equals(PluginServices.getText(this,"ESRI"))){ |
325 |
//crs = new CrsFactory().getCRS(crsMainPanel.getEsriPanel().getCodeCRS(),crsMainPanel.getEsriPanel().getWKT());
|
326 |
crs = new CrsFactory().getCRS("ESRI:"+crsMainPanel.getEsriPanel().getCodeCRS()); |
327 |
} |
328 |
else if (getDataSource().equals(PluginServices.getText(this,"newCRS"))){ |
329 |
crs = new CrsFactory().getCRS("USR:"+crsMainPanel.getNewCrsPanel().getCodeCRS()); |
330 |
} |
331 |
else {
|
332 |
sin_tr = false;
|
333 |
return null; |
334 |
} |
335 |
sin_tr = false;
|
336 |
return crs;
|
337 |
} catch (CrsException e) {
|
338 |
e.printStackTrace(); |
339 |
} |
340 |
return null; |
341 |
} |
342 |
return (ICrs) crsfirst;
|
343 |
} |
344 |
|
345 |
public void setProjection(IProjection proj) { |
346 |
crsfirst = proj; |
347 |
} |
348 |
|
349 |
/**
|
350 |
* Mtodo para aplicarle los eventos necesarios en el panel actual. La
|
351 |
* definicin de estos listeners estarn en la clase CRSMainTrPanelListener
|
352 |
*
|
353 |
*/
|
354 |
private void setListeners(){ |
355 |
|
356 |
CRSMainTrPanelListener listener = new CRSMainTrPanelListener(this); |
357 |
|
358 |
jButtonAccept.addActionListener(listener); |
359 |
jButtonBefore.addActionListener(listener); |
360 |
jButtonCancel.addActionListener(listener); |
361 |
jButtonNext.addActionListener(listener); |
362 |
crsMainPanel.getJComboOptions().addItemListener(listener); |
363 |
getJComboOptions().addActionListener(listener); |
364 |
getRecentsTrPanel().getJButtonInfo().addActionListener(listener); |
365 |
|
366 |
ListSelectionModel rowSM = crsMainPanel.getEpsgPanel().getJTable().getSelectionModel();
|
367 |
rowSM.addListSelectionListener(listener); |
368 |
|
369 |
ListSelectionModel rowSMiau = crsMainPanel.getIauPanel().getJTable().getSelectionModel();
|
370 |
rowSMiau.addListSelectionListener(listener); |
371 |
|
372 |
ListSelectionModel rowSMrecents = crsMainPanel.getRecentsPanel().getJTable().getSelectionModel();
|
373 |
rowSMrecents.addListSelectionListener(listener); |
374 |
|
375 |
ListSelectionModel rowSMesri = crsMainPanel.getEsriPanel().getJTable().getSelectionModel();
|
376 |
rowSMesri.addListSelectionListener(listener); |
377 |
|
378 |
ListSelectionModel rowSMusr = crsMainPanel.getNewCrsPanel().getJTable().getSelectionModel();
|
379 |
rowSMusr.addListSelectionListener(listener); |
380 |
|
381 |
crsMainPanel.getEsriPanel().getJTable().addMouseListener(listener); |
382 |
crsMainPanel.getEpsgPanel().getJTable().addMouseListener(listener); |
383 |
crsMainPanel.getRecentsPanel().getJTable().addMouseListener(listener); |
384 |
crsMainPanel.getIauPanel().getJTable().addMouseListener(listener); |
385 |
crsMainPanel.getNewCrsPanel().getJTable().addMouseListener(listener); |
386 |
getEpsgTrPanel().getJTable().addMouseListener(listener); |
387 |
getRecentsTrPanel().getJTable().addMouseListener(listener); |
388 |
|
389 |
ListSelectionModel rowSMEpsgTr = getEpsgTrPanel().getJTable().getSelectionModel();
|
390 |
rowSMEpsgTr.addListSelectionListener(listener); |
391 |
|
392 |
ListSelectionModel rowSMRecentsTr = getRecentsTrPanel().getJTable().getSelectionModel();
|
393 |
rowSMRecentsTr.addListSelectionListener(listener); |
394 |
|
395 |
getNadsTrPanel().getJComboNadFile().addItemListener(listener); |
396 |
|
397 |
getManualTrPanel().getTx_Translation().addKeyListener(listener); |
398 |
getManualTrPanel().getTy_Translation().addKeyListener(listener); |
399 |
getManualTrPanel().getTz_Translation().addKeyListener(listener); |
400 |
getManualTrPanel().getTx_Rotation().addKeyListener(listener); |
401 |
getManualTrPanel().getTy_Rotation().addKeyListener(listener); |
402 |
getManualTrPanel().getTz_Rotation().addKeyListener(listener); |
403 |
getManualTrPanel().getTscale().addKeyListener(listener); |
404 |
} |
405 |
|
406 |
public void setDataSource(String sour){ |
407 |
dataSource = sour; |
408 |
} |
409 |
|
410 |
public String getDataSource(){ |
411 |
return crsMainPanel.getDataSource();
|
412 |
} |
413 |
|
414 |
public WindowInfo getWindowInfo() {
|
415 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
416 |
m_viewinfo.setTitle(PluginServices.getText(this,"crsview")); |
417 |
return m_viewinfo;
|
418 |
} |
419 |
|
420 |
public CRSMainPanel getCrsMainPanel() {
|
421 |
return crsMainPanel;
|
422 |
} |
423 |
|
424 |
public TransformationEpsgPanel getEpsgTrPanel() {
|
425 |
return epsgTrPanel;
|
426 |
} |
427 |
|
428 |
public TransformationManualPanel getManualTrPanel() {
|
429 |
return manualTrPanel;
|
430 |
} |
431 |
|
432 |
public TransformationNadgridsPanel getNadsTrPanel() {
|
433 |
return nadsTrPanel;
|
434 |
} |
435 |
|
436 |
public TransformationRecentsPanel getRecentsTrPanel() {
|
437 |
return recentsTrPanel;
|
438 |
} |
439 |
|
440 |
public boolean isEpsg_tr() { |
441 |
return epsg_tr;
|
442 |
} |
443 |
|
444 |
public boolean isManual_tr() { |
445 |
return manual_tr;
|
446 |
} |
447 |
|
448 |
public boolean isNads_tr() { |
449 |
return nads_tr;
|
450 |
} |
451 |
|
452 |
public boolean isRecents_tr() { |
453 |
return recents_tr;
|
454 |
} |
455 |
|
456 |
public boolean isSin_tr() { |
457 |
return sin_tr;
|
458 |
} |
459 |
|
460 |
public void setEpsg_tr(boolean epsg_tr) { |
461 |
this.epsg_tr = epsg_tr;
|
462 |
} |
463 |
|
464 |
public void setManual_tr(boolean manual_tr) { |
465 |
this.manual_tr = manual_tr;
|
466 |
} |
467 |
|
468 |
public void setNads_tr(boolean nads_tr) { |
469 |
this.nads_tr = nads_tr;
|
470 |
} |
471 |
|
472 |
public void setRecents_tr(boolean recents_tr) { |
473 |
this.recents_tr = recents_tr;
|
474 |
} |
475 |
|
476 |
public void setSin_tr(boolean sin_tr) { |
477 |
this.sin_tr = sin_tr;
|
478 |
} |
479 |
|
480 |
public boolean isCancelYes() { |
481 |
return cancelYes;
|
482 |
} |
483 |
|
484 |
public void setCancelYes(boolean cancelYes) { |
485 |
this.cancelYes = cancelYes;
|
486 |
} |
487 |
|
488 |
public IProjection getCrsfirst() {
|
489 |
return crsfirst;
|
490 |
} |
491 |
|
492 |
public JPanel getJPanelMain() { |
493 |
return jPanelMain;
|
494 |
} |
495 |
|
496 |
public String getNewSelection() { |
497 |
return newSelection;
|
498 |
} |
499 |
|
500 |
public void setNewSelection(String newSelection) { |
501 |
this.newSelection = newSelection;
|
502 |
} |
503 |
|
504 |
public CrsWkt getCrsWkt_target() {
|
505 |
return crsWkt_target;
|
506 |
} |
507 |
|
508 |
public void setCrsWkt_target(CrsWkt crsWkt_target) { |
509 |
this.crsWkt_target = crsWkt_target;
|
510 |
} |
511 |
|
512 |
/*public EpsgConnection getConnection() {
|
513 |
return connection;
|
514 |
}
|
515 |
|
516 |
public void setConnection(EpsgConnection connect) {
|
517 |
this.connection = connect;
|
518 |
}*/
|
519 |
} |