root / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / panels / ProjChooserPanel.java @ 8127
History | View | Annotate | Download (6.25 KB)
1 |
/*
|
---|---|
2 |
* Created on 30-ene-2005
|
3 |
*/
|
4 |
package org.gvsig.crs.gui.panels; |
5 |
|
6 |
import java.awt.Dimension; |
7 |
import java.awt.FlowLayout; |
8 |
import java.awt.GridLayout; |
9 |
import java.awt.event.ActionListener; |
10 |
|
11 |
import org.gvsig.gui.beans.swing.JButton; |
12 |
import javax.swing.JLabel; |
13 |
import javax.swing.UIDefaults.ActiveValue; |
14 |
|
15 |
import org.cresques.cts.IProjection; |
16 |
import org.gvsig.crs.EpsgConnection; |
17 |
import org.gvsig.crs.ICrs; |
18 |
import org.gvsig.crs.gui.dialog.CSSelectionDialog; |
19 |
import org.gvsig.crs.gui.dialog.TRSelectionDialog; |
20 |
|
21 |
import com.iver.andami.PluginServices; |
22 |
import com.iver.andami.ui.mdiManager.IWindow; |
23 |
import com.iver.cit.gvsig.gui.FOpenDialog; |
24 |
import com.iver.cit.gvsig.gui.View; |
25 |
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel; |
26 |
|
27 |
/**
|
28 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
29 |
*/
|
30 |
public class ProjChooserPanel extends CRSSelectPanel { |
31 |
|
32 |
private static final long serialVersionUID = 1L; |
33 |
|
34 |
public ICrs curProj = null; //(IProjection) new CRSFactory().getCRS("EPSG:23030"); |
35 |
|
36 |
private JLabel jLblProj = null; |
37 |
private JLabel jLblProjName = null; |
38 |
private JButton jBtnChangeProj = null; |
39 |
private boolean okPressed = false; |
40 |
private String abrev; |
41 |
boolean panel = false; |
42 |
boolean targetNad = false; |
43 |
String dataSource = "EPSG"; |
44 |
|
45 |
private ActionListener actionListener = null; |
46 |
|
47 |
public ProjChooserPanel(IProjection proj) {
|
48 |
super(proj);
|
49 |
ICrs pr = (ICrs) proj; |
50 |
IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
51 |
if (activeWindow instanceof View) { |
52 |
View activeView = (com.iver.cit.gvsig.gui.View) activeWindow;
|
53 |
pr = ((ICrs) activeView.getMapControl().getProjection()); |
54 |
} |
55 |
setCurProj(pr); |
56 |
initialize(); |
57 |
} |
58 |
|
59 |
|
60 |
/**
|
61 |
* This method initializes this
|
62 |
*
|
63 |
* @return void
|
64 |
*/
|
65 |
private void initialize() { |
66 |
this.setLayout(new GridLayout(3,1)); |
67 |
this.setLayout(new FlowLayout(FlowLayout.LEFT, 15, 0)); |
68 |
setPreferredSize(new java.awt.Dimension(330,35)); |
69 |
this.setSize(new java.awt.Dimension(330,23)); |
70 |
this.add(getJLblProjName(), null); |
71 |
this.add(getJLblProj(), null); |
72 |
this.add(getJBtnChangeProj(), null); |
73 |
|
74 |
|
75 |
//cambiar cuando la parte de JLuis se ensamble
|
76 |
if(!((ICrs)curProj).getAbrev().equals("EPSG:23030")){ |
77 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
78 |
jLblProj.setText(dataSource+":" +String.valueOf(curProj.getCode())); |
79 |
//jLblProj.setText(((ICrs)curProj).getCrsWkt().getName());
|
80 |
} |
81 |
else
|
82 |
jLblProj.setText("EPSG:23030");
|
83 |
initBtnChangeProj(); |
84 |
} |
85 |
|
86 |
private void initBtnChangeProj() { |
87 |
getJBtnChangeProj().addActionListener(new java.awt.event.ActionListener() {
|
88 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
89 |
CSSelectionDialog csSelect = null;
|
90 |
TRSelectionDialog trSelect = null;
|
91 |
if (!isTransPanelActive()){
|
92 |
okPressed = false;
|
93 |
csSelect = new CSSelectionDialog();
|
94 |
csSelect.setProjection(curProj); |
95 |
|
96 |
csSelect.setLayout(new GridLayout(0,1)); |
97 |
|
98 |
PluginServices.getMDIManager().addWindow(csSelect); |
99 |
abrev = dataSource+ ":" +String.valueOf(curProj.getCode()); |
100 |
if (csSelect.isOkPressed()) {
|
101 |
curProj = (ICrs) csSelect.getProjection(); |
102 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
103 |
//dataSource = csSelect.getDataSource();
|
104 |
abrev = dataSource+ ":" +String.valueOf(curProj.getCode()); |
105 |
|
106 |
jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//.getAbrev()); |
107 |
FOpenDialog.setLastProjection(curProj); |
108 |
okPressed = true;
|
109 |
if (actionListener != null) { |
110 |
actionListener.actionPerformed(e); |
111 |
} |
112 |
}else
|
113 |
jLblProj.setText(abrev); |
114 |
} |
115 |
else {
|
116 |
okPressed = false;
|
117 |
trSelect = new TRSelectionDialog(curProj);
|
118 |
|
119 |
trSelect.setProjection(curProj); |
120 |
|
121 |
trSelect.setLayout(new GridLayout(0,1)); |
122 |
|
123 |
PluginServices.getMDIManager().addWindow(trSelect); |
124 |
setTargetNad(trSelect.getTargetNad()); |
125 |
//abrev = curProj.getAbrev();
|
126 |
|
127 |
if (trSelect.getProjection() != curProj) {
|
128 |
curProj = (ICrs) trSelect.getProjection(); |
129 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
130 |
//dataSource = trSelect.getProjPanel().getDataSource();
|
131 |
//abrev = trSelect.getProjectionName();
|
132 |
jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//abrev); |
133 |
FOpenDialog.setLastProjection(curProj); |
134 |
okPressed = true;
|
135 |
|
136 |
if (actionListener != null) { |
137 |
actionListener.actionPerformed(e); |
138 |
} |
139 |
}else
|
140 |
jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//abrev); |
141 |
|
142 |
} |
143 |
|
144 |
} |
145 |
}); |
146 |
} |
147 |
|
148 |
public JLabel getJLblProjName() { |
149 |
if (jLblProjName == null) { |
150 |
jLblProjName = new JLabel("Proyeccion actual"); |
151 |
jLblProjName.setText(PluginServices.getText(this,"__proyeccion_actual")); //$NON-NLS-1$ |
152 |
} |
153 |
return jLblProjName;
|
154 |
} |
155 |
|
156 |
public JLabel getJLblProj() { |
157 |
if (jLblProj == null) { |
158 |
jLblProj = new JLabel(); |
159 |
jLblProj.setText(curProj.getAbrev()); |
160 |
} |
161 |
return jLblProj;
|
162 |
} |
163 |
public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) { |
164 |
jBtnChangeProj.addActionListener(al); |
165 |
} |
166 |
|
167 |
/**
|
168 |
* This method initializes jButton
|
169 |
*
|
170 |
* @return javax.swing.JButton
|
171 |
*/
|
172 |
public JButton getJBtnChangeProj() { |
173 |
if (jBtnChangeProj == null) { |
174 |
jBtnChangeProj = new JButton(); |
175 |
jBtnChangeProj.setText("..."); //$NON-NLS-1$ |
176 |
jBtnChangeProj.setPreferredSize(new Dimension(50, 23)); |
177 |
} |
178 |
return jBtnChangeProj;
|
179 |
} |
180 |
|
181 |
public void setTargetNad(boolean tarNad){ |
182 |
targetNad = tarNad; |
183 |
} |
184 |
|
185 |
public boolean getTargetNad(){ |
186 |
return targetNad;
|
187 |
} |
188 |
|
189 |
/**
|
190 |
* @return Returns the curProj.
|
191 |
*/
|
192 |
public IProjection getCurProj() {
|
193 |
return curProj;
|
194 |
} |
195 |
/**
|
196 |
* @param curProj The curProj to set.
|
197 |
*/
|
198 |
public void setCurProj(IProjection curProj) { |
199 |
this.curProj = (ICrs) curProj;
|
200 |
} |
201 |
/**
|
202 |
* @return Returns the okPressed.
|
203 |
*/
|
204 |
public boolean isOkPressed() { |
205 |
return okPressed;
|
206 |
} |
207 |
/**
|
208 |
* @param actionListener The actionListener to set.
|
209 |
*/
|
210 |
public void addActionListener(ActionListener actionListener) { |
211 |
this.actionListener = actionListener;
|
212 |
} |
213 |
} // @jve:decl-index=0:visual-constraint="10,10"
|