Statistics
| Revision:

root / trunk / libraries / libJCRS / src / org / gvsig / crs / ui / CrsView.java @ 6871

History | View | Annotate | Download (7.02 KB)

1
package org.gvsig.crs.ui;
2

    
3
import java.awt.Dimension;
4
import java.awt.FlowLayout;
5
import java.awt.GridLayout;
6
import java.awt.event.ActionEvent;
7

    
8
import javax.swing.JButton;
9
import javax.swing.JCheckBox;
10
import javax.swing.JPanel;
11

    
12
import org.cresques.cts.IProjection;
13
import org.gvsig.crs.EpsgConnection;
14
import org.gvsig.crs.ICrs;
15

    
16
import com.iver.andami.PluginServices;
17
import com.iver.andami.ui.mdiManager.View;
18
import com.iver.andami.ui.mdiManager.ViewInfo;
19
import com.iver.cit.gvsig.gui.panels.ProjChooserPanel;
20
import com.iver.cit.gvsig.gui.panels.ProjChooserPanelTransformation;
21

    
22
public class CrsView extends JPanel implements View {
23

    
24
        private static final long serialVersionUID = 1L;
25
        
26
        EpsgConnection connect;
27
        
28
        boolean tra = false; //para que si tenemos seleccionada transformacion nos muestre los parametros
29
        
30
        ProjChooserPanelTransformation pcpt;
31
        ProjChooserPanel pcp;
32
        
33
        private JButton cancel = null;
34
        private JButton next = null;
35
        private JPanel jPanelButton = null;
36
        
37
        int transformation_code = 0;
38
        private CRSSelectionPanel contentPane = null;
39
        private JPanel buttonPane = null;
40
        private JCheckBox withOutTrans = null;
41
        private JCheckBox nadgrids = null;
42
        private JCheckBox epsgTrans = null;
43
        private JCheckBox manualTrans = null;
44

    
45
        public CrsView() {
46
                super();
47
                pcpt = new ProjChooserPanelTransformation();
48
                pcp = new ProjChooserPanel();
49
                initialize();
50
        }
51
        private void initialize() { 
52
                this.add(getContentPanel(),null);
53
                getJPanel();                
54
        }
55
         
56
        private void getJPanel() {
57
                this.add(getCheckButtonPane(), null);
58
                this.add(getButtons(), null);
59
        }
60
        
61
        public CRSSelectionPanel getContentPanel() {
62
            if (contentPane == null) {
63
                contentPane = new CRSSelectionPanel();
64
                contentPane.setLayout(new GridLayout(3,3));
65
                contentPane.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
66
                    contentPane.setPreferredSize(new Dimension(650,370));
67
                
68
       }
69
      return contentPane;
70
    }
71
        
72
        private JPanel getCheckButtonPane() {
73
                if(buttonPane == null) {
74
                        buttonPane = new JPanel();
75
                        buttonPane.setPreferredSize(new Dimension(400,100));
76
                        buttonPane.setLayout(new GridLayout(0,2));
77
                        buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
78
                        buttonPane.add(getWithOutTrans(), null);
79
                        buttonPane.add(getNadgrids(), null);
80
                        buttonPane.add(getEpsgTrans(), null);
81
                        buttonPane.add(getManualTrans(), null);
82
                }
83
                return buttonPane;
84
        }
85
        
86
        private JCheckBox getWithOutTrans() {
87
                if(withOutTrans == null) {
88
                        withOutTrans = new JCheckBox();
89
                        withOutTrans.setText("Sin transformacion");
90
                        withOutTrans.setSelected(true);
91
                        withOutTrans.setPreferredSize(new Dimension(175,20));
92
                        withOutTrans.addActionListener(new java.awt.event.ActionListener() { 
93
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
94
                                        withOutTrans_actionPerformed(e);                                        
95
                                }
96
                        });
97
                }
98
                return withOutTrans;
99
        }
100
        
101
        private void withOutTrans_actionPerformed(ActionEvent e) { 
102
                 if(!withOutTrans.isSelected())
103
                  withOutTrans.setSelected(true);
104
                 epsgTrans.setSelected(false);
105
                manualTrans.setSelected(false);
106
                nadgrids.setSelected(false);
107
        }
108
        
109
        private JCheckBox getNadgrids() {
110
                if(nadgrids == null) {
111
                        nadgrids = new JCheckBox();
112
                        nadgrids.setText("+nadgrids");
113
                        nadgrids.setSelected(false);
114
                        nadgrids.setPreferredSize(new Dimension(175,20));
115
                        nadgrids.addActionListener(new java.awt.event.ActionListener() { 
116
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
117
                                        nadgrids_actionPerformed(e);                                        
118
                                }
119
                        });
120
                }
121
                return nadgrids;
122
        }
123
        
124
        private void nadgrids_actionPerformed(ActionEvent e) {
125
        
126
                if(!nadgrids.isSelected())
127
                        nadgrids.setSelected(true);
128
                withOutTrans.setSelected(false);
129
                epsgTrans.setSelected(false);
130
                manualTrans.setSelected(false);
131
         }
132
        
133
        private JCheckBox getEpsgTrans() {
134
                if(epsgTrans == null) {
135
                        epsgTrans = new JCheckBox();
136
                        epsgTrans.setText("Transformacion epsg");
137
                        epsgTrans.setSelected(false);
138
                        epsgTrans.setPreferredSize(new Dimension(175,20));
139
                        epsgTrans.addActionListener(new java.awt.event.ActionListener() { 
140
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
141
                                        epsgTrans_actionPerformed(e);                                        
142
                                }
143
                        });
144
                }
145
                return epsgTrans;
146
        }
147
        
148
        private void epsgTrans_actionPerformed(ActionEvent e) {
149
                if(!epsgTrans.isSelected())
150
                        epsgTrans.setSelected(true);
151
                nadgrids.setSelected(false);
152
                withOutTrans.setSelected(false);
153
                manualTrans.setSelected(false);
154
        }
155
        
156
        private JCheckBox getManualTrans() {
157
                if(manualTrans == null) {
158
                        manualTrans = new JCheckBox();
159
                        manualTrans.setText("Transformacion manual");
160
                        manualTrans.setSelected(false);
161
                        manualTrans.setPreferredSize(new Dimension(175,20));
162
                        manualTrans.addActionListener(new java.awt.event.ActionListener() { 
163
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
164
                                        manualTrans_actionPerformed(e);                                        
165
                                }
166
                        });
167
                }
168
                return manualTrans;
169
        }
170

    
171
        private void manualTrans_actionPerformed(ActionEvent e) {
172
                if(!manualTrans.isSelected())
173
                        manualTrans.setSelected(true);
174
                nadgrids.setSelected(false);
175
                epsgTrans.setSelected(false);
176
                withOutTrans.setSelected(false);
177
        }
178
        
179
        
180
        private JPanel getButtons() {
181
                if(jPanelButton == null) {
182
                        jPanelButton = new JPanel();
183
                        jPanelButton.setPreferredSize(new Dimension(650,50));
184
                        jPanelButton.setLayout(new GridLayout(0,1));
185
                        jPanelButton.setLayout(new FlowLayout(FlowLayout.RIGHT,5,5));
186
                        jPanelButton.add(getCancel(), null);
187
                        jPanelButton.add(getNext(), null);
188
                        
189
                }
190
                return jPanelButton;
191
        }
192
        
193
        private JButton getNext() {
194
                if(next == null) {
195
                        next = new JButton();
196
                        next.setText("Siguiente");
197
                        next.setMnemonic('S');
198
                        next.setPreferredSize(new Dimension(100,25));
199
                        next.addActionListener(new java.awt.event.ActionListener() { 
200
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
201
                                        next_actionPerformed(e);                                        
202
                                }
203
                        });
204
                }
205
                return next;
206
        }
207
        
208
        private void next_actionPerformed(ActionEvent e) {
209
                if(epsgTrans.isSelected() == true && contentPane.getCodeCRS() != -1){
210
                        PluginServices.getMDIManager().closeView(this);
211
                        TransformationEpsgPanel tr = new TransformationEpsgPanel(contentPane.getWKT(),contentPane.getCodeCRS());
212
                        tr.setSize(new Dimension(550, 400));
213
                        tr.setLayout(new GridLayout(2,2));
214
                        tr.setLayout(new FlowLayout(FlowLayout.LEFT,5,10));
215
                        PluginServices.getMDIManager().addView(tr);
216
                        
217
                }
218
                        
219
        }
220
        
221
        
222
        private JButton getCancel() {
223
                if(cancel == null) {
224
                        cancel = new JButton();
225
                        cancel.setText("Cancelar");
226
                        cancel.setMnemonic('C');
227
                        cancel.setPreferredSize(new Dimension(100,25));
228
                        cancel.addActionListener(new java.awt.event.ActionListener() { 
229
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
230
                                        cancel_actionPerformed(e);                                        
231
                                }
232
                        });
233
                }
234
                return cancel;
235
        }
236
        
237
        private void cancel_actionPerformed(ActionEvent e) {
238
                PluginServices.getMDIManager().closeView(this);
239
        }
240
        
241
        public ICrs getProjection() {
242
                return null;
243
        }
244
        
245
        public void setProjection(IProjection crs) {
246
                //setCrs((ICrs) crs);
247
        }
248
        
249
        public ViewInfo getViewInfo() {
250
                ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
251
                   m_viewinfo.setTitle(PluginServices.getText(this,"CrsView"));
252
                return m_viewinfo;
253
        }
254

    
255
        
256
}