Statistics
| Revision:

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

History | View | Annotate | Download (7.09 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 crs_target = -1;
38
        
39
        int transformation_code = 0;
40
        private CRSSelectionPanel contentPane = null;
41
        private JPanel buttonPane = null;
42
        private JCheckBox withOutTrans = null;
43
        private JCheckBox nadgrids = null;
44
        private JCheckBox epsgTrans = null;
45
        private JCheckBox manualTrans = null;
46

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

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

    
259
        
260
}