svn-gvsig-desktop / trunk / libraries / libJCRS / src / org / gvsig / crs / ui / CrsView.java @ 6906
History | View | Annotate | Download (8.73 KB)
1 |
package org.gvsig.crs.ui; |
---|---|
2 |
|
3 |
import java.awt.Dimension; |
4 |
import java.awt.FlowLayout; |
5 |
import java.awt.GridLayout; |
6 |
import java.awt.event.ActionEvent; |
7 |
|
8 |
import javax.swing.JButton; |
9 |
import javax.swing.JCheckBox; |
10 |
import javax.swing.JPanel; |
11 |
|
12 |
import org.cresques.cts.IProjection; |
13 |
import org.gvsig.crs.EpsgConnection; |
14 |
import org.gvsig.crs.ICrs; |
15 |
|
16 |
import com.iver.andami.PluginServices; |
17 |
import com.iver.andami.ui.mdiManager.View; |
18 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
19 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanel; |
20 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanelTransformation; |
21 |
|
22 |
public class CrsView extends JPanel implements View { |
23 |
|
24 |
private static final long serialVersionUID = 1L; |
25 |
|
26 |
EpsgConnection connect; |
27 |
|
28 |
boolean tra = false; //para que si tenemos seleccionada transformacion nos muestre los parametros |
29 |
|
30 |
ProjChooserPanelTransformation pcpt; |
31 |
ProjChooserPanel pcp; |
32 |
|
33 |
private JButton cancel = null; |
34 |
public static JButton next = null; |
35 |
public static JButton accept = null; |
36 |
private JPanel jPanelButton = null; |
37 |
|
38 |
int crs_target = -1; |
39 |
|
40 |
int transformation_code = 0; |
41 |
private CRSSelectionPanel contentPane = null; |
42 |
private JPanel buttonPane = null; |
43 |
public static JCheckBox withOutTrans = null; |
44 |
public static JCheckBox nadgrids = null; |
45 |
public static JCheckBox epsgTrans = null; |
46 |
public static JCheckBox manualTrans = null; |
47 |
|
48 |
public CrsView(int target) { |
49 |
super();
|
50 |
crs_target = target; |
51 |
pcpt = new ProjChooserPanelTransformation();
|
52 |
pcp = new ProjChooserPanel();
|
53 |
initialize(); |
54 |
} |
55 |
private void initialize() { |
56 |
this.add(getContentPanel(),null); |
57 |
getJPanel(); |
58 |
} |
59 |
|
60 |
private void getJPanel() { |
61 |
this.add(getCheckButtonPane(), null); |
62 |
this.add(getButtons(), null); |
63 |
if (!CRSSelectionPanel.si){
|
64 |
withOutTrans.setEnabled(false);
|
65 |
nadgrids.setEnabled(false);
|
66 |
epsgTrans.setEnabled(false);
|
67 |
manualTrans.setEnabled(false);
|
68 |
next.setVisible(false);
|
69 |
accept.setVisible(true);
|
70 |
} |
71 |
} |
72 |
|
73 |
public CRSSelectionPanel getContentPanel() {
|
74 |
if (contentPane == null) { |
75 |
contentPane = new CRSSelectionPanel(true); |
76 |
contentPane.setLayout(new GridLayout(3,3)); |
77 |
contentPane.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
78 |
contentPane.setPreferredSize(new Dimension(650,370)); |
79 |
|
80 |
} |
81 |
return contentPane;
|
82 |
} |
83 |
|
84 |
private JPanel getCheckButtonPane() { |
85 |
if(buttonPane == null) { |
86 |
buttonPane = new JPanel(); |
87 |
buttonPane.setPreferredSize(new Dimension(400,100)); |
88 |
buttonPane.setLayout(new GridLayout(0,2)); |
89 |
buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
90 |
buttonPane.add(getWithOutTrans(), null);
|
91 |
buttonPane.add(getNadgrids(), null);
|
92 |
buttonPane.add(getEpsgTrans(), null);
|
93 |
buttonPane.add(getManualTrans(), null);
|
94 |
} |
95 |
return buttonPane;
|
96 |
} |
97 |
|
98 |
private JCheckBox getWithOutTrans() { |
99 |
if(withOutTrans == null) { |
100 |
withOutTrans = new JCheckBox(); |
101 |
withOutTrans.setText("Sin transformacion");
|
102 |
withOutTrans.setSelected(true);
|
103 |
withOutTrans.setPreferredSize(new Dimension(175,20)); |
104 |
withOutTrans.addActionListener(new java.awt.event.ActionListener() {
|
105 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
106 |
withOutTrans_actionPerformed(e); |
107 |
} |
108 |
}); |
109 |
} |
110 |
return withOutTrans;
|
111 |
} |
112 |
|
113 |
private void withOutTrans_actionPerformed(ActionEvent e) { |
114 |
if(!withOutTrans.isSelected())
|
115 |
withOutTrans.setSelected(true);
|
116 |
epsgTrans.setSelected(false);
|
117 |
manualTrans.setSelected(false);
|
118 |
nadgrids.setSelected(false);
|
119 |
} |
120 |
|
121 |
private JCheckBox getNadgrids() { |
122 |
if(nadgrids == null) { |
123 |
nadgrids = new JCheckBox(); |
124 |
nadgrids.setText("+nadgrids");
|
125 |
nadgrids.setSelected(false);
|
126 |
nadgrids.setPreferredSize(new Dimension(175,20)); |
127 |
nadgrids.addActionListener(new java.awt.event.ActionListener() {
|
128 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
129 |
nadgrids_actionPerformed(e); |
130 |
} |
131 |
}); |
132 |
} |
133 |
return nadgrids;
|
134 |
} |
135 |
|
136 |
private void nadgrids_actionPerformed(ActionEvent e) { |
137 |
|
138 |
if(!nadgrids.isSelected())
|
139 |
nadgrids.setSelected(true);
|
140 |
withOutTrans.setSelected(false);
|
141 |
epsgTrans.setSelected(false);
|
142 |
manualTrans.setSelected(false);
|
143 |
} |
144 |
|
145 |
private JCheckBox getEpsgTrans() { |
146 |
if(epsgTrans == null) { |
147 |
epsgTrans = new JCheckBox(); |
148 |
epsgTrans.setText("Transformacion epsg");
|
149 |
epsgTrans.setSelected(false);
|
150 |
epsgTrans.setPreferredSize(new Dimension(175,20)); |
151 |
epsgTrans.addActionListener(new java.awt.event.ActionListener() {
|
152 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
153 |
epsgTrans_actionPerformed(e); |
154 |
} |
155 |
}); |
156 |
} |
157 |
return epsgTrans;
|
158 |
} |
159 |
|
160 |
private void epsgTrans_actionPerformed(ActionEvent e) { |
161 |
if(!epsgTrans.isSelected())
|
162 |
epsgTrans.setSelected(true);
|
163 |
nadgrids.setSelected(false);
|
164 |
withOutTrans.setSelected(false);
|
165 |
manualTrans.setSelected(false);
|
166 |
} |
167 |
|
168 |
private JCheckBox getManualTrans() { |
169 |
if(manualTrans == null) { |
170 |
manualTrans = new JCheckBox(); |
171 |
manualTrans.setText("Transformacion manual");
|
172 |
manualTrans.setSelected(false);
|
173 |
manualTrans.setPreferredSize(new Dimension(175,20)); |
174 |
manualTrans.addActionListener(new java.awt.event.ActionListener() {
|
175 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
176 |
manualTrans_actionPerformed(e); |
177 |
} |
178 |
}); |
179 |
} |
180 |
return manualTrans;
|
181 |
} |
182 |
|
183 |
private void manualTrans_actionPerformed(ActionEvent e) { |
184 |
if(!manualTrans.isSelected())
|
185 |
manualTrans.setSelected(true);
|
186 |
nadgrids.setSelected(false);
|
187 |
epsgTrans.setSelected(false);
|
188 |
withOutTrans.setSelected(false);
|
189 |
} |
190 |
|
191 |
|
192 |
private JPanel getButtons() { |
193 |
if(jPanelButton == null) { |
194 |
jPanelButton = new JPanel(); |
195 |
jPanelButton.setPreferredSize(new Dimension(650,50)); |
196 |
jPanelButton.setLayout(new GridLayout(0,1)); |
197 |
jPanelButton.setLayout(new FlowLayout(FlowLayout.RIGHT,5,5)); |
198 |
jPanelButton.add(getCancel(), null);
|
199 |
jPanelButton.add(getNext(), null);
|
200 |
jPanelButton.add(getAccept(), null);
|
201 |
} |
202 |
return jPanelButton;
|
203 |
} |
204 |
|
205 |
private JButton getAccept() { |
206 |
if(accept == null) { |
207 |
accept = new JButton(); |
208 |
accept.setText("Ok");
|
209 |
accept.setMnemonic('O');
|
210 |
accept.setPreferredSize(new Dimension(100,25)); |
211 |
accept.addActionListener(new java.awt.event.ActionListener() {
|
212 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
213 |
accept_actionPerformed(e); |
214 |
} |
215 |
}); |
216 |
} |
217 |
return accept;
|
218 |
} |
219 |
|
220 |
private void accept_actionPerformed(ActionEvent e) { |
221 |
PluginServices.getMDIManager().closeView(this);
|
222 |
} |
223 |
|
224 |
|
225 |
private JButton getNext() { |
226 |
if(next == null) { |
227 |
next = new JButton(); |
228 |
next.setText("Siguiente");
|
229 |
next.setMnemonic('S');
|
230 |
next.setPreferredSize(new Dimension(100,25)); |
231 |
next.addActionListener(new java.awt.event.ActionListener() {
|
232 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
233 |
next_actionPerformed(e); |
234 |
} |
235 |
}); |
236 |
} |
237 |
return next;
|
238 |
} |
239 |
|
240 |
private void next_actionPerformed(ActionEvent e) { |
241 |
if(epsgTrans.isSelected() == true && contentPane.getCodeCRS() != -1){ |
242 |
PluginServices.getMDIManager().closeView(this);
|
243 |
TransformationEpsgPanel tr = new TransformationEpsgPanel(contentPane.getWKT(),contentPane.getCodeCRS(),
|
244 |
crs_target); |
245 |
tr.setSize(new Dimension(550, 400)); |
246 |
tr.setLayout(new GridLayout(2,2)); |
247 |
tr.setLayout(new FlowLayout(FlowLayout.LEFT,5,20)); |
248 |
PluginServices.getMDIManager().addView(tr); |
249 |
|
250 |
}else if(nadgrids.isSelected() == true && contentPane.getCodeCRS() != -1) { |
251 |
PluginServices.getMDIManager().closeView(this);
|
252 |
TransformationNadgridsPanel tn = new TransformationNadgridsPanel(contentPane.getWKT(),contentPane.getCodeCRS());
|
253 |
tn.setSize(new Dimension(550, 275)); |
254 |
tn.setLayout(new GridLayout(2,2)); |
255 |
tn.setLayout(new FlowLayout(FlowLayout.LEFT,5,10)); |
256 |
PluginServices.getMDIManager().addView(tn); |
257 |
}else if(manualTrans.isSelected() == true && contentPane.getCodeCRS() != -1) { |
258 |
PluginServices.getMDIManager().closeView(this);
|
259 |
TransformationManualPanel tm = new TransformationManualPanel(contentPane.getWKT(),contentPane.getCodeCRS());
|
260 |
tm.setSize(new Dimension(550, 400)); |
261 |
tm.setLayout(new GridLayout(2,2)); |
262 |
tm.setLayout(new FlowLayout(FlowLayout.LEFT,5,10)); |
263 |
PluginServices.getMDIManager().addView(tm); |
264 |
} |
265 |
} |
266 |
|
267 |
|
268 |
private JButton getCancel() { |
269 |
if(cancel == null) { |
270 |
cancel = new JButton(); |
271 |
cancel.setText("Cancelar");
|
272 |
cancel.setMnemonic('C');
|
273 |
cancel.setPreferredSize(new Dimension(100,25)); |
274 |
cancel.addActionListener(new java.awt.event.ActionListener() {
|
275 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
276 |
cancel_actionPerformed(e); |
277 |
} |
278 |
}); |
279 |
} |
280 |
return cancel;
|
281 |
} |
282 |
|
283 |
private void cancel_actionPerformed(ActionEvent e) { |
284 |
PluginServices.getMDIManager().closeView(this);
|
285 |
} |
286 |
|
287 |
public ICrs getProjection() {
|
288 |
return null; |
289 |
} |
290 |
|
291 |
public void setProjection(IProjection crs) { |
292 |
//setCrs((ICrs) crs);
|
293 |
} |
294 |
|
295 |
public ViewInfo getViewInfo() {
|
296 |
ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
|
297 |
m_viewinfo.setTitle(PluginServices.getText(this,"CrsView")); |
298 |
return m_viewinfo;
|
299 |
} |
300 |
|
301 |
|
302 |
} |