root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / gui / dialogs / FPositionDialog.java @ 21299
History | View | Annotate | Download (13.3 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.project.documents.layout.gui.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.IWindow; |
54 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
55 |
import com.iver.cit.gvsig.project.documents.layout.LayoutControl; |
56 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
57 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
58 |
|
59 |
|
60 |
/**
|
61 |
* Di?logo que ofrece la posibilidad de posicionar el fframe en un punto en
|
62 |
* concreto del Layout.
|
63 |
*
|
64 |
* @author Vicente Caballero Navarro
|
65 |
*/
|
66 |
public class FPositionDialog extends JPanel implements IWindow { |
67 |
private javax.swing.JLabel lDesdeIzquierda = null; |
68 |
private javax.swing.JLabel lDesdeArriba = null; |
69 |
private javax.swing.JLabel lAnchura = null; |
70 |
private javax.swing.JLabel lAltura = null; |
71 |
private javax.swing.JButton bAceptar = null; |
72 |
private javax.swing.JButton bCancelar = null; |
73 |
private javax.swing.JTextField tDesdeIzquierda = null; |
74 |
private javax.swing.JTextField tDesdeDerecha = null; |
75 |
private javax.swing.JTextField tAnchura = null; |
76 |
private javax.swing.JTextField tAltura = null; |
77 |
private javax.swing.JLabel lNomUnidades = null; |
78 |
private javax.swing.JLabel lUnidades = null; |
79 |
private Layout layout = null; |
80 |
private String m_NameUnit = null; |
81 |
//private ArrayList selecList = new ArrayList();
|
82 |
NumberFormat nf = NumberFormat.getInstance(); |
83 |
private javax.swing.JLabel lAnchoUnidades = null; |
84 |
private javax.swing.JLabel lAlto = null; |
85 |
private javax.swing.JLabel lAltoUnidades = null; |
86 |
private javax.swing.JLabel lAncho = null; |
87 |
private javax.swing.JPanel pFolio = null; |
88 |
private javax.swing.JLabel lSeparador = null; |
89 |
private IFFrame fframe;
|
90 |
/**
|
91 |
* This is the default constructor
|
92 |
*
|
93 |
* @param l Referencia al Layout.
|
94 |
*/
|
95 |
public FPositionDialog(Layout l,IFFrame fframe) {
|
96 |
super();
|
97 |
layout = l; |
98 |
this.fframe=fframe;
|
99 |
|
100 |
/*for (int i = layout.getFFrames().size() - 1; i >= 0; i--) {
|
101 |
IFFrame fframe = (IFFrame) layout.getFFrames().get(i);
|
102 |
|
103 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
104 |
selecList.add(fframe);
|
105 |
}
|
106 |
}
|
107 |
*/
|
108 |
initialize(); |
109 |
} |
110 |
|
111 |
/**
|
112 |
* This method initializes this
|
113 |
*/
|
114 |
private void initialize() { |
115 |
this.setLayout(null); |
116 |
|
117 |
if (layout.getLayoutContext().isAdjustingToGrid()) {
|
118 |
nf.setMaximumFractionDigits(1);
|
119 |
} else {
|
120 |
nf.setMaximumFractionDigits(2);
|
121 |
} |
122 |
|
123 |
m_NameUnit = layout.getLayoutContext().getAtributes().getNameUnit(); |
124 |
this.add(getLDesdeIzquierda(), null); |
125 |
this.add(getLDesdeArriba(), null); |
126 |
this.add(getLAnchura(), null); |
127 |
this.add(getLAltura(), null); |
128 |
this.add(getBAceptar(), null); |
129 |
this.add(getBCancelar(), null); |
130 |
this.add(getTDesdeIzquierda(), null); |
131 |
this.add(getTDesdeDerecha(), null); |
132 |
this.add(getTAnchura(), null); |
133 |
this.add(getTAltura(), null); |
134 |
this.add(getLNomUnidades(), null); |
135 |
this.add(getLUnidades(), null); |
136 |
this.add(getPFolio(), null); |
137 |
this.setSize(203, 215); |
138 |
} |
139 |
|
140 |
/**
|
141 |
* This method initializes lDesdeIzquierda
|
142 |
*
|
143 |
* @return javax.swing.JLabel
|
144 |
*/
|
145 |
private javax.swing.JLabel getLDesdeIzquierda() {
|
146 |
if (lDesdeIzquierda == null) { |
147 |
lDesdeIzquierda = new javax.swing.JLabel();
|
148 |
lDesdeIzquierda.setBounds(9, 85, 116, 20); |
149 |
lDesdeIzquierda.setText(PluginServices.getText(this,
|
150 |
"desde_izquierda"));
|
151 |
} |
152 |
|
153 |
return lDesdeIzquierda;
|
154 |
} |
155 |
|
156 |
/**
|
157 |
* This method initializes lDesdeArriba
|
158 |
*
|
159 |
* @return javax.swing.JLabel
|
160 |
*/
|
161 |
private javax.swing.JLabel getLDesdeArriba() {
|
162 |
if (lDesdeArriba == null) { |
163 |
lDesdeArriba = new javax.swing.JLabel();
|
164 |
lDesdeArriba.setBounds(9, 110, 116, 20); |
165 |
lDesdeArriba.setText(PluginServices.getText(this, "desde_arriba")); |
166 |
} |
167 |
|
168 |
return lDesdeArriba;
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* This method initializes lAnchura
|
173 |
*
|
174 |
* @return javax.swing.JLabel
|
175 |
*/
|
176 |
private javax.swing.JLabel getLAnchura() {
|
177 |
if (lAnchura == null) { |
178 |
lAnchura = new javax.swing.JLabel();
|
179 |
lAnchura.setBounds(9, 135, 116, 20); |
180 |
lAnchura.setText(PluginServices.getText(this, "anchura")); |
181 |
} |
182 |
|
183 |
return lAnchura;
|
184 |
} |
185 |
|
186 |
/**
|
187 |
* This method initializes lAltura
|
188 |
*
|
189 |
* @return javax.swing.JLabel
|
190 |
*/
|
191 |
private javax.swing.JLabel getLAltura() {
|
192 |
if (lAltura == null) { |
193 |
lAltura = new javax.swing.JLabel();
|
194 |
lAltura.setBounds(9, 160, 116, 20); |
195 |
lAltura.setText(PluginServices.getText(this, "altura")); |
196 |
} |
197 |
|
198 |
return lAltura;
|
199 |
} |
200 |
|
201 |
/**
|
202 |
* This method initializes bAceptar
|
203 |
*
|
204 |
* @return javax.swing.JButton
|
205 |
*/
|
206 |
private javax.swing.JButton getBAceptar() {
|
207 |
if (bAceptar == null) { |
208 |
bAceptar = new javax.swing.JButton();
|
209 |
bAceptar.setBounds(12, 185, 85, 23); |
210 |
bAceptar.setText(PluginServices.getText(this, "Aceptar")); |
211 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
212 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
213 |
//if (selecList.size() == 1) {
|
214 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
215 |
|
216 |
if (getTDesdeIzquierda().getText().equals("")) { |
217 |
getTDesdeIzquierda().setText("0");
|
218 |
} |
219 |
|
220 |
if (getTDesdeDerecha().getText().equals("")) { |
221 |
getTDesdeDerecha().setText("0");
|
222 |
} |
223 |
|
224 |
if (getTAnchura().getText().equals("")) { |
225 |
getTAnchura().setText("0");
|
226 |
} |
227 |
|
228 |
if (getTAltura().getText().equals("")) { |
229 |
getTAltura().setText("0");
|
230 |
} |
231 |
|
232 |
r.x = stringToDouble(getTDesdeIzquierda().getText() |
233 |
.toString()); |
234 |
r.y = stringToDouble(getTDesdeDerecha().getText() |
235 |
.toString()); |
236 |
r.width = stringToDouble(getTAnchura().getText() |
237 |
.toString()); |
238 |
r.height = stringToDouble(getTAltura().getText() |
239 |
.toString()); |
240 |
|
241 |
//((IFFrame) selecList.get(0)).setBoundBox(r);
|
242 |
IFFrame fframeAux=fframe.cloneFFrame(layout); |
243 |
fframeAux.setBoundBox(r); |
244 |
layout.getLayoutContext().getEFS().update(fframe,fframeAux); |
245 |
layout.getLayoutContext().updateFFrames(); |
246 |
//}
|
247 |
|
248 |
PluginServices.getMDIManager().closeWindow(FPositionDialog.this); |
249 |
layout.getLayoutControl().setStatus(LayoutControl.DESACTUALIZADO); |
250 |
layout.repaint(); |
251 |
} |
252 |
}); |
253 |
} |
254 |
|
255 |
return bAceptar;
|
256 |
} |
257 |
|
258 |
/**
|
259 |
* Paso de String a double.
|
260 |
*
|
261 |
* @param s String.
|
262 |
*
|
263 |
* @return double obtenido.
|
264 |
*/
|
265 |
private double stringToDouble(String s) { |
266 |
String snew = s.replace(',', '.'); |
267 |
|
268 |
return layout.getLayoutContext().getAtributes().fromUnits(Double.parseDouble(snew)); |
269 |
} |
270 |
|
271 |
/**
|
272 |
* This method initializes bCancelar
|
273 |
*
|
274 |
* @return javax.swing.JButton
|
275 |
*/
|
276 |
private javax.swing.JButton getBCancelar() {
|
277 |
if (bCancelar == null) { |
278 |
bCancelar = new javax.swing.JButton();
|
279 |
bCancelar.setBounds(107, 185, 87, 23); |
280 |
bCancelar.setText(PluginServices.getText(this, "Cancelar")); |
281 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
282 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
283 |
PluginServices.getMDIManager().closeWindow(FPositionDialog.this); |
284 |
} |
285 |
}); |
286 |
} |
287 |
|
288 |
return bCancelar;
|
289 |
} |
290 |
|
291 |
/**
|
292 |
* This method initializes tDesdeIzquierda
|
293 |
*
|
294 |
* @return javax.swing.JTextField
|
295 |
*/
|
296 |
private javax.swing.JTextField getTDesdeIzquierda() {
|
297 |
if (tDesdeIzquierda == null) { |
298 |
tDesdeIzquierda = new javax.swing.JTextField();
|
299 |
tDesdeIzquierda.setBounds(132, 85, 53, 20); |
300 |
tDesdeIzquierda.setText(String.valueOf(nf.format(
|
301 |
layout.getLayoutContext().getAtributes().toUnits(fframe.getBoundBox().x)))); |
302 |
} |
303 |
|
304 |
return tDesdeIzquierda;
|
305 |
} |
306 |
|
307 |
/**
|
308 |
* This method initializes tDesdeDerecha
|
309 |
*
|
310 |
* @return javax.swing.JTextField
|
311 |
*/
|
312 |
private javax.swing.JTextField getTDesdeDerecha() {
|
313 |
if (tDesdeDerecha == null) { |
314 |
tDesdeDerecha = new javax.swing.JTextField();
|
315 |
tDesdeDerecha.setBounds(132, 110, 53, 20); |
316 |
tDesdeDerecha.setText(String.valueOf(nf.format(
|
317 |
layout.getLayoutContext().getAtributes().toUnits(fframe.getBoundBox().y)))); |
318 |
} |
319 |
|
320 |
return tDesdeDerecha;
|
321 |
} |
322 |
|
323 |
/**
|
324 |
* This method initializes tAnchura
|
325 |
*
|
326 |
* @return javax.swing.JTextField
|
327 |
*/
|
328 |
private javax.swing.JTextField getTAnchura() {
|
329 |
if (tAnchura == null) { |
330 |
tAnchura = new javax.swing.JTextField();
|
331 |
tAnchura.setBounds(132, 135, 53, 20); |
332 |
tAnchura.setText(String.valueOf(nf.format(
|
333 |
layout.getLayoutContext().getAtributes().toUnits(fframe.getBoundBox().width)))); |
334 |
} |
335 |
|
336 |
return tAnchura;
|
337 |
} |
338 |
|
339 |
/**
|
340 |
* This method initializes tAltura
|
341 |
*
|
342 |
* @return javax.swing.JTextField
|
343 |
*/
|
344 |
private javax.swing.JTextField getTAltura() {
|
345 |
if (tAltura == null) { |
346 |
tAltura = new javax.swing.JTextField();
|
347 |
tAltura.setBounds(132, 160, 53, 20); |
348 |
tAltura.setText(String.valueOf(nf.format(layout.getLayoutContext().getAtributes()
|
349 |
.toUnits(fframe.getBoundBox().height)))); |
350 |
} |
351 |
|
352 |
return tAltura;
|
353 |
} |
354 |
|
355 |
/**
|
356 |
* This method initializes lNomUnidades
|
357 |
*
|
358 |
* @return javax.swing.JLabel
|
359 |
*/
|
360 |
private javax.swing.JLabel getLNomUnidades() {
|
361 |
if (lNomUnidades == null) { |
362 |
lNomUnidades = new javax.swing.JLabel();
|
363 |
lNomUnidades.setBounds(91, 7, 91, 20); |
364 |
lNomUnidades.setText(PluginServices.getText(this,m_NameUnit));
|
365 |
} |
366 |
|
367 |
return lNomUnidades;
|
368 |
} |
369 |
|
370 |
/**
|
371 |
* This method initializes lUnidades
|
372 |
*
|
373 |
* @return javax.swing.JLabel
|
374 |
*/
|
375 |
private javax.swing.JLabel getLUnidades() {
|
376 |
if (lUnidades == null) { |
377 |
lUnidades = new javax.swing.JLabel();
|
378 |
lUnidades.setBounds(7, 7, 72, 20); |
379 |
lUnidades.setText(PluginServices.getText(this, "unidades")); |
380 |
} |
381 |
|
382 |
return lUnidades;
|
383 |
} |
384 |
|
385 |
/**
|
386 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
387 |
*/
|
388 |
public WindowInfo getWindowInfo() {
|
389 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
390 |
|
391 |
//vi.setResizable(false);
|
392 |
m_viewinfo.setTitle(PluginServices.getText(this, "tamano_posicion")); |
393 |
|
394 |
return m_viewinfo;
|
395 |
} |
396 |
|
397 |
/**
|
398 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
399 |
*/
|
400 |
public void viewActivated() { |
401 |
} |
402 |
|
403 |
/**
|
404 |
* This method initializes lAnchoUnidades
|
405 |
*
|
406 |
* @return javax.swing.JLabel
|
407 |
*/
|
408 |
private javax.swing.JLabel getLAnchoUnidades() {
|
409 |
if (lAnchoUnidades == null) { |
410 |
lAnchoUnidades = new javax.swing.JLabel();
|
411 |
|
412 |
if (layout.getLayoutContext().getAtributes().isLandSpace()) {
|
413 |
lAnchoUnidades.setText(String.valueOf(nf.format(
|
414 |
layout.getLayoutContext().getAtributes().getSizeInUnits().getAlto()))); |
415 |
} else {
|
416 |
lAnchoUnidades.setText(String.valueOf(nf.format(
|
417 |
layout.getLayoutContext().getAtributes().getSizeInUnits().getAncho()))); |
418 |
} |
419 |
} |
420 |
|
421 |
return lAnchoUnidades;
|
422 |
} |
423 |
|
424 |
/**
|
425 |
* This method initializes lAlto
|
426 |
*
|
427 |
* @return javax.swing.JLabel
|
428 |
*/
|
429 |
private javax.swing.JLabel getLAlto() {
|
430 |
if (lAlto == null) { |
431 |
lAlto = new javax.swing.JLabel();
|
432 |
lAlto.setText(PluginServices.getText(this, "alto")); |
433 |
} |
434 |
|
435 |
return lAlto;
|
436 |
} |
437 |
|
438 |
/**
|
439 |
* This method initializes lAltoUnidades
|
440 |
*
|
441 |
* @return javax.swing.JLabel
|
442 |
*/
|
443 |
private javax.swing.JLabel getLAltoUnidades() {
|
444 |
if (lAltoUnidades == null) { |
445 |
lAltoUnidades = new javax.swing.JLabel();
|
446 |
|
447 |
if (layout.getLayoutContext().getAtributes().isLandSpace()) {
|
448 |
lAltoUnidades.setText(String.valueOf(nf.format(
|
449 |
layout.getLayoutContext().getAtributes().getSizeInUnits().getAncho()))); |
450 |
} else {
|
451 |
lAltoUnidades.setText(String.valueOf(nf.format(
|
452 |
layout.getLayoutContext().getAtributes().getSizeInUnits().getAlto()))); |
453 |
} |
454 |
} |
455 |
|
456 |
return lAltoUnidades;
|
457 |
} |
458 |
|
459 |
/**
|
460 |
* This method initializes lAncho
|
461 |
*
|
462 |
* @return javax.swing.JLabel
|
463 |
*/
|
464 |
private javax.swing.JLabel getLAncho() {
|
465 |
if (lAncho == null) { |
466 |
lAncho = new javax.swing.JLabel();
|
467 |
lAncho.setText(PluginServices.getText(this, "ancho")); |
468 |
} |
469 |
|
470 |
return lAncho;
|
471 |
} |
472 |
|
473 |
/**
|
474 |
* This method initializes pFolio
|
475 |
*
|
476 |
* @return javax.swing.JPanel
|
477 |
*/
|
478 |
private javax.swing.JPanel getPFolio() {
|
479 |
if (pFolio == null) { |
480 |
pFolio = new javax.swing.JPanel();
|
481 |
pFolio.add(getLAltoUnidades(), null);
|
482 |
pFolio.add(getLAlto(), null);
|
483 |
pFolio.add(getLSeparador(), null);
|
484 |
pFolio.add(getLAnchoUnidades(), null);
|
485 |
pFolio.add(getLAncho(), null);
|
486 |
pFolio.setBounds(9, 31, 180, 43); |
487 |
pFolio.setBorder(javax.swing.BorderFactory.createTitledBorder( |
488 |
null, PluginServices.getText(this, "tamanyo_pagina"), |
489 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
490 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
491 |
} |
492 |
|
493 |
return pFolio;
|
494 |
} |
495 |
|
496 |
/**
|
497 |
* This method initializes lSeparador
|
498 |
*
|
499 |
* @return javax.swing.JLabel
|
500 |
*/
|
501 |
private javax.swing.JLabel getLSeparador() {
|
502 |
if (lSeparador == null) { |
503 |
lSeparador = new javax.swing.JLabel();
|
504 |
lSeparador.setText("/");
|
505 |
} |
506 |
|
507 |
return lSeparador;
|
508 |
} |
509 |
} |