root / org.gvsig.projection.jcrs / trunk / org.gvsig.projection.jcrs / org.gvsig.projection.app.jcrs / org.gvsig.projection.app.jcrs.common / src / main / java / org / gvsig / crs / gui / CRSMainPanel.java @ 674
History | View | Annotate | Download (11 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; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.CardLayout; |
45 |
import java.awt.Dimension; |
46 |
import java.awt.FlowLayout; |
47 |
import java.awt.GridLayout; |
48 |
import java.awt.event.ActionEvent; |
49 |
|
50 |
import javax.swing.JButton; |
51 |
import javax.swing.JComboBox; |
52 |
import javax.swing.JLabel; |
53 |
import javax.swing.JPanel; |
54 |
|
55 |
import org.cresques.cts.IProjection; |
56 |
import org.gvsig.andami.PluginServices; |
57 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
58 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
59 |
import org.gvsig.crs.CrsFactory; |
60 |
import org.gvsig.crs.ICrs; |
61 |
import org.gvsig.crs.gui.panels.CrsAndTransformationRecentsPanel; |
62 |
import org.gvsig.crs.gui.panels.CrsRecentsPanel; |
63 |
import org.gvsig.crs.gui.panels.EPSGpanel; |
64 |
import org.gvsig.crs.gui.panels.ESRIpanel; |
65 |
import org.gvsig.crs.gui.panels.IAU2000panel; |
66 |
import org.gvsig.crs.gui.panels.NewCRSPanel; |
67 |
import org.gvsig.crs.gui.panels.NoAuthCRSpanel; |
68 |
|
69 |
|
70 |
/**
|
71 |
* Clase que genera el panel principal para la seleccin de CRS
|
72 |
*
|
73 |
* @author Jos Luis Gmez Martnez (jolugomar@gmail.com)
|
74 |
* @author Luisa Marina Fernandez (luisam.fernandez@uclm.es)
|
75 |
*
|
76 |
*/
|
77 |
public class CRSMainPanel extends JPanel implements IWindow { |
78 |
|
79 |
private static final long serialVersionUID = 1L; |
80 |
|
81 |
private JComboBox jComboOptions = null; |
82 |
private JPanel Combopanel = null; |
83 |
private JPanel USGSpanel = null; |
84 |
|
85 |
final String recientes = PluginServices.getText(this,"recientes"); |
86 |
final String epsg = PluginServices.getText(this,"EPSG"); |
87 |
final String usgs = PluginServices.getText(this,"USGS"); |
88 |
final String esri = PluginServices.getText(this,"ESRI"); |
89 |
final String noAuth = PluginServices.getText(this,"CRS"); |
90 |
final String iau2000 = PluginServices.getText(this,"IAU2000"); |
91 |
final String newCRS = PluginServices.getText(this,"newCRS"); |
92 |
|
93 |
//String[] selection = {recientes, epsg, usgs, esri, iau2000, newCRS};
|
94 |
String[] selection = {recientes, epsg, noAuth, esri, iau2000, newCRS};//, esri}; |
95 |
|
96 |
boolean inAnApplet = true; |
97 |
public CrsRecentsPanel crsRecentsPanel = null; |
98 |
public CrsAndTransformationRecentsPanel crsAndTransformationRecentsPanel = null; |
99 |
public EPSGpanel epsgPanel = null; |
100 |
public NoAuthCRSpanel noAuthPanel = null; |
101 |
|
102 |
public ESRIpanel esriPanel = null; |
103 |
public IAU2000panel iauPanel = null; |
104 |
public NewCRSPanel newCrsPanel=null; |
105 |
|
106 |
private JPanel jPanelMain = null; |
107 |
|
108 |
private JPanel jPanelButtons; |
109 |
private JButton jButtonAccept; |
110 |
private JButton jButonCancel; |
111 |
|
112 |
private ICrs viewCrs;
|
113 |
|
114 |
String dataSource = ""; |
115 |
|
116 |
public CRSMainPanel(ICrs crs) {
|
117 |
CrsFactory.initializeDatabaseInbackground(); |
118 |
|
119 |
viewCrs = crs; |
120 |
crsRecentsPanel = new CrsRecentsPanel();
|
121 |
epsgPanel = new EPSGpanel();
|
122 |
noAuthPanel = new NoAuthCRSpanel();
|
123 |
esriPanel = new ESRIpanel();
|
124 |
iauPanel = new IAU2000panel();
|
125 |
newCrsPanel=new NewCRSPanel(viewCrs);
|
126 |
|
127 |
this.setLayout(new BorderLayout()); |
128 |
this.add(vista(), BorderLayout.NORTH); |
129 |
this.add(getJPanelButtons(), BorderLayout.SOUTH); |
130 |
|
131 |
setDataSource(selection[0]);
|
132 |
|
133 |
} |
134 |
|
135 |
public CRSMainPanel(int target, ICrs crs) { |
136 |
viewCrs = crs; |
137 |
crsAndTransformationRecentsPanel = new CrsAndTransformationRecentsPanel();
|
138 |
epsgPanel = new EPSGpanel();
|
139 |
noAuthPanel = new NoAuthCRSpanel();
|
140 |
esriPanel = new ESRIpanel();
|
141 |
iauPanel = new IAU2000panel();
|
142 |
newCrsPanel=new NewCRSPanel(viewCrs);
|
143 |
|
144 |
setDataSource(selection[0]);
|
145 |
} |
146 |
|
147 |
/**
|
148 |
* Panel con los controles necesarios para visualizarlo en el panel de
|
149 |
* seleccin de CRS y transformacin de la capa a aadir
|
150 |
* @return
|
151 |
*/
|
152 |
public JPanel capa(){ |
153 |
JPanel p = new JPanel(); |
154 |
//**p.setPreferredSize(new Dimension(550, 320));
|
155 |
//**p.setLayout(new GridLayout(0,1));
|
156 |
//p.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
|
157 |
p.setLayout(new BorderLayout()); |
158 |
//p.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this,"seleccione_crs_capa")));//,
|
159 |
/*BorderFactory.createEmptyBorder(1,1,1,1)),
|
160 |
p.getBorder()));*/
|
161 |
p.add(getCombopanel(),BorderLayout.NORTH);
|
162 |
p.add(getJPanelLayerMain(),BorderLayout.CENTER);
|
163 |
return p;
|
164 |
} |
165 |
|
166 |
public JPanel vista(){ |
167 |
JPanel p = new JPanel(); |
168 |
//p.setPreferredSize(new Dimension(550, 320));
|
169 |
//p.setLayout(new GridLayout(0,1));
|
170 |
//p.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
|
171 |
/*p.setBorder(
|
172 |
BorderFactory.createCompoundBorder(
|
173 |
BorderFactory.createCompoundBorder(
|
174 |
BorderFactory.createTitledBorder(PluginServices.getText(this,"seleccione_crs_vista")),
|
175 |
BorderFactory.createEmptyBorder(2,2,2,2)),
|
176 |
p.getBorder()));*/
|
177 |
p.setLayout(new BorderLayout()); |
178 |
p.add(getCombopanel(),BorderLayout.NORTH);
|
179 |
p.add(getJPanelMain(),BorderLayout.CENTER);
|
180 |
return p;
|
181 |
} |
182 |
|
183 |
public JPanel getJPanelMain(){ |
184 |
if (jPanelMain == null){ |
185 |
jPanelMain = new JPanel(); |
186 |
jPanelMain.setLayout(new CardLayout()); |
187 |
jPanelMain.setPreferredSize(new Dimension(525, 230)); |
188 |
jPanelMain.add(recientes, crsRecentsPanel); |
189 |
jPanelMain.add(epsg, epsgPanel); |
190 |
jPanelMain.add(newCRS,newCrsPanel); |
191 |
jPanelMain.add(noAuth, noAuthPanel); |
192 |
jPanelMain.add(esri, esriPanel); |
193 |
jPanelMain.add(usgs, getJPanelUSGS()); |
194 |
jPanelMain.add(iau2000, iauPanel); |
195 |
} |
196 |
|
197 |
return jPanelMain;
|
198 |
} |
199 |
|
200 |
public JPanel getJPanelLayerMain(){ |
201 |
if (jPanelMain == null){ |
202 |
jPanelMain = new JPanel(); |
203 |
jPanelMain.setLayout(new CardLayout()); |
204 |
jPanelMain.setPreferredSize(new Dimension(525, 230)); |
205 |
jPanelMain.add(recientes, crsAndTransformationRecentsPanel); |
206 |
jPanelMain.add(epsg, epsgPanel); |
207 |
jPanelMain.add(newCRS,newCrsPanel); |
208 |
jPanelMain.add(noAuth, noAuthPanel); |
209 |
jPanelMain.add(esri, esriPanel); |
210 |
jPanelMain.add(usgs, getJPanelUSGS()); |
211 |
jPanelMain.add(iau2000, iauPanel); |
212 |
} |
213 |
|
214 |
return jPanelMain;
|
215 |
} |
216 |
|
217 |
public JPanel getCombopanel(){ |
218 |
if (Combopanel == null){ |
219 |
Combopanel = new JPanel(); |
220 |
Combopanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,5)); |
221 |
Combopanel.add(getJLabelTipo()); |
222 |
Combopanel.add(getJComboOptions()); |
223 |
} |
224 |
|
225 |
return Combopanel;
|
226 |
} |
227 |
|
228 |
private JLabel getJLabelTipo(){ |
229 |
JLabel jLabelTipo = new JLabel(); |
230 |
jLabelTipo.setPreferredSize(new Dimension(50,25)); |
231 |
jLabelTipo.setText(PluginServices.getText(this,"tipo")+":"); |
232 |
return jLabelTipo;
|
233 |
} |
234 |
|
235 |
public JComboBox getJComboOptions(){ |
236 |
if (jComboOptions == null){ |
237 |
jComboOptions = new JComboBox(selection); |
238 |
jComboOptions.setPreferredSize(new Dimension(100,25)); |
239 |
jComboOptions.setEditable(false);
|
240 |
jComboOptions.setSelectedIndex(0);
|
241 |
} |
242 |
return jComboOptions;
|
243 |
} |
244 |
|
245 |
public JPanel getJPanelUSGS() { |
246 |
if (USGSpanel == null){ |
247 |
USGSpanel = new JPanel(); |
248 |
USGSpanel.setLayout(new GridLayout(3,4)); |
249 |
USGSpanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
250 |
USGSpanel.setPreferredSize(new Dimension(525, 400)); |
251 |
} |
252 |
return USGSpanel;
|
253 |
} |
254 |
|
255 |
private JPanel getJPanelButtons() { |
256 |
if(jPanelButtons == null) { |
257 |
jPanelButtons = new JPanel(); |
258 |
jPanelButtons.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
259 |
//jPanelButtons.setPreferredSize(new Dimension(525,50));
|
260 |
jPanelButtons.add(getJButtonCancel(),null);
|
261 |
jPanelButtons.add(getJButtonAccept(),null);
|
262 |
} |
263 |
return jPanelButtons;
|
264 |
} |
265 |
|
266 |
public JButton getJButtonCancel() { |
267 |
if(jButonCancel == null) { |
268 |
jButonCancel = new JButton(); |
269 |
jButonCancel.setText(PluginServices.getText(this,"cancel")); |
270 |
jButonCancel.setPreferredSize(new Dimension(100,25)); |
271 |
jButonCancel.setMnemonic('C');
|
272 |
jButonCancel.setToolTipText("Cancel");
|
273 |
} |
274 |
return jButonCancel;
|
275 |
} |
276 |
|
277 |
public void cancelButton_actionPerformed(ActionEvent e) { |
278 |
PluginServices.getMDIManager().closeWindow(this);
|
279 |
} |
280 |
|
281 |
public JButton getJButtonAccept() { |
282 |
if(jButtonAccept == null) { |
283 |
jButtonAccept = new JButton(); |
284 |
jButtonAccept.setText(PluginServices.getText(this,"ok")); |
285 |
jButtonAccept.setPreferredSize(new Dimension(100,25)); |
286 |
jButtonAccept.setEnabled(false);
|
287 |
jButtonAccept.setMnemonic('A');
|
288 |
jButtonAccept.setToolTipText(PluginServices.getText(this,"ok")); |
289 |
} |
290 |
return jButtonAccept;
|
291 |
} |
292 |
|
293 |
public ICrs getProjection() {
|
294 |
if (getDataSource().equals(PluginServices.getText(this,"EPSG"))){ |
295 |
return epsgPanel.getProjection();
|
296 |
} |
297 |
else if (getDataSource().equals(PluginServices.getText(this,"IAU2000"))) { |
298 |
return iauPanel.getProjection();
|
299 |
} |
300 |
else if (getDataSource().equals(PluginServices.getText(this,"recientes"))) { |
301 |
return crsRecentsPanel.getProjection();
|
302 |
} |
303 |
else if (getDataSource().equals(PluginServices.getText(this,"CRS"))) { |
304 |
return noAuthPanel.getProjection();
|
305 |
} |
306 |
else if (getDataSource().equals(PluginServices.getText(this,"ESRI"))) { |
307 |
return esriPanel.getProjection();
|
308 |
} |
309 |
else if (getDataSource().equals(PluginServices.getText(this,"newCRS"))) { |
310 |
return newCrsPanel.getProjection();
|
311 |
} |
312 |
return null; |
313 |
} |
314 |
|
315 |
public void setProjection(IProjection crs) { |
316 |
//setCrs((ICrs) crs);
|
317 |
} |
318 |
|
319 |
public void setDataSource(String sour){ |
320 |
dataSource = sour; |
321 |
} |
322 |
|
323 |
public String getDataSource(){ |
324 |
return dataSource;
|
325 |
} |
326 |
|
327 |
public WindowInfo getWindowInfo() {
|
328 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
329 |
m_viewinfo.setTitle(PluginServices.getText(this, "seleccionar_crs")); |
330 |
return m_viewinfo;
|
331 |
} |
332 |
|
333 |
public EPSGpanel getEpsgPanel() {
|
334 |
return epsgPanel;
|
335 |
} |
336 |
|
337 |
public NoAuthCRSpanel getNoAuthPanel() {
|
338 |
return noAuthPanel;
|
339 |
} |
340 |
|
341 |
|
342 |
public ESRIpanel getEsriPanel() {
|
343 |
return esriPanel;
|
344 |
} |
345 |
public IAU2000panel getIauPanel() {
|
346 |
return iauPanel;
|
347 |
} |
348 |
|
349 |
public CrsRecentsPanel getRecentsPanel() {
|
350 |
return crsRecentsPanel;
|
351 |
} |
352 |
|
353 |
public CrsAndTransformationRecentsPanel getCrsAndTransformationRecentsPanel() {
|
354 |
return crsAndTransformationRecentsPanel;
|
355 |
} |
356 |
|
357 |
public NewCRSPanel getNewCrsPanel() {
|
358 |
return newCrsPanel;
|
359 |
} |
360 |
|
361 |
public Object getWindowProfile() { |
362 |
return WindowInfo.DIALOG_PROFILE;
|
363 |
} |
364 |
} |