root / branches / gvSIG_CAD_Layout_version / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / dialogs / FPositionDialog.java @ 1822
History | View | Annotate | Download (12.7 KB)
1 |
/*
|
---|---|
2 |
* Created on 31-ago-2004
|
3 |
*
|
4 |
*/
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
6 |
*
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
8 |
*
|
9 |
* This program is free software; you can redistribute it and/or
|
10 |
* modify it under the terms of the GNU General Public License
|
11 |
* as published by the Free Software Foundation; either version 2
|
12 |
* of the License, or (at your option) any later version.
|
13 |
*
|
14 |
* This program is distributed in the hope that it will be useful,
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
* GNU General Public License for more details.
|
18 |
*
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Generalitat Valenciana
|
26 |
* Conselleria d'Infraestructures i Transport
|
27 |
* Av. Blasco Ib??ez, 50
|
28 |
* 46010 VALENCIA
|
29 |
* SPAIN
|
30 |
*
|
31 |
* +34 963862235
|
32 |
* gvsig@gva.es
|
33 |
* www.gvsig.gva.es
|
34 |
*
|
35 |
* or
|
36 |
*
|
37 |
* IVER T.I. S.A
|
38 |
* Salamanca 50
|
39 |
* 46005 Valencia
|
40 |
* Spain
|
41 |
*
|
42 |
* +34 963163400
|
43 |
* dac@iver.es
|
44 |
*/
|
45 |
package com.iver.cit.gvsig.gui.layout.dialogs; |
46 |
|
47 |
import java.awt.geom.Rectangle2D; |
48 |
import java.text.NumberFormat; |
49 |
|
50 |
import javax.swing.JPanel; |
51 |
|
52 |
import com.iver.andami.PluginServices; |
53 |
import com.iver.andami.ui.mdiManager.View; |
54 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
55 |
import com.iver.cit.gvsig.gui.layout.Layout; |
56 |
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
57 |
|
58 |
|
59 |
/**
|
60 |
* Di?logo que ofrece la posibilidad de posicionar el fframe en un punto en
|
61 |
* concreto del Layout.
|
62 |
*
|
63 |
* @author Vicente Caballero Navarro
|
64 |
*/
|
65 |
public class FPositionDialog extends JPanel implements View { |
66 |
private javax.swing.JLabel lDesdeIzquierda = null; |
67 |
private javax.swing.JLabel lDesdeArriba = null; |
68 |
private javax.swing.JLabel lAnchura = null; |
69 |
private javax.swing.JLabel lAltura = null; |
70 |
private javax.swing.JButton bAceptar = null; |
71 |
private javax.swing.JButton bCancelar = null; |
72 |
private javax.swing.JTextField tDesdeIzquierda = null; |
73 |
private javax.swing.JTextField tDesdeDerecha = null; |
74 |
private javax.swing.JTextField tAnchura = null; |
75 |
private javax.swing.JTextField tAltura = null; |
76 |
private javax.swing.JLabel lNomUnidades = null; |
77 |
private javax.swing.JLabel lUnidades = null; |
78 |
private Layout layout = null; |
79 |
private String m_NameUnit = null; |
80 |
//private ArrayList selecList = new ArrayList();
|
81 |
NumberFormat nf = NumberFormat.getInstance(); |
82 |
private javax.swing.JLabel lAnchoUnidades = null; |
83 |
private javax.swing.JLabel lAlto = null; |
84 |
private javax.swing.JLabel lAltoUnidades = null; |
85 |
private javax.swing.JLabel lAncho = null; |
86 |
private javax.swing.JPanel pFolio = null; |
87 |
private javax.swing.JLabel lSeparador = null; |
88 |
private IFFrame fframe;
|
89 |
/**
|
90 |
* This is the default constructor
|
91 |
*
|
92 |
* @param l Referencia al Layout.
|
93 |
*/
|
94 |
public FPositionDialog(Layout l,IFFrame fframe) {
|
95 |
super();
|
96 |
layout = l; |
97 |
this.fframe=fframe;
|
98 |
|
99 |
/*for (int i = layout.getFFrames().size() - 1; i >= 0; i--) {
|
100 |
IFFrame fframe = (IFFrame) layout.getFFrames().get(i);
|
101 |
|
102 |
if (fframe.getSelected() != IFFrame.NOSELECT) {
|
103 |
selecList.add(fframe);
|
104 |
}
|
105 |
}
|
106 |
*/
|
107 |
initialize(); |
108 |
} |
109 |
|
110 |
/**
|
111 |
* This method initializes this
|
112 |
*/
|
113 |
private void initialize() { |
114 |
this.setLayout(null); |
115 |
|
116 |
if (layout.isCuadricula()) {
|
117 |
nf.setMaximumFractionDigits(1);
|
118 |
} else {
|
119 |
nf.setMaximumFractionDigits(2);
|
120 |
} |
121 |
|
122 |
m_NameUnit = layout.getAtributes().getNameUnit(); |
123 |
this.add(getLDesdeIzquierda(), null); |
124 |
this.add(getLDesdeArriba(), null); |
125 |
this.add(getLAnchura(), null); |
126 |
this.add(getLAltura(), null); |
127 |
this.add(getBAceptar(), null); |
128 |
this.add(getBCancelar(), null); |
129 |
this.add(getTDesdeIzquierda(), null); |
130 |
this.add(getTDesdeDerecha(), null); |
131 |
this.add(getTAnchura(), null); |
132 |
this.add(getTAltura(), null); |
133 |
this.add(getLNomUnidades(), null); |
134 |
this.add(getLUnidades(), null); |
135 |
this.add(getPFolio(), null); |
136 |
this.setSize(203, 215); |
137 |
} |
138 |
|
139 |
/**
|
140 |
* This method initializes lDesdeIzquierda
|
141 |
*
|
142 |
* @return javax.swing.JLabel
|
143 |
*/
|
144 |
private javax.swing.JLabel getLDesdeIzquierda() {
|
145 |
if (lDesdeIzquierda == null) { |
146 |
lDesdeIzquierda = new javax.swing.JLabel();
|
147 |
lDesdeIzquierda.setBounds(9, 85, 116, 20); |
148 |
lDesdeIzquierda.setText(PluginServices.getText(this,
|
149 |
"desde_izquierda"));
|
150 |
} |
151 |
|
152 |
return lDesdeIzquierda;
|
153 |
} |
154 |
|
155 |
/**
|
156 |
* This method initializes lDesdeArriba
|
157 |
*
|
158 |
* @return javax.swing.JLabel
|
159 |
*/
|
160 |
private javax.swing.JLabel getLDesdeArriba() {
|
161 |
if (lDesdeArriba == null) { |
162 |
lDesdeArriba = new javax.swing.JLabel();
|
163 |
lDesdeArriba.setBounds(9, 110, 116, 20); |
164 |
lDesdeArriba.setText(PluginServices.getText(this, "desde_arriba")); |
165 |
} |
166 |
|
167 |
return lDesdeArriba;
|
168 |
} |
169 |
|
170 |
/**
|
171 |
* This method initializes lAnchura
|
172 |
*
|
173 |
* @return javax.swing.JLabel
|
174 |
*/
|
175 |
private javax.swing.JLabel getLAnchura() {
|
176 |
if (lAnchura == null) { |
177 |
lAnchura = new javax.swing.JLabel();
|
178 |
lAnchura.setBounds(9, 135, 116, 20); |
179 |
lAnchura.setText(PluginServices.getText(this, "anchura")); |
180 |
} |
181 |
|
182 |
return lAnchura;
|
183 |
} |
184 |
|
185 |
/**
|
186 |
* This method initializes lAltura
|
187 |
*
|
188 |
* @return javax.swing.JLabel
|
189 |
*/
|
190 |
private javax.swing.JLabel getLAltura() {
|
191 |
if (lAltura == null) { |
192 |
lAltura = new javax.swing.JLabel();
|
193 |
lAltura.setBounds(9, 160, 116, 20); |
194 |
lAltura.setText(PluginServices.getText(this, "altura")); |
195 |
} |
196 |
|
197 |
return lAltura;
|
198 |
} |
199 |
|
200 |
/**
|
201 |
* This method initializes bAceptar
|
202 |
*
|
203 |
* @return javax.swing.JButton
|
204 |
*/
|
205 |
private javax.swing.JButton getBAceptar() {
|
206 |
if (bAceptar == null) { |
207 |
bAceptar = new javax.swing.JButton();
|
208 |
bAceptar.setBounds(12, 185, 85, 23); |
209 |
bAceptar.setText(PluginServices.getText(this, "Aceptar")); |
210 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
211 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
212 |
//if (selecList.size() == 1) {
|
213 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
214 |
|
215 |
if (getTDesdeIzquierda().getText().equals("")) { |
216 |
getTDesdeIzquierda().setText("0");
|
217 |
} |
218 |
|
219 |
if (getTDesdeDerecha().getText().equals("")) { |
220 |
getTDesdeDerecha().setText("0");
|
221 |
} |
222 |
|
223 |
if (getTAnchura().getText().equals("")) { |
224 |
getTAnchura().setText("0");
|
225 |
} |
226 |
|
227 |
if (getTAltura().getText().equals("")) { |
228 |
getTAltura().setText("0");
|
229 |
} |
230 |
|
231 |
r.x = stringToDouble(getTDesdeIzquierda().getText() |
232 |
.toString()); |
233 |
r.y = stringToDouble(getTDesdeDerecha().getText() |
234 |
.toString()); |
235 |
r.width = stringToDouble(getTAnchura().getText() |
236 |
.toString()); |
237 |
r.height = stringToDouble(getTAltura().getText() |
238 |
.toString()); |
239 |
|
240 |
//((IFFrame) selecList.get(0)).setBoundBox(r);
|
241 |
fframe.setBoundBox(r); |
242 |
//}
|
243 |
|
244 |
PluginServices.getMDIManager().closeView(FPositionDialog.this); |
245 |
layout.setStatus(Layout.DESACTUALIZADO); |
246 |
layout.repaint(); |
247 |
} |
248 |
}); |
249 |
} |
250 |
|
251 |
return bAceptar;
|
252 |
} |
253 |
|
254 |
/**
|
255 |
* Paso de String a double.
|
256 |
*
|
257 |
* @param s String.
|
258 |
*
|
259 |
* @return double obtenido.
|
260 |
*/
|
261 |
private double stringToDouble(String s) { |
262 |
String snew = s.replace(',', '.'); |
263 |
|
264 |
return layout.getAtributes().fromUnits(Double.parseDouble(snew)); |
265 |
} |
266 |
|
267 |
/**
|
268 |
* This method initializes bCancelar
|
269 |
*
|
270 |
* @return javax.swing.JButton
|
271 |
*/
|
272 |
private javax.swing.JButton getBCancelar() {
|
273 |
if (bCancelar == null) { |
274 |
bCancelar = new javax.swing.JButton();
|
275 |
bCancelar.setBounds(107, 185, 87, 23); |
276 |
bCancelar.setText(PluginServices.getText(this, "Cancelar")); |
277 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
278 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
279 |
PluginServices.getMDIManager().closeView(FPositionDialog.this); |
280 |
} |
281 |
}); |
282 |
} |
283 |
|
284 |
return bCancelar;
|
285 |
} |
286 |
|
287 |
/**
|
288 |
* This method initializes tDesdeIzquierda
|
289 |
*
|
290 |
* @return javax.swing.JTextField
|
291 |
*/
|
292 |
private javax.swing.JTextField getTDesdeIzquierda() {
|
293 |
if (tDesdeIzquierda == null) { |
294 |
tDesdeIzquierda = new javax.swing.JTextField();
|
295 |
tDesdeIzquierda.setBounds(132, 85, 53, 20); |
296 |
tDesdeIzquierda.setText(String.valueOf(nf.format(
|
297 |
layout.getAtributes().toUnits(fframe.getBoundBox().x)))); |
298 |
} |
299 |
|
300 |
return tDesdeIzquierda;
|
301 |
} |
302 |
|
303 |
/**
|
304 |
* This method initializes tDesdeDerecha
|
305 |
*
|
306 |
* @return javax.swing.JTextField
|
307 |
*/
|
308 |
private javax.swing.JTextField getTDesdeDerecha() {
|
309 |
if (tDesdeDerecha == null) { |
310 |
tDesdeDerecha = new javax.swing.JTextField();
|
311 |
tDesdeDerecha.setBounds(132, 110, 53, 20); |
312 |
tDesdeDerecha.setText(String.valueOf(nf.format(
|
313 |
layout.getAtributes().toUnits(fframe.getBoundBox().y)))); |
314 |
} |
315 |
|
316 |
return tDesdeDerecha;
|
317 |
} |
318 |
|
319 |
/**
|
320 |
* This method initializes tAnchura
|
321 |
*
|
322 |
* @return javax.swing.JTextField
|
323 |
*/
|
324 |
private javax.swing.JTextField getTAnchura() {
|
325 |
if (tAnchura == null) { |
326 |
tAnchura = new javax.swing.JTextField();
|
327 |
tAnchura.setBounds(132, 135, 53, 20); |
328 |
tAnchura.setText(String.valueOf(nf.format(
|
329 |
layout.getAtributes().toUnits(fframe.getBoundBox().width)))); |
330 |
} |
331 |
|
332 |
return tAnchura;
|
333 |
} |
334 |
|
335 |
/**
|
336 |
* This method initializes tAltura
|
337 |
*
|
338 |
* @return javax.swing.JTextField
|
339 |
*/
|
340 |
private javax.swing.JTextField getTAltura() {
|
341 |
if (tAltura == null) { |
342 |
tAltura = new javax.swing.JTextField();
|
343 |
tAltura.setBounds(132, 160, 53, 20); |
344 |
tAltura.setText(String.valueOf(nf.format(layout.getAtributes()
|
345 |
.toUnits(fframe.getBoundBox().height)))); |
346 |
} |
347 |
|
348 |
return tAltura;
|
349 |
} |
350 |
|
351 |
/**
|
352 |
* This method initializes lNomUnidades
|
353 |
*
|
354 |
* @return javax.swing.JLabel
|
355 |
*/
|
356 |
private javax.swing.JLabel getLNomUnidades() {
|
357 |
if (lNomUnidades == null) { |
358 |
lNomUnidades = new javax.swing.JLabel();
|
359 |
lNomUnidades.setBounds(91, 7, 91, 20); |
360 |
lNomUnidades.setText(m_NameUnit); |
361 |
} |
362 |
|
363 |
return lNomUnidades;
|
364 |
} |
365 |
|
366 |
/**
|
367 |
* This method initializes lUnidades
|
368 |
*
|
369 |
* @return javax.swing.JLabel
|
370 |
*/
|
371 |
private javax.swing.JLabel getLUnidades() {
|
372 |
if (lUnidades == null) { |
373 |
lUnidades = new javax.swing.JLabel();
|
374 |
lUnidades.setBounds(7, 7, 72, 20); |
375 |
lUnidades.setText(PluginServices.getText(this, "unidades")); |
376 |
} |
377 |
|
378 |
return lUnidades;
|
379 |
} |
380 |
|
381 |
/**
|
382 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
383 |
*/
|
384 |
public ViewInfo getViewInfo() {
|
385 |
ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
386 |
|
387 |
//vi.setResizable(false);
|
388 |
m_viewinfo.setTitle(PluginServices.getText(this, "tama?o_posicion")); |
389 |
|
390 |
return m_viewinfo;
|
391 |
} |
392 |
|
393 |
/**
|
394 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
395 |
*/
|
396 |
public void viewActivated() { |
397 |
} |
398 |
|
399 |
/**
|
400 |
* This method initializes lAnchoUnidades
|
401 |
*
|
402 |
* @return javax.swing.JLabel
|
403 |
*/
|
404 |
private javax.swing.JLabel getLAnchoUnidades() {
|
405 |
if (lAnchoUnidades == null) { |
406 |
lAnchoUnidades = new javax.swing.JLabel();
|
407 |
|
408 |
if (layout.getAtributes().isLandSpace()) {
|
409 |
lAnchoUnidades.setText(String.valueOf(nf.format(
|
410 |
layout.getAtributes().getSizeInUnits().getAlto()))); |
411 |
} else {
|
412 |
lAnchoUnidades.setText(String.valueOf(nf.format(
|
413 |
layout.getAtributes().getSizeInUnits().getAncho()))); |
414 |
} |
415 |
} |
416 |
|
417 |
return lAnchoUnidades;
|
418 |
} |
419 |
|
420 |
/**
|
421 |
* This method initializes lAlto
|
422 |
*
|
423 |
* @return javax.swing.JLabel
|
424 |
*/
|
425 |
private javax.swing.JLabel getLAlto() {
|
426 |
if (lAlto == null) { |
427 |
lAlto = new javax.swing.JLabel();
|
428 |
lAlto.setText(PluginServices.getText(this, "alto")); |
429 |
} |
430 |
|
431 |
return lAlto;
|
432 |
} |
433 |
|
434 |
/**
|
435 |
* This method initializes lAltoUnidades
|
436 |
*
|
437 |
* @return javax.swing.JLabel
|
438 |
*/
|
439 |
private javax.swing.JLabel getLAltoUnidades() {
|
440 |
if (lAltoUnidades == null) { |
441 |
lAltoUnidades = new javax.swing.JLabel();
|
442 |
|
443 |
if (layout.getAtributes().isLandSpace()) {
|
444 |
lAltoUnidades.setText(String.valueOf(nf.format(
|
445 |
layout.getAtributes().getSizeInUnits().getAncho()))); |
446 |
} else {
|
447 |
lAltoUnidades.setText(String.valueOf(nf.format(
|
448 |
layout.getAtributes().getSizeInUnits().getAlto()))); |
449 |
} |
450 |
} |
451 |
|
452 |
return lAltoUnidades;
|
453 |
} |
454 |
|
455 |
/**
|
456 |
* This method initializes lAncho
|
457 |
*
|
458 |
* @return javax.swing.JLabel
|
459 |
*/
|
460 |
private javax.swing.JLabel getLAncho() {
|
461 |
if (lAncho == null) { |
462 |
lAncho = new javax.swing.JLabel();
|
463 |
lAncho.setText(PluginServices.getText(this, "ancho")); |
464 |
} |
465 |
|
466 |
return lAncho;
|
467 |
} |
468 |
|
469 |
/**
|
470 |
* This method initializes pFolio
|
471 |
*
|
472 |
* @return javax.swing.JPanel
|
473 |
*/
|
474 |
private javax.swing.JPanel getPFolio() {
|
475 |
if (pFolio == null) { |
476 |
pFolio = new javax.swing.JPanel();
|
477 |
pFolio.add(getLAltoUnidades(), null);
|
478 |
pFolio.add(getLAlto(), null);
|
479 |
pFolio.add(getLSeparador(), null);
|
480 |
pFolio.add(getLAnchoUnidades(), null);
|
481 |
pFolio.add(getLAncho(), null);
|
482 |
pFolio.setBounds(9, 31, 180, 43); |
483 |
pFolio.setBorder(javax.swing.BorderFactory.createTitledBorder( |
484 |
null, PluginServices.getText(this, "tama?o_pagina"), |
485 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
486 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
487 |
} |
488 |
|
489 |
return pFolio;
|
490 |
} |
491 |
|
492 |
/**
|
493 |
* This method initializes lSeparador
|
494 |
*
|
495 |
* @return javax.swing.JLabel
|
496 |
*/
|
497 |
private javax.swing.JLabel getLSeparador() {
|
498 |
if (lSeparador == null) { |
499 |
lSeparador = new javax.swing.JLabel();
|
500 |
lSeparador.setText("/");
|
501 |
} |
502 |
|
503 |
return lSeparador;
|
504 |
} |
505 |
} |