svn-gvsig-desktop / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / CRSMainTrPanel.java @ 8711
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 |
* cargamos en la capa el CRS que hemos fijado en la vista en el primer caso
|
106 |
* o el que pusimos en la ultima eleccion del crs para la capa
|
107 |
*/
|
108 |
|
109 |
/*habra que hacerlo para que lo printe en el primer panel que pongamos
|
110 |
* en nuestro caso seria en el de recientes
|
111 |
*/
|
112 |
/*String sour = curProj.getCrsWkt().getAuthority()[0];
|
113 |
if (sour.equals("EPSG")){
|
114 |
crsMainPanel.getEpsgPanel().loadViewCRS(curProj.getCode());
|
115 |
crsMainPanel.getEpsgPanel().getJTable().setRowSelectionInterval(0,0);
|
116 |
}else if(sour.equals("IAU2000")){
|
117 |
crsMainPanel.getIauPanel().loadViewCRS(curProj.getCode());
|
118 |
crsMainPanel.getIauPanel().getJTable().setRowSelectionInterval(0,0);
|
119 |
}*/
|
120 |
|
121 |
setDataSource(crsMainPanel.getDataSource()); |
122 |
|
123 |
crsMainPanel.getRecentsPanel().loadRecents(); |
124 |
} |
125 |
|
126 |
/*
|
127 |
* Este metodo cargara todo el panel utilizado en el CRSViewPanel y el combobox de
|
128 |
* las transformaciones
|
129 |
*/
|
130 |
private JPanel viewPanel(){ |
131 |
JPanel integro = new JPanel(); |
132 |
integro.setLayout(new GridLayout(0,1)); |
133 |
integro.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
134 |
integro.setPreferredSize(new Dimension(560,300)); |
135 |
|
136 |
integro.add(viewPan.capa(), null);
|
137 |
integro.add(getJPanel(), null);
|
138 |
return integro;
|
139 |
} |
140 |
|
141 |
|
142 |
private JPanel getJPanel() { |
143 |
if (panel == null){ |
144 |
panel = new JPanel(); |
145 |
panel.setPreferredSize(new Dimension(540,80)); |
146 |
panel.setLayout(new GridLayout(0,2)); |
147 |
panel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
148 |
panel.add(getCombopanel(), null);
|
149 |
} |
150 |
return panel;
|
151 |
} |
152 |
|
153 |
public JPanel getCombopanel(){ |
154 |
if (jPanelCombo == null){ |
155 |
jPanelCombo = new JPanel(); |
156 |
jPanelCombo.setPreferredSize(new Dimension(400,30)); |
157 |
jPanelCombo.add(getJLabelTrans()); |
158 |
jPanelCombo.add(getJComboOptions()); |
159 |
} |
160 |
|
161 |
return jPanelCombo;
|
162 |
} |
163 |
|
164 |
private JLabel getJLabelTrans(){ |
165 |
JLabel jLabelTrans = new JLabel(); |
166 |
jLabelTrans.setPreferredSize(new Dimension(180, 25)); |
167 |
jLabelTrans.setText(PluginServices.getText(this, "seleccione_transformacion")+":"); |
168 |
return jLabelTrans;
|
169 |
} |
170 |
|
171 |
public JComboBox getJComboOptions(){ |
172 |
if (jComboOptions == null){ |
173 |
String[] selection = {PluginServices.getText(this, "sin_transformacion"), |
174 |
PluginServices.getText(this, "transformacion_manual"), |
175 |
PluginServices.getText(this, "nadgrids"), |
176 |
PluginServices.getText(this, "transformacion_epsg")}; |
177 |
jComboOptions = new JComboBox(selection); |
178 |
jComboOptions.setPreferredSize(new Dimension(150,25)); |
179 |
jComboOptions.setEnabled(false);
|
180 |
jComboOptions.setEditable(false);
|
181 |
jComboOptions.setSelectedIndex(0);
|
182 |
newSelection = (String) jComboOptions.getSelectedItem();
|
183 |
} |
184 |
// jComboOptions.addActionListener(this);
|
185 |
return jComboOptions;
|
186 |
} |
187 |
|
188 |
private JPanel getButtons() { |
189 |
if(jPanelButtons == null) { |
190 |
jPanelButtons = new JPanel(); |
191 |
jPanelButtons.setPreferredSize(new Dimension(550,50)); |
192 |
jPanelButtons.setLayout(new GridLayout(0,1)); |
193 |
jPanelButtons.setLayout(new FlowLayout(FlowLayout.RIGHT,5,5)); |
194 |
jPanelButtons.add(getJButtonCancel(), null);
|
195 |
jPanelButtons.add(getJButtonBefore(), null);
|
196 |
jPanelButtons.add(getJButtonNext(), null);
|
197 |
jPanelButtons.add(getJButtonAccept(), null);
|
198 |
} |
199 |
return jPanelButtons;
|
200 |
} |
201 |
|
202 |
public JButton getJButtonBefore(){ |
203 |
if(jButtonBefore == null) { |
204 |
jButtonBefore = new JButton(); |
205 |
jButtonBefore.setText(PluginServices.getText(this,"anterior")); |
206 |
jButtonBefore.setMnemonic('B');
|
207 |
jButtonBefore.setPreferredSize(new Dimension(100,25)); |
208 |
jButtonBefore.setEnabled(false);
|
209 |
// jButtonBefore.addActionListener(this);
|
210 |
} |
211 |
return jButtonBefore;
|
212 |
} |
213 |
|
214 |
public JButton getJButtonAccept() { |
215 |
if(jButtonAccept == null) { |
216 |
jButtonAccept = new JButton(); |
217 |
jButtonAccept.setText(PluginServices.getText(this,"finalizar")); |
218 |
jButtonAccept.setMnemonic('O');
|
219 |
jButtonAccept.setVisible(true);
|
220 |
jButtonAccept.setPreferredSize(new Dimension(100,25)); |
221 |
// jButtonAccept.addActionListener(this);
|
222 |
} |
223 |
return jButtonAccept;
|
224 |
} |
225 |
|
226 |
public JButton getJButtonNext() { |
227 |
if(jButtonNext == null) { |
228 |
jButtonNext = new JButton(); |
229 |
jButtonNext.setText(PluginServices.getText(this,"siguiente")); |
230 |
jButtonNext.setMnemonic('S');
|
231 |
jButtonNext.setVisible(false);
|
232 |
jButtonNext.setPreferredSize(new Dimension(100,25)); |
233 |
// jButtonNext.addActionListener(this);
|
234 |
} |
235 |
return jButtonNext;
|
236 |
} |
237 |
|
238 |
public JButton getJButtonCancel() { |
239 |
if(jButtonCancel == null) { |
240 |
jButtonCancel = new JButton(); |
241 |
jButtonCancel.setText(PluginServices.getText(this,"cancel")); |
242 |
jButtonCancel.setMnemonic('C');
|
243 |
jButtonCancel.setPreferredSize(new Dimension(100,25)); |
244 |
// jButtonCancel.addActionListener(this);
|
245 |
} |
246 |
return jButtonCancel;
|
247 |
} |
248 |
|
249 |
public void setTargetNad(boolean tarNad){ |
250 |
targetNad = tarNad; |
251 |
} |
252 |
|
253 |
public boolean getTargetNad(){ |
254 |
return targetNad;
|
255 |
} |
256 |
|
257 |
/*
|
258 |
* revisar esta solucion
|
259 |
*/
|
260 |
public ICrs getProjection() {
|
261 |
if (sin_tr) {
|
262 |
ICrs crs; |
263 |
try {
|
264 |
if (getDataSource().equals(PluginServices.getText(this,"EPSG"))){ |
265 |
crs = new CrsFactory().getCRS(crsMainPanel.getEpsgPanel().getCodeCRS(),crsMainPanel.getEpsgPanel().getWKT());
|
266 |
} |
267 |
else if (getDataSource().equals(PluginServices.getText(this,"IAU2000"))){ |
268 |
crs = new CrsFactory().getCRS(crsMainPanel.getIauPanel().getCodeCRS(),crsMainPanel.getIauPanel().getWKT());
|
269 |
} |
270 |
else if (getDataSource().equals(PluginServices.getText(this,"recientes"))){ |
271 |
crs = new CrsFactory().getCRS(crsMainPanel.getRecentsPanel().getCodeCRS(),crsMainPanel.getRecentsPanel().getWKT());
|
272 |
} else {
|
273 |
sin_tr = false;
|
274 |
return null; |
275 |
} |
276 |
sin_tr = false;
|
277 |
return crs;
|
278 |
} catch (CrsException e) {
|
279 |
e.printStackTrace(); |
280 |
} |
281 |
return null; |
282 |
} |
283 |
return (ICrs) crsfirst;
|
284 |
} |
285 |
|
286 |
public void setProjection(IProjection proj) { |
287 |
crsfirst = proj; |
288 |
} |
289 |
|
290 |
private void setListeners(){ |
291 |
|
292 |
CRSMainTrPanelListener listener = new CRSMainTrPanelListener(this); |
293 |
|
294 |
jButtonAccept.addActionListener(listener); |
295 |
jButtonBefore.addActionListener(listener); |
296 |
jButtonCancel.addActionListener(listener); |
297 |
jButtonNext.addActionListener(listener); |
298 |
crsMainPanel.getJComboOptions().addItemListener(listener); |
299 |
getJComboOptions().addActionListener(listener); |
300 |
|
301 |
ListSelectionModel rowSM = crsMainPanel.getEpsgPanel().getJTable().getSelectionModel();
|
302 |
rowSM.addListSelectionListener(listener); |
303 |
|
304 |
ListSelectionModel rowSMiau = crsMainPanel.getIauPanel().getJTable().getSelectionModel();
|
305 |
rowSMiau.addListSelectionListener(listener); |
306 |
|
307 |
ListSelectionModel rowSMrecents = crsMainPanel.getRecentsPanel().getJTable().getSelectionModel();
|
308 |
rowSMrecents.addListSelectionListener(listener); |
309 |
|
310 |
crsMainPanel.getEsriPanel().getJTextOpen().getDocument().addDocumentListener(listener); |
311 |
crsMainPanel.getEpsgPanel().getJTable().addMouseListener(listener); |
312 |
crsMainPanel.getRecentsPanel().getJTable().addMouseListener(listener); |
313 |
crsMainPanel.getIauPanel().getJTable().addMouseListener(listener); |
314 |
getEpsgTrPanel().getJTable().addMouseListener(listener); |
315 |
|
316 |
} |
317 |
|
318 |
public void compareDatum(String wktSource){ |
319 |
CrsWkt crsWkt_source = new CrsWkt(wktSource);
|
320 |
|
321 |
if (!crsWkt_source.getSpheroid()[1].equals(getCrsWkt_target().getSpheroid()[1])){ |
322 |
jComboOptions.setEnabled(true);
|
323 |
getJButtonAccept().setEnabled(true);
|
324 |
} |
325 |
else if (!crsWkt_source.getSpheroid()[2].equals(getCrsWkt_target().getSpheroid()[2])){ |
326 |
jComboOptions.setEnabled(true);
|
327 |
getJButtonAccept().setEnabled(true);
|
328 |
} |
329 |
else {
|
330 |
jComboOptions.setEnabled(false);
|
331 |
jComboOptions.setSelectedIndex(0);
|
332 |
getJButtonAccept().setEnabled(true);
|
333 |
getJButtonAccept().setVisible(true);
|
334 |
getJButtonNext().setVisible(false);
|
335 |
} |
336 |
|
337 |
|
338 |
} |
339 |
|
340 |
|
341 |
|
342 |
public void setDataSource(String sour){ |
343 |
dataSource = sour; |
344 |
} |
345 |
|
346 |
public String getDataSource(){ |
347 |
return crsMainPanel.getDataSource();
|
348 |
} |
349 |
|
350 |
public WindowInfo getWindowInfo() {
|
351 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
352 |
m_viewinfo.setTitle(PluginServices.getText(this,"crsview")); |
353 |
return m_viewinfo;
|
354 |
} |
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
public CRSMainPanel getCrsMainPanel() {
|
369 |
return crsMainPanel;
|
370 |
} |
371 |
|
372 |
public TransformationEpsgPanel getEpsgTrPanel() {
|
373 |
return epsgTrPanel;
|
374 |
} |
375 |
|
376 |
public TransformationManualPanel getManualTrPanel() {
|
377 |
return manualTrPanel;
|
378 |
} |
379 |
|
380 |
public TransformationNadgridsPanel getNadsTrPanel() {
|
381 |
return nadsTrPanel;
|
382 |
} |
383 |
|
384 |
public boolean isEpsg_tr() { |
385 |
return epsg_tr;
|
386 |
} |
387 |
|
388 |
public boolean isManual_tr() { |
389 |
return manual_tr;
|
390 |
} |
391 |
|
392 |
public boolean isNads_tr() { |
393 |
return nads_tr;
|
394 |
} |
395 |
|
396 |
public boolean isSin_tr() { |
397 |
return sin_tr;
|
398 |
} |
399 |
|
400 |
public void setEpsg_tr(boolean epsg_tr) { |
401 |
this.epsg_tr = epsg_tr;
|
402 |
} |
403 |
|
404 |
public void setManual_tr(boolean manual_tr) { |
405 |
this.manual_tr = manual_tr;
|
406 |
} |
407 |
|
408 |
public void setNads_tr(boolean nads_tr) { |
409 |
this.nads_tr = nads_tr;
|
410 |
} |
411 |
|
412 |
public void setSin_tr(boolean sin_tr) { |
413 |
this.sin_tr = sin_tr;
|
414 |
} |
415 |
|
416 |
public boolean isCancelYes() { |
417 |
return cancelYes;
|
418 |
} |
419 |
|
420 |
public void setCancelYes(boolean cancelYes) { |
421 |
this.cancelYes = cancelYes;
|
422 |
} |
423 |
|
424 |
public IProjection getCrsfirst() {
|
425 |
return crsfirst;
|
426 |
} |
427 |
|
428 |
public JPanel getJPanelMain() { |
429 |
return jPanelMain;
|
430 |
} |
431 |
|
432 |
public String getNewSelection() { |
433 |
return newSelection;
|
434 |
} |
435 |
|
436 |
public void setNewSelection(String newSelection) { |
437 |
this.newSelection = newSelection;
|
438 |
} |
439 |
|
440 |
public CrsWkt getCrsWkt_target() {
|
441 |
return crsWkt_target;
|
442 |
} |
443 |
|
444 |
public void setCrsWkt_target(CrsWkt crsWkt_target) { |
445 |
this.crsWkt_target = crsWkt_target;
|
446 |
} |
447 |
|
448 |
/*public EpsgConnection getConnection() {
|
449 |
return connection;
|
450 |
}
|
451 |
|
452 |
public void setConnection(EpsgConnection connect) {
|
453 |
this.connection = connect;
|
454 |
}*/
|
455 |
} |