root / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / CRSMainPanel.java @ 10145
History | View | Annotate | Download (8.7 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; |
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.BorderFactory; |
51 |
import javax.swing.JButton; |
52 |
import javax.swing.JComboBox; |
53 |
import javax.swing.JLabel; |
54 |
import javax.swing.JPanel; |
55 |
|
56 |
import org.cresques.cts.IProjection; |
57 |
import org.gvsig.crs.ICrs; |
58 |
import org.gvsig.crs.gui.panels.CrsRecentsPanel; |
59 |
import org.gvsig.crs.gui.panels.EPSGpanel; |
60 |
import org.gvsig.crs.gui.panels.ESRIpanel; |
61 |
import org.gvsig.crs.gui.panels.IAU2000panel; |
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 principal para la selecci?n de CRS
|
69 |
*
|
70 |
* @author Jos? Luis G?mez Mart?nez (jolugomar@gmail.com)
|
71 |
*
|
72 |
*/
|
73 |
public class CRSMainPanel extends JPanel implements IWindow { |
74 |
|
75 |
private static final long serialVersionUID = 1L; |
76 |
|
77 |
private JComboBox jComboOptions = null; |
78 |
private JPanel Combopanel = null; |
79 |
private JPanel USGSpanel = null; |
80 |
|
81 |
final String recientes = PluginServices.getText(this,"recientes"); |
82 |
final String epsg = PluginServices.getText(this,"EPSG"); |
83 |
final String usgs = PluginServices.getText(this,"USGS"); |
84 |
final String esri = PluginServices.getText(this,"ESRI"); |
85 |
final String iau2000 = PluginServices.getText(this,"IAU2000"); |
86 |
final String newCRS = PluginServices.getText(this,"nuevo_crs"); |
87 |
|
88 |
//String[] selection = {recientes, epsg, usgs, esri, iau2000, newCRS};
|
89 |
String[] selection = {recientes, epsg, iau2000};//, esri}; |
90 |
|
91 |
boolean inAnApplet = true; |
92 |
public CrsRecentsPanel crsRecentsPanel = null; |
93 |
public EPSGpanel epsgPanel = null; |
94 |
public ESRIpanel esriPanel = null; |
95 |
public IAU2000panel iauPanel = null; |
96 |
|
97 |
private JPanel jPanelMain = null; |
98 |
|
99 |
private JPanel jPanelButtons; |
100 |
private JButton jButtonAccept; |
101 |
private JButton jButonCancel; |
102 |
|
103 |
String dataSource = ""; |
104 |
|
105 |
public CRSMainPanel() {
|
106 |
crsRecentsPanel = new CrsRecentsPanel();
|
107 |
epsgPanel = new EPSGpanel();
|
108 |
esriPanel = new ESRIpanel();
|
109 |
iauPanel = new IAU2000panel();
|
110 |
|
111 |
this.add(vista(), BorderLayout.NORTH); |
112 |
this.add(getJPanelButtons(), BorderLayout.SOUTH); |
113 |
|
114 |
setDataSource(selection[0]);
|
115 |
} |
116 |
|
117 |
public CRSMainPanel(int target) { |
118 |
crsRecentsPanel = new CrsRecentsPanel();
|
119 |
epsgPanel = new EPSGpanel();
|
120 |
esriPanel = new ESRIpanel();
|
121 |
iauPanel = new IAU2000panel();
|
122 |
|
123 |
setDataSource(selection[0]);
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* Panel con los controles necesarios para visualizarlo en el panel de
|
128 |
* selecci?n de CRS y transformaci?n de la capa a a?adir
|
129 |
* @return
|
130 |
*/
|
131 |
public JPanel capa(){ |
132 |
JPanel p = new JPanel(); |
133 |
p.setPreferredSize(new Dimension(550, 320)); |
134 |
p.setLayout(new GridLayout(0,1)); |
135 |
p.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
136 |
p.setBorder( |
137 |
BorderFactory.createCompoundBorder(
|
138 |
BorderFactory.createCompoundBorder(
|
139 |
BorderFactory.createTitledBorder(PluginServices.getText(this,"seleccione_crs_capa")), |
140 |
BorderFactory.createEmptyBorder(1,1,1,1)), |
141 |
p.getBorder())); |
142 |
p.add(getCombopanel()); |
143 |
p.add(getJPanelMain()); |
144 |
return p;
|
145 |
} |
146 |
|
147 |
/**
|
148 |
* Panel con los controles necesarios del panel de selecci?n de CRS
|
149 |
* de la vista actual
|
150 |
* @return
|
151 |
*/
|
152 |
public JPanel vista(){ |
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.setBorder( |
158 |
BorderFactory.createCompoundBorder(
|
159 |
BorderFactory.createCompoundBorder(
|
160 |
BorderFactory.createTitledBorder(PluginServices.getText(this,"seleccione_crs_vista")), |
161 |
BorderFactory.createEmptyBorder(2,2,2,2)), |
162 |
p.getBorder())); |
163 |
p.add(getCombopanel()); |
164 |
p.add(getJPanelMain()); |
165 |
return p;
|
166 |
} |
167 |
|
168 |
public JPanel getJPanelMain(){ |
169 |
if (jPanelMain == null){ |
170 |
jPanelMain = new JPanel(); |
171 |
jPanelMain.setLayout(new CardLayout()); |
172 |
jPanelMain.setPreferredSize(new Dimension(525, 230)); |
173 |
jPanelMain.add(recientes, crsRecentsPanel); |
174 |
jPanelMain.add(epsg, epsgPanel); |
175 |
jPanelMain.add(esri, esriPanel); |
176 |
jPanelMain.add(usgs, getJPanelUSGS()); |
177 |
jPanelMain.add(iau2000, iauPanel); |
178 |
} |
179 |
|
180 |
return jPanelMain;
|
181 |
} |
182 |
|
183 |
public JPanel getCombopanel(){ |
184 |
if (Combopanel == null){ |
185 |
Combopanel = new JPanel(); |
186 |
Combopanel.setPreferredSize(new Dimension(525,30)); |
187 |
Combopanel.add(getJLabelTipo()); |
188 |
Combopanel.add(getJComboOptions()); |
189 |
} |
190 |
|
191 |
return Combopanel;
|
192 |
} |
193 |
|
194 |
private JLabel getJLabelTipo(){ |
195 |
JLabel jLabelTipo = new JLabel(); |
196 |
jLabelTipo.setPreferredSize(new Dimension(50,25)); |
197 |
jLabelTipo.setText(PluginServices.getText(this,"Tipo")+":"); |
198 |
return jLabelTipo;
|
199 |
} |
200 |
|
201 |
public JComboBox getJComboOptions(){ |
202 |
if (jComboOptions == null){ |
203 |
jComboOptions = new JComboBox(selection); |
204 |
jComboOptions.setPreferredSize(new Dimension(100,25)); |
205 |
jComboOptions.setEditable(false);
|
206 |
jComboOptions.setSelectedIndex(0);
|
207 |
} |
208 |
return jComboOptions;
|
209 |
} |
210 |
|
211 |
public JPanel getJPanelUSGS() { |
212 |
if (USGSpanel == null){ |
213 |
USGSpanel = new JPanel(); |
214 |
USGSpanel.setLayout(new GridLayout(3,4)); |
215 |
USGSpanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
216 |
USGSpanel.setPreferredSize(new Dimension(525, 400)); |
217 |
} |
218 |
return USGSpanel;
|
219 |
} |
220 |
|
221 |
private JPanel getJPanelButtons() { |
222 |
if(jPanelButtons == null) { |
223 |
jPanelButtons = new JPanel(); |
224 |
jPanelButtons.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
225 |
jPanelButtons.setPreferredSize(new Dimension(525,50)); |
226 |
jPanelButtons.add(getJButtonCancel(),null);
|
227 |
jPanelButtons.add(getJButtonAccept(),null);
|
228 |
} |
229 |
return jPanelButtons;
|
230 |
} |
231 |
|
232 |
public JButton getJButtonCancel() { |
233 |
if(jButonCancel == null) { |
234 |
jButonCancel = new JButton(); |
235 |
jButonCancel.setText(PluginServices.getText(this,"cancel")); |
236 |
jButonCancel.setPreferredSize(new Dimension(100,25)); |
237 |
jButonCancel.setMnemonic('C');
|
238 |
jButonCancel.setToolTipText("Cancel");
|
239 |
} |
240 |
return jButonCancel;
|
241 |
} |
242 |
|
243 |
public void cancelButton_actionPerformed(ActionEvent e) { |
244 |
PluginServices.getMDIManager().closeWindow(this);
|
245 |
} |
246 |
|
247 |
public JButton getJButtonAccept() { |
248 |
if(jButtonAccept == null) { |
249 |
jButtonAccept = new JButton(); |
250 |
jButtonAccept.setText(PluginServices.getText(this,"ok")); |
251 |
jButtonAccept.setPreferredSize(new Dimension(100,25)); |
252 |
jButtonAccept.setEnabled(false);
|
253 |
jButtonAccept.setMnemonic('A');
|
254 |
jButtonAccept.setToolTipText("Accept");
|
255 |
} |
256 |
return jButtonAccept;
|
257 |
} |
258 |
|
259 |
public ICrs getProjection() {
|
260 |
if (getDataSource().equals(PluginServices.getText(this,"EPSG"))){ |
261 |
return epsgPanel.getProjection();
|
262 |
} |
263 |
else if (getDataSource().equals(PluginServices.getText(this,"IAU2000"))) { |
264 |
return iauPanel.getProjection();
|
265 |
} |
266 |
else if (getDataSource().equals(PluginServices.getText(this,"recientes"))) { |
267 |
return crsRecentsPanel.getProjection();
|
268 |
} |
269 |
else if (getDataSource().equals(PluginServices.getText(this,"ESRI"))) { |
270 |
return esriPanel.getProjection();
|
271 |
} |
272 |
return null; |
273 |
} |
274 |
|
275 |
public void setProjection(IProjection crs) { |
276 |
//setCrs((ICrs) crs);
|
277 |
} |
278 |
|
279 |
public void setDataSource(String sour){ |
280 |
dataSource = sour; |
281 |
} |
282 |
|
283 |
public String getDataSource(){ |
284 |
return dataSource;
|
285 |
} |
286 |
|
287 |
public WindowInfo getWindowInfo() {
|
288 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
289 |
m_viewinfo.setTitle(PluginServices.getText(this, "seleccionar_crs")); |
290 |
return m_viewinfo;
|
291 |
} |
292 |
|
293 |
public EPSGpanel getEpsgPanel() {
|
294 |
return epsgPanel;
|
295 |
} |
296 |
|
297 |
|
298 |
|
299 |
public ESRIpanel getEsriPanel() {
|
300 |
return esriPanel;
|
301 |
} |
302 |
|
303 |
|
304 |
|
305 |
public IAU2000panel getIauPanel() {
|
306 |
return iauPanel;
|
307 |
} |
308 |
|
309 |
public CrsRecentsPanel getRecentsPanel() {
|
310 |
return crsRecentsPanel;
|
311 |
} |
312 |
|
313 |
} |