svn-gvsig-desktop / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / CRSMainTrPanel.java @ 8816
History | View | Annotate | Download (12.3 KB)
1 |
package org.gvsig.crs.gui; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.CardLayout; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.FlowLayout; |
7 |
import java.awt.GridLayout; |
8 |
|
9 |
import javax.swing.JButton; |
10 |
import javax.swing.JComboBox; |
11 |
import javax.swing.JLabel; |
12 |
import javax.swing.JPanel; |
13 |
import javax.swing.ListSelectionModel; |
14 |
|
15 |
import org.cresques.cts.IProjection; |
16 |
import org.gvsig.crs.CrsException; |
17 |
import org.gvsig.crs.CrsFactory; |
18 |
import org.gvsig.crs.CrsWkt; |
19 |
import org.gvsig.crs.ICrs; |
20 |
import org.gvsig.crs.gui.listeners.CRSMainTrPanelListener; |
21 |
import org.gvsig.crs.gui.panels.TransformationEpsgPanel; |
22 |
import org.gvsig.crs.gui.panels.TransformationManualPanel; |
23 |
import org.gvsig.crs.gui.panels.TransformationNadgridsPanel; |
24 |
|
25 |
import com.iver.andami.PluginServices; |
26 |
import com.iver.andami.ui.mdiManager.IWindow; |
27 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
28 |
|
29 |
public class CRSMainTrPanel extends JPanel implements IWindow{ |
30 |
|
31 |
private static final long serialVersionUID = 1L; |
32 |
|
33 |
/*
|
34 |
* Para mostrar los parametros si tenemos seleccionada transformacion
|
35 |
*/
|
36 |
boolean tra = false; |
37 |
boolean inAnApplet = true; |
38 |
private boolean cancelYes = false; |
39 |
private JButton jButtonCancel = null; |
40 |
private JButton jButtonNext = null; |
41 |
private JButton jButtonAccept = null; |
42 |
private JButton jButtonBefore = null; |
43 |
private JPanel jPanelButtons = null; |
44 |
|
45 |
boolean targetNad = false; |
46 |
|
47 |
int crs_target = -1; |
48 |
CrsWkt crsWkt_target = null;
|
49 |
|
50 |
//private EpsgConnection connection = null;
|
51 |
|
52 |
int transformation_code = 0; |
53 |
|
54 |
private JPanel panel = null; |
55 |
CRSMainPanel viewPan = null;
|
56 |
|
57 |
private JPanel jPanelMain = null; |
58 |
private TransformationManualPanel manualTrPanel = null; |
59 |
private boolean manual_tr = false; |
60 |
private TransformationEpsgPanel epsgTrPanel = null; |
61 |
private boolean epsg_tr = false; |
62 |
private TransformationNadgridsPanel nadsTrPanel = null; |
63 |
private boolean nads_tr = false; |
64 |
|
65 |
private boolean sin_tr = false; |
66 |
private JPanel jPanelCombo = null; |
67 |
private JComboBox jComboOptions = null; |
68 |
|
69 |
private IProjection crsfirst;
|
70 |
|
71 |
private CRSMainPanel crsMainPanel;
|
72 |
private String newSelection; |
73 |
String dataSource = ""; |
74 |
ICrs curProj = null;
|
75 |
|
76 |
public CRSMainTrPanel(int target, CrsWkt crsWkttarget, ICrs proj) { |
77 |
curProj = proj; |
78 |
crsMainPanel = new CRSMainPanel(target);
|
79 |
viewPan = crsMainPanel; |
80 |
|
81 |
crs_target = target; |
82 |
setCrsWkt_target(crsWkttarget); |
83 |
|
84 |
manualTrPanel = new TransformationManualPanel();
|
85 |
epsgTrPanel = new TransformationEpsgPanel(crs_target);
|
86 |
nadsTrPanel = new TransformationNadgridsPanel();
|
87 |
|
88 |
/*
|
89 |
* esta variable contendr? tanto el panel utilizado en CRSViewPanel, como los paneles
|
90 |
* que seran necesarios para realizar las transformaciones
|
91 |
*/
|
92 |
jPanelMain = new JPanel(); |
93 |
jPanelMain.setLayout(new CardLayout()); |
94 |
jPanelMain.add("primero", viewPanel());
|
95 |
jPanelMain.add("manual", manualTrPanel.getJPanel());
|
96 |
jPanelMain.add("epsg", epsgTrPanel.getJPanel());
|
97 |
jPanelMain.add("nad", nadsTrPanel.getJPanel());
|
98 |
|
99 |
this.add(jPanelMain, BorderLayout.CENTER); |
100 |
|
101 |
this.add(getButtons(), BorderLayout.SOUTH); |
102 |
|
103 |
setListeners(); |
104 |
|
105 |
setDataSource(crsMainPanel.getDataSource()); |
106 |
|
107 |
crsMainPanel.getRecentsPanel().loadRecents(); |
108 |
} |
109 |
|
110 |
/*
|
111 |
* Este metodo cargara todo el panel utilizado en el CRSViewPanel y el combobox de
|
112 |
* las transformaciones
|
113 |
*/
|
114 |
private JPanel viewPanel(){ |
115 |
JPanel integro = new JPanel(); |
116 |
integro.setLayout(new GridLayout(0,1)); |
117 |
integro.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
118 |
integro.setPreferredSize(new Dimension(560,300)); |
119 |
|
120 |
integro.add(viewPan.capa(), null);
|
121 |
integro.add(getJPanel(), null);
|
122 |
return integro;
|
123 |
} |
124 |
|
125 |
|
126 |
private JPanel getJPanel() { |
127 |
if (panel == null){ |
128 |
panel = new JPanel(); |
129 |
panel.setPreferredSize(new Dimension(540,80)); |
130 |
panel.setLayout(new GridLayout(0,2)); |
131 |
panel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
132 |
panel.add(getCombopanel(), null);
|
133 |
} |
134 |
return panel;
|
135 |
} |
136 |
|
137 |
public JPanel getCombopanel(){ |
138 |
if (jPanelCombo == null){ |
139 |
jPanelCombo = new JPanel(); |
140 |
jPanelCombo.setPreferredSize(new Dimension(400,30)); |
141 |
jPanelCombo.add(getJLabelTrans()); |
142 |
jPanelCombo.add(getJComboOptions()); |
143 |
} |
144 |
|
145 |
return jPanelCombo;
|
146 |
} |
147 |
|
148 |
private JLabel getJLabelTrans(){ |
149 |
JLabel jLabelTrans = new JLabel(); |
150 |
jLabelTrans.setPreferredSize(new Dimension(180, 25)); |
151 |
jLabelTrans.setText(PluginServices.getText(this, "seleccione_transformacion")+":"); |
152 |
return jLabelTrans;
|
153 |
} |
154 |
|
155 |
public JComboBox getJComboOptions(){ |
156 |
if (jComboOptions == null){ |
157 |
String[] selection = {PluginServices.getText(this, "sin_transformacion"), |
158 |
PluginServices.getText(this, "transformacion_manual"), |
159 |
PluginServices.getText(this, "nadgrids"), |
160 |
PluginServices.getText(this, "transformacion_epsg")}; |
161 |
jComboOptions = new JComboBox(selection); |
162 |
jComboOptions.setPreferredSize(new Dimension(150,25)); |
163 |
jComboOptions.setEnabled(false);
|
164 |
jComboOptions.setEditable(false);
|
165 |
jComboOptions.setSelectedIndex(0);
|
166 |
newSelection = (String) jComboOptions.getSelectedItem();
|
167 |
} |
168 |
// jComboOptions.addActionListener(this);
|
169 |
return jComboOptions;
|
170 |
} |
171 |
|
172 |
private JPanel getButtons() { |
173 |
if(jPanelButtons == null) { |
174 |
jPanelButtons = new JPanel(); |
175 |
jPanelButtons.setPreferredSize(new Dimension(550,50)); |
176 |
jPanelButtons.setLayout(new GridLayout(0,1)); |
177 |
jPanelButtons.setLayout(new FlowLayout(FlowLayout.RIGHT,5,5)); |
178 |
jPanelButtons.add(getJButtonCancel(), null);
|
179 |
jPanelButtons.add(getJButtonBefore(), null);
|
180 |
jPanelButtons.add(getJButtonNext(), null);
|
181 |
jPanelButtons.add(getJButtonAccept(), null);
|
182 |
} |
183 |
return jPanelButtons;
|
184 |
} |
185 |
|
186 |
public JButton getJButtonBefore(){ |
187 |
if(jButtonBefore == null) { |
188 |
jButtonBefore = new JButton(); |
189 |
jButtonBefore.setText(PluginServices.getText(this,"anterior")); |
190 |
jButtonBefore.setMnemonic('B');
|
191 |
jButtonBefore.setPreferredSize(new Dimension(100,25)); |
192 |
jButtonBefore.setEnabled(false);
|
193 |
// jButtonBefore.addActionListener(this);
|
194 |
} |
195 |
return jButtonBefore;
|
196 |
} |
197 |
|
198 |
public JButton getJButtonAccept() { |
199 |
if(jButtonAccept == null) { |
200 |
jButtonAccept = new JButton(); |
201 |
jButtonAccept.setText(PluginServices.getText(this,"finalizar")); |
202 |
jButtonAccept.setMnemonic('O');
|
203 |
jButtonAccept.setVisible(true);
|
204 |
jButtonAccept.setEnabled(false);
|
205 |
jButtonAccept.setPreferredSize(new Dimension(100,25)); |
206 |
// jButtonAccept.addActionListener(this);
|
207 |
} |
208 |
return jButtonAccept;
|
209 |
} |
210 |
|
211 |
public JButton getJButtonNext() { |
212 |
if(jButtonNext == null) { |
213 |
jButtonNext = new JButton(); |
214 |
jButtonNext.setText(PluginServices.getText(this,"siguiente")); |
215 |
jButtonNext.setMnemonic('S');
|
216 |
jButtonNext.setVisible(false);
|
217 |
jButtonNext.setPreferredSize(new Dimension(100,25)); |
218 |
// jButtonNext.addActionListener(this);
|
219 |
} |
220 |
return jButtonNext;
|
221 |
} |
222 |
|
223 |
public JButton getJButtonCancel() { |
224 |
if(jButtonCancel == null) { |
225 |
jButtonCancel = new JButton(); |
226 |
jButtonCancel.setText(PluginServices.getText(this,"cancel")); |
227 |
jButtonCancel.setMnemonic('C');
|
228 |
jButtonCancel.setPreferredSize(new Dimension(100,25)); |
229 |
// jButtonCancel.addActionListener(this);
|
230 |
} |
231 |
return jButtonCancel;
|
232 |
} |
233 |
|
234 |
public void setTargetNad(boolean tarNad){ |
235 |
targetNad = tarNad; |
236 |
} |
237 |
|
238 |
public boolean getTargetNad(){ |
239 |
return targetNad;
|
240 |
} |
241 |
|
242 |
/*
|
243 |
* revisar esta solucion
|
244 |
*/
|
245 |
public ICrs getProjection() {
|
246 |
if (sin_tr) {
|
247 |
ICrs crs; |
248 |
try {
|
249 |
if (getDataSource().equals(PluginServices.getText(this,"EPSG"))){ |
250 |
crs = new CrsFactory().getCRS(crsMainPanel.getEpsgPanel().getCodeCRS(),crsMainPanel.getEpsgPanel().getWKT());
|
251 |
} |
252 |
else if (getDataSource().equals(PluginServices.getText(this,"IAU2000"))){ |
253 |
crs = new CrsFactory().getCRS(crsMainPanel.getIauPanel().getCodeCRS(),crsMainPanel.getIauPanel().getWKT());
|
254 |
} |
255 |
else if (getDataSource().equals(PluginServices.getText(this,"recientes"))){ |
256 |
crs = new CrsFactory().getCRS(crsMainPanel.getRecentsPanel().getCodeCRS(),crsMainPanel.getRecentsPanel().getCrs().getWKT());
|
257 |
} else {
|
258 |
sin_tr = false;
|
259 |
return null; |
260 |
} |
261 |
sin_tr = false;
|
262 |
return crs;
|
263 |
} catch (CrsException e) {
|
264 |
e.printStackTrace(); |
265 |
} |
266 |
return null; |
267 |
} |
268 |
return (ICrs) crsfirst;
|
269 |
} |
270 |
|
271 |
public void setProjection(IProjection proj) { |
272 |
crsfirst = proj; |
273 |
} |
274 |
|
275 |
private void setListeners(){ |
276 |
|
277 |
CRSMainTrPanelListener listener = new CRSMainTrPanelListener(this); |
278 |
|
279 |
jButtonAccept.addActionListener(listener); |
280 |
jButtonBefore.addActionListener(listener); |
281 |
jButtonCancel.addActionListener(listener); |
282 |
jButtonNext.addActionListener(listener); |
283 |
crsMainPanel.getJComboOptions().addItemListener(listener); |
284 |
getJComboOptions().addActionListener(listener); |
285 |
|
286 |
ListSelectionModel rowSM = crsMainPanel.getEpsgPanel().getJTable().getSelectionModel();
|
287 |
rowSM.addListSelectionListener(listener); |
288 |
|
289 |
ListSelectionModel rowSMiau = crsMainPanel.getIauPanel().getJTable().getSelectionModel();
|
290 |
rowSMiau.addListSelectionListener(listener); |
291 |
|
292 |
ListSelectionModel rowSMrecents = crsMainPanel.getRecentsPanel().getJTable().getSelectionModel();
|
293 |
rowSMrecents.addListSelectionListener(listener); |
294 |
|
295 |
crsMainPanel.getEsriPanel().getJTextOpen().getDocument().addDocumentListener(listener); |
296 |
crsMainPanel.getEpsgPanel().getJTable().addMouseListener(listener); |
297 |
crsMainPanel.getRecentsPanel().getJTable().addMouseListener(listener); |
298 |
crsMainPanel.getIauPanel().getJTable().addMouseListener(listener); |
299 |
getEpsgTrPanel().getJTable().addMouseListener(listener); |
300 |
|
301 |
ListSelectionModel rowSMEpsgTr = getEpsgTrPanel().getJTable().getSelectionModel();
|
302 |
rowSMEpsgTr.addListSelectionListener(listener); |
303 |
|
304 |
getNadsTrPanel().getJComboNadFile().addItemListener(listener); |
305 |
|
306 |
getManualTrPanel().getTx_Translation().addKeyListener(listener); |
307 |
getManualTrPanel().getTy_Translation().addKeyListener(listener); |
308 |
getManualTrPanel().getTz_Translation().addKeyListener(listener); |
309 |
getManualTrPanel().getTx_Rotation().addKeyListener(listener); |
310 |
getManualTrPanel().getTy_Rotation().addKeyListener(listener); |
311 |
getManualTrPanel().getTz_Rotation().addKeyListener(listener); |
312 |
getManualTrPanel().getTscale().addKeyListener(listener); |
313 |
} |
314 |
|
315 |
public void compareDatum(String wktSource){ |
316 |
CrsWkt crsWkt_source = new CrsWkt(wktSource);
|
317 |
|
318 |
if (!crsWkt_source.getSpheroid()[1].equals(getCrsWkt_target().getSpheroid()[1])){ |
319 |
jComboOptions.setEnabled(true);
|
320 |
getJButtonAccept().setEnabled(true);
|
321 |
} |
322 |
else if (!crsWkt_source.getSpheroid()[2].equals(getCrsWkt_target().getSpheroid()[2])){ |
323 |
jComboOptions.setEnabled(true);
|
324 |
getJButtonAccept().setEnabled(true);
|
325 |
} |
326 |
else {
|
327 |
jComboOptions.setEnabled(false);
|
328 |
jComboOptions.setSelectedIndex(0);
|
329 |
getJButtonAccept().setEnabled(true);
|
330 |
getJButtonAccept().setVisible(true);
|
331 |
getJButtonNext().setVisible(false);
|
332 |
} |
333 |
|
334 |
|
335 |
} |
336 |
|
337 |
|
338 |
|
339 |
public void setDataSource(String sour){ |
340 |
dataSource = sour; |
341 |
} |
342 |
|
343 |
public String getDataSource(){ |
344 |
return crsMainPanel.getDataSource();
|
345 |
} |
346 |
|
347 |
public WindowInfo getWindowInfo() {
|
348 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
349 |
m_viewinfo.setTitle(PluginServices.getText(this,"crsview")); |
350 |
return m_viewinfo;
|
351 |
} |
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
public CRSMainPanel getCrsMainPanel() {
|
366 |
return crsMainPanel;
|
367 |
} |
368 |
|
369 |
public TransformationEpsgPanel getEpsgTrPanel() {
|
370 |
return epsgTrPanel;
|
371 |
} |
372 |
|
373 |
public TransformationManualPanel getManualTrPanel() {
|
374 |
return manualTrPanel;
|
375 |
} |
376 |
|
377 |
public TransformationNadgridsPanel getNadsTrPanel() {
|
378 |
return nadsTrPanel;
|
379 |
} |
380 |
|
381 |
public boolean isEpsg_tr() { |
382 |
return epsg_tr;
|
383 |
} |
384 |
|
385 |
public boolean isManual_tr() { |
386 |
return manual_tr;
|
387 |
} |
388 |
|
389 |
public boolean isNads_tr() { |
390 |
return nads_tr;
|
391 |
} |
392 |
|
393 |
public boolean isSin_tr() { |
394 |
return sin_tr;
|
395 |
} |
396 |
|
397 |
public void setEpsg_tr(boolean epsg_tr) { |
398 |
this.epsg_tr = epsg_tr;
|
399 |
} |
400 |
|
401 |
public void setManual_tr(boolean manual_tr) { |
402 |
this.manual_tr = manual_tr;
|
403 |
} |
404 |
|
405 |
public void setNads_tr(boolean nads_tr) { |
406 |
this.nads_tr = nads_tr;
|
407 |
} |
408 |
|
409 |
public void setSin_tr(boolean sin_tr) { |
410 |
this.sin_tr = sin_tr;
|
411 |
} |
412 |
|
413 |
public boolean isCancelYes() { |
414 |
return cancelYes;
|
415 |
} |
416 |
|
417 |
public void setCancelYes(boolean cancelYes) { |
418 |
this.cancelYes = cancelYes;
|
419 |
} |
420 |
|
421 |
public IProjection getCrsfirst() {
|
422 |
return crsfirst;
|
423 |
} |
424 |
|
425 |
public JPanel getJPanelMain() { |
426 |
return jPanelMain;
|
427 |
} |
428 |
|
429 |
public String getNewSelection() { |
430 |
return newSelection;
|
431 |
} |
432 |
|
433 |
public void setNewSelection(String newSelection) { |
434 |
this.newSelection = newSelection;
|
435 |
} |
436 |
|
437 |
public CrsWkt getCrsWkt_target() {
|
438 |
return crsWkt_target;
|
439 |
} |
440 |
|
441 |
public void setCrsWkt_target(CrsWkt crsWkt_target) { |
442 |
this.crsWkt_target = crsWkt_target;
|
443 |
} |
444 |
|
445 |
/*public EpsgConnection getConnection() {
|
446 |
return connection;
|
447 |
}
|
448 |
|
449 |
public void setConnection(EpsgConnection connect) {
|
450 |
this.connection = connect;
|
451 |
}*/
|
452 |
} |