root / branches / F2 / extensions / extJCRS / src / org / gvsig / crs / gui / panels / InfoCRSPanel.java @ 10788
History | View | Annotate | Download (11.6 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica 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 Ib??ez, 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.ICrs; |
62 |
|
63 |
import com.iver.andami.PluginServices; |
64 |
import com.iver.andami.ui.mdiManager.IWindow; |
65 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
66 |
|
67 |
/**
|
68 |
* Clase que genera el panel de informaci?n del CRS seleccionado
|
69 |
* en el caso del repositorio de la EPSG
|
70 |
* @author Miguel Garc?a Jim?nez (garciajimenez.miguel@gmail.com)
|
71 |
* @author Luisa Marina Fern?ndez (luisam.fernandez@uclm.es)
|
72 |
*
|
73 |
*/
|
74 |
public class InfoCRSPanel extends DefaultDialogPanel implements IWindow, ActionListener{ |
75 |
|
76 |
private static final long serialVersionUID = 1L; |
77 |
|
78 |
private JPanel panelLabels; |
79 |
|
80 |
private JTable jTable; |
81 |
public DefaultTableModel dtm = null; |
82 |
private JScrollPane jScrollPane1 = null; |
83 |
private JPanel jPanelbuttons; |
84 |
private JButton jButtonOk; |
85 |
|
86 |
private ICrs proj;
|
87 |
|
88 |
private JLabel jLabelProjcs; |
89 |
private JLabel jLabelGeogcs; |
90 |
private JLabel jLabelDatum; |
91 |
private JLabel jLabelSpheroid; |
92 |
private JLabel jLabelPrimem; |
93 |
private JLabel jLabelProjection; |
94 |
private JLabel jLabelUnits; |
95 |
private JLabel jLabelUnits_p; |
96 |
private JLabel jLabelProjcsdinamic; |
97 |
private JLabel jLabelGeogcsdinamic; |
98 |
private JLabel jLabelDatumdinamic; |
99 |
private JLabel jLabelSpheroiddinamic; |
100 |
private JLabel jLabelPrimemdinamic; |
101 |
private JLabel jLabelProjectiondinamic; |
102 |
private JLabel jLabelUnitsdinamic; |
103 |
private JLabel jLabelUnits_pdinamic; |
104 |
|
105 |
public InfoCRSPanel(ICrs p) {
|
106 |
super(false); |
107 |
proj = p; |
108 |
inicializate(); |
109 |
} |
110 |
|
111 |
private void inicializate() { |
112 |
this.setLayout(new BorderLayout()); |
113 |
JPanel p=new JPanel(new BorderLayout()); |
114 |
p.setBorder(new EmptyBorder(0,10,0,10)); |
115 |
p.add(getPanel(),BorderLayout.NORTH);
|
116 |
p.add(getJScrollPane1(),BorderLayout.CENTER);
|
117 |
this.add(p, BorderLayout.CENTER); |
118 |
this.add(getJPanelButtons(),BorderLayout.SOUTH); |
119 |
} |
120 |
|
121 |
private JPanel getPanel() { |
122 |
if(panelLabels == null) { |
123 |
panelLabels = new JPanel(); |
124 |
panelLabels.setLayout(new GridLayout(4,2)); |
125 |
JPanel p00=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
126 |
p00.add(getJLabelProjcs()); |
127 |
p00.add(getJLabelProjcsDinamic()); |
128 |
JPanel p01=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
129 |
p01.add(getJLabelGeogcs()); |
130 |
p01.add(getJLabelGeogcsDinamic()); |
131 |
JPanel p10=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
132 |
p10.add(getJLabelDatum()); |
133 |
p10.add(getJLabelDatumDinamic()); |
134 |
JPanel p11=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
135 |
p11.add(getJLabelSpheroid()); |
136 |
p11.add(getJLabelSpheroidDinamic()); |
137 |
JPanel p20=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
138 |
p20.add(getJLabelPrimen()); |
139 |
p20.add(getJLabelPrimenDinamic()); |
140 |
JPanel p21=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
141 |
p21.add(getJLabelUnits()); |
142 |
p21.add(getJLabelUnitsDinamic()); |
143 |
JPanel p30=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
144 |
p30.add(getJLabelProjection()); |
145 |
p30.add(getJLabelProjectionDinamic()); |
146 |
JPanel p31=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); |
147 |
p31.add(getJLabelUnits_p()); |
148 |
p31.add(getJLabelUnits_pDinamic()); |
149 |
|
150 |
panelLabels.add(p00); |
151 |
panelLabels.add(p01); |
152 |
panelLabels.add(p10); |
153 |
panelLabels.add(p11); |
154 |
panelLabels.add(p20); |
155 |
panelLabels.add(p21); |
156 |
panelLabels.add(p30); |
157 |
panelLabels.add(p31); |
158 |
|
159 |
} |
160 |
return panelLabels;
|
161 |
} |
162 |
|
163 |
private JPanel getJPanelButtons() { |
164 |
if(jPanelbuttons == null) { |
165 |
jPanelbuttons = new JPanel(); |
166 |
jPanelbuttons.setLayout(new FlowLayout(FlowLayout.RIGHT,10,10)); |
167 |
jPanelbuttons.add(getJButtonOk(),null);
|
168 |
} |
169 |
return jPanelbuttons;
|
170 |
} |
171 |
|
172 |
private JButton getJButtonOk() { |
173 |
if(jButtonOk == null) { |
174 |
jButtonOk = new JButton(); |
175 |
jButtonOk.setText(PluginServices.getText(this,"ok")); |
176 |
jButtonOk.setPreferredSize(new Dimension(100,25)); |
177 |
jButtonOk.setMnemonic('O');
|
178 |
jButtonOk.setToolTipText("Accept");
|
179 |
jButtonOk.addActionListener(this);
|
180 |
} |
181 |
return jButtonOk;
|
182 |
} |
183 |
|
184 |
private JLabel getJLabelProjcs() { |
185 |
if(jLabelProjcs == null) { |
186 |
jLabelProjcs = new JLabel(); |
187 |
jLabelProjcs.setFont(new Font("Projcs:",Font.BOLD,10)); |
188 |
jLabelProjcs.setText(PluginServices.getText(this,"projcs")+":"); |
189 |
} |
190 |
return jLabelProjcs;
|
191 |
} |
192 |
|
193 |
private JLabel getJLabelProjcsDinamic() { |
194 |
if(jLabelProjcsdinamic == null) { |
195 |
jLabelProjcsdinamic = new JLabel(); |
196 |
jLabelProjcsdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
197 |
jLabelProjcsdinamic.setText(proj.getCrsWkt().getProjcs()); |
198 |
} |
199 |
return jLabelProjcsdinamic;
|
200 |
} |
201 |
|
202 |
private JLabel getJLabelGeogcs() { |
203 |
if(jLabelGeogcs == null) { |
204 |
jLabelGeogcs = new JLabel(); |
205 |
jLabelGeogcs.setFont(new Font("Geogcs:",Font.BOLD,10)); |
206 |
jLabelGeogcs.setText(PluginServices.getText(this,"geogcs")+ ":"); |
207 |
} |
208 |
return jLabelGeogcs;
|
209 |
} |
210 |
|
211 |
private JLabel getJLabelGeogcsDinamic() { |
212 |
if(jLabelGeogcsdinamic == null) { |
213 |
jLabelGeogcsdinamic = new JLabel(); |
214 |
jLabelGeogcsdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
215 |
jLabelGeogcsdinamic.setText(proj.getCrsWkt().getGeogcs()); |
216 |
} |
217 |
return jLabelGeogcsdinamic;
|
218 |
} |
219 |
|
220 |
private JLabel getJLabelDatum() { |
221 |
if(jLabelDatum == null) { |
222 |
jLabelDatum = new JLabel(); |
223 |
jLabelDatum.setFont(new Font("Datum:",Font.BOLD,10)); |
224 |
jLabelDatum.setText(PluginServices.getText(this,"datum")+":"); |
225 |
} |
226 |
return jLabelDatum;
|
227 |
} |
228 |
|
229 |
private JLabel getJLabelDatumDinamic() { |
230 |
if(jLabelDatumdinamic == null) { |
231 |
jLabelDatumdinamic = new JLabel(); |
232 |
jLabelDatumdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
233 |
jLabelDatumdinamic.setText(proj.getCrsWkt().getDatumName()); |
234 |
} |
235 |
return jLabelDatumdinamic;
|
236 |
} |
237 |
|
238 |
private JLabel getJLabelSpheroid() { |
239 |
if(jLabelSpheroid == null) { |
240 |
jLabelSpheroid = new JLabel(); |
241 |
jLabelSpheroid.setFont(new Font("Spheroid",Font.BOLD,10)); |
242 |
jLabelSpheroid.setText(PluginServices.getText(this,"spheriod")+":"); |
243 |
} |
244 |
return jLabelSpheroid;
|
245 |
} |
246 |
|
247 |
private JLabel getJLabelSpheroidDinamic() { |
248 |
if(jLabelSpheroiddinamic == null) { |
249 |
String[] sphe = proj.getCrsWkt().getSpheroid(); |
250 |
jLabelSpheroiddinamic = new JLabel(); |
251 |
jLabelSpheroiddinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
252 |
jLabelSpheroiddinamic.setText(sphe[0]+" , "+sphe[1]+" , "+sphe[2]); |
253 |
} |
254 |
return jLabelSpheroiddinamic;
|
255 |
} |
256 |
|
257 |
private JLabel getJLabelPrimen() { |
258 |
if(jLabelPrimem == null) { |
259 |
jLabelPrimem = new JLabel(); |
260 |
jLabelPrimem.setFont(new Font("Primen:",Font.BOLD,10)); |
261 |
jLabelPrimem.setText(PluginServices.getText(this,"primem")+":"); |
262 |
} |
263 |
return jLabelPrimem;
|
264 |
} |
265 |
|
266 |
private JLabel getJLabelPrimenDinamic() { |
267 |
if(jLabelPrimemdinamic == null) { |
268 |
String pri[] = proj.getCrsWkt().getPrimen(); |
269 |
jLabelPrimemdinamic = new JLabel(); |
270 |
jLabelPrimemdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
271 |
jLabelPrimemdinamic.setText(pri[0]+" , "+pri[1]); |
272 |
} |
273 |
return jLabelPrimemdinamic;
|
274 |
} |
275 |
|
276 |
private JLabel getJLabelProjection() { |
277 |
if(jLabelProjection == null) { |
278 |
jLabelProjection = new JLabel(); |
279 |
jLabelProjection.setFont(new Font("Projection",Font.BOLD,10)); |
280 |
jLabelProjection.setText(PluginServices.getText(this,"projection")+":"); |
281 |
} |
282 |
return jLabelProjection;
|
283 |
} |
284 |
|
285 |
private JLabel getJLabelProjectionDinamic() { |
286 |
if(jLabelProjectiondinamic == null) { |
287 |
jLabelProjectiondinamic = new JLabel(); |
288 |
jLabelProjectiondinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
289 |
jLabelProjectiondinamic.setText(proj.getCrsWkt().getProjection()); |
290 |
} |
291 |
return jLabelProjectiondinamic;
|
292 |
} |
293 |
|
294 |
private JLabel getJLabelUnits() { |
295 |
if(jLabelUnits == null) { |
296 |
jLabelUnits = new JLabel(); |
297 |
jLabelUnits.setFont(new Font("Units",Font.BOLD,10)); |
298 |
jLabelUnits.setText(PluginServices.getText(this,"units")+":"); |
299 |
} |
300 |
return jLabelUnits;
|
301 |
} |
302 |
|
303 |
private JLabel getJLabelUnitsDinamic() { |
304 |
if(jLabelUnitsdinamic == null) { |
305 |
String[] units = proj.getCrsWkt().getUnit(); |
306 |
jLabelUnitsdinamic = new JLabel(); |
307 |
jLabelUnitsdinamic.setPreferredSize(new Dimension(200,20)); |
308 |
jLabelUnitsdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
309 |
jLabelUnitsdinamic.setText(units[0]+" , "+units[1]); |
310 |
System.out.println("Unidades: "+ units[0]+" , "+units[1]); |
311 |
|
312 |
} |
313 |
return jLabelUnitsdinamic;
|
314 |
} |
315 |
|
316 |
private JLabel getJLabelUnits_p() { |
317 |
if(jLabelUnits_p == null) { |
318 |
jLabelUnits_p = new JLabel(); |
319 |
jLabelUnits_p.setFont(new Font("",Font.BOLD,10)); |
320 |
jLabelUnits_p.setText(PluginServices.getText(this,"units_p")+":"); |
321 |
} |
322 |
return jLabelUnits_p;
|
323 |
} |
324 |
|
325 |
private JLabel getJLabelUnits_pDinamic() { |
326 |
if(jLabelUnits_pdinamic == null) { |
327 |
String[] uni_p = proj.getCrsWkt().getUnit_p(); |
328 |
jLabelUnits_pdinamic = new JLabel(); |
329 |
jLabelUnits_pdinamic.setFont(new Font("",Font.ROMAN_BASELINE,10)); |
330 |
jLabelUnits_pdinamic.setText(uni_p[0]+" , "+uni_p[1]); |
331 |
|
332 |
} |
333 |
return jLabelUnits_pdinamic;
|
334 |
} |
335 |
|
336 |
private JScrollPane getJScrollPane1() { |
337 |
if(jScrollPane1 == null) { |
338 |
jScrollPane1 = new JScrollPane(); |
339 |
jScrollPane1.setPreferredSize(new Dimension(400,150)); |
340 |
jScrollPane1.setViewportView(getJTable()); |
341 |
} |
342 |
return jScrollPane1;
|
343 |
} |
344 |
|
345 |
private JTable getJTable() { |
346 |
if(jTable == null) { |
347 |
String[] columnNames = {PluginServices.getText(this,"nombre") |
348 |
,PluginServices.getText(this,"valor")}; |
349 |
String[] param_n = proj.getCrsWkt().getParam_name(); |
350 |
String[] param_v = proj.getCrsWkt().getParam_value(); |
351 |
Object[][]data; |
352 |
if(param_v != null) { |
353 |
data = new Object[param_v.length][2]; |
354 |
for(int i = 0 ; i < 2 ; i++ ) |
355 |
for(int j = 0 ; j < param_n.length ; j++) { |
356 |
if(i == 0) |
357 |
data[j][i] = param_n[j]; |
358 |
else
|
359 |
data[j][i] = param_v[j]; |
360 |
} |
361 |
} else
|
362 |
data = new Object[1][1]; |
363 |
dtm = new DefaultTableModel(data, columnNames); |
364 |
jTable = new JTable(dtm); |
365 |
jTable.setCellSelectionEnabled(false);
|
366 |
jTable.setRowSelectionAllowed(true);
|
367 |
jTable.setColumnSelectionAllowed(false);
|
368 |
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
369 |
|
370 |
} |
371 |
return jTable;
|
372 |
} |
373 |
|
374 |
public WindowInfo getWindowInfo() {
|
375 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
376 |
m_viewinfo.setTitle(PluginServices.getText(this,proj.getCrsWkt().getName()));
|
377 |
m_viewinfo.setWidth(600);
|
378 |
m_viewinfo.setHeight(250);
|
379 |
return m_viewinfo;
|
380 |
} |
381 |
|
382 |
public void actionPerformed(ActionEvent e) { |
383 |
if (e.getSource() == getJButtonOk()){
|
384 |
PluginServices.getMDIManager().closeWindow(this);
|
385 |
} |
386 |
} |
387 |
} |