root / branches / 3D_Animation_prepto_osgvp_2_2_0 / extensions / ext3Dgui / src / org / gvsig / gvsig3dgui / view / InsertPosition.java @ 26998
History | View | Annotate | Download (13.8 KB)
1 | 15587 | rgaitan | /* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|---|---|
2 | 15361 | afraile | *
|
3 | * Copyright (C) 2004 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 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | 15587 | rgaitan | * Av. Blasco Ib��ez, 50
|
24 | 15361 | afraile | * 46010 VALENCIA
|
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 21960 | jcampos | package org.gvsig.gvsig3dgui.view; |
42 | 15361 | afraile | |
43 | import java.awt.Dimension; |
||
44 | import java.awt.Insets; |
||
45 | import java.awt.event.ActionEvent; |
||
46 | import java.awt.event.ActionListener; |
||
47 | import java.util.Enumeration; |
||
48 | |||
49 | import javax.swing.AbstractAction; |
||
50 | import javax.swing.Action; |
||
51 | import javax.swing.BorderFactory; |
||
52 | import javax.swing.ButtonGroup; |
||
53 | import javax.swing.JPanel; |
||
54 | import javax.swing.JRadioButton; |
||
55 | import javax.swing.JTextField; |
||
56 | |||
57 | import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
||
58 | import org.gvsig.gui.beans.swing.JButton; |
||
59 | 21960 | jcampos | import org.gvsig.gvsig3dgui.ProjectView3D; |
60 | 26998 | jtorres | import org.gvsig.osgvp.core.osg.Vec3; |
61 | 20900 | jcampos | import org.gvsig.osgvp.planets.Planet; |
62 | 15361 | afraile | |
63 | import com.iver.andami.PluginServices; |
||
64 | import com.iver.andami.ui.mdiManager.SingletonWindow; |
||
65 | import com.iver.andami.ui.mdiManager.WindowInfo; |
||
66 | import com.iver.cit.gvsig.project.documents.view.IProjectView; |
||
67 | |||
68 | /**
|
||
69 | * Dialogo donde se muestran las propiedades de una vista
|
||
70 | *
|
||
71 | 15587 | rgaitan | * @author Fernando Gonz�lez Cort�s
|
72 | 15361 | afraile | */
|
73 | public class InsertPosition extends GridBagLayoutPanel implements |
||
74 | SingletonWindow { |
||
75 | |||
76 | private ProjectView3D view3D;
|
||
77 | |||
78 | private JTextField txtName; |
||
79 | |||
80 | private JPanel jPanelSelectProjection; |
||
81 | |||
82 | private ButtonGroup radioButtonGroup; |
||
83 | |||
84 | private int width = 375; |
||
85 | |||
86 | private int height = 300; |
||
87 | |||
88 | private GridBagLayoutPanel okCancelPanel;
|
||
89 | |||
90 | private JButton okButton; |
||
91 | |||
92 | private JButton cancelButton; |
||
93 | |||
94 | private GridBagLayoutPanel sphericalPanel;
|
||
95 | |||
96 | private GridBagLayoutPanel cartesianasPanel;
|
||
97 | |||
98 | private GridBagLayoutPanel coordPanel;
|
||
99 | |||
100 | private JTextField coordX; |
||
101 | |||
102 | private JTextField coordY; |
||
103 | |||
104 | private JTextField coordZ; |
||
105 | |||
106 | private JTextField latG; |
||
107 | |||
108 | private JTextField lonG; |
||
109 | |||
110 | private JTextField altura; |
||
111 | |||
112 | private JTextField latH; |
||
113 | |||
114 | private JTextField lonH; |
||
115 | |||
116 | private JTextField latM; |
||
117 | |||
118 | private JTextField lonM; |
||
119 | |||
120 | private GridBagLayoutPanel cartesianasLatitudPanel;
|
||
121 | |||
122 | private GridBagLayoutPanel cartesianasLongitudPanel;
|
||
123 | |||
124 | /**
|
||
125 | * This is the default constructor
|
||
126 | *
|
||
127 | * @param f
|
||
128 | * Frame padre del dialogo
|
||
129 | * @param v
|
||
130 | * Vista que se representa
|
||
131 | */
|
||
132 | public InsertPosition(IProjectView v) {
|
||
133 | view3D = (ProjectView3D) v; |
||
134 | |||
135 | initialize(); |
||
136 | } |
||
137 | |||
138 | /**
|
||
139 | * This method initializes this
|
||
140 | */
|
||
141 | private void initialize() { |
||
142 | // Inicialize component
|
||
143 | setName("Insercion de punto 3D");
|
||
144 | // Introducing the margin
|
||
145 | setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
||
146 | // Dimension of the panel
|
||
147 | // setSize(new Dimension(width, height));
|
||
148 | this.setPreferredSize(new Dimension(width, height)); |
||
149 | |||
150 | // ADDING COMPONENTS
|
||
151 | |||
152 | // Name Component
|
||
153 | this.addComponent("Nombre:", getTxtName(), new Insets(0, 10, 2, 10)); |
||
154 | |||
155 | // Projection selector (Radio buton group)
|
||
156 | 15587 | rgaitan | // this.addComponent("Seleccione proyecci�n:",
|
157 | 15361 | afraile | // getJPanelSelectProjection(), new Insets(2, 10, 2, 10));
|
158 | |||
159 | // this.addComponent(getSphericalPanel());
|
||
160 | this.addComponent(getCoordPanel(), new Insets(2, 10, 2, 10)); |
||
161 | |||
162 | // Accept buton
|
||
163 | this.addComponent(getOkCancelPanel(), new Insets(2, 150, 2, 0)); |
||
164 | |||
165 | // Inicialicing default values
|
||
166 | coordX.setEnabled(true);
|
||
167 | coordY.setEnabled(true);
|
||
168 | coordZ.setEnabled(true);
|
||
169 | |||
170 | latG.setText("0");
|
||
171 | lonG.setText("0");
|
||
172 | latH.setText("0");
|
||
173 | lonH.setText("0");
|
||
174 | latM.setText("0");
|
||
175 | lonM.setText("0");
|
||
176 | latG.setEnabled(true);
|
||
177 | lonG.setEnabled(true);
|
||
178 | latH.setEnabled(true);
|
||
179 | lonH.setEnabled(true);
|
||
180 | latM.setEnabled(true);
|
||
181 | lonM.setEnabled(true);
|
||
182 | altura.setText("0");
|
||
183 | altura.setEnabled(true);
|
||
184 | } |
||
185 | |||
186 | private javax.swing.JTextField getTxtName() {
|
||
187 | if (txtName == null) { |
||
188 | txtName = new javax.swing.JTextField();
|
||
189 | txtName.setPreferredSize(new java.awt.Dimension(150, 23)); |
||
190 | } |
||
191 | |||
192 | return txtName;
|
||
193 | } |
||
194 | |||
195 | private JPanel getJPanelSelectProjection() { |
||
196 | if (jPanelSelectProjection == null) { |
||
197 | // Create JPanel
|
||
198 | jPanelSelectProjection = new GridBagLayoutPanel();
|
||
199 | |||
200 | if (radioButtonGroup == null) { |
||
201 | radioButtonGroup = getRadioButonGroup(); |
||
202 | } |
||
203 | for (Enumeration e = radioButtonGroup.getElements(); e |
||
204 | .hasMoreElements();) { |
||
205 | JRadioButton b = (JRadioButton) e.nextElement(); |
||
206 | jPanelSelectProjection.add(b, null);
|
||
207 | } |
||
208 | |||
209 | } |
||
210 | |||
211 | return jPanelSelectProjection;
|
||
212 | } |
||
213 | |||
214 | /**
|
||
215 | * Method to inicialize the radio button group
|
||
216 | *
|
||
217 | * @return the radio button group
|
||
218 | */
|
||
219 | private ButtonGroup getRadioButonGroup() { |
||
220 | if (radioButtonGroup == null) { |
||
221 | |||
222 | // Create an action for each radio button
|
||
223 | Action sphericalAction = new AbstractAction("spherical") { |
||
224 | // This method is called whenever the radio button is pressed,
|
||
225 | // even if it is already selected; this method is not called
|
||
226 | // if the radio button was selected programmatically
|
||
227 | public void actionPerformed(ActionEvent evt) { |
||
228 | sphericalPanel.setEnabled(true);
|
||
229 | cartesianasPanel.setEnabled(false);
|
||
230 | coordX.setEnabled(true);
|
||
231 | coordY.setEnabled(true);
|
||
232 | coordZ.setEnabled(true);
|
||
233 | latG.setEnabled(false);
|
||
234 | lonG.setEnabled(false);
|
||
235 | altura.setEnabled(false);
|
||
236 | |||
237 | } |
||
238 | }; |
||
239 | Action flatAction = new AbstractAction("flat") { |
||
240 | // See above
|
||
241 | public void actionPerformed(ActionEvent evt) { |
||
242 | sphericalPanel.setEnabled(false);
|
||
243 | cartesianasPanel.setEnabled(true);
|
||
244 | coordX.setEnabled(false);
|
||
245 | coordY.setEnabled(false);
|
||
246 | coordZ.setEnabled(false);
|
||
247 | latG.setEnabled(true);
|
||
248 | lonG.setEnabled(true);
|
||
249 | altura.setEnabled(true);
|
||
250 | } |
||
251 | }; |
||
252 | |||
253 | // Create the radio buttons using the actions
|
||
254 | JRadioButton spherical = new JRadioButton(sphericalAction); |
||
255 | JRadioButton flat = new JRadioButton(flatAction); |
||
256 | |||
257 | // Inicialize the button properties
|
||
258 | spherical.setName("spherical");
|
||
259 | spherical.setLabel("Esferica");
|
||
260 | flat.setName("flat");
|
||
261 | flat.setLabel("Plana");
|
||
262 | |||
263 | 15587 | rgaitan | if (view3D.getPlanetType() == Planet.CoordinateSystemType.GEOCENTRIC)
|
264 | 15361 | afraile | spherical.setSelected(true);
|
265 | else
|
||
266 | flat.setSelected(true);
|
||
267 | |||
268 | // Associate the two buttons with a button group
|
||
269 | radioButtonGroup = new ButtonGroup(); |
||
270 | radioButtonGroup.add(spherical); |
||
271 | radioButtonGroup.add(flat); |
||
272 | } |
||
273 | |||
274 | return radioButtonGroup;
|
||
275 | } |
||
276 | |||
277 | private GridBagLayoutPanel getCoordPanel() {
|
||
278 | if (coordPanel == null) { |
||
279 | coordPanel = new GridBagLayoutPanel();
|
||
280 | // coordPanel.addComponent(getSphericalPanel());
|
||
281 | coordPanel.addComponent(getCartesianasPanel()); |
||
282 | getSphericalPanel(); |
||
283 | } |
||
284 | |||
285 | return coordPanel;
|
||
286 | } |
||
287 | |||
288 | private GridBagLayoutPanel getSphericalPanel() {
|
||
289 | if (sphericalPanel == null) { |
||
290 | sphericalPanel = new GridBagLayoutPanel();
|
||
291 | sphericalPanel.setSize(new java.awt.Dimension(200, 100)); |
||
292 | sphericalPanel.setPreferredSize(new java.awt.Dimension(200, 100)); |
||
293 | sphericalPanel.addComponent("X ", getCoordX());
|
||
294 | sphericalPanel.addComponent("Y ", getCoordY());
|
||
295 | sphericalPanel.addComponent("Z ", getCoordZ());
|
||
296 | } |
||
297 | |||
298 | return sphericalPanel;
|
||
299 | } |
||
300 | |||
301 | private javax.swing.JTextField getCoordX() {
|
||
302 | if (coordX == null) { |
||
303 | coordX = new javax.swing.JTextField();
|
||
304 | coordX.setPreferredSize(new java.awt.Dimension(150, 23)); |
||
305 | } |
||
306 | |||
307 | return coordX;
|
||
308 | } |
||
309 | |||
310 | private javax.swing.JTextField getCoordY() {
|
||
311 | if (coordY == null) { |
||
312 | coordY = new javax.swing.JTextField();
|
||
313 | coordY.setPreferredSize(new java.awt.Dimension(150, 23)); |
||
314 | } |
||
315 | |||
316 | return coordY;
|
||
317 | } |
||
318 | |||
319 | private javax.swing.JTextField getCoordZ() {
|
||
320 | if (coordZ == null) { |
||
321 | coordZ = new javax.swing.JTextField();
|
||
322 | coordZ.setPreferredSize(new java.awt.Dimension(150, 23)); |
||
323 | } |
||
324 | |||
325 | return coordZ;
|
||
326 | } |
||
327 | |||
328 | private GridBagLayoutPanel getCartesianasPanel() {
|
||
329 | if (cartesianasPanel == null) { |
||
330 | cartesianasPanel = new GridBagLayoutPanel();
|
||
331 | latG = new JTextField(); |
||
332 | latG.setPreferredSize(new java.awt.Dimension(40, 23)); |
||
333 | latG.setAlignmentX(GridBagLayoutPanel.LEFT_ALIGNMENT); |
||
334 | latG.setMargin(new Insets(2, 5, 2, 5)); |
||
335 | lonG = new JTextField(); |
||
336 | lonG.setPreferredSize(new java.awt.Dimension(40, 23)); |
||
337 | lonG.setAlignmentX(GridBagLayoutPanel.LEFT_ALIGNMENT); |
||
338 | lonG.setMargin(new Insets(2, 5, 2, 5)); |
||
339 | latH = new JTextField(); |
||
340 | latH.setPreferredSize(new java.awt.Dimension(40, 23)); |
||
341 | latH.setAlignmentX(GridBagLayoutPanel.LEFT_ALIGNMENT); |
||
342 | lonH = new JTextField(); |
||
343 | lonH.setPreferredSize(new java.awt.Dimension(40, 23)); |
||
344 | lonH.setAlignmentX(GridBagLayoutPanel.LEFT_ALIGNMENT); |
||
345 | latM = new JTextField(); |
||
346 | latM.setPreferredSize(new java.awt.Dimension(40, 23)); |
||
347 | latM.setAlignmentX(GridBagLayoutPanel.LEFT_ALIGNMENT); |
||
348 | lonM = new JTextField(); |
||
349 | lonM.setPreferredSize(new java.awt.Dimension(40, 23)); |
||
350 | lonM.setAlignmentX(GridBagLayoutPanel.LEFT_ALIGNMENT); |
||
351 | altura = new JTextField(); |
||
352 | altura.setPreferredSize(new java.awt.Dimension(40, 23)); |
||
353 | altura.setAlignmentX(GridBagLayoutPanel.LEFT_ALIGNMENT); |
||
354 | cartesianasPanel.addComponent("Longitud",getCartesianasLongitudPanel());
|
||
355 | cartesianasPanel.addComponent("Latitud ", getCartesianasLatitudPanel());
|
||
356 | cartesianasPanel.addComponent("Altura ", getHeithg());
|
||
357 | } |
||
358 | |||
359 | return cartesianasPanel;
|
||
360 | } |
||
361 | |||
362 | private GridBagLayoutPanel getCartesianasLatitudPanel() {
|
||
363 | if (cartesianasLatitudPanel == null) { |
||
364 | cartesianasLatitudPanel = new GridBagLayoutPanel();
|
||
365 | // latG = new JTextField();
|
||
366 | // latG.setPreferredSize(new java.awt.Dimension(50, 23));
|
||
367 | // lonG = new JTextField();
|
||
368 | // lonG.setPreferredSize(new java.awt.Dimension(50, 23));
|
||
369 | // latH = new JTextField();
|
||
370 | // latH.setPreferredSize(new java.awt.Dimension(50, 23));
|
||
371 | cartesianasLatitudPanel.addComponent(latG,latH,latM); |
||
372 | } |
||
373 | |||
374 | return cartesianasLatitudPanel;
|
||
375 | } |
||
376 | |||
377 | private GridBagLayoutPanel getCartesianasLongitudPanel() {
|
||
378 | if (cartesianasLongitudPanel == null) { |
||
379 | cartesianasLongitudPanel = new GridBagLayoutPanel();
|
||
380 | // lonG = new JTextField();
|
||
381 | // lonG.setPreferredSize(new java.awt.Dimension(50, 23));
|
||
382 | // lonH = new JTextField();
|
||
383 | // lonH.setPreferredSize(new java.awt.Dimension(50, 23));
|
||
384 | // lonM = new JTextField();
|
||
385 | // lonM.setPreferredSize(new java.awt.Dimension(50, 23));
|
||
386 | cartesianasLongitudPanel.addComponent(lonG,lonH,lonM); |
||
387 | } |
||
388 | |||
389 | return cartesianasLongitudPanel;
|
||
390 | } |
||
391 | |||
392 | |||
393 | |||
394 | // private javax.swing.JTextField getLat() {
|
||
395 | // if (latG == null) {
|
||
396 | // latG = new javax.swing.JTextField();
|
||
397 | // latG.setPreferredSize(new java.awt.Dimension(150, 23));
|
||
398 | // }
|
||
399 | //
|
||
400 | // return latG;
|
||
401 | // }
|
||
402 | //
|
||
403 | // private javax.swing.JTextField getLon() {
|
||
404 | // if (lonG == null) {
|
||
405 | // lonG = new javax.swing.JTextField();
|
||
406 | // lonG.setPreferredSize(new java.awt.Dimension(150, 23));
|
||
407 | // }
|
||
408 | //
|
||
409 | // return lonG;
|
||
410 | // }
|
||
411 | |||
412 | private javax.swing.JTextField getHeithg() {
|
||
413 | if (altura == null) { |
||
414 | altura = new javax.swing.JTextField();
|
||
415 | altura.setPreferredSize(new java.awt.Dimension(150, 23)); |
||
416 | } |
||
417 | |||
418 | return altura;
|
||
419 | } |
||
420 | |||
421 | private GridBagLayoutPanel getOkCancelPanel() {
|
||
422 | if (okCancelPanel == null) { |
||
423 | ActionListener okAction, cancelAction;
|
||
424 | okAction = new java.awt.event.ActionListener() {
|
||
425 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
426 | //Pulsacion del boton de Aceptar
|
||
427 | |||
428 | if (latG.isEnabled()){
|
||
429 | double h = Double.valueOf(altura.getText()).doubleValue(); |
||
430 | |||
431 | double lati = Double.valueOf(latG.getText()).doubleValue(); |
||
432 | double longi = Double.valueOf(lonG.getText()).doubleValue(); |
||
433 | lati = lati + (Double.valueOf(latG.getText()).doubleValue()/60); |
||
434 | longi = longi + (Double.valueOf(lonG.getText()).doubleValue()/60); |
||
435 | lati = lati + (Double.valueOf(latG.getText()).doubleValue()/3600); |
||
436 | longi = longi + (Double.valueOf(lonG.getText()).doubleValue()/3600); |
||
437 | |||
438 | // Vec3 posicion = new Vec3(h,lati,longi);
|
||
439 | Vec3 posicion = new Vec3(lati,longi,h);
|
||
440 | view3D.insertaText(txtName.getText(),posicion); |
||
441 | |||
442 | } |
||
443 | PluginServices.getMDIManager().closeWindow( |
||
444 | InsertPosition.this); |
||
445 | } |
||
446 | }; |
||
447 | cancelAction = new java.awt.event.ActionListener() {
|
||
448 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
449 | PluginServices.getMDIManager().closeWindow( |
||
450 | InsertPosition.this); |
||
451 | } |
||
452 | }; |
||
453 | |||
454 | okCancelPanel = new GridBagLayoutPanel();
|
||
455 | okCancelPanel.setAlignmentX(GridBagLayoutPanel.RIGHT_ALIGNMENT); |
||
456 | okButton = new JButton(); |
||
457 | okButton.setLabel("Aceptar");
|
||
458 | okButton.addActionListener(okAction); |
||
459 | cancelButton = new JButton(); |
||
460 | cancelButton.setLabel("Cancelar");
|
||
461 | cancelButton.addActionListener(cancelAction); |
||
462 | |||
463 | okCancelPanel.addComponent(okButton, cancelButton); |
||
464 | } |
||
465 | return okCancelPanel;
|
||
466 | } |
||
467 | |||
468 | public Object getWindowModel() { |
||
469 | // TODO Auto-generated method stub
|
||
470 | return view3D;
|
||
471 | } |
||
472 | |||
473 | public WindowInfo getWindowInfo() {
|
||
474 | WindowInfo m_viewinfo = new WindowInfo();
|
||
475 | m_viewinfo.setTitle("Insercion_de_punto_3D");
|
||
476 | m_viewinfo.setHeight(height); |
||
477 | m_viewinfo.setWidth(width); |
||
478 | return m_viewinfo;
|
||
479 | } |
||
480 | 24708 | jcampos | public Object getWindowProfile() { |
481 | 24996 | jcampos | return WindowInfo.DIALOG_PROFILE;
|
482 | 24708 | jcampos | } |
483 | |||
484 | 15361 | afraile | } |