Statistics
| Revision:

root / trunk / extensions / extJCRS / src / org / gvsig / crs / gui / CRSMainPanel.java @ 24986

History | View | Annotate | Download (10 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.crs.ICrs;
57
import org.gvsig.crs.gui.panels.CrsAndTransformationRecentsPanel;
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
import org.gvsig.crs.gui.panels.NewCRSPanel;
63

    
64
import com.iver.andami.PluginServices;
65
import com.iver.andami.ui.mdiManager.IWindow;
66
import com.iver.andami.ui.mdiManager.WindowInfo;
67

    
68
/**
69
 * Clase que genera el panel principal para la seleccin de CRS 
70
 * 
71
 * @author Jos Luis Gmez Martnez (jolugomar@gmail.com)
72
 * @author Luisa Marina Fernandez (luisam.fernandez@uclm.es)
73
 *
74
 */
75
public class CRSMainPanel extends JPanel implements IWindow {
76
                
77
        private static final long serialVersionUID = 1L;
78
        
79
        private JComboBox jComboOptions = null;        
80
        private JPanel Combopanel = null;        
81
        private JPanel USGSpanel = null;        
82
        
83
        final String recientes = PluginServices.getText(this,"recientes");
84
        final String epsg = PluginServices.getText(this,"EPSG"); 
85
        final String usgs = PluginServices.getText(this,"USGS");
86
        final String esri = PluginServices.getText(this,"ESRI");
87
        final String iau2000 = PluginServices.getText(this,"IAU2000");
88
        final String newCRS = PluginServices.getText(this,"newCRS");
89
        
90
        //String[] selection = {recientes, epsg, usgs, esri, iau2000, newCRS};
91
        String[] selection = {recientes, epsg, esri, iau2000, newCRS};//, esri};
92
        
93
        boolean inAnApplet = true;        
94
        public CrsRecentsPanel crsRecentsPanel = null;
95
        public CrsAndTransformationRecentsPanel crsAndTransformationRecentsPanel = null;
96
        public EPSGpanel epsgPanel = null;
97
        public ESRIpanel esriPanel = null;
98
        public IAU2000panel iauPanel = null;
99
        public NewCRSPanel newCrsPanel=null;
100
        
101
        private JPanel jPanelMain = null;        
102
        
103
        private JPanel jPanelButtons;
104
        private JButton jButtonAccept;
105
        private JButton jButonCancel;
106
        
107
        private ICrs viewCrs;
108
        
109
        String dataSource = "";
110

    
111
        public CRSMainPanel(ICrs crs) {
112
                viewCrs = crs;
113
                crsRecentsPanel = new CrsRecentsPanel();
114
                epsgPanel = new EPSGpanel();
115
                esriPanel = new ESRIpanel();
116
                iauPanel = new IAU2000panel();
117
                newCrsPanel=new NewCRSPanel(viewCrs);
118
                
119
                this.add(vista(), BorderLayout.NORTH);                
120
                this.add(getJPanelButtons(), BorderLayout.SOUTH);
121
                
122
            setDataSource(selection[0]);
123
        }
124
        
125
        public CRSMainPanel(int target, ICrs crs) {
126
                viewCrs = crs;
127
                crsAndTransformationRecentsPanel = new CrsAndTransformationRecentsPanel();
128
                epsgPanel = new EPSGpanel();
129
                esriPanel = new ESRIpanel();
130
                iauPanel = new IAU2000panel();
131
                newCrsPanel=new NewCRSPanel(viewCrs);
132
                
133
                setDataSource(selection[0]);
134
        }
135
        
136
        /**
137
         * Panel con los controles necesarios para visualizarlo en el panel de 
138
         * seleccin de CRS y transformacin de la capa a aadir
139
         * @return
140
         */
141
        public JPanel capa(){
142
                JPanel p = new JPanel();
143
                //**p.setPreferredSize(new Dimension(550, 320));
144
                //**p.setLayout(new GridLayout(0,1));
145
                //p.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
146
                p.setLayout(new BorderLayout());
147
                //p.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this,"seleccione_crs_capa")));//,
148
                                                                /*BorderFactory.createEmptyBorder(1,1,1,1)),
149
                                                                p.getBorder()));*/
150
                p.add(getCombopanel(),BorderLayout.NORTH);
151
                p.add(getJPanelLayerMain(),BorderLayout.CENTER);
152
                return p;
153
        }
154
        
155
        public JPanel vista(){
156
                JPanel p = new JPanel();
157
                //p.setPreferredSize(new Dimension(550, 320));
158
                //p.setLayout(new GridLayout(0,1));
159
                //p.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
160
                /*p.setBorder(
161
                            BorderFactory.createCompoundBorder(
162
                                                BorderFactory.createCompoundBorder(
163
                                                                BorderFactory.createTitledBorder(PluginServices.getText(this,"seleccione_crs_vista")),
164
                                                                BorderFactory.createEmptyBorder(2,2,2,2)),
165
                                                                p.getBorder()));*/
166
                p.setLayout(new BorderLayout());
167
                p.add(getCombopanel(),BorderLayout.NORTH);
168
                p.add(getJPanelMain(),BorderLayout.CENTER);
169
                return p;
170
        }
171
        
172
        public JPanel getJPanelMain(){
173
                if (jPanelMain == null){
174
                        jPanelMain = new JPanel();
175
                        jPanelMain.setLayout(new CardLayout());
176
                        jPanelMain.setPreferredSize(new Dimension(525, 230));        
177
                        jPanelMain.add(recientes, crsRecentsPanel);
178
                        jPanelMain.add(epsg, epsgPanel);
179
                        jPanelMain.add(newCRS,newCrsPanel);
180
                        jPanelMain.add(esri, esriPanel);
181
                        jPanelMain.add(usgs, getJPanelUSGS());
182
                        jPanelMain.add(iau2000, iauPanel);
183
                }
184
                
185
                return jPanelMain;                
186
        }
187
        
188
        public JPanel getJPanelLayerMain(){
189
                if (jPanelMain == null){
190
                        jPanelMain = new JPanel();
191
                        jPanelMain.setLayout(new CardLayout());
192
                        jPanelMain.setPreferredSize(new Dimension(525, 230));        
193
                        jPanelMain.add(recientes, crsAndTransformationRecentsPanel);
194
                        jPanelMain.add(epsg, epsgPanel);
195
                        jPanelMain.add(newCRS,newCrsPanel);
196
                        jPanelMain.add(esri, esriPanel);
197
                        jPanelMain.add(usgs, getJPanelUSGS());
198
                        jPanelMain.add(iau2000, iauPanel);
199
                }
200
                
201
                return jPanelMain;                
202
        }
203
        
204
        public JPanel getCombopanel(){
205
                if (Combopanel == null){
206
                        Combopanel = new JPanel();
207
                        Combopanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,5));
208
                        Combopanel.add(getJLabelTipo());
209
                        Combopanel.add(getJComboOptions());
210
                }
211
                
212
                return Combopanel;
213
        }
214
        
215
        private JLabel getJLabelTipo(){
216
                JLabel jLabelTipo = new JLabel();
217
                jLabelTipo.setPreferredSize(new Dimension(50,25));
218
                jLabelTipo.setText(PluginServices.getText(this,"tipo")+":");
219
                return jLabelTipo;
220
        }
221
        
222
        public JComboBox getJComboOptions(){
223
                if (jComboOptions == null){
224
                        jComboOptions = new JComboBox(selection);
225
                        jComboOptions.setPreferredSize(new Dimension(100,25));                        
226
                        jComboOptions.setEditable(false);
227
                        jComboOptions.setSelectedIndex(0);                                        
228
                }
229
                return jComboOptions;
230
        }
231
                        
232
        public JPanel getJPanelUSGS() {        
233
                if (USGSpanel == null){
234
                        USGSpanel = new JPanel();
235
                        USGSpanel.setLayout(new GridLayout(3,4));
236
                        USGSpanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
237
                        USGSpanel.setPreferredSize(new Dimension(525, 400));                        
238
                }        
239
                return USGSpanel;
240
        }                        
241
        
242
        private JPanel getJPanelButtons() {
243
                if(jPanelButtons == null) {
244
                        jPanelButtons = new JPanel();
245
                        jPanelButtons.setLayout(new FlowLayout(FlowLayout.RIGHT));
246
                        //jPanelButtons.setPreferredSize(new Dimension(525,50));
247
                        jPanelButtons.add(getJButtonCancel(),null);
248
                        jPanelButtons.add(getJButtonAccept(),null);                        
249
                }
250
                return jPanelButtons;
251
        }
252
        
253
        public JButton getJButtonCancel() {
254
                if(jButonCancel == null) {
255
                        jButonCancel = new JButton();
256
                        jButonCancel.setText(PluginServices.getText(this,"cancel"));
257
                        jButonCancel.setPreferredSize(new Dimension(100,25));
258
                        jButonCancel.setMnemonic('C');
259
                        jButonCancel.setToolTipText("Cancel");                        
260
                }
261
                return jButonCancel;
262
        }
263
        
264
        public void cancelButton_actionPerformed(ActionEvent e) {                
265
                 PluginServices.getMDIManager().closeWindow(this);
266
        }
267
        
268
        public JButton getJButtonAccept() {
269
                if(jButtonAccept == null) {
270
                        jButtonAccept = new JButton();
271
                        jButtonAccept.setText(PluginServices.getText(this,"ok"));
272
                        jButtonAccept.setPreferredSize(new Dimension(100,25));
273
                        jButtonAccept.setEnabled(false);
274
                        jButtonAccept.setMnemonic('A');
275
                        jButtonAccept.setToolTipText(PluginServices.getText(this,"ok"));                        
276
                }
277
                return jButtonAccept;
278
        }
279
        
280
        public ICrs getProjection() {
281
                if (getDataSource().equals(PluginServices.getText(this,"EPSG"))){
282
                        return epsgPanel.getProjection();
283
                }
284
                else if (getDataSource().equals(PluginServices.getText(this,"IAU2000"))) {
285
                        return iauPanel.getProjection();
286
                }
287
                else if (getDataSource().equals(PluginServices.getText(this,"recientes"))) {
288
                        return crsRecentsPanel.getProjection();
289
                }
290
                else if (getDataSource().equals(PluginServices.getText(this,"ESRI"))) {
291
                        return esriPanel.getProjection();
292
                }
293
                else if (getDataSource().equals(PluginServices.getText(this,"newCRS"))) {
294
                        return newCrsPanel.getProjection();
295
                }
296
                return null;
297
        }
298
        
299
        public void setProjection(IProjection crs) {
300
                //setCrs((ICrs) crs);
301
        }
302
        
303
        public void setDataSource(String sour){
304
                dataSource = sour;
305
        }
306
        
307
        public String getDataSource(){
308
                return dataSource;
309
        }
310

    
311
        public WindowInfo getWindowInfo() {
312
                WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
313
                   m_viewinfo.setTitle(PluginServices.getText(this, "seleccionar_crs"));
314
                return m_viewinfo;
315
        }
316

    
317
        public EPSGpanel getEpsgPanel() {
318
                return epsgPanel;
319
        }
320

    
321
        
322

    
323
        public ESRIpanel getEsriPanel() {
324
                return esriPanel;
325
        }
326
        public IAU2000panel getIauPanel() {
327
                return iauPanel;
328
        }
329

    
330
        public CrsRecentsPanel getRecentsPanel() {
331
                return crsRecentsPanel;
332
        }
333
        
334
        public CrsAndTransformationRecentsPanel getCrsAndTransformationRecentsPanel() {
335
                return crsAndTransformationRecentsPanel;
336
        }
337

    
338
        public NewCRSPanel getNewCrsPanel() {
339
                return newCrsPanel;
340
        }
341

    
342
        public Object getWindowProfile() {
343
                return WindowInfo.DIALOG_PROFILE;
344
        }
345
}