Statistics
| Revision:

root / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / gui / selectPoints / DataPointPanel.java @ 8250

History | View | Annotate | Download (9.56 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 IVER T.I. 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
package org.gvsig.georeferencing.gui.selectPoints;
20

    
21
import java.awt.Color;
22
import java.awt.FlowLayout;
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
25

    
26
import javax.swing.JCheckBox;
27
import javax.swing.JLabel;
28
import javax.swing.JPanel;
29
import javax.swing.JTextField;
30

    
31
import com.iver.andami.PluginServices;
32

    
33
/**
34
 * Panel que contiene la informaci?n de cada punto. 
35
 * No contiene eventos, estos deben ser manejados desde la 
36
 * clase que lo llame.
37
 * 
38
 * @author Nacho Brodin (brodin_ign@gva.es)
39
 *
40
 */
41
public class DataPointPanel extends JPanel{
42
        
43
        //**********************Vars**********************************
44
        private JPanel pInfoPoint = null;
45
        private JPanel pX = null;
46
        private JPanel pY = null;
47
        private JPanel pLatitud = null;
48
        private JPanel pLongitud = null;
49
        private JTextField tX = null;
50
        private JLabel lX = null;
51
        private JLabel lY = null;
52
        private JTextField tY = null;
53
        private JLabel lLongitud = null;
54
        private JLabel lLatitud = null;
55
        private JTextField tLatitud = null;
56
        private JTextField tLongitud = null;
57
        //**********************End Vars******************************
58
        private JPanel jPanel = null;
59
        private JCheckBox cbActive = null;
60
        
61
        //**********************Methods*******************************
62
        /**
63
         * This is the default constructor
64
         */
65
        public DataPointPanel() {
66
                super();
67
                initialize();
68
        }
69

    
70
        /**
71
         * This method initializes this
72
         * 
73
         * @return void
74
         */
75
        private void initialize() {                
76
                GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
77
                gridBagConstraints6.insets = new java.awt.Insets(0,0,0,0);
78
                gridBagConstraints6.gridy = 4;
79
                gridBagConstraints6.gridx = 0;
80
                GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
81
                gridBagConstraints5.insets = new java.awt.Insets(0,0,0,0);
82
                gridBagConstraints5.gridy = 3;
83
                gridBagConstraints5.weighty = 0.0D;
84
                gridBagConstraints5.gridx = 0;
85
                GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
86
                gridBagConstraints4.insets = new java.awt.Insets(0,0,0,0);
87
                gridBagConstraints4.gridy = 2;
88
                gridBagConstraints4.weighty = 0.0D;
89
                gridBagConstraints4.gridx = 0;
90
                GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
91
                gridBagConstraints3.insets = new java.awt.Insets(0,0,0,0);
92
                gridBagConstraints3.gridy = 1;
93
                gridBagConstraints3.ipadx = 0;
94
                gridBagConstraints3.gridx = 0;
95
                
96
                this.setLayout(new GridBagLayout());
97
                this.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "punto"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
98
                this.setSize(new java.awt.Dimension(190,125));
99
                this.setPreferredSize(new java.awt.Dimension(190,125));
100
                this.add(getPX(), gridBagConstraints3);
101
                this.add(getPY(), gridBagConstraints4);
102
                this.add(getPLatitud(), gridBagConstraints5);
103
                this.add(getPLongitud(), gridBagConstraints6);
104
                this.add(getJPanel(), new GridBagConstraints());
105
        }
106
        
107
        /**
108
         * Esta funci?n resetea los controles del panel de info de un punto.
109
         */
110
        public void resetControls(String value){
111
                String data = "";
112
                if(value != null)
113
                        data = value;
114
                getTX().setText(data);
115
                getTY().setText(data);
116
                getLatitud().setText(data);
117
                getLongitud().setText(data);
118
                getCbActive().setSelected(true);
119
        }
120
        //**********************End Methods***************************
121
        
122
        //**********************Setters & Getters*********************
123
        /**
124
         * This method initializes pX        
125
         *         
126
         * @return javax.swing.JPanel        
127
         */
128
        private JPanel getPX() {
129
                if (pX == null) {
130
                        lX = new JLabel();
131
                        lX.setText("x: ");
132
                        FlowLayout flowLayout2 = new FlowLayout();
133
                        flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT);
134
                        pX = new JPanel();
135
                        pX.setLayout(flowLayout2);
136
                        pX.setPreferredSize(new java.awt.Dimension(170,20));
137
                        flowLayout2.setVgap(1);
138
                        flowLayout2.setHgap(0);
139
                        pX.add(lX, null);
140
                        pX.add(getTX(), null);
141
                }
142
                return pX;
143
        }
144

    
145
        /**
146
         * This method initializes pY        
147
         *         
148
         * @return javax.swing.JPanel        
149
         */
150
        private JPanel getPY() {
151
                if (pY == null) {
152
                        lY = new JLabel();
153
                        lY.setText("y: ");
154
                        FlowLayout flowLayout1 = new FlowLayout();
155
                        flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
156
                        pY = new JPanel();
157
                        pY.setLayout(flowLayout1);
158
                        pY.setPreferredSize(new java.awt.Dimension(170,20));
159
                        flowLayout1.setHgap(0);
160
                        flowLayout1.setVgap(1);
161
                        pY.add(lY, null);
162
                        pY.add(getTY(), null);
163
                }
164
                return pY;
165
        }
166

    
167
        /**
168
         * This method initializes pLatitud        
169
         *         
170
         * @return javax.swing.JPanel        
171
         */
172
        private JPanel getPLatitud() {
173
                if (pLatitud == null) {
174
                        lLongitud = new JLabel();
175
                        lLongitud.setText("X': ");
176
                        FlowLayout flowLayout3 = new FlowLayout();
177
                        flowLayout3.setAlignment(java.awt.FlowLayout.RIGHT);
178
                        pLatitud = new JPanel();
179
                        pLatitud.setLayout(flowLayout3);
180
                        pLatitud.setPreferredSize(new java.awt.Dimension(170,20));
181
                        flowLayout3.setHgap(0);
182
                        flowLayout3.setVgap(1);
183
                        pLatitud.add(lLongitud, null);
184
                        pLatitud.add(getLongitud(), null);
185
                }
186
                return pLatitud;
187
        }
188

    
189
        /**
190
         * This method initializes pLongitud        
191
         *         
192
         * @return javax.swing.JPanel        
193
         */
194
        private JPanel getPLongitud() {
195
                if (pLongitud == null) {
196
                        lLatitud = new JLabel();
197
                        lLatitud.setText("Y': ");
198
                        FlowLayout flowLayout4 = new FlowLayout();
199
                        flowLayout4.setAlignment(java.awt.FlowLayout.RIGHT);
200
                        pLongitud = new JPanel();
201
                        pLongitud.setLayout(flowLayout4);
202
                        pLongitud.setPreferredSize(new java.awt.Dimension(170,20));
203
                        flowLayout4.setHgap(0);
204
                        flowLayout4.setVgap(1);
205
                        pLongitud.add(lLatitud, null);
206
                        pLongitud.add(getLatitud(), null);
207
                }
208
                return pLongitud;
209
        }
210
        
211
        /**
212
         * Este m?todo inicializa el campo de texto que tiene la coordenada en X 
213
         * de la vista. Controla que le sean introducidos valores numericos y
214
         * salva el valor que contiene en la capa.        
215
         *         
216
         * @return javax.swing.JTextField        
217
         */
218
        public JTextField getTX() {
219
                if (tX == null) {
220
                        tX = new JTextField();
221
                        tX.setPreferredSize(new java.awt.Dimension(90,18));
222
                        tX.setHorizontalAlignment(javax.swing.JTextField.LEADING);
223
                }
224
                return tX;
225
        }
226

    
227
        /**
228
         * Este m?todo inicializa el campo de texto que tiene la coordenada en Y 
229
         * de la vista. Controla que le sean introducidos valores numericos y
230
         * salva el valor que contiene en la capa.        
231
         *         
232
         * @return javax.swing.JTextField        
233
         */
234
        public JTextField getTY() {
235
                if (tY == null) {
236
                        tY = new JTextField();
237
                        tY.setPreferredSize(new java.awt.Dimension(90,18));
238
                }
239
                return tY;
240
        }
241

    
242
        /**
243
         * Este m?todo inicializa el campo de texto que tiene la coordenada en Y 
244
         * del mundo real. Controla que le sean introducidos valores numericos y
245
         * salva el valor que contiene en la capa.        
246
         *         
247
         * @return javax.swing.JTextField        
248
         */
249
        public JTextField getLatitud() {
250
                if (tLatitud == null) {
251
                        tLatitud = new JTextField();
252
                        tLatitud.setPreferredSize(new java.awt.Dimension(111,18));
253
                        tLatitud.setHorizontalAlignment(javax.swing.JTextField.LEFT);
254
                }
255
                return tLatitud;
256
        }
257

    
258
        /**
259
         * Este m?todo inicializa el campo de texto que tiene la coordenada en X 
260
         * del mundo real. Controla que le sean introducidos valores numericos y
261
         * salva el valor que contiene en la capa.
262
         *         
263
         * @return javax.swing.JTextField        
264
         */
265
        public JTextField getLongitud() {
266
                if (tLongitud == null) {
267
                        tLongitud = new JTextField();
268
                        tLongitud.setPreferredSize(new java.awt.Dimension(111,18));
269
                        tLongitud.setHorizontalAlignment(javax.swing.JTextField.LEFT);
270
                }
271
                return tLongitud;
272
        }        
273
        //**********************End Setters & Getters*****************
274

    
275
        /**
276
         * This method initializes jPanel        
277
         *         
278
         * @return javax.swing.JPanel        
279
         */
280
        private JPanel getJPanel() {
281
                if (jPanel == null) {
282
                        FlowLayout flowLayout = new FlowLayout();
283
                        flowLayout.setVgap(0);
284
                        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
285
                        flowLayout.setHgap(0);
286
                        jPanel = new JPanel();
287
                        jPanel.setName("activo");
288
                        jPanel.setLayout(flowLayout);
289
                        jPanel.setPreferredSize(new java.awt.Dimension(170,19));
290
                        jPanel.add(getCbActive(), null);
291
                }
292
                return jPanel;
293
        }
294

    
295
        /**
296
         * This method initializes jCheckBox        
297
         *         
298
         * @return javax.swing.JCheckBox        
299
         */
300
        public JCheckBox getCbActive() {
301
                if (cbActive == null) {
302
                        cbActive = new JCheckBox();
303
                        cbActive.setText(PluginServices.getText(this,"activo"));
304
                        cbActive.setSelected(true);
305
                }
306
                return cbActive;
307
        }
308
        
309
        /**
310
     * Activa o desactiva este panel y todos los que lo componen
311
     * @param enabled variable booleana para la activaci?n y/o desactivaci?n
312
     */
313
    public void setEnabled(boolean enabled){
314
            Color color = Color.WHITE;
315
            if(!enabled)
316
                    color = this.getBackground();
317
            this.getTX().setBackground(color);
318
            this.getTX().setEnabled(enabled);
319
            this.getTY().setBackground(color);
320
            this.getTY().setEnabled(enabled);
321
            this.getLatitud().setBackground(color);
322
            this.getLatitud().setEnabled(enabled);
323
            this.getLongitud().setBackground(color);
324
            this.getLongitud().setEnabled(enabled);
325
    }
326
}