svn-gvsig-desktop / trunk / libraries / libJCRS / src / org / gvsig / crs / ui / InfoCrs.java @ 7020
History | View | Annotate | Download (9.31 KB)
1 |
package org.gvsig.crs.ui; |
---|---|
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 |
} |