Revision 7191
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/CrsView.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.FlowLayout; |
|
5 |
import java.awt.GridLayout; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.sql.ResultSet; |
|
8 |
import java.sql.SQLException; |
|
9 |
|
|
10 |
import javax.swing.BorderFactory; |
|
11 |
import javax.swing.JButton; |
|
12 |
import javax.swing.JPanel; |
|
13 |
import javax.swing.JRadioButton; |
|
14 |
import javax.swing.ListSelectionModel; |
|
15 |
import javax.swing.event.ListSelectionEvent; |
|
16 |
import javax.swing.event.ListSelectionListener; |
|
17 |
|
|
18 |
import org.cresques.cts.IProjection; |
|
19 |
import org.gvsig.crs.CrsException; |
|
20 |
import org.gvsig.crs.CrsFactory; |
|
21 |
import org.gvsig.crs.EpsgConnection; |
|
22 |
import org.gvsig.crs.ICrs; |
|
23 |
import org.gvsig.crs.Query; |
|
24 |
|
|
25 |
import com.iver.andami.PluginServices; |
|
26 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
27 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
28 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanel; |
|
29 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanelTransformation; |
|
30 |
|
|
31 |
public class CrsView extends JPanel implements IWindow, ListSelectionListener{ |
|
32 |
|
|
33 |
private static final long serialVersionUID = 1L; |
|
34 |
|
|
35 |
EpsgConnection connect; |
|
36 |
|
|
37 |
private IProjection crsfirst; |
|
38 |
private String params = "+towgs84="; |
|
39 |
|
|
40 |
boolean tra = false; //para que si tenemos seleccionada transformacion nos muestre los parametros |
|
41 |
|
|
42 |
ProjChooserPanelTransformation pcpt; |
|
43 |
ProjChooserPanel pcp; |
|
44 |
|
|
45 |
private JButton cancel = null; |
|
46 |
public static JButton next = null; |
|
47 |
public static JButton accept = null; |
|
48 |
private JPanel jPanelButton = null; |
|
49 |
|
|
50 |
int crs_target = -1; |
|
51 |
private CRSSelectionPanel CRSPanel; |
|
52 |
String datum_target = ""; |
|
53 |
|
|
54 |
int transformation_code = 0; |
|
55 |
private CRSSelectionPanel contentPane = null; |
|
56 |
private JPanel buttonPane = null; |
|
57 |
public JRadioButton withOutTrans = null; |
|
58 |
public JRadioButton nadgrids = null; |
|
59 |
public JRadioButton epsgTrans = null; |
|
60 |
public JRadioButton manualTrans = null; |
|
61 |
|
|
62 |
public CrsView(int target, String datum) { |
|
63 |
super(); |
|
64 |
crs_target = target; |
|
65 |
datum_target = datum; |
|
66 |
pcp = new ProjChooserPanel(); |
|
67 |
initialize(); |
|
68 |
} |
|
69 |
private void initialize() { |
|
70 |
CRSPanel = (CRSSelectionPanel)getContentPanel(); |
|
71 |
ListSelectionModel rowSM = CRSPanel.getJTable().getSelectionModel(); |
|
72 |
rowSM.addListSelectionListener(this); |
|
73 |
this.add(getContentPanel(),null); |
|
74 |
getJPanel(); |
|
75 |
} |
|
76 |
|
|
77 |
private void getJPanel() { |
|
78 |
this.add(getCheckButtonPane(), null); |
|
79 |
this.add(getButtons(), null); |
|
80 |
} |
|
81 |
|
|
82 |
public CRSSelectionPanel getContentPanel() { |
|
83 |
if (contentPane == null) { |
|
84 |
contentPane = new CRSSelectionPanel(); |
|
85 |
contentPane.setLayout(new GridLayout(3,3)); |
|
86 |
contentPane.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
|
87 |
contentPane.setPreferredSize(new Dimension(650,370)); |
|
88 |
|
|
89 |
} |
|
90 |
return contentPane; |
|
91 |
} |
|
92 |
|
|
93 |
private JPanel getCheckButtonPane() { |
|
94 |
if(buttonPane == null) { |
|
95 |
buttonPane = new JPanel(); |
|
96 |
buttonPane.setPreferredSize(new Dimension(400,100)); |
|
97 |
buttonPane.setLayout(new GridLayout(0,2)); |
|
98 |
buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
|
99 |
buttonPane.setBorder( |
|
100 |
BorderFactory.createCompoundBorder( |
|
101 |
BorderFactory.createCompoundBorder( |
|
102 |
BorderFactory.createTitledBorder("Seleccione Transformacion"), |
|
103 |
BorderFactory.createEmptyBorder(2,2,2,2)), |
|
104 |
buttonPane.getBorder())); |
|
105 |
buttonPane.add(getWithOutTrans(), null); |
|
106 |
buttonPane.add(getNadgrids(), null); |
|
107 |
buttonPane.add(getEpsgTrans(), null); |
|
108 |
buttonPane.add(getManualTrans(), null); |
|
109 |
} |
|
110 |
return buttonPane; |
|
111 |
} |
|
112 |
|
|
113 |
private JRadioButton getWithOutTrans() { |
|
114 |
if(withOutTrans == null) { |
|
115 |
withOutTrans = new JRadioButton(); |
|
116 |
withOutTrans.setText("Sin transformacion"); |
|
117 |
withOutTrans.setSelected(true); |
|
118 |
withOutTrans.setEnabled(false); |
|
119 |
withOutTrans.setPreferredSize(new Dimension(175,20)); |
|
120 |
withOutTrans.addActionListener(new java.awt.event.ActionListener() { |
|
121 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
122 |
withOutTrans_actionPerformed(e); |
|
123 |
} |
|
124 |
}); |
|
125 |
} |
|
126 |
return withOutTrans; |
|
127 |
} |
|
128 |
|
|
129 |
private void withOutTrans_actionPerformed(ActionEvent e) { |
|
130 |
if(!withOutTrans.isSelected()) |
|
131 |
withOutTrans.setSelected(true); |
|
132 |
epsgTrans.setSelected(false); |
|
133 |
manualTrans.setSelected(false); |
|
134 |
nadgrids.setSelected(false); |
|
135 |
} |
|
136 |
|
|
137 |
private JRadioButton getNadgrids() { |
|
138 |
if(nadgrids == null) { |
|
139 |
nadgrids = new JRadioButton(); |
|
140 |
nadgrids.setText("+nadgrids"); |
|
141 |
nadgrids.setSelected(false); |
|
142 |
nadgrids.setEnabled(false); |
|
143 |
nadgrids.setPreferredSize(new Dimension(175,20)); |
|
144 |
nadgrids.addActionListener(new java.awt.event.ActionListener() { |
|
145 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
146 |
nadgrids_actionPerformed(e); |
|
147 |
} |
|
148 |
}); |
|
149 |
} |
|
150 |
return nadgrids; |
|
151 |
} |
|
152 |
|
|
153 |
private void nadgrids_actionPerformed(ActionEvent e) { |
|
154 |
|
|
155 |
if(!nadgrids.isSelected()) |
|
156 |
nadgrids.setSelected(true); |
|
157 |
withOutTrans.setSelected(false); |
|
158 |
epsgTrans.setSelected(false); |
|
159 |
manualTrans.setSelected(false); |
|
160 |
} |
|
161 |
|
|
162 |
private JRadioButton getEpsgTrans() { |
|
163 |
if(epsgTrans == null) { |
|
164 |
epsgTrans = new JRadioButton(); |
|
165 |
epsgTrans.setText("Transformacion epsg"); |
|
166 |
epsgTrans.setSelected(false); |
|
167 |
epsgTrans.setEnabled(false); |
|
168 |
epsgTrans.setPreferredSize(new Dimension(175,20)); |
|
169 |
epsgTrans.addActionListener(new java.awt.event.ActionListener() { |
|
170 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
171 |
epsgTrans_actionPerformed(e); |
|
172 |
} |
|
173 |
}); |
|
174 |
} |
|
175 |
return epsgTrans; |
|
176 |
} |
|
177 |
|
|
178 |
private void epsgTrans_actionPerformed(ActionEvent e) { |
|
179 |
if(!epsgTrans.isSelected()) |
|
180 |
epsgTrans.setSelected(true); |
|
181 |
nadgrids.setSelected(false); |
|
182 |
withOutTrans.setSelected(false); |
|
183 |
manualTrans.setSelected(false); |
|
184 |
} |
|
185 |
|
|
186 |
private JRadioButton getManualTrans() { |
|
187 |
if(manualTrans == null) { |
|
188 |
manualTrans = new JRadioButton(); |
|
189 |
manualTrans.setText("Transformacion manual"); |
|
190 |
manualTrans.setSelected(false); |
|
191 |
manualTrans.setEnabled(false); |
|
192 |
manualTrans.setPreferredSize(new Dimension(175,20)); |
|
193 |
manualTrans.addActionListener(new java.awt.event.ActionListener() { |
|
194 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
195 |
manualTrans_actionPerformed(e); |
|
196 |
} |
|
197 |
}); |
|
198 |
} |
|
199 |
return manualTrans; |
|
200 |
} |
|
201 |
|
|
202 |
private void manualTrans_actionPerformed(ActionEvent e) { |
|
203 |
if(!manualTrans.isSelected()) |
|
204 |
manualTrans.setSelected(true); |
|
205 |
nadgrids.setSelected(false); |
|
206 |
epsgTrans.setSelected(false); |
|
207 |
withOutTrans.setSelected(false); |
|
208 |
} |
|
209 |
|
|
210 |
|
|
211 |
private JPanel getButtons() { |
|
212 |
if(jPanelButton == null) { |
|
213 |
jPanelButton = new JPanel(); |
|
214 |
jPanelButton.setPreferredSize(new Dimension(650,50)); |
|
215 |
jPanelButton.setLayout(new GridLayout(0,1)); |
|
216 |
jPanelButton.setLayout(new FlowLayout(FlowLayout.RIGHT,5,5)); |
|
217 |
jPanelButton.add(getCancel(), null); |
|
218 |
jPanelButton.add(getNext(), null); |
|
219 |
jPanelButton.add(getAccept(), null); |
|
220 |
} |
|
221 |
return jPanelButton; |
|
222 |
} |
|
223 |
|
|
224 |
private JButton getAccept() { |
|
225 |
if(accept == null) { |
|
226 |
accept = new JButton(); |
|
227 |
accept.setText("Ok"); |
|
228 |
accept.setMnemonic('O'); |
|
229 |
accept.setPreferredSize(new Dimension(100,25)); |
|
230 |
accept.addActionListener(new java.awt.event.ActionListener() { |
|
231 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
232 |
accept_actionPerformed(e); |
|
233 |
} |
|
234 |
}); |
|
235 |
} |
|
236 |
return accept; |
|
237 |
} |
|
238 |
|
|
239 |
private void accept_actionPerformed(ActionEvent e) { |
|
240 |
setProjection(this.getProjection()); |
|
241 |
PluginServices.getMDIManager().closeWindow(this); |
|
242 |
} |
|
243 |
|
|
244 |
|
|
245 |
private JButton getNext() { |
|
246 |
if(next == null) { |
|
247 |
next = new JButton(); |
|
248 |
next.setText("Siguiente"); |
|
249 |
next.setMnemonic('S'); |
|
250 |
next.setVisible(false); |
|
251 |
next.setPreferredSize(new Dimension(100,25)); |
|
252 |
next.addActionListener(new java.awt.event.ActionListener() { |
|
253 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
254 |
next_actionPerformed(e); |
|
255 |
} |
|
256 |
}); |
|
257 |
} |
|
258 |
return next; |
|
259 |
} |
|
260 |
|
|
261 |
private void next_actionPerformed(ActionEvent e) { |
|
262 |
if(epsgTrans.isSelected() == true && contentPane.getCodeCRS() != -1){ |
|
263 |
//PluginServices.getMDIManager().closeWindow(this); |
|
264 |
TransformationEpsgPanel tr = new TransformationEpsgPanel(contentPane.getWKT(),contentPane.getCodeCRS(), |
|
265 |
crs_target); |
|
266 |
tr.setSize(new Dimension(550, 400)); |
|
267 |
tr.setLayout(new GridLayout(2,2)); |
|
268 |
tr.setLayout(new FlowLayout(FlowLayout.LEFT,5,20)); |
|
269 |
PluginServices.getMDIManager().addWindow(tr); |
|
270 |
setProjection(tr.getProjection()); |
|
271 |
|
|
272 |
}else if(nadgrids.isSelected() == true && contentPane.getCodeCRS() != -1) { |
|
273 |
//PluginServices.getMDIManager().closeWindow(this); |
|
274 |
TransformationNadgridsPanel tn = new TransformationNadgridsPanel(contentPane.getWKT(),contentPane.getCodeCRS()); |
|
275 |
tn.setSize(new Dimension(550, 275)); |
|
276 |
tn.setLayout(new GridLayout(2,2)); |
|
277 |
tn.setLayout(new FlowLayout(FlowLayout.LEFT,5,10)); |
|
278 |
PluginServices.getMDIManager().addWindow(tn); |
|
279 |
setProjection(tn.getProjection()); |
|
280 |
}else if(manualTrans.isSelected() == true && contentPane.getCodeCRS() != -1) { |
|
281 |
//PluginServices.getMDIManager().closeWindow(this); |
|
282 |
TransformationManualPanel tm = new TransformationManualPanel(contentPane.getWKT(),contentPane.getCodeCRS()); |
|
283 |
tm.setSize(new Dimension(550, 400)); |
|
284 |
tm.setLayout(new GridLayout(2,2)); |
|
285 |
tm.setLayout(new FlowLayout(FlowLayout.LEFT,5,10)); |
|
286 |
PluginServices.getMDIManager().addWindow(tm); |
|
287 |
}/*else if(withOutTrans.isSelected() == true && contentPane.getCodeCRS() != -1) { |
|
288 |
PluginServices.getMDIManager().closeWindow(this); |
|
289 |
WithoutTranformation wt = new WithoutTranformation(contentPane.getWKT(),contentPane.getCodeCRS()); |
|
290 |
wt.setSize(new Dimension(550, 200)); |
|
291 |
wt.setLayout(new GridLayout(2,2)); |
|
292 |
wt.setLayout(new FlowLayout(FlowLayout.LEFT,5,10)); |
|
293 |
PluginServices.getMDIManager().addWindow(wt); |
|
294 |
}*/ |
|
295 |
} |
|
296 |
|
|
297 |
|
|
298 |
private JButton getCancel() { |
|
299 |
if(cancel == null) { |
|
300 |
cancel = new JButton(); |
|
301 |
cancel.setText("Cancelar"); |
|
302 |
cancel.setMnemonic('C'); |
|
303 |
cancel.setPreferredSize(new Dimension(100,25)); |
|
304 |
cancel.addActionListener(new java.awt.event.ActionListener() { |
|
305 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
306 |
cancel_actionPerformed(e); |
|
307 |
} |
|
308 |
}); |
|
309 |
} |
|
310 |
return cancel; |
|
311 |
} |
|
312 |
|
|
313 |
private void cancel_actionPerformed(ActionEvent e) { |
|
314 |
PluginServices.getMDIManager().closeWindow(this); |
|
315 |
} |
|
316 |
|
|
317 |
public ICrs getProjection() { |
|
318 |
ICrs crs; |
|
319 |
try { |
|
320 |
crs = new CrsFactory().getCRS(CRSPanel.getCodeCRS(),CRSPanel.getWKT()); |
|
321 |
return crs; |
|
322 |
} catch (CrsException e) { |
|
323 |
e.printStackTrace(); |
|
324 |
} |
|
325 |
return null; |
|
326 |
} |
|
327 |
|
|
328 |
public void setProjection(IProjection proj) { |
|
329 |
crsfirst = proj; |
|
330 |
} |
|
331 |
|
|
332 |
public void valueChanged(ListSelectionEvent e) { |
|
333 |
ListSelectionModel lsm = (ListSelectionModel)e.getSource(); |
|
334 |
if (lsm.isSelectionEmpty()) { |
|
335 |
CRSPanel.selectedRowTable = -1; |
|
336 |
CRSPanel.setCodeCRS(-1); |
|
337 |
withOutTrans.setEnabled(false); |
|
338 |
nadgrids.setEnabled(false); |
|
339 |
epsgTrans.setEnabled(false); |
|
340 |
manualTrans.setEnabled(false); |
|
341 |
next.setVisible(false); |
|
342 |
accept.setVisible(true); |
|
343 |
} |
|
344 |
else { |
|
345 |
CRSPanel.selectedRowTable = lsm.getMinSelectionIndex(); |
|
346 |
CRSPanel.setCodeCRS(Integer.parseInt((String)CRSPanel.dtm.getValueAt(CRSPanel.selectedRowTable,0))); |
|
347 |
CRSPanel.setWKT(); |
|
348 |
|
|
349 |
int base = contentPane.getCodeCRS(); |
|
350 |
String datum = ""; |
|
351 |
int datum_code = -1; |
|
352 |
String sentence = "SELECT source_geogcrs_code " + |
|
353 |
"FROM epsg_coordinatereferencesystem " + |
|
354 |
"WHERE coord_ref_sys_code = "+ base ; |
|
355 |
ResultSet result = Query.select(sentence,pcp.connect.getConnection()); |
|
356 |
int source = 0; |
|
357 |
try { |
|
358 |
result.next(); |
|
359 |
source = result.getInt("source_geogcrs_code"); |
|
360 |
} catch (SQLException e1) { |
|
361 |
e1.printStackTrace(); |
|
362 |
} |
|
363 |
|
|
364 |
if (source != 0){ |
|
365 |
base = source; |
|
366 |
} |
|
367 |
|
|
368 |
sentence = "SELECT datum_code " + |
|
369 |
"FROM epsg_coordinatereferencesystem " + |
|
370 |
"WHERE coord_ref_sys_code = "+ base ; |
|
371 |
result = Query.select(sentence,pcp.connect.getConnection()); |
|
372 |
|
|
373 |
try { |
|
374 |
result.next(); |
|
375 |
datum_code = result.getInt("datum_code"); |
|
376 |
} catch (SQLException e1) { |
|
377 |
e1.printStackTrace(); |
|
378 |
} |
|
379 |
|
|
380 |
sentence = "SELECT datum_name " + |
|
381 |
"FROM epsg_datum " + |
|
382 |
"WHERE datum_code = "+ datum_code ; |
|
383 |
result = Query.select(sentence,pcp.connect.getConnection()); |
|
384 |
|
|
385 |
try { |
|
386 |
result.next(); |
|
387 |
datum = result.getString("datum_name"); |
|
388 |
} catch (SQLException e1) { |
|
389 |
e1.printStackTrace(); |
|
390 |
} |
|
391 |
|
|
392 |
if (!(datum_target.equals(datum.replaceAll(" ","")))){ |
|
393 |
withOutTrans.setEnabled(true); |
|
394 |
nadgrids.setEnabled(true); |
|
395 |
epsgTrans.setEnabled(true); |
|
396 |
manualTrans.setEnabled(true); |
|
397 |
next.setVisible(true); |
|
398 |
accept.setVisible(false); |
|
399 |
} |
|
400 |
else { |
|
401 |
withOutTrans.setEnabled(false); |
|
402 |
nadgrids.setEnabled(false); |
|
403 |
epsgTrans.setEnabled(false); |
|
404 |
manualTrans.setEnabled(false); |
|
405 |
next.setVisible(false); |
|
406 |
accept.setVisible(true); |
|
407 |
} |
|
408 |
} |
|
409 |
CRSPanel.getInfoCrs().setEnabled(true); |
|
410 |
|
|
411 |
|
|
412 |
} |
|
413 |
public WindowInfo getWindowInfo() { |
|
414 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG); |
|
415 |
m_viewinfo.setTitle(PluginServices.getText(this,"CrsView")); |
|
416 |
return m_viewinfo; |
|
417 |
} |
|
418 |
} |
|
0 | 419 |
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/TransformationNadgridsPanel.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
|
|
3 |
import java.awt.Component; |
|
4 |
import java.awt.Dimension; |
|
5 |
import java.awt.FlowLayout; |
|
6 |
import java.awt.GridLayout; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
import java.io.File; |
|
9 |
|
|
10 |
import javax.swing.BorderFactory; |
|
11 |
import javax.swing.JButton; |
|
12 |
import javax.swing.JFileChooser; |
|
13 |
import javax.swing.JLabel; |
|
14 |
import javax.swing.JPanel; |
|
15 |
import javax.swing.JScrollPane; |
|
16 |
import javax.swing.JTextArea; |
|
17 |
import javax.swing.JTextField; |
|
18 |
|
|
19 |
import org.cresques.cts.IProjection; |
|
20 |
import org.cresques.ui.DefaultDialogPanel; |
|
21 |
import org.gvsig.crs.CrsFactory; |
|
22 |
import org.gvsig.crs.ICrs; |
|
23 |
|
|
24 |
import com.iver.andami.PluginServices; |
|
25 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
26 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
27 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanelTransformation; |
|
28 |
|
|
29 |
public class TransformationNadgridsPanel extends DefaultDialogPanel implements IWindow { |
|
30 |
|
|
31 |
private static final long serialVersionUID = 1L; |
|
32 |
|
|
33 |
private IProjection firstProj; |
|
34 |
private String nad = "+nadgrids=sped2et.gsb"; |
|
35 |
|
|
36 |
private JPanel buttonPane; |
|
37 |
private JButton accept; |
|
38 |
private JButton cancel; |
|
39 |
|
|
40 |
ProjChooserPanelTransformation pcpt; |
|
41 |
|
|
42 |
private String cadWKT = ""; |
|
43 |
private int codeEpsg; |
|
44 |
|
|
45 |
private JPanel jPaneOpen; |
|
46 |
private JLabel open_gsb; |
|
47 |
private JTextField jTextOpen; |
|
48 |
private JFileChooser openChooser; |
|
49 |
private JButton jButtonOpen; |
|
50 |
File f = new File("C:/Archivos de programa/FWTools1.0.0a7/proj_lib"); |
|
51 |
|
|
52 |
private JPanel panel; |
|
53 |
private JLabel wkt; |
|
54 |
private JTextArea info; |
|
55 |
private JScrollPane areaScrollPane; |
|
56 |
|
|
57 |
public TransformationNadgridsPanel(String cad, int code) { |
|
58 |
super(false); |
|
59 |
pcpt = new ProjChooserPanelTransformation(); |
|
60 |
cadWKT = cad; |
|
61 |
codeEpsg = code; |
|
62 |
/*this.setPreferredSize(new Dimension(680, 650)); |
|
63 |
this.setLayout(new GridLayout(2,2)); |
|
64 |
this.setLayout(new FlowLayout(FlowLayout.LEFT,5,10));*/ |
|
65 |
init(); |
|
66 |
} |
|
67 |
|
|
68 |
private void init() { |
|
69 |
this.add(getJPanel(), null); |
|
70 |
this.add(getOpenPanel(), null); |
|
71 |
this.add(getButtonPane(), null); |
|
72 |
} |
|
73 |
|
|
74 |
private JPanel getJPanel(){ |
|
75 |
if (panel == null) { |
|
76 |
panel = new JPanel(); |
|
77 |
panel.setLayout(new GridLayout(1,2)); |
|
78 |
panel.setLayout(new FlowLayout(FlowLayout.LEADING,5,10)); |
|
79 |
panel.setPreferredSize(new Dimension(525, 110)); |
|
80 |
panel.add(getLabel()); |
|
81 |
panel.add(getScrollPanelArea()); |
|
82 |
} |
|
83 |
return panel; |
|
84 |
} |
|
85 |
|
|
86 |
private JScrollPane getScrollPanelArea() { |
|
87 |
if(areaScrollPane == null) { |
|
88 |
areaScrollPane = new JScrollPane(getInfo()); |
|
89 |
areaScrollPane.setVerticalScrollBarPolicy( |
|
90 |
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
|
91 |
areaScrollPane.setPreferredSize(new Dimension(420, 100)); |
|
92 |
areaScrollPane.setBorder( |
|
93 |
BorderFactory.createCompoundBorder( |
|
94 |
BorderFactory.createCompoundBorder( |
|
95 |
BorderFactory.createTitledBorder("Wkt"), |
|
96 |
BorderFactory.createEmptyBorder(2,2,2,2)), |
|
97 |
areaScrollPane.getBorder())); |
|
98 |
} |
|
99 |
return areaScrollPane; |
|
100 |
} |
|
101 |
|
|
102 |
private Component getLabel() { |
|
103 |
if (wkt == null){ |
|
104 |
wkt = new JLabel(); |
|
105 |
wkt.setPreferredSize(new Dimension(90, 80)); |
|
106 |
wkt.setText("Cadena WKT: "); |
|
107 |
} |
|
108 |
return wkt; |
|
109 |
} |
|
110 |
|
|
111 |
private Component getInfo() { |
|
112 |
if (info == null){ |
|
113 |
info = new JTextArea(); |
|
114 |
info.setLineWrap(true); |
|
115 |
info.setWrapStyleWord(true); |
|
116 |
info.setPreferredSize(new Dimension(400, 100)); |
|
117 |
info.setEditable(false); |
|
118 |
info.setText(cadWKT); |
|
119 |
} |
|
120 |
return info; |
|
121 |
} |
|
122 |
|
|
123 |
private JPanel getButtonPane() { |
|
124 |
if(buttonPane == null) { |
|
125 |
buttonPane = new JPanel(); |
|
126 |
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
|
127 |
buttonPane.setPreferredSize(new Dimension(525,50)); |
|
128 |
buttonPane.add(getButtonAccept(),null); |
|
129 |
buttonPane.add(getButtonCancel(),null); |
|
130 |
} |
|
131 |
return buttonPane; |
|
132 |
} |
|
133 |
|
|
134 |
private JButton getButtonCancel() { |
|
135 |
if(cancel == null) { |
|
136 |
cancel = new JButton(); |
|
137 |
cancel.setText("Cancelar"); |
|
138 |
cancel.setPreferredSize(new Dimension(100,25)); |
|
139 |
cancel.setMnemonic('C'); |
|
140 |
cancel.setToolTipText("Cancel"); |
|
141 |
cancel.addActionListener(new java.awt.event.ActionListener() { |
|
142 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
143 |
cancelButton_actionPerformed(e); |
|
144 |
} |
|
145 |
}); |
|
146 |
} |
|
147 |
return cancel; |
|
148 |
} |
|
149 |
|
|
150 |
public void cancelButton_actionPerformed(ActionEvent e) { |
|
151 |
PluginServices.getMDIManager().closeWindow(this); |
|
152 |
} |
|
153 |
|
|
154 |
private JButton getButtonAccept() { |
|
155 |
if(accept == null) { |
|
156 |
accept = new JButton(); |
|
157 |
accept.setText("Aceptar"); |
|
158 |
accept.setPreferredSize(new Dimension(100,25)); |
|
159 |
accept.setMnemonic('A'); |
|
160 |
accept.setToolTipText("Accept"); |
|
161 |
accept.addActionListener(new java.awt.event.ActionListener() { |
|
162 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
163 |
acceptButton_actionPerformed(e); |
|
164 |
} |
|
165 |
}); |
|
166 |
} |
|
167 |
return accept; |
|
168 |
} |
|
169 |
|
|
170 |
public void acceptButton_actionPerformed(ActionEvent e) { |
|
171 |
PluginServices.getMDIManager().closeWindow(this); |
|
172 |
} |
|
173 |
|
|
174 |
private JPanel getOpenPanel() { |
|
175 |
if(jPaneOpen == null) { |
|
176 |
jPaneOpen = new JPanel(); |
|
177 |
jPaneOpen.setPreferredSize(new Dimension(525,50)); |
|
178 |
jPaneOpen.setLayout(new GridLayout(2,2)); |
|
179 |
jPaneOpen.setLayout(new FlowLayout(FlowLayout.LEFT,5,5)); |
|
180 |
jPaneOpen.add(getOpenGsb(), null); |
|
181 |
jPaneOpen.add(getOpenTextField(), null); |
|
182 |
jPaneOpen.add(getButtonOpen(), null); |
|
183 |
// jPaneOpen.add(getOpen(), null); |
|
184 |
|
|
185 |
} |
|
186 |
return jPaneOpen; |
|
187 |
} |
|
188 |
|
|
189 |
private JLabel getOpenGsb() { |
|
190 |
if(open_gsb == null) { |
|
191 |
open_gsb = new JLabel(); |
|
192 |
open_gsb.setPreferredSize(new Dimension(80,20)); |
|
193 |
open_gsb.setText("Open .gsb:"); |
|
194 |
} |
|
195 |
return open_gsb; |
|
196 |
} |
|
197 |
|
|
198 |
private JTextField getOpenTextField() { |
|
199 |
if(jTextOpen == null) { |
|
200 |
jTextOpen = new JTextField(); |
|
201 |
jTextOpen.setPreferredSize(new Dimension(200,20)); |
|
202 |
jTextOpen.setText(""); |
|
203 |
} |
|
204 |
return jTextOpen; |
|
205 |
} |
|
206 |
|
|
207 |
private JFileChooser getOpen(){ |
|
208 |
if(openChooser == null){ |
|
209 |
openChooser = new JFileChooser(); |
|
210 |
openChooser.setEnabled(false); |
|
211 |
} |
|
212 |
return openChooser; |
|
213 |
} |
|
214 |
|
|
215 |
private JButton getButtonOpen() { |
|
216 |
if(jButtonOpen == null) { |
|
217 |
jButtonOpen = new JButton(); |
|
218 |
jButtonOpen.setText(""); |
|
219 |
jButtonOpen.setPreferredSize(new Dimension(20,20)); |
|
220 |
jButtonOpen.addActionListener(new java.awt.event.ActionListener() { |
|
221 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
222 |
Open_actionPerformed(e); |
|
223 |
} |
|
224 |
}); |
|
225 |
} |
|
226 |
return jButtonOpen; |
|
227 |
} |
|
228 |
|
|
229 |
private void Open_actionPerformed(ActionEvent e){ |
|
230 |
jPaneOpen.add(getOpen(), null); |
|
231 |
openChooser.setCurrentDirectory(f); |
|
232 |
int returnVal = openChooser.showOpenDialog(TransformationNadgridsPanel.this); |
|
233 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
|
234 |
File file = openChooser.getSelectedFile(); |
|
235 |
jTextOpen.setText(file.getAbsolutePath()); |
|
236 |
} |
|
237 |
} |
|
238 |
|
|
239 |
public ICrs getProjection() { |
|
240 |
try { |
|
241 |
ICrs crs = new CrsFactory().getCRS(codeEpsg, |
|
242 |
cadWKT,nad); |
|
243 |
return crs; |
|
244 |
} catch (org.gvsig.crs.CrsException e) { |
|
245 |
e.printStackTrace(); |
|
246 |
} |
|
247 |
return null; |
|
248 |
} |
|
249 |
|
|
250 |
public void setProjection(IProjection proj) { |
|
251 |
firstProj = proj; |
|
252 |
} |
|
253 |
|
|
254 |
public WindowInfo getWindowInfo() { |
|
255 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG); |
|
256 |
m_viewinfo.setTitle(PluginServices.getText(this,"Nadgrids")); |
|
257 |
return m_viewinfo; |
|
258 |
} |
|
259 |
} |
|
0 | 260 |
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/InfoCrs.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.FlowLayout; |
|
5 |
import java.awt.Font; |
|
6 |
import java.awt.GridLayout; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
|
|
9 |
import javax.swing.JButton; |
|
10 |
import javax.swing.JLabel; |
|
11 |
import javax.swing.JPanel; |
|
12 |
import javax.swing.JScrollPane; |
|
13 |
import javax.swing.JTable; |
|
14 |
import javax.swing.ListSelectionModel; |
|
15 |
import javax.swing.table.DefaultTableModel; |
|
16 |
|
|
17 |
import org.cresques.ui.DefaultDialogPanel; |
|
18 |
import org.gvsig.crs.ICrs; |
|
19 |
|
|
20 |
import com.iver.andami.PluginServices; |
|
21 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
22 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
23 |
|
|
24 |
public class InfoCrs extends DefaultDialogPanel implements IWindow{ |
|
25 |
|
|
26 |
private static final long serialVersionUID = 1L; |
|
27 |
|
|
28 |
private JPanel panelLabels; |
|
29 |
|
|
30 |
private JTable jTable; |
|
31 |
public DefaultTableModel dtm = null; |
|
32 |
private JScrollPane jScrollPane1 = null; |
|
33 |
private JPanel buttonPane; |
|
34 |
private JButton ok; |
|
35 |
|
|
36 |
private ICrs proj; |
|
37 |
|
|
38 |
private JLabel projcs; |
|
39 |
private JLabel geogcs; |
|
40 |
private JLabel datum; |
|
41 |
private JLabel spheroid; |
|
42 |
private JLabel primem; |
|
43 |
private JLabel projection; |
|
44 |
private JLabel units; |
|
45 |
private JLabel units_p; |
|
46 |
private JLabel projcsdinamic; |
|
47 |
private JLabel geogcsdinamic; |
|
48 |
private JLabel datumdinamic; |
|
49 |
private JLabel spheroiddinamic; |
|
50 |
private JLabel primemdinamic; |
|
51 |
private JLabel projectiondinamic; |
|
52 |
private JLabel unitsdinamic; |
|
53 |
private JLabel units_pdinamic; |
|
54 |
|
|
55 |
public InfoCrs(ICrs p) { |
|
56 |
super(false); |
|
57 |
proj = p; |
|
58 |
inicializate(); |
|
59 |
} |
|
60 |
|
|
61 |
private void inicializate() { |
|
62 |
this.add(getPanel(), null); |
|
63 |
this.add(getButtonPane(),null); |
|
64 |
} |
|
65 |
|
|
66 |
private JPanel getPanel() { |
|
67 |
if(panelLabels == null) { |
|
68 |
panelLabels = new JPanel(); |
|
69 |
panelLabels.setLayout(new GridLayout(6,4)); |
|
70 |
panelLabels.setLayout(new FlowLayout(FlowLayout.LEADING,5,10)); |
|
71 |
panelLabels.setPreferredSize(new Dimension(525, 300)); |
|
72 |
panelLabels.add(getProjcs(),null); |
|
73 |
panelLabels.add(getProjcsDinamic(),null); |
|
74 |
panelLabels.add(getGeogcs(),null); |
|
75 |
panelLabels.add(getGeogcsDinamic(),null); |
|
76 |
panelLabels.add(getDatum(),null); |
|
77 |
panelLabels.add(getDatumDinamic(),null); |
|
78 |
panelLabels.add(getSpheroid(),null); |
|
79 |
panelLabels.add(getSpheroidDinamic(),null); |
|
80 |
panelLabels.add(getPrimen(),null); |
|
81 |
panelLabels.add(getPrimenDinamic(),null); |
|
82 |
panelLabels.add(getUnits(),null); |
|
83 |
panelLabels.add(getUnitsDinamic(),null); |
|
84 |
panelLabels.add(getProjection(),null); |
|
85 |
panelLabels.add(getProjectionDinamic(),null); |
|
86 |
panelLabels.add(getUnits_p(),null); |
|
87 |
panelLabels.add(getUnits_pDinamic(),null); |
|
88 |
panelLabels.add(getScrollPane(), null); |
|
89 |
} |
|
90 |
return panelLabels; |
|
91 |
} |
|
92 |
|
|
93 |
private JPanel getButtonPane() { |
|
94 |
if(buttonPane == null) { |
|
95 |
buttonPane = new JPanel(); |
|
96 |
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
|
97 |
buttonPane.setPreferredSize(new Dimension(525,50)); |
|
98 |
buttonPane.add(getButtonOk(),null); |
|
99 |
} |
|
100 |
return buttonPane; |
|
101 |
} |
|
102 |
|
|
103 |
private JButton getButtonOk() { |
|
104 |
if(ok == null) { |
|
105 |
ok = new JButton(); |
|
106 |
ok.setText("OK"); |
|
107 |
ok.setPreferredSize(new Dimension(50,25)); |
|
108 |
ok.setMnemonic('O'); |
|
109 |
ok.setToolTipText("Accept"); |
|
110 |
ok.addActionListener(new java.awt.event.ActionListener() { |
|
111 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
112 |
OkButton_actionPerformed(e); |
|
113 |
} |
|
114 |
}); |
|
115 |
} |
|
116 |
return ok; |
|
117 |
} |
|
118 |
|
|
119 |
public void OkButton_actionPerformed(ActionEvent e) { |
|
120 |
PluginServices.getMDIManager().closeWindow(this); |
|
121 |
} |
|
122 |
|
|
123 |
private JLabel getProjcs() { |
|
124 |
if(projcs == null) { |
|
125 |
projcs = new JLabel(); |
|
126 |
projcs.setPreferredSize(new Dimension(75,20)); |
|
127 |
projcs.setFont(new Font("Projcs:",Font.BOLD,10)); |
|
128 |
projcs.setText("Projcs:"); |
|
129 |
} |
|
130 |
return projcs; |
|
131 |
} |
|
132 |
|
|
133 |
private JLabel getProjcsDinamic() { |
|
134 |
if(projcsdinamic == null) { |
|
135 |
projcsdinamic = new JLabel(); |
|
136 |
projcsdinamic.setPreferredSize(new Dimension(150,20)); |
|
137 |
projcsdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
|
138 |
projcsdinamic.setText(proj.getCrsWkt().getProjcs()); |
|
139 |
} |
|
140 |
return projcsdinamic; |
|
141 |
} |
|
142 |
|
|
143 |
private JLabel getGeogcs() { |
|
144 |
if(geogcs == null) { |
|
145 |
geogcs = new JLabel(); |
|
146 |
geogcs.setPreferredSize(new Dimension(75,20)); |
|
147 |
geogcs.setFont(new Font("Geogcs:",Font.BOLD,10)); |
|
148 |
geogcs.setText("Geogcs:"); |
|
149 |
} |
|
150 |
return geogcs; |
|
151 |
} |
|
152 |
|
|
153 |
private JLabel getGeogcsDinamic() { |
|
154 |
if(geogcsdinamic == null) { |
|
155 |
geogcsdinamic = new JLabel(); |
|
156 |
geogcsdinamic.setPreferredSize(new Dimension(150,20)); |
|
157 |
geogcsdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
|
158 |
geogcsdinamic.setText(proj.getCrsWkt().getGeogcs()); |
|
159 |
} |
|
160 |
return geogcsdinamic; |
|
161 |
} |
|
162 |
|
|
163 |
private JLabel getDatum() { |
|
164 |
if(datum == null) { |
|
165 |
datum = new JLabel(); |
|
166 |
datum.setPreferredSize(new Dimension(75,20)); |
|
167 |
datum.setFont(new Font("Datum:",Font.BOLD,10)); |
|
168 |
datum.setText("Datum:"); |
|
169 |
} |
|
170 |
return datum; |
|
171 |
} |
|
172 |
|
|
173 |
private JLabel getDatumDinamic() { |
|
174 |
if(datumdinamic == null) { |
|
175 |
datumdinamic = new JLabel(); |
|
176 |
datumdinamic.setPreferredSize(new Dimension(150,20)); |
|
177 |
datumdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
|
178 |
datumdinamic.setText(proj.getCrsWkt().getDatumName()); |
|
179 |
} |
|
180 |
return datumdinamic; |
|
181 |
} |
|
182 |
|
|
183 |
private JLabel getSpheroid() { |
|
184 |
if(spheroid == null) { |
|
185 |
spheroid = new JLabel(); |
|
186 |
spheroid.setPreferredSize(new Dimension(75,20)); |
|
187 |
spheroid.setFont(new Font("Spheroid",Font.BOLD,10)); |
|
188 |
spheroid.setText("Spheriod:"); |
|
189 |
} |
|
190 |
return spheroid; |
|
191 |
} |
|
192 |
|
|
193 |
private JLabel getSpheroidDinamic() { |
|
194 |
if(spheroiddinamic == null) { |
|
195 |
String[] sphe = proj.getCrsWkt().getSpheroid(); |
|
196 |
spheroiddinamic = new JLabel(); |
|
197 |
spheroiddinamic.setPreferredSize(new Dimension(200,20)); |
|
198 |
spheroiddinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
|
199 |
spheroiddinamic.setText(sphe[0]+" , "+sphe[1]+" , "+sphe[2]); |
|
200 |
} |
|
201 |
return spheroiddinamic; |
|
202 |
} |
|
203 |
|
|
204 |
private JLabel getPrimen() { |
|
205 |
if(primem == null) { |
|
206 |
primem = new JLabel(); |
|
207 |
primem.setPreferredSize(new Dimension(75,20)); |
|
208 |
primem.setFont(new Font("Primen:",Font.BOLD,10)); |
|
209 |
primem.setText("Primem:"); |
|
210 |
} |
|
211 |
return primem; |
|
212 |
} |
|
213 |
|
|
214 |
private JLabel getPrimenDinamic() { |
|
215 |
if(primemdinamic == null) { |
|
216 |
String pri[] = proj.getCrsWkt().getPrimen(); |
|
217 |
primemdinamic = new JLabel(); |
|
218 |
primemdinamic.setPreferredSize(new Dimension(150,20)); |
|
219 |
primemdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
|
220 |
primemdinamic.setText(pri[0]+" , "+pri[1]); |
|
221 |
} |
|
222 |
return primemdinamic; |
|
223 |
} |
|
224 |
|
|
225 |
private JLabel getProjection() { |
|
226 |
if(projection == null) { |
|
227 |
projection = new JLabel(); |
|
228 |
projection.setPreferredSize(new Dimension(75,20)); |
|
229 |
projection.setFont(new Font("Projection",Font.BOLD,10)); |
|
230 |
projection.setText("Projection:"); |
|
231 |
} |
|
232 |
return projection; |
|
233 |
} |
|
234 |
|
|
235 |
private JLabel getProjectionDinamic() { |
|
236 |
if(projectiondinamic == null) { |
|
237 |
projectiondinamic = new JLabel(); |
|
238 |
projectiondinamic.setPreferredSize(new Dimension(150,20)); |
|
239 |
projectiondinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
|
240 |
projectiondinamic.setText(proj.getCrsWkt().getProjection()); |
|
241 |
} |
|
242 |
return projectiondinamic; |
|
243 |
} |
|
244 |
|
|
245 |
private JLabel getUnits() { |
|
246 |
if(units == null) { |
|
247 |
units = new JLabel(); |
|
248 |
units.setPreferredSize(new Dimension(75,20)); |
|
249 |
units.setFont(new Font("Units",Font.BOLD,10)); |
|
250 |
units.setText("Units:"); |
|
251 |
} |
|
252 |
return units; |
|
253 |
} |
|
254 |
|
|
255 |
private JLabel getUnitsDinamic() { |
|
256 |
if(unitsdinamic == null) { |
|
257 |
String[] units = proj.getCrsWkt().getUnit(); |
|
258 |
unitsdinamic = new JLabel(); |
|
259 |
unitsdinamic.setPreferredSize(new Dimension(200,20)); |
|
260 |
unitsdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
|
261 |
unitsdinamic.setText(units[0]+" , "+units[1]); |
|
262 |
} |
|
263 |
return unitsdinamic; |
|
264 |
} |
|
265 |
|
|
266 |
private JLabel getUnits_p() { |
|
267 |
if(units_p == null) { |
|
268 |
units_p = new JLabel(); |
|
269 |
units_p.setPreferredSize(new Dimension(75,20)); |
|
270 |
units_p.setFont(new Font("",Font.BOLD,10)); |
|
271 |
units_p.setText("Units_p:"); |
|
272 |
} |
|
273 |
return units_p; |
|
274 |
} |
|
275 |
|
|
276 |
private JLabel getUnits_pDinamic() { |
|
277 |
if(units_pdinamic == null) { |
|
278 |
String[] uni_p = proj.getCrsWkt().getUnit_p(); |
|
279 |
units_pdinamic = new JLabel(); |
|
280 |
units_pdinamic.setPreferredSize(new Dimension(150,20)); |
|
281 |
units_pdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
|
282 |
units_pdinamic.setText(uni_p[0]+" , "+uni_p[1]); |
|
283 |
|
|
284 |
} |
|
285 |
return units_pdinamic; |
|
286 |
} |
|
287 |
|
|
288 |
private JScrollPane getScrollPane() { |
|
289 |
if(jScrollPane1 == null) { |
|
290 |
jScrollPane1 = new JScrollPane(); |
|
291 |
jScrollPane1.setPreferredSize(new Dimension(400,150)); |
|
292 |
/* jScrollPane1.setBorder( |
|
293 |
BorderFactory.createCompoundBorder( |
|
294 |
BorderFactory.createCompoundBorder( |
|
295 |
BorderFactory.createTitledBorder("Transformations"), |
|
296 |
BorderFactory.createEmptyBorder(5,5,5,5)), |
|
297 |
jScrollPane1.getBorder()));*/ |
|
298 |
jScrollPane1.setViewportView(getTable()); |
|
299 |
} |
|
300 |
return jScrollPane1; |
|
301 |
} |
|
302 |
|
|
303 |
private JTable getTable() { |
|
304 |
if(jTable == null) { |
|
305 |
String[] columnNames = {"Name","Value"}; |
|
306 |
String[] param_n = proj.getCrsWkt().getParam_name(); |
|
307 |
String[] param_v = proj.getCrsWkt().getParam_value(); |
|
308 |
Object[][]data; |
|
309 |
if(param_v != null) { |
|
310 |
data = new Object[param_v.length][2]; |
|
311 |
for(int i = 0 ; i < 2 ; i++ ) |
|
312 |
for(int j = 0 ; j < param_n.length ; j++) { |
|
313 |
if(i == 0) |
|
314 |
data[j][i] = param_n[j]; |
|
315 |
else |
|
316 |
data[j][i] = param_v[j]; |
|
317 |
} |
|
318 |
} else |
|
319 |
data = new Object[1][1]; |
|
320 |
dtm = new DefaultTableModel(data, columnNames); |
|
321 |
jTable = new JTable(dtm); |
|
322 |
jTable.setCellSelectionEnabled(false); |
|
323 |
jTable.setRowSelectionAllowed(true); |
|
324 |
jTable.setColumnSelectionAllowed(false); |
|
325 |
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
326 |
|
|
327 |
} |
|
328 |
return jTable; |
|
329 |
} |
|
330 |
|
|
331 |
public WindowInfo getWindowInfo() { |
|
332 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG); |
|
333 |
m_viewinfo.setTitle(PluginServices.getText(this,proj.getCrsWkt().getName())); |
|
334 |
return m_viewinfo; |
|
335 |
} |
|
336 |
} |
|
0 | 337 |
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/TransformationManualPanel.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
|
|
3 |
import java.awt.Component; |
|
4 |
import java.awt.Dimension; |
|
5 |
import java.awt.FlowLayout; |
|
6 |
import java.awt.Font; |
|
7 |
import java.awt.GridLayout; |
|
8 |
import java.awt.event.ActionEvent; |
|
9 |
|
|
10 |
import javax.swing.BorderFactory; |
|
11 |
import javax.swing.JButton; |
|
12 |
import javax.swing.JLabel; |
|
13 |
import javax.swing.JPanel; |
|
14 |
import javax.swing.JScrollPane; |
|
15 |
import javax.swing.JTextArea; |
|
16 |
import javax.swing.JTextField; |
|
17 |
|
|
18 |
import org.cresques.ui.DefaultDialogPanel; |
|
19 |
|
|
20 |
import com.iver.andami.PluginServices; |
|
21 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
22 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
23 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanelTransformation; |
|
24 |
|
|
25 |
public class TransformationManualPanel extends DefaultDialogPanel implements IWindow { |
|
26 |
|
|
27 |
private static final long serialVersionUID = 1L; |
|
28 |
|
|
29 |
private static boolean pressed = true; |
|
30 |
|
|
31 |
private JLabel x_Translation; |
|
32 |
private JLabel y_Translation; |
|
33 |
private JLabel z_Translation; |
|
34 |
private JLabel x_Rotation; |
|
35 |
private JLabel y_Rotation; |
|
36 |
private JLabel z_Rotation; |
|
37 |
private JLabel scale; |
|
38 |
|
|
39 |
private JTextField tx_Translation; |
|
40 |
private JTextField ty_Translation; |
|
41 |
private JTextField tz_Translation; |
|
42 |
private JTextField tx_Rotation; |
|
43 |
private JTextField ty_Rotation; |
|
44 |
private JTextField tz_Rotation; |
|
45 |
private JTextField tScale; |
|
46 |
|
|
47 |
private JLabel wkt; |
|
48 |
private JTextArea info; |
|
49 |
private JScrollPane areaScrollPane; |
|
50 |
|
|
51 |
private JPanel panel; |
|
52 |
private JPanel buttonPane; |
|
53 |
private JButton accept; |
|
54 |
private JButton cancel; |
|
55 |
|
|
56 |
private String cadWKT = ""; |
|
57 |
|
|
58 |
ProjChooserPanelTransformation pcpt; |
|
59 |
|
|
60 |
public TransformationManualPanel(String cad, int code) { |
|
61 |
super(false); |
|
62 |
pcpt = new ProjChooserPanelTransformation(); |
|
63 |
cadWKT = cad; |
|
64 |
init(); |
|
65 |
} |
|
66 |
|
|
67 |
private void init() { |
|
68 |
this.add(getJPanel(), null); |
|
69 |
this.add(getJPanelParams(), null); |
|
70 |
this.add(getButtonPane(), null); |
|
71 |
|
|
72 |
} |
|
73 |
|
|
74 |
private JPanel getJPanelParams() { |
|
75 |
if(panel == null) { |
|
76 |
panel = new JPanel(); |
|
77 |
panel.setLayout(new GridLayout(4,4)); |
|
78 |
panel.setLayout(new FlowLayout(FlowLayout.LEFT,5,5)); |
|
79 |
panel.setPreferredSize(new Dimension(520,300)); |
|
80 |
panel.add(getX_Translation(),null); |
|
81 |
panel.add(getTx_Translation(),null); |
|
82 |
panel.add(getX_Rotation(),null); |
|
83 |
panel.add(getTx_Rotation(),null); |
|
84 |
panel.add(getY_Translation(),null); |
|
85 |
panel.add(getTy_Translation(),null); |
|
86 |
panel.add(getY_Rotation(),null); |
|
87 |
panel.add(getTy_Rotation(),null); |
|
88 |
panel.add(getZ_Translation(),null); |
|
89 |
panel.add(getTz_Translation(),null); |
|
90 |
panel.add(getZ_Rotation(),null); |
|
91 |
panel.add(getTz_Rotation(),null); |
|
92 |
panel.add(getScale(),null); |
|
93 |
panel.add(getTscale(),null); |
|
94 |
|
|
95 |
} |
|
96 |
return panel; |
|
97 |
} |
|
98 |
|
|
99 |
private JLabel getX_Translation() { |
|
100 |
if(x_Translation == null ) { |
|
101 |
x_Translation = new JLabel(); |
|
102 |
x_Translation.setPreferredSize(new Dimension(80,20)); |
|
103 |
x_Translation.setFont(new Font("x_Translation:",Font.BOLD,15)); |
|
104 |
x_Translation.setText("x_Translation:"); |
|
105 |
} |
|
106 |
return x_Translation; |
|
107 |
} |
|
108 |
|
|
109 |
private JLabel getY_Translation() { |
|
110 |
if(y_Translation == null ) { |
|
111 |
y_Translation = new JLabel(); |
|
112 |
y_Translation.setPreferredSize(new Dimension(80,20)); |
|
113 |
y_Translation.setFont(new Font("y_Translation:",Font.BOLD,15)); |
|
114 |
y_Translation.setText("y_Translation:"); |
|
115 |
} |
|
116 |
return y_Translation; |
|
117 |
} |
|
118 |
|
|
119 |
private JLabel getZ_Translation() { |
|
120 |
if(z_Translation == null ) { |
|
121 |
z_Translation = new JLabel(); |
|
122 |
z_Translation.setPreferredSize(new Dimension(80,20)); |
|
123 |
z_Translation.setFont(new Font("z_Translation:",Font.BOLD,15)); |
|
124 |
z_Translation.setText("z_Translation:"); |
|
125 |
} |
|
126 |
return z_Translation; |
|
127 |
} |
|
128 |
|
|
129 |
private JLabel getX_Rotation() { |
|
130 |
if(x_Rotation == null ) { |
|
131 |
x_Rotation = new JLabel(); |
|
132 |
x_Rotation.setPreferredSize(new Dimension(80,20)); |
|
133 |
x_Rotation.setFont(new Font("x_Rotation:",Font.BOLD,15)); |
|
134 |
x_Rotation.setText("x_Rotation:"); |
|
135 |
} |
|
136 |
return x_Translation; |
|
137 |
} |
|
138 |
|
|
139 |
private JLabel getY_Rotation() { |
|
140 |
if(y_Rotation == null ) { |
|
141 |
y_Rotation = new JLabel(); |
|
142 |
y_Rotation.setPreferredSize(new Dimension(80,20)); |
|
143 |
y_Rotation.setFont(new Font("x_Rotation:",Font.BOLD,15)); |
|
144 |
y_Rotation.setText("y_Rotation:"); |
|
145 |
} |
|
146 |
return y_Translation; |
|
147 |
} |
|
148 |
|
|
149 |
private JLabel getZ_Rotation() { |
|
150 |
if(z_Rotation == null ) { |
|
151 |
z_Rotation = new JLabel(); |
|
152 |
z_Rotation.setPreferredSize(new Dimension(80,20)); |
|
153 |
z_Rotation.setFont(new Font("x_Translation:",Font.BOLD,15)); |
|
154 |
z_Rotation.setText("z_Rotation:"); |
|
155 |
} |
|
156 |
return z_Rotation; |
|
157 |
} |
|
158 |
|
|
159 |
private JLabel getScale() { |
|
160 |
if(scale == null ) { |
|
161 |
scale = new JLabel(); |
|
162 |
scale.setPreferredSize(new Dimension(80,20)); |
|
163 |
scale.setFont(new Font("scale:",Font.BOLD,15)); |
|
164 |
scale.setText("scale:"); |
|
165 |
} |
|
166 |
return scale; |
|
167 |
} |
|
168 |
|
|
169 |
private JTextField getTx_Translation() { |
|
170 |
if(tx_Translation == null ) { |
|
171 |
tx_Translation = new JTextField(); |
|
172 |
tx_Translation.setPreferredSize(new Dimension(100,20)); |
|
173 |
tx_Translation.setFont(new Font("",Font.ITALIC,10)); |
|
174 |
tx_Translation.setText(""); |
|
175 |
tx_Translation.setEditable(true); |
|
176 |
} |
|
177 |
return tx_Translation; |
|
178 |
} |
|
179 |
|
|
180 |
private JTextField getTy_Translation() { |
|
181 |
if(ty_Translation == null ) { |
|
182 |
ty_Translation = new JTextField(); |
|
183 |
ty_Translation.setPreferredSize(new Dimension(100,20)); |
|
184 |
ty_Translation.setFont(new Font("",Font.ITALIC,10)); |
|
185 |
ty_Translation.setText(""); |
|
186 |
ty_Translation.setEditable(true); |
|
187 |
} |
|
188 |
return ty_Translation; |
|
189 |
} |
|
190 |
|
|
191 |
private JTextField getTz_Translation() { |
|
192 |
if(tz_Translation == null ) { |
|
193 |
tz_Translation = new JTextField(); |
|
194 |
tz_Translation.setPreferredSize(new Dimension(100,20)); |
|
195 |
tz_Translation.setFont(new Font("",Font.ITALIC,10)); |
|
196 |
tz_Translation.setText(""); |
|
197 |
tz_Translation.setEditable(true); |
|
198 |
} |
|
199 |
return tz_Translation; |
|
200 |
} |
|
201 |
|
|
202 |
private JTextField getTx_Rotation() { |
|
203 |
if(tx_Rotation == null ) { |
|
204 |
tx_Rotation = new JTextField(); |
|
205 |
tx_Rotation.setPreferredSize(new Dimension(100,20)); |
|
206 |
tx_Rotation.setFont(new Font("",Font.ITALIC,10)); |
|
207 |
tx_Rotation.setText(""); |
|
208 |
tx_Rotation.setEditable(true); |
|
209 |
} |
|
210 |
return tx_Rotation; |
|
211 |
} |
|
212 |
|
|
213 |
private JTextField getTy_Rotation() { |
|
214 |
if(ty_Rotation == null ) { |
|
215 |
ty_Rotation = new JTextField(); |
|
216 |
ty_Rotation.setPreferredSize(new Dimension(100,20)); |
|
217 |
ty_Rotation.setFont(new Font("",Font.ITALIC,10)); |
|
218 |
ty_Rotation.setText(""); |
|
219 |
ty_Rotation.setEditable(true); |
|
220 |
} |
|
221 |
return ty_Rotation; |
|
222 |
} |
|
223 |
|
|
224 |
private JTextField getTz_Rotation() { |
|
225 |
if(tz_Rotation == null ) { |
|
226 |
tz_Rotation = new JTextField(); |
|
227 |
tz_Rotation.setPreferredSize(new Dimension(100,20)); |
|
228 |
tz_Rotation.setFont(new Font("",Font.ITALIC,10)); |
|
229 |
tz_Rotation.setText(""); |
|
230 |
tz_Rotation.setEditable(true); |
|
231 |
} |
|
232 |
return tz_Rotation; |
|
233 |
} |
|
234 |
|
|
235 |
private JTextField getTscale() { |
|
236 |
if(tScale == null ) { |
|
237 |
tScale = new JTextField(); |
|
238 |
tScale.setPreferredSize(new Dimension(100,20)); |
|
239 |
tScale.setFont(new Font("",Font.ITALIC,10)); |
|
240 |
tScale.setText(""); |
|
241 |
tScale.setEditable(true); |
|
242 |
} |
|
243 |
return tScale; |
|
244 |
} |
|
245 |
|
|
246 |
private JPanel getJPanel(){ |
|
247 |
if (panel == null) { |
|
248 |
panel = new JPanel(); |
|
249 |
panel.setLayout(new GridLayout(1,2)); |
|
250 |
panel.setLayout(new FlowLayout(FlowLayout.LEADING,5,10)); |
|
251 |
panel.setPreferredSize(new Dimension(525, 110)); |
|
252 |
panel.add(getLabel()); |
|
253 |
panel.add(getScrollPanelArea()); |
|
254 |
} |
|
255 |
return panel; |
|
256 |
} |
|
257 |
|
|
258 |
private JScrollPane getScrollPanelArea() { |
|
259 |
if(areaScrollPane == null) { |
|
260 |
areaScrollPane = new JScrollPane(getInfo()); |
|
261 |
areaScrollPane.setVerticalScrollBarPolicy( |
|
262 |
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
|
263 |
areaScrollPane.setPreferredSize(new Dimension(420, 100)); |
|
264 |
areaScrollPane.setBorder( |
|
265 |
BorderFactory.createCompoundBorder( |
|
266 |
BorderFactory.createCompoundBorder( |
|
267 |
BorderFactory.createTitledBorder("Wkt"), |
|
268 |
BorderFactory.createEmptyBorder(2,2,2,2)), |
|
269 |
areaScrollPane.getBorder())); |
|
270 |
} |
|
271 |
return areaScrollPane; |
|
272 |
} |
|
273 |
|
|
274 |
private Component getLabel() { |
|
275 |
if (wkt == null){ |
|
276 |
wkt = new JLabel(); |
|
277 |
wkt.setPreferredSize(new Dimension(90, 80)); |
|
278 |
wkt.setText("Cadena WKT: "); |
|
279 |
} |
|
280 |
return wkt; |
|
281 |
} |
|
282 |
|
|
283 |
private Component getInfo() { |
|
284 |
if (info == null){ |
|
285 |
info = new JTextArea(); |
|
286 |
info.setLineWrap(true); |
|
287 |
info.setWrapStyleWord(true); |
|
288 |
info.setPreferredSize(new Dimension(400, 240)); |
|
289 |
info.setEditable(false); |
|
290 |
info.setText(cadWKT); |
|
291 |
} |
|
292 |
return info; |
|
293 |
} |
|
294 |
|
|
295 |
|
|
296 |
private JPanel getButtonPane() { |
|
297 |
if(buttonPane == null) { |
|
298 |
buttonPane = new JPanel(); |
|
299 |
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
|
300 |
buttonPane.setPreferredSize(new Dimension(525,50)); |
|
301 |
buttonPane.add(getButtonAccept(),null); |
|
302 |
buttonPane.add(getButtonCancel(),null); |
|
303 |
} |
|
304 |
return buttonPane; |
|
305 |
} |
|
306 |
|
|
307 |
private JButton getButtonCancel() { |
|
308 |
if(cancel == null) { |
|
309 |
cancel = new JButton(); |
|
310 |
cancel.setText("Cancelar"); |
|
311 |
cancel.setPreferredSize(new Dimension(100,25)); |
|
312 |
cancel.setMnemonic('C'); |
|
313 |
cancel.setToolTipText("Cancel"); |
|
314 |
cancel.addActionListener(new java.awt.event.ActionListener() { |
|
315 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
316 |
cancelButton_actionPerformed(e); |
|
317 |
} |
|
318 |
}); |
|
319 |
} |
|
320 |
return cancel; |
|
321 |
} |
|
322 |
|
|
323 |
public void cancelButton_actionPerformed(ActionEvent e) { |
|
324 |
PluginServices.getMDIManager().closeWindow(this); |
|
325 |
} |
|
326 |
|
|
327 |
private JButton getButtonAccept() { |
|
328 |
if(accept == null) { |
|
329 |
accept = new JButton(); |
|
330 |
accept.setText("Aceptar"); |
|
331 |
accept.setPreferredSize(new Dimension(100,25)); |
|
332 |
accept.setMnemonic('A'); |
|
333 |
accept.setToolTipText("Accept"); |
|
334 |
accept.addActionListener(new java.awt.event.ActionListener() { |
|
335 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
336 |
acceptButton_actionPerformed(e); |
|
337 |
} |
|
338 |
}); |
|
339 |
} |
|
340 |
return accept; |
|
341 |
} |
|
342 |
|
|
343 |
public void acceptButton_actionPerformed(ActionEvent e) { |
|
344 |
PluginServices.getMDIManager().closeWindow(this); |
|
345 |
} |
|
346 |
|
|
347 |
public static boolean isPressed() { return pressed; } |
|
348 |
|
|
349 |
|
|
350 |
|
|
351 |
public WindowInfo getWindowInfo() { |
|
352 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG); |
|
353 |
m_viewinfo.setTitle(PluginServices.getText(this,"Manual")); |
|
354 |
return m_viewinfo; |
|
355 |
} |
|
356 |
|
|
357 |
} |
|
0 | 358 |
trunk/libraries/libJCRS/src/org/gvsig/crs/gui/TransformationEpsgPanel.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Component; |
|
5 |
import java.awt.Dimension; |
|
6 |
import java.awt.FlowLayout; |
|
7 |
import java.awt.GridLayout; |
|
8 |
import java.awt.event.ActionEvent; |
|
9 |
import java.sql.ResultSet; |
|
10 |
import java.sql.SQLException; |
|
11 |
import java.util.ArrayList; |
|
12 |
|
|
13 |
import javax.swing.BorderFactory; |
|
14 |
import javax.swing.JButton; |
|
15 |
import javax.swing.JLabel; |
|
16 |
import javax.swing.JPanel; |
|
17 |
import javax.swing.JScrollPane; |
|
18 |
import javax.swing.JTable; |
|
19 |
import javax.swing.JTextArea; |
|
20 |
import javax.swing.ListSelectionModel; |
|
21 |
import javax.swing.event.ListSelectionEvent; |
|
22 |
import javax.swing.event.ListSelectionListener; |
|
23 |
import javax.swing.table.DefaultTableModel; |
|
24 |
import javax.swing.table.TableColumn; |
|
25 |
|
|
26 |
import org.cresques.cts.IProjection; |
|
27 |
import org.cresques.ui.DefaultDialogPanel; |
|
28 |
import org.gvsig.crs.CrsFactory; |
|
29 |
import org.gvsig.crs.ICrs; |
|
30 |
import org.gvsig.crs.Query; |
|
31 |
import org.gvsig.crs.ogr.GetTransepsg; |
|
32 |
|
|
33 |
import com.iver.andami.PluginServices; |
|
34 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
35 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
36 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanelTransformation; |
|
37 |
|
|
38 |
public class TransformationEpsgPanel extends DefaultDialogPanel implements IWindow { |
|
39 |
|
|
40 |
|
|
41 |
/** |
|
42 |
* |
|
43 |
*/ |
|
44 |
private static final long serialVersionUID = 1L; |
|
45 |
|
|
46 |
private JPanel panel; |
|
47 |
private IProjection firstProj; |
|
48 |
|
|
49 |
String[] transformations = {"9603", "9606", "9607", "9613", "9615", "9633"}; |
|
50 |
|
|
51 |
private int trasnformation_code = -1; |
|
52 |
private String[] values; |
|
53 |
private String params = "+towgs84="; |
|
54 |
|
|
55 |
private JTable transformationTable; |
|
56 |
private JScrollPane jScrollPane = null; |
|
57 |
private JPanel buttonPane; |
|
58 |
private JButton accept; |
|
59 |
private JButton cancel; |
|
60 |
|
|
61 |
ProjChooserPanelTransformation pcpt; |
|
62 |
int crs_target = -1; |
|
63 |
|
|
64 |
public DefaultTableModel dtm = null; |
|
65 |
|
|
66 |
private int codeEpsg; |
|
67 |
private String cadWKT = ""; |
|
68 |
private ListSelectionModel lsm2 = null; |
|
69 |
public int selectedRowTable = -1; |
|
70 |
boolean tra = false; |
|
71 |
|
|
72 |
private JLabel wkt; |
Also available in: Unified diff