root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / CoordinatesPanel.java @ 9754
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 9754 2007-01-16 13:21:54Z ppiqueras $
|
58 |
* $Log$
|
59 |
* Revision 1.4 2007-01-16 13:21:54 ppiqueras
|
60 |
* Reorganizado el c?digo para que sea m?s f?cil de leer y entender.
|
61 |
*
|
62 |
* Revision 1.3 2007/01/12 13:09:41 jorpiell
|
63 |
* added searches by area
|
64 |
*
|
65 |
* Revision 1.2 2007/01/10 09:01:25 jorpiell
|
66 |
* The coordinates panel is opened with the view coordinates
|
67 |
*
|
68 |
* Revision 1.1 2006/12/22 11:45:53 jorpiell
|
69 |
* Actualizado el driver del WFS
|
70 |
*
|
71 |
*
|
72 |
*/
|
73 |
/**
|
74 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
75 |
*/
|
76 |
public class CoordinatesPanel extends JPanel { |
77 |
private static final int COORDINATES_WIDTH = 120; |
78 |
private static final int COORDINATES_HEIGHT = 19; |
79 |
private static final int LABELS_WIDTH = 60; |
80 |
private static final int PANEL_HEIGHT = 60; |
81 |
private JPanel ulxLabelPanel = null; |
82 |
private JPanel brxLabelPanel = null; |
83 |
private JLabel ulxLabel = null; |
84 |
private JLabel brxLabel = null; |
85 |
private JPanel labelsLeftPanel = null; |
86 |
private JPanel textsLeftPanel = null; |
87 |
private JPanel ulxTextPanel = null; |
88 |
private JPanel brxTextPanel = null; |
89 |
private JTextField brxText = null; |
90 |
private JTextField ulxText = 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 ulxLabelPanel
|
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 ulyLabelPanel
|
147 |
*
|
148 |
* @return javax.swing.JPanel
|
149 |
*/
|
150 |
private JPanel getUlyLabelPanel() { |
151 |
if (ulyLabelPanel == null) { |
152 |
ulyLabel = new JLabel(); |
153 |
ulyLabel.setText(PluginServices.getText(this, "uly") + ": "); |
154 |
FlowLayout flowLayout3 = new FlowLayout(); |
155 |
flowLayout3.setHgap(0);
|
156 |
flowLayout3.setAlignment(FlowLayout.RIGHT);
|
157 |
flowLayout3.setVgap(1);
|
158 |
ulyLabelPanel = new JPanel(); |
159 |
ulyLabelPanel.setPreferredSize(new Dimension(LABELS_WIDTH, COORDINATES_HEIGHT)); |
160 |
ulyLabelPanel.setLayout(flowLayout3); |
161 |
ulyLabelPanel.add(ulyLabel, null);
|
162 |
} |
163 |
return ulyLabelPanel;
|
164 |
} |
165 |
|
166 |
/**
|
167 |
* This method initializes brxLabelPanel
|
168 |
*
|
169 |
* @return javax.swing.JPanel
|
170 |
*/
|
171 |
private JPanel getBrxLabelPanel() { |
172 |
if (brxLabelPanel == null) { |
173 |
brxLabel = new JLabel(); |
174 |
brxLabel.setText(PluginServices.getText(this, "brx") + ": "); |
175 |
FlowLayout flowLayout1 = new FlowLayout(); |
176 |
flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT); |
177 |
brxLabelPanel = new JPanel(); |
178 |
brxLabelPanel.setLayout(flowLayout1); |
179 |
brxLabelPanel.setPreferredSize(new java.awt.Dimension(LABELS_WIDTH,COORDINATES_HEIGHT));
|
180 |
flowLayout1.setHgap(0);
|
181 |
flowLayout1.setVgap(1);
|
182 |
brxLabelPanel.add(brxLabel, null);
|
183 |
} |
184 |
return brxLabelPanel;
|
185 |
} |
186 |
|
187 |
/**
|
188 |
* This method initializes bryLabelPanel
|
189 |
*
|
190 |
* @return javax.swing.JPanel
|
191 |
*/
|
192 |
private JPanel getBryLabelPanel() { |
193 |
if (bryLabelPanel == null) { |
194 |
bryLabel = new JLabel(); |
195 |
bryLabel.setText(PluginServices.getText(this, "bry") + ": "); |
196 |
FlowLayout flowLayout4 = new FlowLayout(); |
197 |
flowLayout4.setHgap(0);
|
198 |
flowLayout4.setAlignment(FlowLayout.RIGHT);
|
199 |
flowLayout4.setVgap(1);
|
200 |
bryLabelPanel = new JPanel(); |
201 |
bryLabelPanel.setPreferredSize(new Dimension(LABELS_WIDTH, COORDINATES_HEIGHT)); |
202 |
bryLabelPanel.setLayout(flowLayout4); |
203 |
bryLabelPanel.add(bryLabel, null);
|
204 |
} |
205 |
return bryLabelPanel;
|
206 |
} |
207 |
|
208 |
/**
|
209 |
* This method initializes jPanel
|
210 |
*
|
211 |
* @return javax.swing.JPanel
|
212 |
*/
|
213 |
private JPanel getLabelsLeftPanel() { |
214 |
if (labelsLeftPanel == null) { |
215 |
labelsLeftPanel = new JPanel(); |
216 |
labelsLeftPanel.setPreferredSize(new Dimension(LABELS_WIDTH,PANEL_HEIGHT)); |
217 |
labelsLeftPanel.add(getUlxLabelPanel(), null);
|
218 |
labelsLeftPanel.add(getBrxLabelPanel(), null);
|
219 |
} |
220 |
return labelsLeftPanel;
|
221 |
} |
222 |
|
223 |
/**
|
224 |
* This method initializes jPanel
|
225 |
*
|
226 |
* @return javax.swing.JPanel
|
227 |
*/
|
228 |
private JPanel getTextsLeftPanel() { |
229 |
if (textsLeftPanel == null) { |
230 |
textsLeftPanel = new JPanel(); |
231 |
textsLeftPanel.setPreferredSize(new Dimension(COORDINATES_WIDTH,PANEL_HEIGHT)); |
232 |
textsLeftPanel.add(getUlxTextPanel(), null);
|
233 |
textsLeftPanel.add(getBrxTextPanel(), null);
|
234 |
} |
235 |
return textsLeftPanel;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* This method initializes ulxText
|
240 |
*
|
241 |
* @return javax.swing.JTextField
|
242 |
*/
|
243 |
private JTextField getUlxText() { |
244 |
if (ulxText == null) { |
245 |
ulxText = new JTextField(); |
246 |
ulxText.setPreferredSize(new Dimension(COORDINATES_WIDTH, COORDINATES_HEIGHT)); |
247 |
} |
248 |
return ulxText;
|
249 |
} |
250 |
|
251 |
/**
|
252 |
* This method initializes jPanel
|
253 |
*
|
254 |
* @return javax.swing.JPanel
|
255 |
*/
|
256 |
private JPanel getUlxTextPanel() { |
257 |
if (ulxTextPanel == null) { |
258 |
FlowLayout flowLayout = new FlowLayout(); |
259 |
flowLayout.setHgap(0);
|
260 |
flowLayout.setAlignment(java.awt.FlowLayout.LEFT); |
261 |
flowLayout.setVgap(1);
|
262 |
ulxTextPanel = new JPanel(); |
263 |
ulxTextPanel.setPreferredSize(new Dimension(COORDINATES_WIDTH, 22)); |
264 |
ulxTextPanel.setLayout(flowLayout); |
265 |
ulxTextPanel.add(getUlxText(), null);
|
266 |
} |
267 |
return ulxTextPanel;
|
268 |
} |
269 |
|
270 |
/**
|
271 |
* This method initializes jTextField2
|
272 |
*
|
273 |
* @return javax.swing.JTextField
|
274 |
*/
|
275 |
private JTextField getUlyText() { |
276 |
if (ulyText == null) { |
277 |
ulyText = new JTextField(); |
278 |
ulyText.setPreferredSize(new Dimension(120, 19)); |
279 |
} |
280 |
return ulyText;
|
281 |
} |
282 |
|
283 |
/**
|
284 |
* This method initializes jPanel8
|
285 |
*
|
286 |
* @return javax.swing.JPanel
|
287 |
*/
|
288 |
private JPanel getUlyTextPanel() { |
289 |
if (ulyTextPanel == null) { |
290 |
FlowLayout flowLayout8 = new FlowLayout(); |
291 |
flowLayout8.setHgap(0);
|
292 |
flowLayout8.setAlignment(FlowLayout.LEFT);
|
293 |
flowLayout8.setVgap(1);
|
294 |
ulyTextPanel = new JPanel(); |
295 |
ulyTextPanel.setPreferredSize(new Dimension(120, 22)); |
296 |
ulyTextPanel.setLayout(flowLayout8); |
297 |
ulyTextPanel.add(getUlyText(), null);
|
298 |
} |
299 |
return ulyTextPanel;
|
300 |
} |
301 |
|
302 |
/**
|
303 |
* This method initializes cityText
|
304 |
*
|
305 |
* @return javax.swing.JTextField
|
306 |
*/
|
307 |
private JTextField getBrxText() { |
308 |
if (brxText == null) { |
309 |
brxText = new JTextField(); |
310 |
brxText.setPreferredSize(new Dimension(COORDINATES_WIDTH,COORDINATES_HEIGHT)); |
311 |
} |
312 |
return brxText;
|
313 |
} |
314 |
|
315 |
/**
|
316 |
* This method initializes jPanel1
|
317 |
*
|
318 |
* @return javax.swing.JPanel
|
319 |
*/
|
320 |
private JPanel getBrxTextPanel() { |
321 |
if (brxTextPanel == null) { |
322 |
FlowLayout flowLayout5 = new FlowLayout(); |
323 |
flowLayout5.setHgap(0);
|
324 |
flowLayout5.setAlignment(java.awt.FlowLayout.LEFT); |
325 |
flowLayout5.setVgap(1);
|
326 |
brxTextPanel = new JPanel(); |
327 |
brxTextPanel.setPreferredSize(new Dimension(COORDINATES_WIDTH, 22)); |
328 |
brxTextPanel.setLayout(flowLayout5); |
329 |
brxTextPanel.add(getBrxText(), null);
|
330 |
} |
331 |
return brxTextPanel;
|
332 |
} |
333 |
|
334 |
/**
|
335 |
* This method initializes jTextField3
|
336 |
*
|
337 |
* @return javax.swing.JTextField
|
338 |
*/
|
339 |
private JTextField getBryText() { |
340 |
if (bryText == null) { |
341 |
bryText = new JTextField(); |
342 |
bryText.setPreferredSize(new Dimension(120, 19)); |
343 |
} |
344 |
return bryText;
|
345 |
} |
346 |
|
347 |
/**
|
348 |
* This method initializes jPanel9
|
349 |
*
|
350 |
* @return javax.swing.JPanel
|
351 |
*/
|
352 |
private JPanel getBryTextPanel() { |
353 |
if (bryTextPanel == null) { |
354 |
FlowLayout flowLayout9 = new FlowLayout(); |
355 |
flowLayout9.setHgap(0);
|
356 |
flowLayout9.setAlignment(FlowLayout.LEFT);
|
357 |
flowLayout9.setVgap(1);
|
358 |
bryTextPanel = new JPanel(); |
359 |
bryTextPanel.setPreferredSize(new Dimension(120, 22)); |
360 |
bryTextPanel.setLayout(flowLayout9); |
361 |
bryTextPanel.add(getBryText(), null);
|
362 |
} |
363 |
return bryTextPanel;
|
364 |
} |
365 |
|
366 |
/**
|
367 |
* This method initializes jPanel
|
368 |
*
|
369 |
* @return javax.swing.JPanel
|
370 |
*/
|
371 |
private JPanel getLabelsRigthPanel() { |
372 |
if (labelsRigthPanel == null) { |
373 |
labelsRigthPanel = new JPanel(); |
374 |
labelsRigthPanel.setPreferredSize(new Dimension(LABELS_WIDTH,PANEL_HEIGHT)); |
375 |
labelsRigthPanel.add(getUlyLabelPanel(), null);
|
376 |
labelsRigthPanel.add(getBryLabelPanel(), null);
|
377 |
} |
378 |
return labelsRigthPanel;
|
379 |
} |
380 |
|
381 |
/**
|
382 |
* This method initializes jPanel3
|
383 |
*
|
384 |
* @return javax.swing.JPanel
|
385 |
*/
|
386 |
private JPanel getTextsRigthPanel() { |
387 |
if (textsRigthPanel == null) { |
388 |
textsRigthPanel = new JPanel(); |
389 |
textsRigthPanel.setPreferredSize(new Dimension(COORDINATES_WIDTH,PANEL_HEIGHT)); |
390 |
textsRigthPanel.add(getUlyTextPanel(), null);
|
391 |
textsRigthPanel.add(getBryTextPanel(), null);
|
392 |
} |
393 |
return textsRigthPanel;
|
394 |
} |
395 |
|
396 |
/**
|
397 |
* Sets the extent
|
398 |
* @param extent
|
399 |
*/
|
400 |
public void setExtent(Rectangle2D extent){ |
401 |
getUlxText().setText(String.valueOf(extent.getMaxX()));
|
402 |
getUlyText().setText(String.valueOf(extent.getMaxY()));
|
403 |
getBrxText().setText(String.valueOf(extent.getMinX()));
|
404 |
getBryText().setText(String.valueOf(extent.getMinY()));
|
405 |
} |
406 |
|
407 |
/**
|
408 |
* Gets the extent
|
409 |
* @return
|
410 |
*/
|
411 |
public Rectangle2D getExtent(){ |
412 |
if ((!getUlxText().getText().equals("")) && |
413 |
(!getUlyText().getText().equals("")) &&
|
414 |
(!getBrxText().getText().equals("")) &&
|
415 |
(!getBryText().getText().equals(""))){
|
416 |
Rectangle2D r2d = new Rectangle2D.Double(new Double(getUlxText().getText()).doubleValue(), |
417 |
new Double(getUlyText().getText()).doubleValue(), |
418 |
new Double(getBrxText().getText()).doubleValue(), |
419 |
new Double(getBryText().getText()).doubleValue()); |
420 |
return r2d;
|
421 |
} |
422 |
return null; |
423 |
} |
424 |
} // @jve:decl-index=0:visual-constraint="10,10"
|