Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libJCRS / src / org / gvsig / crs / ui / TransformationManualPanel.java @ 7020

History | View | Annotate | Download (9.53 KB)

1
package org.gvsig.crs.ui;
2

    
3
import java.awt.Component;
4
import java.awt.Dimension;
5
import java.awt.FlowLayout;
6
import java.awt.Font;
7
import java.awt.GridLayout;
8
import java.awt.event.ActionEvent;
9

    
10
import javax.swing.BorderFactory;
11
import javax.swing.JButton;
12
import javax.swing.JLabel;
13
import javax.swing.JPanel;
14
import javax.swing.JScrollPane;
15
import javax.swing.JTextArea;
16
import javax.swing.JTextField;
17

    
18
import org.cresques.ui.DefaultDialogPanel;
19

    
20
import com.iver.andami.PluginServices;
21
import com.iver.andami.ui.mdiManager.IWindow;
22
import com.iver.andami.ui.mdiManager.WindowInfo;
23
import com.iver.cit.gvsig.gui.panels.ProjChooserPanelTransformation;
24

    
25
public class TransformationManualPanel extends DefaultDialogPanel implements IWindow {
26
        
27
        private static final long serialVersionUID = 1L;
28
        
29
        private static boolean pressed = true;
30
        
31
        private JLabel x_Translation;
32
        private JLabel y_Translation;
33
        private JLabel z_Translation;
34
        private JLabel x_Rotation;
35
        private JLabel y_Rotation;
36
        private JLabel z_Rotation;
37
        private JLabel scale;
38
        
39
        private JTextField tx_Translation;
40
        private JTextField ty_Translation;
41
        private JTextField tz_Translation;
42
        private JTextField tx_Rotation;
43
        private JTextField ty_Rotation;
44
        private JTextField tz_Rotation;
45
        private JTextField tScale;
46
        
47
        private JLabel wkt;
48
        private JTextArea info;
49
        private JScrollPane areaScrollPane;
50
        
51
        private JPanel panel;
52
        private JPanel buttonPane;
53
        private JButton accept;
54
        private JButton cancel;
55
        
56
        private String cadWKT = "";
57
        
58
        ProjChooserPanelTransformation pcpt;
59
        
60
        public TransformationManualPanel(String cad, int code) {
61
                super(false);
62
                pcpt = new ProjChooserPanelTransformation();                
63
                cadWKT = cad;
64
                init();        
65
        }
66
        
67
        private void init() {
68
                this.add(getJPanel(), null);
69
                this.add(getJPanelParams(), null);
70
                this.add(getButtonPane(), null);
71
                
72
        }
73
        
74
        private JPanel getJPanelParams() {
75
                if(panel == null) {
76
                        panel = new JPanel();
77
                        panel.setLayout(new GridLayout(4,4));
78
                        panel.setLayout(new FlowLayout(FlowLayout.LEFT,5,5));
79
                        panel.setPreferredSize(new Dimension(520,300));
80
                        panel.add(getX_Translation(),null);
81
                        panel.add(getTx_Translation(),null);
82
                        panel.add(getX_Rotation(),null);
83
                        panel.add(getTx_Rotation(),null);
84
                        panel.add(getY_Translation(),null);
85
                        panel.add(getTy_Translation(),null);
86
                        panel.add(getY_Rotation(),null);
87
                        panel.add(getTy_Rotation(),null);
88
                        panel.add(getZ_Translation(),null);
89
                        panel.add(getTz_Translation(),null);
90
                        panel.add(getZ_Rotation(),null);
91
                        panel.add(getTz_Rotation(),null);
92
                        panel.add(getScale(),null);
93
                        panel.add(getTscale(),null);
94
                                        
95
                }
96
                return panel;
97
        }
98
        
99
        private JLabel getX_Translation() {
100
                if(x_Translation == null ) {
101
                        x_Translation = new JLabel();
102
                        x_Translation.setPreferredSize(new Dimension(80,20));
103
                        x_Translation.setFont(new Font("x_Translation:",Font.BOLD,15));
104
                        x_Translation.setText("x_Translation:");
105
                }
106
                return x_Translation;
107
        }
108
        
109
        private JLabel getY_Translation() {
110
                if(y_Translation == null ) {
111
                        y_Translation = new JLabel();
112
                        y_Translation.setPreferredSize(new Dimension(80,20));
113
                        y_Translation.setFont(new Font("y_Translation:",Font.BOLD,15));
114
                        y_Translation.setText("y_Translation:");
115
                }
116
                return y_Translation;
117
        }
118
        
119
        private JLabel getZ_Translation() {
120
                if(z_Translation == null ) {
121
                        z_Translation = new JLabel();
122
                        z_Translation.setPreferredSize(new Dimension(80,20));
123
                        z_Translation.setFont(new Font("z_Translation:",Font.BOLD,15));
124
                        z_Translation.setText("z_Translation:");
125
                }
126
                return z_Translation;
127
        }
128
        
129
        private JLabel getX_Rotation() {
130
                if(x_Rotation == null ) {
131
                        x_Rotation = new JLabel();
132
                        x_Rotation.setPreferredSize(new Dimension(80,20));
133
                        x_Rotation.setFont(new Font("x_Rotation:",Font.BOLD,15));
134
                        x_Rotation.setText("x_Rotation:");
135
                }
136
                return x_Translation;
137
        }
138
        
139
        private JLabel getY_Rotation() {
140
                if(y_Rotation == null ) {
141
                        y_Rotation = new JLabel();
142
                        y_Rotation.setPreferredSize(new Dimension(80,20));
143
                        y_Rotation.setFont(new Font("x_Rotation:",Font.BOLD,15));
144
                        y_Rotation.setText("y_Rotation:");
145
                }
146
                return y_Translation;
147
        }
148
        
149
        private JLabel getZ_Rotation() {
150
                if(z_Rotation == null ) {
151
                        z_Rotation = new JLabel();
152
                        z_Rotation.setPreferredSize(new Dimension(80,20));
153
                        z_Rotation.setFont(new Font("x_Translation:",Font.BOLD,15));
154
                        z_Rotation.setText("z_Rotation:");
155
                }
156
                return z_Rotation;
157
        }
158
        
159
        private JLabel getScale() {
160
                if(scale == null ) {
161
                        scale = new JLabel();
162
                        scale.setPreferredSize(new Dimension(80,20));
163
                        scale.setFont(new Font("scale:",Font.BOLD,15));
164
                        scale.setText("scale:");
165
                }
166
                return scale;
167
        }
168
        
169
        private JTextField getTx_Translation() {
170
                if(tx_Translation == null ) {
171
                        tx_Translation = new JTextField();
172
                        tx_Translation.setPreferredSize(new Dimension(100,20));
173
                        tx_Translation.setFont(new Font("",Font.ITALIC,10));
174
                        tx_Translation.setText("");
175
                        tx_Translation.setEditable(true);
176
                }
177
                return tx_Translation;
178
        }
179
        
180
        private JTextField getTy_Translation() {
181
                if(ty_Translation == null ) {
182
                        ty_Translation = new JTextField();
183
                        ty_Translation.setPreferredSize(new Dimension(100,20));
184
                        ty_Translation.setFont(new Font("",Font.ITALIC,10));
185
                        ty_Translation.setText("");
186
                        ty_Translation.setEditable(true);
187
                }
188
                return ty_Translation;
189
        }
190
        
191
        private JTextField getTz_Translation() {
192
                if(tz_Translation == null ) {
193
                        tz_Translation = new JTextField();
194
                        tz_Translation.setPreferredSize(new Dimension(100,20));
195
                        tz_Translation.setFont(new Font("",Font.ITALIC,10));
196
                        tz_Translation.setText("");
197
                        tz_Translation.setEditable(true);
198
                }
199
                return tz_Translation;
200
        }
201
        
202
        private JTextField getTx_Rotation() {
203
                if(tx_Rotation == null ) {
204
                        tx_Rotation = new JTextField();
205
                        tx_Rotation.setPreferredSize(new Dimension(100,20));
206
                        tx_Rotation.setFont(new Font("",Font.ITALIC,10));
207
                        tx_Rotation.setText("");
208
                        tx_Rotation.setEditable(true);
209
                }
210
                return tx_Rotation;
211
        }
212
        
213
        private JTextField getTy_Rotation() {
214
                if(ty_Rotation == null ) {
215
                        ty_Rotation = new JTextField();
216
                        ty_Rotation.setPreferredSize(new Dimension(100,20));
217
                        ty_Rotation.setFont(new Font("",Font.ITALIC,10));
218
                        ty_Rotation.setText("");
219
                        ty_Rotation.setEditable(true);
220
                }
221
                return ty_Rotation;
222
        }
223
        
224
        private JTextField getTz_Rotation() {
225
                if(tz_Rotation == null ) {
226
                        tz_Rotation = new JTextField();
227
                        tz_Rotation.setPreferredSize(new Dimension(100,20));
228
                        tz_Rotation.setFont(new Font("",Font.ITALIC,10));
229
                        tz_Rotation.setText("");
230
                        tz_Rotation.setEditable(true);
231
                }
232
                return tz_Rotation;
233
        }
234
        
235
        private JTextField getTscale() {
236
                if(tScale == null ) {
237
                        tScale = new JTextField();
238
                        tScale.setPreferredSize(new Dimension(100,20));
239
                        tScale.setFont(new Font("",Font.ITALIC,10));
240
                        tScale.setText("");
241
                        tScale.setEditable(true);
242
                }
243
                return tScale;
244
        }
245
        
246
        private JPanel getJPanel(){
247
                if (panel == null) {
248
                        panel = new JPanel();
249
                        panel.setLayout(new GridLayout(1,2));
250
                        panel.setLayout(new FlowLayout(FlowLayout.LEADING,5,10));
251
                        panel.setPreferredSize(new Dimension(525, 110));
252
                        panel.add(getLabel());
253
                        panel.add(getScrollPanelArea());
254
                }
255
                return panel;
256
        }
257
        
258
        private JScrollPane getScrollPanelArea() {
259
                if(areaScrollPane == null) {
260
                        areaScrollPane = new JScrollPane(getInfo());
261
                        areaScrollPane.setVerticalScrollBarPolicy(
262
                                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
263
                        areaScrollPane.setPreferredSize(new Dimension(420, 100));
264
                        areaScrollPane.setBorder(
265
                            BorderFactory.createCompoundBorder(
266
                                BorderFactory.createCompoundBorder(
267
                                                BorderFactory.createTitledBorder("Wkt"),
268
                                                BorderFactory.createEmptyBorder(2,2,2,2)),
269
                                areaScrollPane.getBorder()));
270
                }
271
                return areaScrollPane;
272
        }
273

    
274
        private Component getLabel() {
275
                if (wkt == null){
276
                        wkt = new JLabel();
277
                        wkt.setPreferredSize(new Dimension(90, 80));
278
                        wkt.setText("Cadena WKT: ");
279
                }                
280
                return wkt;
281
        }
282
        
283
        private Component getInfo() {
284
                if (info == null){
285
                        info = new JTextArea();
286
                        info.setLineWrap(true);
287
                        info.setWrapStyleWord(true);
288
                        info.setPreferredSize(new Dimension(400, 240));
289
                        info.setEditable(false);
290
                        info.setText(cadWKT);
291
                }
292
                return info;
293
        }
294
        
295
        
296
        private JPanel getButtonPane() {
297
                if(buttonPane == null) {
298
                        buttonPane = new JPanel();
299
                        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
300
                        buttonPane.setPreferredSize(new Dimension(525,50));
301
                        buttonPane.add(getButtonAccept(),null);
302
                        buttonPane.add(getButtonCancel(),null);
303
                }
304
                return buttonPane;
305
        }
306
        
307
        private JButton getButtonCancel() {
308
                if(cancel == null) {
309
                        cancel = new JButton();
310
                        cancel.setText("Cancelar");
311
                        cancel.setPreferredSize(new Dimension(100,25));
312
                        cancel.setMnemonic('C');
313
                        cancel.setToolTipText("Cancel");
314
                        cancel.addActionListener(new java.awt.event.ActionListener() { 
315
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
316
                                        cancelButton_actionPerformed(e);                
317
                                }        
318
                        });
319
                }
320
                return cancel;
321
        }
322
        
323
        public void cancelButton_actionPerformed(ActionEvent e) {
324
                PluginServices.getMDIManager().closeWindow(this);
325
        }
326
        
327
        private JButton getButtonAccept() {
328
                if(accept == null) {
329
                        accept = new JButton();
330
                        accept.setText("Aceptar");
331
                        accept.setPreferredSize(new Dimension(100,25));
332
                        accept.setMnemonic('A');
333
                        accept.setToolTipText("Accept");
334
                        accept.addActionListener(new java.awt.event.ActionListener() { 
335
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
336
                                        acceptButton_actionPerformed(e);                
337
                                }        
338
                        });
339
                }
340
                return accept;
341
        }
342
        
343
        public void acceptButton_actionPerformed(ActionEvent e) {
344
                PluginServices.getMDIManager().closeWindow(this);
345
        }
346
        
347
        public static boolean isPressed() { return pressed; }
348

    
349
        
350

    
351
        public WindowInfo getWindowInfo() {
352
                WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
353
                   m_viewinfo.setTitle(PluginServices.getText(this,"Manual"));
354
                return m_viewinfo;
355
        }
356

    
357
}