root / branches / F2 / extensions / extJCRS / src / org / gvsig / crs / gui / panels / InfoCRSPanel.java @ 12202
History | View | Annotate | Download (11.8 KB)
1 |
/* gvSIG. Sistema de Informacin Geogrfica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ibez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
|
34 |
* Campus Universitario s/n
|
35 |
* 02071 Alabacete
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 967 599 200
|
39 |
*/
|
40 |
|
41 |
package org.gvsig.crs.gui.panels; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.Dimension; |
45 |
import java.awt.FlowLayout; |
46 |
import java.awt.Font; |
47 |
import java.awt.GridLayout; |
48 |
import java.awt.event.ActionEvent; |
49 |
import java.awt.event.ActionListener; |
50 |
|
51 |
import javax.swing.JButton; |
52 |
import javax.swing.JLabel; |
53 |
import javax.swing.JPanel; |
54 |
import javax.swing.JScrollPane; |
55 |
import javax.swing.JTable; |
56 |
import javax.swing.ListSelectionModel; |
57 |
import javax.swing.border.EmptyBorder; |
58 |
import javax.swing.table.DefaultTableModel; |
59 |
|
60 |
import org.cresques.ui.DefaultDialogPanel; |
61 |
import org.gvsig.crs.CrsException; |
62 |
import org.gvsig.crs.CrsFactory; |
63 |
import org.gvsig.crs.ICrs; |
64 |
|
65 |
import com.iver.andami.PluginServices; |
66 |
import com.iver.andami.ui.mdiManager.IWindow; |
67 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
68 |
|
69 |
/**
|
70 |
* Clase que genera el panel de informacin del CRS seleccionado
|
71 |
* en el caso del repositorio de la EPSG
|
72 |
* @author Miguel Garca Jimnez (garciajimenez.miguel@gmail.com)
|
73 |
* @author Luisa Marina Fernndez (luisam.fernandez@uclm.es)
|
74 |
*
|
75 |
*/
|
76 |
public class InfoCRSPanel extends DefaultDialogPanel implements IWindow, ActionListener{ |
77 |
|
78 |
private static final long serialVersionUID = 1L; |
79 |
|
80 |
private JPanel panelLabels; |
81 |
|
82 |
private JTable jTable; |
83 |
public DefaultTableModel dtm = null; |
84 |
private JScrollPane jScrollPane1 = null; |
85 |
private JPanel jPanelbuttons; |
86 |
private JButton jButtonOk; |
87 |
|
88 |
private ICrs proj;
|
89 |
|
90 |
private JLabel jLabelProjcs; |
91 |
private JLabel jLabelGeogcs; |
92 |
private JLabel jLabelDatum; |
93 |
private JLabel jLabelSpheroid; |
94 |
private JLabel jLabelPrimem; |
95 |
private JLabel jLabelProjection; |
96 |
private JLabel jLabelUnits; |
97 |
private JLabel jLabelUnits_p; |
98 |
private JLabel jLabelProjcsdinamic; |
99 |
private JLabel jLabelGeogcsdinamic; |
100 |
private JLabel jLabelDatumdinamic; |
101 |
private JLabel jLabelSpheroiddinamic; |
102 |
private JLabel jLabelPrimemdinamic; |
103 |
private JLabel jLabelProjectiondinamic; |
104 |
private JLabel jLabelUnitsdinamic; |
105 |
private JLabel jLabelUnits_pdinamic; |
106 |
|
107 |
public InfoCRSPanel(String fuente, int codigo) { |
108 |
super(false); |
109 |
try {
|
110 |
proj = new CrsFactory().getCRS(fuente+":"+codigo); |
111 |
} catch (CrsException e) {
|
112 |
// TODO Auto-generated catch block
|
113 |
e.printStackTrace(); |
114 |
} |
115 |
inicializate(); |
116 |
} |
117 |
|
118 |
private void inicializate() { |
119 |
this.setLayout(new BorderLayout()); |
120 |
JPanel p=new JPanel(new BorderLayout()); |
121 |
p.setBorder(new EmptyBorder(0,10,0,10)); |
122 |
p.add(getPanel(),BorderLayout.NORTH);
|
123 |
p.add(getJScrollPane1(),BorderLayout.CENTER);
|
124 |
this.add(p, BorderLayout.CENTER); |
125 |
this.add(getJPanelButtons(),BorderLayout.SOUTH); |
126 |
} |
127 |
|
128 |
private JPanel getPanel() { |
129 |
if(panelLabels == null) { |
130 |
panelLabels = new JPanel(); |
131 |
panelLabels.setLayout(new GridLayout(4,2)); |
132 |
JPanel p00=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
133 |
p00.add(getJLabelProjcs()); |
134 |
p00.add(getJLabelProjcsDinamic()); |
135 |
JPanel p01=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
136 |
p01.add(getJLabelGeogcs()); |
137 |
p01.add(getJLabelGeogcsDinamic()); |
138 |
JPanel p10=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
139 |
p10.add(getJLabelDatum()); |
140 |
p10.add(getJLabelDatumDinamic()); |
141 |
JPanel p11=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
142 |
p11.add(getJLabelSpheroid()); |
143 |
p11.add(getJLabelSpheroidDinamic()); |
144 |
JPanel p20=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
145 |
p20.add(getJLabelPrimen()); |
146 |
p20.add(getJLabelPrimenDinamic()); |
147 |
JPanel p21=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
148 |
p21.add(getJLabelUnits()); |
149 |
p21.add(getJLabelUnitsDinamic()); |
150 |
JPanel p30=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
151 |
p30.add(getJLabelProjection()); |
152 |
p30.add(getJLabelProjectionDinamic()); |
153 |
JPanel p31=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
154 |
p31.add(getJLabelUnits_p()); |
155 |
p31.add(getJLabelUnits_pDinamic()); |
156 |
|
157 |
panelLabels.add(p00); |
158 |
panelLabels.add(p01); |
159 |
panelLabels.add(p10); |
160 |
panelLabels.add(p11); |
161 |
panelLabels.add(p20); |
162 |
panelLabels.add(p21); |
163 |
panelLabels.add(p30); |
164 |
panelLabels.add(p31); |
165 |
|
166 |
} |
167 |
return panelLabels;
|
168 |
} |
169 |
|
170 |
private JPanel getJPanelButtons() { |
171 |
if(jPanelbuttons == null) { |
172 |
jPanelbuttons = new JPanel(); |
173 |
jPanelbuttons.setLayout(new FlowLayout(FlowLayout.RIGHT,10,10)); |
174 |
jPanelbuttons.add(getJButtonOk(),null);
|
175 |
} |
176 |
return jPanelbuttons;
|
177 |
} |
178 |
|
179 |
private JButton getJButtonOk() { |
180 |
if(jButtonOk == null) { |
181 |
jButtonOk = new JButton(); |
182 |
jButtonOk.setText(PluginServices.getText(this,"ok")); |
183 |
jButtonOk.setPreferredSize(new Dimension(100,25)); |
184 |
jButtonOk.setMnemonic('O');
|
185 |
jButtonOk.setToolTipText("Accept");
|
186 |
jButtonOk.addActionListener(this);
|
187 |
} |
188 |
return jButtonOk;
|
189 |
} |
190 |
|
191 |
private JLabel getJLabelProjcs() { |
192 |
if(jLabelProjcs == null) { |
193 |
jLabelProjcs = new JLabel(); |
194 |
jLabelProjcs.setFont(new Font("Projcs:",Font.BOLD,10)); |
195 |
jLabelProjcs.setText(PluginServices.getText(this,"projcs")+":"); |
196 |
} |
197 |
return jLabelProjcs;
|
198 |
} |
199 |
|
200 |
private JLabel getJLabelProjcsDinamic() { |
201 |
if(jLabelProjcsdinamic == null) { |
202 |
jLabelProjcsdinamic = new JLabel(); |
203 |
jLabelProjcsdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
204 |
jLabelProjcsdinamic.setText(proj.getCrsWkt().getProjcs()); |
205 |
} |
206 |
return jLabelProjcsdinamic;
|
207 |
} |
208 |
|
209 |
private JLabel getJLabelGeogcs() { |
210 |
if(jLabelGeogcs == null) { |
211 |
jLabelGeogcs = new JLabel(); |
212 |
jLabelGeogcs.setFont(new Font("Geogcs:",Font.BOLD,10)); |
213 |
jLabelGeogcs.setText(PluginServices.getText(this,"geogcs")+ ":"); |
214 |
} |
215 |
return jLabelGeogcs;
|
216 |
} |
217 |
|
218 |
private JLabel getJLabelGeogcsDinamic() { |
219 |
if(jLabelGeogcsdinamic == null) { |
220 |
jLabelGeogcsdinamic = new JLabel(); |
221 |
jLabelGeogcsdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
222 |
jLabelGeogcsdinamic.setText(proj.getCrsWkt().getGeogcs()); |
223 |
} |
224 |
return jLabelGeogcsdinamic;
|
225 |
} |
226 |
|
227 |
private JLabel getJLabelDatum() { |
228 |
if(jLabelDatum == null) { |
229 |
jLabelDatum = new JLabel(); |
230 |
jLabelDatum.setFont(new Font("Datum:",Font.BOLD,10)); |
231 |
jLabelDatum.setText(PluginServices.getText(this,"datum")+":"); |
232 |
} |
233 |
return jLabelDatum;
|
234 |
} |
235 |
|
236 |
private JLabel getJLabelDatumDinamic() { |
237 |
if(jLabelDatumdinamic == null) { |
238 |
jLabelDatumdinamic = new JLabel(); |
239 |
jLabelDatumdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
240 |
jLabelDatumdinamic.setText(proj.getCrsWkt().getDatumName()); |
241 |
} |
242 |
return jLabelDatumdinamic;
|
243 |
} |
244 |
|
245 |
private JLabel getJLabelSpheroid() { |
246 |
if(jLabelSpheroid == null) { |
247 |
jLabelSpheroid = new JLabel(); |
248 |
jLabelSpheroid.setFont(new Font("Spheroid",Font.BOLD,10)); |
249 |
jLabelSpheroid.setText(PluginServices.getText(this,"spheriod")+":"); |
250 |
} |
251 |
return jLabelSpheroid;
|
252 |
} |
253 |
|
254 |
private JLabel getJLabelSpheroidDinamic() { |
255 |
if(jLabelSpheroiddinamic == null) { |
256 |
String[] sphe = proj.getCrsWkt().getSpheroid(); |
257 |
jLabelSpheroiddinamic = new JLabel(); |
258 |
jLabelSpheroiddinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
259 |
jLabelSpheroiddinamic.setText(sphe[0]+" , "+sphe[1]+" , "+sphe[2]); |
260 |
} |
261 |
return jLabelSpheroiddinamic;
|
262 |
} |
263 |
|
264 |
private JLabel getJLabelPrimen() { |
265 |
if(jLabelPrimem == null) { |
266 |
jLabelPrimem = new JLabel(); |
267 |
jLabelPrimem.setFont(new Font("Primen:",Font.BOLD,10)); |
268 |
jLabelPrimem.setText(PluginServices.getText(this,"primem")+":"); |
269 |
} |
270 |
return jLabelPrimem;
|
271 |
} |
272 |
|
273 |
private JLabel getJLabelPrimenDinamic() { |
274 |
if(jLabelPrimemdinamic == null) { |
275 |
String pri[] = proj.getCrsWkt().getPrimen(); |
276 |
jLabelPrimemdinamic = new JLabel(); |
277 |
jLabelPrimemdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
278 |
jLabelPrimemdinamic.setText(pri[0]+" , "+pri[1]); |
279 |
} |
280 |
return jLabelPrimemdinamic;
|
281 |
} |
282 |
|
283 |
private JLabel getJLabelProjection() { |
284 |
if(jLabelProjection == null) { |
285 |
jLabelProjection = new JLabel(); |
286 |
jLabelProjection.setFont(new Font("Projection",Font.BOLD,10)); |
287 |
jLabelProjection.setText(PluginServices.getText(this,"projection")+":"); |
288 |
} |
289 |
return jLabelProjection;
|
290 |
} |
291 |
|
292 |
private JLabel getJLabelProjectionDinamic() { |
293 |
if(jLabelProjectiondinamic == null) { |
294 |
jLabelProjectiondinamic = new JLabel(); |
295 |
jLabelProjectiondinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
296 |
jLabelProjectiondinamic.setText(proj.getCrsWkt().getProjection()); |
297 |
} |
298 |
return jLabelProjectiondinamic;
|
299 |
} |
300 |
|
301 |
private JLabel getJLabelUnits() { |
302 |
if(jLabelUnits == null) { |
303 |
jLabelUnits = new JLabel(); |
304 |
jLabelUnits.setFont(new Font("Units",Font.BOLD,10)); |
305 |
jLabelUnits.setText(PluginServices.getText(this,"units")+":"); |
306 |
} |
307 |
return jLabelUnits;
|
308 |
} |
309 |
|
310 |
private JLabel getJLabelUnitsDinamic() { |
311 |
if(jLabelUnitsdinamic == null) { |
312 |
String[] units = proj.getCrsWkt().getUnit(); |
313 |
jLabelUnitsdinamic = new JLabel(); |
314 |
jLabelUnitsdinamic.setPreferredSize(new Dimension(200,20)); |
315 |
jLabelUnitsdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
316 |
jLabelUnitsdinamic.setText(units[0]+" , "+units[1]); |
317 |
System.out.println("Unidades: "+ units[0]+" , "+units[1]); |
318 |
|
319 |
} |
320 |
return jLabelUnitsdinamic;
|
321 |
} |
322 |
|
323 |
private JLabel getJLabelUnits_p() { |
324 |
if(jLabelUnits_p == null) { |
325 |
jLabelUnits_p = new JLabel(); |
326 |
jLabelUnits_p.setFont(new Font("",Font.BOLD,10)); |
327 |
jLabelUnits_p.setText(PluginServices.getText(this,"units_p")+":"); |
328 |
} |
329 |
return jLabelUnits_p;
|
330 |
} |
331 |
|
332 |
private JLabel getJLabelUnits_pDinamic() { |
333 |
if(jLabelUnits_pdinamic == null) { |
334 |
String[] uni_p = proj.getCrsWkt().getUnit_p(); |
335 |
jLabelUnits_pdinamic = new JLabel(); |
336 |
jLabelUnits_pdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
337 |
jLabelUnits_pdinamic.setText(uni_p[0]+" , "+uni_p[1]); |
338 |
|
339 |
} |
340 |
return jLabelUnits_pdinamic;
|
341 |
} |
342 |
|
343 |
private JScrollPane getJScrollPane1() { |
344 |
if(jScrollPane1 == null) { |
345 |
jScrollPane1 = new JScrollPane(); |
346 |
jScrollPane1.setPreferredSize(new Dimension(400,150)); |
347 |
jScrollPane1.setViewportView(getJTable()); |
348 |
} |
349 |
return jScrollPane1;
|
350 |
} |
351 |
|
352 |
private JTable getJTable() { |
353 |
if(jTable == null) { |
354 |
String[] columnNames = {PluginServices.getText(this,"nombre") |
355 |
,PluginServices.getText(this,"valor")}; |
356 |
String[] param_n = proj.getCrsWkt().getParam_name(); |
357 |
String[] param_v = proj.getCrsWkt().getParam_value(); |
358 |
Object[][]data; |
359 |
if(param_v != null) { |
360 |
data = new Object[param_v.length][2]; |
361 |
for(int i = 0 ; i < 2 ; i++ ) |
362 |
for(int j = 0 ; j < param_n.length ; j++) { |
363 |
if(i == 0) |
364 |
data[j][i] = param_n[j]; |
365 |
else
|
366 |
data[j][i] = param_v[j]; |
367 |
} |
368 |
} else
|
369 |
data = new Object[1][1]; |
370 |
dtm = new DefaultTableModel(data, columnNames); |
371 |
jTable = new JTable(dtm); |
372 |
jTable.setCellSelectionEnabled(false);
|
373 |
jTable.setRowSelectionAllowed(true);
|
374 |
jTable.setColumnSelectionAllowed(false);
|
375 |
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
376 |
|
377 |
} |
378 |
return jTable;
|
379 |
} |
380 |
|
381 |
public WindowInfo getWindowInfo() {
|
382 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
383 |
m_viewinfo.setTitle(PluginServices.getText(this,proj.getCrsWkt().getName()));
|
384 |
m_viewinfo.setWidth(600);
|
385 |
m_viewinfo.setHeight(250);
|
386 |
return m_viewinfo;
|
387 |
} |
388 |
|
389 |
public void actionPerformed(ActionEvent e) { |
390 |
if (e.getSource() == getJButtonOk()){
|
391 |
PluginServices.getMDIManager().closeWindow(this);
|
392 |
} |
393 |
} |
394 |
} |