Statistics
| Revision:

root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / CoordinatesPanel.java @ 9709

History | View | Annotate | Download (11.5 KB)

1
package com.iver.cit.gvsig.gui.panels;
2

    
3
import java.awt.Dimension;
4
import java.awt.FlowLayout;
5
import java.awt.GridBagConstraints;
6
import java.awt.GridBagLayout;
7
import java.awt.geom.Rectangle2D;
8

    
9
import javax.swing.JLabel;
10
import javax.swing.JPanel;
11
import javax.swing.JTextField;
12

    
13
import com.iver.andami.PluginServices;
14

    
15
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
16
 *
17
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
18
 *
19
 * This program is free software; you can redistribute it and/or
20
 * modify it under the terms of the GNU General Public License
21
 * as published by the Free Software Foundation; either version 2
22
 * of the License, or (at your option) any later version.
23
 *
24
 * This program is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 * GNU General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU General Public License
30
 * along with this program; if not, write to the Free Software
31
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
32
 *
33
 * For more information, contact:
34
 *
35
 *  Generalitat Valenciana
36
 *   Conselleria d'Infraestructures i Transport
37
 *   Av. Blasco Ib??ez, 50
38
 *   46010 VALENCIA
39
 *   SPAIN
40
 *
41
 *      +34 963862235
42
 *   gvsig@gva.es
43
 *      www.gvsig.gva.es
44
 *
45
 *    or
46
 *
47
 *   IVER T.I. S.A
48
 *   Salamanca 50
49
 *   46005 Valencia
50
 *   Spain
51
 *
52
 *   +34 963163400
53
 *   dac@iver.es
54
 */
55
/* CVS MESSAGES:
56
 *
57
 * $Id: CoordinatesPanel.java 9709 2007-01-12 13:09:42Z jorpiell $
58
 * $Log$
59
 * Revision 1.3  2007-01-12 13:09:41  jorpiell
60
 * added searches by area
61
 *
62
 * Revision 1.2  2007/01/10 09:01:25  jorpiell
63
 * The coordinates panel is opened with the view coordinates
64
 *
65
 * Revision 1.1  2006/12/22 11:45:53  jorpiell
66
 * Actualizado el driver del WFS
67
 *
68
 *
69
 */
70
/**
71
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
72
 */
73
public class CoordinatesPanel extends JPanel {
74
        private static final int COORDINATES_WIDTH = 120;
75
        private static final int COORDINATES_HEIGHT = 19;
76
        private static final int LABELS_WIDTH = 60;
77
        private static final int PANEL_HEIGHT = 60;
78
        private JPanel ulxLabelPanel = null;
79
        private JPanel brxLabelPanel = null;
80
        private JLabel ulxLabel = null;
81
        private JLabel brxLabel = null;
82
        private JPanel labelsLeftPanel = null;
83
        private JPanel textsLeftPanel = null;
84
        private JPanel ulxTextPanel = null;
85
        private JPanel brxTextPanel = null;
86
        private JTextField brxText = null;
87
        private JTextField ulxText = null;
88
        private JTextField jTextField = null;
89
        private JPanel jPanel5 = null;
90
        private JTextField jTextField1 = null;
91
        private JPanel labelsRigthPanel = null;
92
        private JPanel ulyLabelPanel = null;
93
        private JLabel ulyLabel = null;
94
        private JPanel bryLabelPanel = null;
95
        private JLabel bryLabel = null;
96
        private JPanel textsRigthPanel = null;
97
        private JPanel ulyTextPanel = null;
98
        private JTextField ulyText = null;
99
        private JPanel bryTextPanel = null;
100
        private JTextField bryText = null;
101
        /**
102
         * This is the default constructor
103
         */
104
        public CoordinatesPanel() {
105
                super();
106
                initialize();
107
        }
108

    
109
        /**
110
         * This method initializes this
111
         * 
112
         * @return void
113
         */
114
        private void initialize() {                
115
                
116
                this.setLayout(new GridBagLayout());
117
                this.setSize(new java.awt.Dimension(367,60));
118
                this.add(getLabelsLeftPanel(), new GridBagConstraints());
119
                this.add(getTextsLeftPanel(), new GridBagConstraints());
120
                this.add(getLabelsRigthPanel(), new GridBagConstraints());
121
                this.add(getTextsRigthPanel(), new GridBagConstraints());
122
        }
123
        
124
        /**
125
         * This method initializes pX        
126
         *         
127
         * @return javax.swing.JPanel        
128
         */
129
        private JPanel getUlxLabelPanel() {
130
                if (ulxLabelPanel == null) {
131
                        ulxLabel = new JLabel();
132
                        ulxLabel.setText(PluginServices.getText(this, "ulx") + ": ");
133
                        FlowLayout flowLayout2 = new FlowLayout();
134
                        flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT);
135
                        ulxLabelPanel = new JPanel();
136
                        ulxLabelPanel.setLayout(flowLayout2);
137
                        ulxLabelPanel.setPreferredSize(new java.awt.Dimension(LABELS_WIDTH,COORDINATES_HEIGHT));
138
                        flowLayout2.setVgap(1);
139
                        flowLayout2.setHgap(0);
140
                        ulxLabelPanel.add(ulxLabel, null);
141
                }
142
                return ulxLabelPanel;
143
        }
144

    
145
        /**
146
         * This method initializes pY        
147
         *         
148
         * @return javax.swing.JPanel        
149
         */
150
        private JPanel getBrxLabelPanel() {
151
                if (brxLabelPanel == null) {
152
                        brxLabel = new JLabel();
153
                        brxLabel.setText(PluginServices.getText(this, "brx") + ": ");
154
                        FlowLayout flowLayout1 = new FlowLayout();
155
                        flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
156
                        brxLabelPanel = new JPanel();
157
                        brxLabelPanel.setLayout(flowLayout1);
158
                        brxLabelPanel.setPreferredSize(new java.awt.Dimension(LABELS_WIDTH,COORDINATES_HEIGHT));
159
                        flowLayout1.setHgap(0);
160
                        flowLayout1.setVgap(1);
161
                        brxLabelPanel.add(brxLabel, null);
162
                }
163
                return brxLabelPanel;
164
        }
165

    
166
        
167
        /**
168
         * This method initializes jPanel        
169
         *         
170
         * @return javax.swing.JPanel        
171
         */
172
        private JPanel getLabelsLeftPanel() {
173
                if (labelsLeftPanel == null) {
174
                        labelsLeftPanel = new JPanel();
175
                        labelsLeftPanel.setPreferredSize(new Dimension(LABELS_WIDTH,PANEL_HEIGHT));
176
                        labelsLeftPanel.add(getUlxLabelPanel(), null);
177
                        labelsLeftPanel.add(getBrxLabelPanel(), null);
178
                }
179
                return labelsLeftPanel;
180
        }
181

    
182
        /**
183
         * This method initializes jPanel        
184
         *         
185
         * @return javax.swing.JPanel        
186
         */
187
        private JPanel getTextsLeftPanel() {
188
                if (textsLeftPanel == null) {
189
                        textsLeftPanel = new JPanel();
190
                        textsLeftPanel.setPreferredSize(new Dimension(COORDINATES_WIDTH,PANEL_HEIGHT));
191
                        textsLeftPanel.add(getUlxTextPanel(), null);
192
                        textsLeftPanel.add(getBrxTextPanel(), null);
193
                }
194
                return textsLeftPanel;
195
        }
196

    
197
        /**
198
         * This method initializes jPanel        
199
         *         
200
         * @return javax.swing.JPanel        
201
         */
202
        private JPanel getUlxTextPanel() {
203
                if (ulxTextPanel == null) {
204
                        FlowLayout flowLayout = new FlowLayout();
205
                        flowLayout.setHgap(0);
206
                        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
207
                        flowLayout.setVgap(1);
208
                        ulxTextPanel = new JPanel();
209
                        ulxTextPanel.setPreferredSize(new Dimension(COORDINATES_WIDTH, 22));
210
                        ulxTextPanel.setLayout(flowLayout);
211
                        ulxTextPanel.add(getUlxText(), null);
212
                }
213
                return ulxTextPanel;
214
        }
215

    
216
        /**
217
         * This method initializes jPanel1        
218
         *         
219
         * @return javax.swing.JPanel        
220
         */
221
        private JPanel getBrxTextPanel() {
222
                if (brxTextPanel == null) {
223
                        FlowLayout flowLayout5 = new FlowLayout();
224
                        flowLayout5.setHgap(0);
225
                        flowLayout5.setAlignment(java.awt.FlowLayout.LEFT);
226
                        flowLayout5.setVgap(1);
227
                        brxTextPanel = new JPanel();
228
                        brxTextPanel.setPreferredSize(new Dimension(COORDINATES_WIDTH, 22));
229
                        brxTextPanel.setLayout(flowLayout5);
230
                        brxTextPanel.add(getBrxText(), null);
231
                }
232
                return brxTextPanel;
233
        }
234

    
235
        /**
236
         * This method initializes cityText        
237
         *         
238
         * @return javax.swing.JTextField        
239
         */
240
        private JTextField getBrxText() {
241
                if (brxText == null) {
242
                        brxText = new JTextField();
243
                        brxText.setPreferredSize(new Dimension(COORDINATES_WIDTH,COORDINATES_HEIGHT));
244
                }
245
                return brxText;
246
        }
247
        
248
        /**
249
         * This method initializes ulxText        
250
         *         
251
         * @return javax.swing.JTextField        
252
         */
253
        private JTextField getUlxText() {
254
                if (ulxText == null) {
255
                        ulxText = new JTextField();
256
                        ulxText.setPreferredSize(new Dimension(COORDINATES_WIDTH, COORDINATES_HEIGHT));
257
                }
258
                return ulxText;
259
        }                
260

    
261
        /**
262
         * This method initializes jPanel        
263
         *         
264
         * @return javax.swing.JPanel        
265
         */
266
        private JPanel getLabelsRigthPanel() {
267
                if (labelsRigthPanel == null) {
268
                        labelsRigthPanel = new JPanel();
269
                        labelsRigthPanel.setPreferredSize(new Dimension(LABELS_WIDTH,PANEL_HEIGHT));
270
                        labelsRigthPanel.add(getUlyLabelPanel(), null);
271
                        labelsRigthPanel.add(getJPanel7(), null);
272
                }
273
                return labelsRigthPanel;
274
        }
275

    
276
        /**
277
         * This method initializes jPanel6        
278
         *         
279
         * @return javax.swing.JPanel        
280
         */
281
        private JPanel getUlyLabelPanel() {
282
                if (ulyLabelPanel == null) {
283
                        ulyLabel = new JLabel();
284
                        ulyLabel.setText(PluginServices.getText(this, "uly") + ": ");
285
                        FlowLayout flowLayout3 = new FlowLayout();
286
                        flowLayout3.setHgap(0);
287
                        flowLayout3.setAlignment(FlowLayout.RIGHT);
288
                        flowLayout3.setVgap(1);
289
                        ulyLabelPanel = new JPanel();
290
                        ulyLabelPanel.setPreferredSize(new Dimension(LABELS_WIDTH, COORDINATES_HEIGHT));
291
                        ulyLabelPanel.setLayout(flowLayout3);
292
                        ulyLabelPanel.add(ulyLabel, null);
293
                }
294
                return ulyLabelPanel;
295
        }
296

    
297
        /**
298
         * This method initializes jPanel7        
299
         *         
300
         * @return javax.swing.JPanel        
301
         */
302
        private JPanel getJPanel7() {
303
                if (bryLabelPanel == null) {
304
                        bryLabel = new JLabel();
305
                        bryLabel.setText(PluginServices.getText(this, "bry") + ": ");
306
                        FlowLayout flowLayout4 = new FlowLayout();
307
                        flowLayout4.setHgap(0);
308
                        flowLayout4.setAlignment(FlowLayout.RIGHT);
309
                        flowLayout4.setVgap(1);
310
                        bryLabelPanel = new JPanel();
311
                        bryLabelPanel.setPreferredSize(new Dimension(LABELS_WIDTH, COORDINATES_HEIGHT));
312
                        bryLabelPanel.setLayout(flowLayout4);
313
                        bryLabelPanel.add(bryLabel, null);
314
                }
315
                return bryLabelPanel;
316
        }
317

    
318
        /**
319
         * This method initializes jPanel3        
320
         *         
321
         * @return javax.swing.JPanel        
322
         */
323
        private JPanel getTextsRigthPanel() {
324
                if (textsRigthPanel == null) {
325
                        textsRigthPanel = new JPanel();
326
                        textsRigthPanel.setPreferredSize(new Dimension(COORDINATES_WIDTH,PANEL_HEIGHT));
327
                        textsRigthPanel.add(getUlyTextPanel(), null);
328
                        textsRigthPanel.add(getBryTextPanel(), null);
329
                }
330
                return textsRigthPanel;
331
        }
332

    
333
        /**
334
         * This method initializes jPanel8        
335
         *         
336
         * @return javax.swing.JPanel        
337
         */
338
        private JPanel getUlyTextPanel() {
339
                if (ulyTextPanel == null) {
340
                        FlowLayout flowLayout8 = new FlowLayout();
341
                        flowLayout8.setHgap(0);
342
                        flowLayout8.setAlignment(FlowLayout.LEFT);
343
                        flowLayout8.setVgap(1);
344
                        ulyTextPanel = new JPanel();
345
                        ulyTextPanel.setPreferredSize(new Dimension(120, 22));
346
                        ulyTextPanel.setLayout(flowLayout8);
347
                        ulyTextPanel.add(getUlyText(), null);
348
                }
349
                return ulyTextPanel;
350
        }
351

    
352
        /**
353
         * This method initializes jTextField2        
354
         *         
355
         * @return javax.swing.JTextField        
356
         */
357
        private JTextField getUlyText() {
358
                if (ulyText == null) {
359
                        ulyText = new JTextField();
360
                        ulyText.setPreferredSize(new Dimension(120, 19));
361
                }
362
                return ulyText;
363
        }
364

    
365
        /**
366
         * This method initializes jPanel9        
367
         *         
368
         * @return javax.swing.JPanel        
369
         */
370
        private JPanel getBryTextPanel() {
371
                if (bryTextPanel == null) {
372
                        FlowLayout flowLayout9 = new FlowLayout();
373
                        flowLayout9.setHgap(0);
374
                        flowLayout9.setAlignment(FlowLayout.LEFT);
375
                        flowLayout9.setVgap(1);
376
                        bryTextPanel = new JPanel();
377
                        bryTextPanel.setPreferredSize(new Dimension(120, 22));
378
                        bryTextPanel.setLayout(flowLayout9);
379
                        bryTextPanel.add(getBryText(), null);
380
                }
381
                return bryTextPanel;
382
        }
383

    
384
        /**
385
         * This method initializes jTextField3        
386
         *         
387
         * @return javax.swing.JTextField        
388
         */
389
        private JTextField getBryText() {
390
                if (bryText == null) {
391
                        bryText = new JTextField();
392
                        bryText.setPreferredSize(new Dimension(120, 19));
393
                }
394
                return bryText;
395
        }
396
        
397
        /**
398
         * Sets the extent
399
         * @param extent
400
         */
401
        public void setExtent(Rectangle2D extent){
402
                getUlxText().setText(String.valueOf(extent.getMaxX()));
403
                getUlyText().setText(String.valueOf(extent.getMaxY()));
404
                getBrxText().setText(String.valueOf(extent.getMinX()));
405
                getBryText().setText(String.valueOf(extent.getMinY()));
406
        }
407
        
408
        /**
409
         * Gets the extent
410
         * @return
411
         */
412
        public Rectangle2D getExtent(){
413
                if ((!getUlxText().getText().equals("")) &&
414
                                (!getUlyText().getText().equals("")) &&
415
                                (!getBrxText().getText().equals("")) &&
416
                                (!getBryText().getText().equals(""))){
417
                        Rectangle2D r2d = new Rectangle2D.Double(new Double(getUlxText().getText()).doubleValue(),
418
                                        new Double(getUlyText().getText()).doubleValue(),
419
                                        new Double(getBrxText().getText()).doubleValue(),
420
                                        new Double(getBryText().getText()).doubleValue());
421
                        return r2d;
422
                }
423
                return null;
424
        }
425
}  //  @jve:decl-index=0:visual-constraint="10,10"