svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / gui / dialogs / FConfigLayoutDialog.java @ 219
History | View | Annotate | Download (35.5 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.app.project.documents.layout.gui.dialogs; |
23 |
|
24 |
import java.awt.GridBagConstraints; |
25 |
import java.awt.GridBagLayout; |
26 |
import java.awt.Insets; |
27 |
import java.awt.event.ActionEvent; |
28 |
import java.awt.event.ActionListener; |
29 |
import java.awt.geom.Rectangle2D; |
30 |
import java.text.NumberFormat; |
31 |
|
32 |
import javax.swing.ButtonGroup; |
33 |
import javax.swing.JButton; |
34 |
import javax.swing.JCheckBox; |
35 |
import javax.swing.JList; |
36 |
import javax.swing.JOptionPane; |
37 |
import javax.swing.JPanel; |
38 |
import javax.swing.JScrollPane; |
39 |
|
40 |
import org.gvsig.andami.PluginServices; |
41 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
42 |
import org.gvsig.andami.ui.mdiManager.IWindowListener; |
43 |
import org.gvsig.andami.ui.mdiManager.SingletonWindow; |
44 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
45 |
import org.gvsig.app.ApplicationLocator; |
46 |
import org.gvsig.app.ApplicationManager; |
47 |
import org.gvsig.app.project.ProjectManager; |
48 |
import org.gvsig.app.project.documents.layout.Attributes; |
49 |
import org.gvsig.app.project.documents.layout.LayoutContext; |
50 |
import org.gvsig.app.project.documents.layout.LayoutManager; |
51 |
import org.gvsig.app.project.documents.layout.Size; |
52 |
import org.gvsig.app.project.documents.layout.fframes.FFrameView; |
53 |
import org.gvsig.app.project.documents.layout.fframes.ListViewModel; |
54 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
55 |
import org.gvsig.app.project.documents.view.ViewDocument; |
56 |
import org.gvsig.app.project.documents.view.ViewManager; |
57 |
import org.gvsig.fmap.mapcontext.MapContext; |
58 |
import org.gvsig.i18n.Messages; |
59 |
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager; |
60 |
|
61 |
/**
|
62 |
* Dialog which can be used to configure the Layout page settings
|
63 |
*
|
64 |
* @author Vicente Caballero Navarro
|
65 |
* @author Cesar Martinez Izquierdo
|
66 |
*/
|
67 |
public class FConfigLayoutDialog extends JPanel implements SingletonWindow { |
68 |
|
69 |
private static final long serialVersionUID = -425263925680280142L; |
70 |
private javax.swing.JLabel lTamPag = null; |
71 |
private javax.swing.JComboBox cbTipoFolio = null; |
72 |
private javax.swing.JComboBox cbUnidades = null; |
73 |
private javax.swing.JLabel lAnchura = null; |
74 |
private javax.swing.JLabel lAltura = null; |
75 |
private javax.swing.JTextField tAncho = null; |
76 |
private javax.swing.JTextField tAlto = null; |
77 |
private javax.swing.JLabel lOrientacion = null; |
78 |
private javax.swing.JLabel lMargenes = null; |
79 |
private javax.swing.JCheckBox chbMargenes = null; |
80 |
private javax.swing.JLabel lSuperior = null; |
81 |
private javax.swing.JTextField tSuperior = null; |
82 |
private javax.swing.JLabel lIzquierdo = null; |
83 |
private javax.swing.JTextField tIzquierdo = null; |
84 |
private javax.swing.JLabel lInferior = null; |
85 |
private javax.swing.JTextField tInferior = null; |
86 |
private javax.swing.JLabel lDerecho = null; |
87 |
private javax.swing.JTextField tDerecho = null; |
88 |
private javax.swing.JLabel lResolucion = null; |
89 |
private javax.swing.JComboBox cbResolucion = null; |
90 |
private javax.swing.JButton bAceptar = null; |
91 |
private javax.swing.JButton bCancelar = null; |
92 |
private LayoutPanel m_layout = null; |
93 |
private JPanel pOrientation = null; |
94 |
private javax.swing.JRadioButton rbHorizontal = null; |
95 |
private javax.swing.JRadioButton rbVertical = null; |
96 |
private int unit = 2; |
97 |
private int type = 0; |
98 |
private boolean isLand = true; |
99 |
private boolean margin = false; |
100 |
private int resolution = 1; |
101 |
private double der = 2.54; |
102 |
private double izq = 2.54; |
103 |
private double sup = 2.54; |
104 |
private double inf = 2.54; |
105 |
private NumberFormat nf = NumberFormat.getInstance(); |
106 |
private JList liViews = null; |
107 |
private boolean showViewList; |
108 |
private JCheckBox chbViews = null; |
109 |
private JButton btConfigView = null; |
110 |
private ViewDocument createdView = null; |
111 |
private JScrollPane jViewScrollPane = null; |
112 |
private WindowInfo windowInfo = null; |
113 |
|
114 |
/**
|
115 |
* This is the default constructor
|
116 |
*
|
117 |
* @param layout
|
118 |
* Referencia al Layout.
|
119 |
*/
|
120 |
public FConfigLayoutDialog(LayoutPanel layout) {
|
121 |
this(layout, false); |
122 |
} |
123 |
|
124 |
/**
|
125 |
* This is the default constructor
|
126 |
*
|
127 |
* @param layout
|
128 |
* Referencia al Layout.
|
129 |
*/
|
130 |
public FConfigLayoutDialog(LayoutPanel layout, boolean showViewList) { |
131 |
super();
|
132 |
m_layout = layout; |
133 |
this.showViewList = showViewList;
|
134 |
initialize(); |
135 |
} |
136 |
|
137 |
/**
|
138 |
* This method initializes this
|
139 |
*/
|
140 |
private void initialize() { |
141 |
int row = 0; |
142 |
nf.setMaximumFractionDigits(2);
|
143 |
this.setLayout(new GridBagLayout()); |
144 |
GridBagConstraints c = new GridBagConstraints(); |
145 |
type = m_layout.getLayoutContext().getAttributes().getType(); |
146 |
unit = m_layout.getLayoutContext().getAttributes().getSelTypeUnit(); |
147 |
isLand = m_layout.getLayoutContext().getAttributes().isLandscape(); |
148 |
sup = m_layout.getLayoutContext().getAttributes().getAreaInsets()[0];
|
149 |
inf = m_layout.getLayoutContext().getAttributes().getAreaInsets()[1];
|
150 |
izq = m_layout.getLayoutContext().getAttributes().getAreaInsets()[2];
|
151 |
der = m_layout.getLayoutContext().getAttributes().getAreaInsets()[3];
|
152 |
c.fill = GridBagConstraints.HORIZONTAL;
|
153 |
c.anchor = GridBagConstraints.LINE_START;
|
154 |
c.insets = new Insets(5, 5, 5, 5); |
155 |
c.gridx = 0;
|
156 |
c.gridy = row++; |
157 |
c.gridwidth = 1;
|
158 |
this.add(getLTamPag(), c);
|
159 |
c.gridx = GridBagConstraints.RELATIVE;
|
160 |
c.fill = GridBagConstraints.HORIZONTAL;
|
161 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
162 |
this.add(getCbTipoFolio(), c);
|
163 |
c.gridx = 0;
|
164 |
c.gridy = row++; |
165 |
c.gridwidth = 1;
|
166 |
c.fill = GridBagConstraints.NONE;
|
167 |
this.add(getLAnchura(), c);
|
168 |
c.gridx = 1;
|
169 |
this.add(getTAncho(), c);
|
170 |
c.gridx = 2;
|
171 |
this.add(getLAltura(), c);
|
172 |
c.gridx = 3;
|
173 |
this.add(getTAlto(), c);
|
174 |
c.gridx = 4;
|
175 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
176 |
c.fill = GridBagConstraints.HORIZONTAL;
|
177 |
this.add(getCbUnidades(), c);
|
178 |
c.gridx = 0;
|
179 |
c.gridy = row++; |
180 |
c.gridwidth = 1;
|
181 |
this.add(getLOrientacion(), c);
|
182 |
c.gridx = GridBagConstraints.RELATIVE;
|
183 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
184 |
this.add(getOrientationPanel(), c);
|
185 |
c.gridy = row++; |
186 |
c.gridx = 0;
|
187 |
c.gridwidth = 1;
|
188 |
this.add(getLResolucion(), c);
|
189 |
c.gridx = GridBagConstraints.RELATIVE;
|
190 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
191 |
this.add(getCbResolucion(), c);
|
192 |
if (this.showViewList) { |
193 |
c.gridy = row++; |
194 |
c.gridx = 0;
|
195 |
c.gridwidth = 1;
|
196 |
c.anchor = GridBagConstraints.PAGE_START;
|
197 |
this.add(getChbViews(), c);
|
198 |
c.gridx = 1;
|
199 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
200 |
this.add(getViewScrollPane(), c);
|
201 |
c.anchor = GridBagConstraints.LINE_START;
|
202 |
c.gridy = row++; |
203 |
c.gridx = 1;
|
204 |
c.gridwidth = 1;
|
205 |
this.add(getBtConfigView(), c);
|
206 |
} |
207 |
c.gridy = row++; |
208 |
c.gridx = 0;
|
209 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
210 |
this.add(getChbMargenes(), c);
|
211 |
c.fill = GridBagConstraints.NONE;
|
212 |
c.gridy = row++; |
213 |
c.gridx = 0;
|
214 |
c.gridwidth = 1;
|
215 |
this.add(getLSuperior(), c);
|
216 |
c.gridx = GridBagConstraints.RELATIVE;
|
217 |
this.add(getTSuperior(), c);
|
218 |
c.gridx = GridBagConstraints.RELATIVE;
|
219 |
this.add(getLIzquierdo(), c);
|
220 |
this.add(getTIzquierdo(), c);
|
221 |
c.gridy = row++; |
222 |
c.gridx = 0;
|
223 |
this.add(getLInferior(), c);
|
224 |
c.gridx = GridBagConstraints.RELATIVE;
|
225 |
this.add(getTInferior(), c);
|
226 |
this.add(getLDerecho(), c);
|
227 |
this.add(getTDerecho(), c);
|
228 |
c.gridy = row++; |
229 |
c.gridx = 3;
|
230 |
c.insets = new Insets(15, 5, 10, 5); |
231 |
this.add(getBAceptar(), c);
|
232 |
c.gridx = GridBagConstraints.RELATIVE;
|
233 |
this.add(getBCancelar(), c);
|
234 |
} |
235 |
|
236 |
/**
|
237 |
* This method initializes lTamPag
|
238 |
*
|
239 |
* @return javax.swing.JLabel
|
240 |
*/
|
241 |
private javax.swing.JLabel getLTamPag() {
|
242 |
if (lTamPag == null) { |
243 |
lTamPag = new javax.swing.JLabel();
|
244 |
lTamPag |
245 |
.setText(PluginServices.getText(this, "tamano_pagina")); |
246 |
} |
247 |
|
248 |
return lTamPag;
|
249 |
} |
250 |
|
251 |
/**
|
252 |
* This method initializes cbTipoFolio
|
253 |
*
|
254 |
* @return javax.swing.JComboBox
|
255 |
*/
|
256 |
private javax.swing.JComboBox getCbTipoFolio() {
|
257 |
if (cbTipoFolio == null) { |
258 |
cbTipoFolio = new javax.swing.JComboBox();
|
259 |
cbTipoFolio.addItem(PluginServices.getText(this,
|
260 |
"Igual_que_la_impresora"));
|
261 |
cbTipoFolio.addItem(PluginServices.getText(this, "A4")); |
262 |
cbTipoFolio.addItem(PluginServices.getText(this, "A3")); |
263 |
cbTipoFolio.addItem(PluginServices.getText(this, "A2")); |
264 |
cbTipoFolio.addItem(PluginServices.getText(this, "A1")); |
265 |
cbTipoFolio.addItem(PluginServices.getText(this, "A0")); |
266 |
cbTipoFolio.addItem(PluginServices.getText(this, "Personalizado")); |
267 |
|
268 |
cbTipoFolio.setSelectedIndex(m_layout.getLayoutContext() |
269 |
.getAttributes().getType()); |
270 |
cbTipoFolio.addActionListener(new java.awt.event.ActionListener() {
|
271 |
|
272 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
273 |
type = cbTipoFolio.getSelectedIndex(); |
274 |
|
275 |
Size size = |
276 |
m_layout.getLayoutContext().getAttributes() |
277 |
.getSizeinUnits(isLand, type); |
278 |
getTAlto().setText( |
279 |
String.valueOf(nf.format(size.getAlto())));
|
280 |
getTAncho().setText( |
281 |
String.valueOf(nf.format(size.getAncho())));
|
282 |
setMargin(margin); |
283 |
if (cbTipoFolio.getSelectedItem().equals(
|
284 |
PluginServices.getText(this, "Personalizado"))) { |
285 |
getTAlto().setEnabled(true);
|
286 |
getTAncho().setEnabled(true);
|
287 |
getRbVertical().setSelected(true);
|
288 |
isLand = false;
|
289 |
getRbVertical().setEnabled(false);
|
290 |
getRbHorizontal().setEnabled(false);
|
291 |
} else {
|
292 |
getTAlto().setEnabled(false);
|
293 |
getTAncho().setEnabled(false);
|
294 |
getRbVertical().setEnabled(true);
|
295 |
getRbHorizontal().setEnabled(true);
|
296 |
} |
297 |
} |
298 |
}); |
299 |
} |
300 |
|
301 |
return cbTipoFolio;
|
302 |
} |
303 |
|
304 |
/**
|
305 |
* This method initializes cbUnidades
|
306 |
*
|
307 |
* @return javax.swing.JComboBox
|
308 |
*/
|
309 |
private javax.swing.JComboBox getCbUnidades() {
|
310 |
if (cbUnidades == null) { |
311 |
cbUnidades = new javax.swing.JComboBox();
|
312 |
String[] names = MapContext.getDistanceNames(); |
313 |
for (int i = 0; i < names.length; i++) { |
314 |
cbUnidades.addItem(PluginServices.getText(this, names[i]));
|
315 |
} |
316 |
cbUnidades.setSelectedIndex(m_layout.getLayoutContext() |
317 |
.getAttributes().getSelTypeUnit()); |
318 |
cbUnidades.addActionListener(new java.awt.event.ActionListener() {
|
319 |
|
320 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
321 |
unit = cbUnidades.getSelectedIndex(); |
322 |
m_layout.getLayoutContext().getAttributes().setUnit(unit); |
323 |
|
324 |
Size size = |
325 |
m_layout.getLayoutContext().getAttributes() |
326 |
.getSizeinUnits(isLand, type); |
327 |
getTAlto().setText( |
328 |
String.valueOf(nf.format(size.getAncho())));
|
329 |
getTAncho().setText( |
330 |
String.valueOf(nf.format(size.getAlto())));
|
331 |
setMargin(margin); |
332 |
} |
333 |
}); |
334 |
} |
335 |
|
336 |
return cbUnidades;
|
337 |
} |
338 |
|
339 |
/**
|
340 |
* This method initializes lAnchura
|
341 |
*
|
342 |
* @return javax.swing.JLabel
|
343 |
*/
|
344 |
private javax.swing.JLabel getLAnchura() {
|
345 |
if (lAnchura == null) { |
346 |
lAnchura = new javax.swing.JLabel();
|
347 |
lAnchura.setText(PluginServices.getText(this, "anchura")); |
348 |
} |
349 |
return lAnchura;
|
350 |
} |
351 |
|
352 |
/**
|
353 |
* This method initializes lAltura
|
354 |
*
|
355 |
* @return javax.swing.JLabel
|
356 |
*/
|
357 |
private javax.swing.JLabel getLAltura() {
|
358 |
if (lAltura == null) { |
359 |
lAltura = new javax.swing.JLabel();
|
360 |
lAltura.setText(PluginServices.getText(this, "altura")); |
361 |
} |
362 |
return lAltura;
|
363 |
} |
364 |
|
365 |
/**
|
366 |
* This method initializes tAncho
|
367 |
*
|
368 |
* @return javax.swing.JTextField
|
369 |
*/
|
370 |
private javax.swing.JTextField getTAncho() {
|
371 |
if (tAncho == null) { |
372 |
tAncho = new javax.swing.JTextField(4); |
373 |
Size size = |
374 |
m_layout.getLayoutContext().getAttributes() |
375 |
.getSizeinUnits(isLand, type); |
376 |
String s = String.valueOf(nf.format(size.getAncho())); |
377 |
tAncho.setText(s); |
378 |
if (getCbTipoFolio().getSelectedItem().equals(
|
379 |
PluginServices.getText(this, "Personalizado"))) { |
380 |
tAncho.setEnabled(true);
|
381 |
} else {
|
382 |
tAncho.setEnabled(false);
|
383 |
} |
384 |
} |
385 |
|
386 |
return tAncho;
|
387 |
} |
388 |
|
389 |
/**
|
390 |
* This method initializes tAlto
|
391 |
*
|
392 |
* @return javax.swing.JTextField
|
393 |
*/
|
394 |
private javax.swing.JTextField getTAlto() {
|
395 |
if (tAlto == null) { |
396 |
tAlto = new javax.swing.JTextField(4); |
397 |
Size size = |
398 |
m_layout.getLayoutContext().getAttributes() |
399 |
.getSizeinUnits(isLand, type); |
400 |
String s = String.valueOf(nf.format(size.getAlto())); |
401 |
tAlto.setText(s); |
402 |
if (getCbTipoFolio().getSelectedItem().equals(
|
403 |
PluginServices.getText(this, "Personalizado"))) { |
404 |
tAlto.setEnabled(true);
|
405 |
} else {
|
406 |
tAlto.setEnabled(false);
|
407 |
} |
408 |
} |
409 |
|
410 |
return tAlto;
|
411 |
} |
412 |
|
413 |
/**
|
414 |
* This method initializes lOrientacion
|
415 |
*
|
416 |
* @return javax.swing.JLabel
|
417 |
*/
|
418 |
private javax.swing.JLabel getLOrientacion() {
|
419 |
if (lOrientacion == null) { |
420 |
lOrientacion = new javax.swing.JLabel();
|
421 |
lOrientacion.setText(PluginServices.getText(this, "orientacion")); |
422 |
} |
423 |
|
424 |
return lOrientacion;
|
425 |
} |
426 |
|
427 |
/**
|
428 |
* This method initializes lMargenes
|
429 |
*
|
430 |
* @return javax.swing.JLabel
|
431 |
*/
|
432 |
private javax.swing.JLabel getLMargenes() {
|
433 |
if (lMargenes == null) { |
434 |
lMargenes = new javax.swing.JLabel();
|
435 |
lMargenes.setText(PluginServices.getText(this, "margenes")); |
436 |
} |
437 |
|
438 |
return lMargenes;
|
439 |
} |
440 |
|
441 |
/**
|
442 |
* Inserta si se dibuja los margenes sobre el Layout o no.
|
443 |
*
|
444 |
* @param b
|
445 |
* True si se tiene que dibujar los margenes.
|
446 |
*/
|
447 |
private void setMargin(boolean b) { |
448 |
margin = b; |
449 |
|
450 |
if (b) {
|
451 |
getTSuperior().setText( |
452 |
String.valueOf(nf.format(m_layout.getLayoutContext()
|
453 |
.getAttributes().toUnits(sup)))); |
454 |
getTIzquierdo().setText( |
455 |
String.valueOf(nf.format(m_layout.getLayoutContext()
|
456 |
.getAttributes().toUnits(izq)))); |
457 |
getTInferior().setText( |
458 |
String.valueOf(nf.format(m_layout.getLayoutContext()
|
459 |
.getAttributes().toUnits(inf)))); |
460 |
getTDerecho().setText( |
461 |
String.valueOf(nf.format(m_layout.getLayoutContext()
|
462 |
.getAttributes().toUnits(der)))); |
463 |
getTSuperior().setEnabled(true);
|
464 |
getTIzquierdo().setEnabled(true);
|
465 |
getTInferior().setEnabled(true);
|
466 |
getTDerecho().setEnabled(true);
|
467 |
} else {
|
468 |
getTSuperior().setText("");
|
469 |
getTIzquierdo().setText("");
|
470 |
getTInferior().setText("");
|
471 |
getTDerecho().setText("");
|
472 |
getTSuperior().setEnabled(false);
|
473 |
getTIzquierdo().setEnabled(false);
|
474 |
getTInferior().setEnabled(false);
|
475 |
getTDerecho().setEnabled(false);
|
476 |
} |
477 |
} |
478 |
|
479 |
/**
|
480 |
* This method initializes chbMargenes
|
481 |
*
|
482 |
* @return javax.swing.JCheckBox
|
483 |
*/
|
484 |
private javax.swing.JCheckBox getChbMargenes() {
|
485 |
if (chbMargenes == null) { |
486 |
chbMargenes = new javax.swing.JCheckBox();
|
487 |
chbMargenes.setText(PluginServices.getText(this,
|
488 |
"personalizar_margenes"));
|
489 |
chbMargenes.setSelected(m_layout.getLayoutContext().getAttributes() |
490 |
.isMargin()); |
491 |
setMargin(m_layout.getLayoutContext().getAttributes().isMargin()); |
492 |
chbMargenes.addActionListener(new java.awt.event.ActionListener() {
|
493 |
|
494 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
495 |
if (chbMargenes.isSelected()) {
|
496 |
margin = true;
|
497 |
} else {
|
498 |
margin = false;
|
499 |
} |
500 |
|
501 |
setMargin(margin); |
502 |
} |
503 |
}); |
504 |
} |
505 |
|
506 |
return chbMargenes;
|
507 |
} |
508 |
|
509 |
/**
|
510 |
* This method initializes lSuperior
|
511 |
*
|
512 |
* @return javax.swing.JLabel
|
513 |
*/
|
514 |
private javax.swing.JLabel getLSuperior() {
|
515 |
if (lSuperior == null) { |
516 |
lSuperior = new javax.swing.JLabel();
|
517 |
lSuperior.setText(PluginServices.getText(this, "Superior")); |
518 |
} |
519 |
|
520 |
return lSuperior;
|
521 |
} |
522 |
|
523 |
/**
|
524 |
* This method initializes tSuperior
|
525 |
*
|
526 |
* @return javax.swing.JTextField
|
527 |
*/
|
528 |
private javax.swing.JTextField getTSuperior() {
|
529 |
if (tSuperior == null) { |
530 |
tSuperior = new javax.swing.JTextField(4); |
531 |
if (m_layout.getLayoutContext().getAttributes().isMargin()) {
|
532 |
tSuperior.setText(String.valueOf(nf.format(m_layout
|
533 |
.getLayoutContext().getAttributes().toUnits(sup)))); |
534 |
} |
535 |
} |
536 |
|
537 |
return tSuperior;
|
538 |
} |
539 |
|
540 |
/**
|
541 |
* This method initializes lIzquierdo
|
542 |
*
|
543 |
* @return javax.swing.JLabel
|
544 |
*/
|
545 |
private javax.swing.JLabel getLIzquierdo() {
|
546 |
if (lIzquierdo == null) { |
547 |
lIzquierdo = new javax.swing.JLabel();
|
548 |
lIzquierdo.setText(PluginServices.getText(this, "Izquierdo")); |
549 |
} |
550 |
|
551 |
return lIzquierdo;
|
552 |
} |
553 |
|
554 |
/**
|
555 |
* This method initializes tIzquierdo
|
556 |
*
|
557 |
* @return javax.swing.JTextField
|
558 |
*/
|
559 |
private javax.swing.JTextField getTIzquierdo() {
|
560 |
if (tIzquierdo == null) { |
561 |
tIzquierdo = new javax.swing.JTextField(4); |
562 |
if (m_layout.getLayoutContext().getAttributes().isMargin()) {
|
563 |
tIzquierdo.setText(String.valueOf(nf.format(m_layout
|
564 |
.getLayoutContext().getAttributes().toUnits(izq)))); |
565 |
} |
566 |
} |
567 |
|
568 |
return tIzquierdo;
|
569 |
} |
570 |
|
571 |
/**
|
572 |
* This method initializes lInferior
|
573 |
*
|
574 |
* @return javax.swing.JLabel
|
575 |
*/
|
576 |
private javax.swing.JLabel getLInferior() {
|
577 |
if (lInferior == null) { |
578 |
lInferior = new javax.swing.JLabel();
|
579 |
lInferior.setText(PluginServices.getText(this, "Inferior")); |
580 |
} |
581 |
|
582 |
return lInferior;
|
583 |
} |
584 |
|
585 |
/**
|
586 |
* This method initializes tInferior
|
587 |
*
|
588 |
* @return javax.swing.JTextField
|
589 |
*/
|
590 |
private javax.swing.JTextField getTInferior() {
|
591 |
if (tInferior == null) { |
592 |
tInferior = new javax.swing.JTextField(4); |
593 |
if (m_layout.getLayoutContext().getAttributes().isMargin()) {
|
594 |
tInferior.setText(String.valueOf(nf.format(m_layout
|
595 |
.getLayoutContext().getAttributes().toUnits(inf)))); |
596 |
} |
597 |
} |
598 |
|
599 |
return tInferior;
|
600 |
} |
601 |
|
602 |
/**
|
603 |
* This method initializes lDerecho
|
604 |
*
|
605 |
* @return javax.swing.JLabel
|
606 |
*/
|
607 |
private javax.swing.JLabel getLDerecho() {
|
608 |
if (lDerecho == null) { |
609 |
lDerecho = new javax.swing.JLabel();
|
610 |
lDerecho.setText(PluginServices.getText(this, "Derecho")); |
611 |
} |
612 |
|
613 |
return lDerecho;
|
614 |
} |
615 |
|
616 |
/**
|
617 |
* This method initializes tDerecho
|
618 |
*
|
619 |
* @return javax.swing.JTextField
|
620 |
*/
|
621 |
private javax.swing.JTextField getTDerecho() {
|
622 |
if (tDerecho == null) { |
623 |
tDerecho = new javax.swing.JTextField(4); |
624 |
if (m_layout.getLayoutContext().getAttributes().isMargin()) {
|
625 |
tDerecho.setText(String.valueOf(nf.format(m_layout
|
626 |
.getLayoutContext().getAttributes().toUnits(der)))); |
627 |
} |
628 |
} |
629 |
|
630 |
return tDerecho;
|
631 |
} |
632 |
|
633 |
/**
|
634 |
* This method initializes lResolucion
|
635 |
*
|
636 |
* @return javax.swing.JLabel
|
637 |
*/
|
638 |
private javax.swing.JLabel getLResolucion() {
|
639 |
if (lResolucion == null) { |
640 |
lResolucion = new javax.swing.JLabel();
|
641 |
lResolucion.setText(PluginServices.getText(this,
|
642 |
"resolucion_resultado"));
|
643 |
} |
644 |
|
645 |
return lResolucion;
|
646 |
} |
647 |
|
648 |
/**
|
649 |
* This method initializes cbResolucion
|
650 |
*
|
651 |
* @return javax.swing.JComboBox
|
652 |
*/
|
653 |
private javax.swing.JComboBox getCbResolucion() {
|
654 |
if (cbResolucion == null) { |
655 |
cbResolucion = new javax.swing.JComboBox();
|
656 |
cbResolucion.addItem(PluginServices.getText(this, "High_600_dpi")); |
657 |
cbResolucion.addItem(PluginServices.getText(this, "Normal_300_dpi")); |
658 |
cbResolucion.addItem(PluginServices.getText(this, "Low_72_dpi")); |
659 |
cbResolucion.setSelectedIndex(m_layout.getLayoutContext() |
660 |
.getAttributes().getResolution()); |
661 |
cbResolucion.addActionListener(new java.awt.event.ActionListener() {
|
662 |
|
663 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
664 |
resolution = cbResolucion.getSelectedIndex(); |
665 |
} |
666 |
}); |
667 |
} |
668 |
|
669 |
return cbResolucion;
|
670 |
} |
671 |
|
672 |
/**
|
673 |
* This method initializes bAceptar
|
674 |
*
|
675 |
* @return javax.swing.JButton
|
676 |
*/
|
677 |
private javax.swing.JButton getBAceptar() {
|
678 |
if (bAceptar == null) { |
679 |
bAceptar = new javax.swing.JButton();
|
680 |
bAceptar.setText(PluginServices.getText(this, "Aceptar")); |
681 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
682 |
|
683 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
684 |
Attributes attributes = m_layout.getLayoutContext().getAttributes();
|
685 |
attributes.setUnit(unit); |
686 |
|
687 |
if (isLand) {
|
688 |
attributes.setIsLandScape(true);
|
689 |
} else {
|
690 |
attributes.setIsLandScape(false);
|
691 |
} |
692 |
|
693 |
attributes.setType(type); |
694 |
attributes.resetSizeinUnits(isLand); |
695 |
obtainArea(); |
696 |
|
697 |
double[] area = { sup, inf, izq, der }; |
698 |
|
699 |
if (type == Attributes.CUSTOM) { |
700 |
String width = getTAncho().getText().replace(',', '.'); |
701 |
String height = getTAlto().getText().replace(',', '.'); |
702 |
Attributes.CUSTOM_PAPER_SIZE =
|
703 |
new Size(
|
704 |
Double.valueOf(height).doubleValue(),
|
705 |
Double.valueOf(width).doubleValue());
|
706 |
attributes.m_sizePaper = |
707 |
Attributes.CUSTOM_PAPER_SIZE;
|
708 |
} |
709 |
attributes.setType(type); |
710 |
m_layout.obtainRect(false);
|
711 |
m_layout |
712 |
.getLayoutContext() |
713 |
.getAttributes() |
714 |
.setSelectedOptions(type, unit, isLand, margin, |
715 |
resolution, area); |
716 |
if (showViewList && getChbViews().isSelected()) { // a view has been selected |
717 |
ViewDocument vd = getSelectedView(); |
718 |
ProjectManager projectManager = ApplicationLocator.getProjectManager(); |
719 |
LayoutManager layoutManager = (LayoutManager) projectManager.getDocumentManager(LayoutManager.TYPENAME); |
720 |
FFrameView ffv = (FFrameView) layoutManager.createFrame(FFrameView.PERSISTENCE_DEFINITION_NAME); |
721 |
ffv.setDocument(m_layout.getDocument()); |
722 |
LayoutContext lctxt = m_layout.getLayoutContext(); |
723 |
ffv.setLayoutContext(lctxt); |
724 |
ffv.setBoundBox(new Rectangle2D.Double(izq, sup, attributes.getPaperSize().getAncho()-(izq+der), attributes.getPaperSize().getAlto()-(sup+inf))); |
725 |
ffv.setView(vd); |
726 |
lctxt.addFFrame(ffv, true, true); |
727 |
m_layout.getLayoutControl().setDefaultTool(); |
728 |
} |
729 |
if (createdView!=null && createdView!=getSelectedView()) { // a view was created but later de-selected |
730 |
deleteView(); |
731 |
} |
732 |
PluginServices.getMDIManager().closeWindow( |
733 |
FConfigLayoutDialog.this); |
734 |
m_layout.getLayoutControl().fullRect(); |
735 |
} |
736 |
}); |
737 |
} |
738 |
|
739 |
return bAceptar;
|
740 |
} |
741 |
|
742 |
/**
|
743 |
* This method initializes bCancelar
|
744 |
*
|
745 |
* @return javax.swing.JButton
|
746 |
*/
|
747 |
private javax.swing.JButton getBCancelar() {
|
748 |
if (bCancelar == null) { |
749 |
bCancelar = new javax.swing.JButton();
|
750 |
bCancelar.setText(PluginServices.getText(this, "Cancelar")); |
751 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
752 |
|
753 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
754 |
if (createdView!=null) { |
755 |
deleteView(); |
756 |
} |
757 |
PluginServices.getMDIManager().closeWindow( |
758 |
FConfigLayoutDialog.this); |
759 |
} |
760 |
}); |
761 |
} |
762 |
|
763 |
return bCancelar;
|
764 |
} |
765 |
|
766 |
private JPanel getOrientationPanel() { |
767 |
if (pOrientation == null) { |
768 |
pOrientation = new JPanel(new GridBagLayout()); |
769 |
GridBagConstraints c = new GridBagConstraints(); |
770 |
c.anchor = GridBagConstraints.WEST;
|
771 |
c.gridx = 0;
|
772 |
c.gridy = 0;
|
773 |
c.insets = new Insets(0, 0, 0, 10); |
774 |
pOrientation.add(getRbHorizontal(), c); |
775 |
c.gridx = 1;
|
776 |
c.insets = new Insets(0, 0, 0, 0); |
777 |
c.weightx = 1.0;
|
778 |
c.fill = GridBagConstraints.HORIZONTAL;
|
779 |
pOrientation.add(getRbVertical(), c); |
780 |
// add the radios to the button group
|
781 |
ButtonGroup bgOrientation = new ButtonGroup(); |
782 |
bgOrientation.add(getRbHorizontal()); |
783 |
bgOrientation.add(getRbVertical()); |
784 |
if (isLand) {
|
785 |
getRbHorizontal().setSelected(true);
|
786 |
} |
787 |
else {
|
788 |
getRbVertical().setSelected(true);
|
789 |
} |
790 |
if (getCbTipoFolio().getSelectedItem().equals(
|
791 |
PluginServices.getText(this, "Personalizado"))) { |
792 |
rbHorizontal.setEnabled(false);
|
793 |
rbVertical.setEnabled(false);
|
794 |
rbVertical.setSelected(true);
|
795 |
isLand = false;
|
796 |
} |
797 |
} |
798 |
return pOrientation;
|
799 |
} |
800 |
|
801 |
/**
|
802 |
* This method initializes chbHorizontal
|
803 |
*
|
804 |
* @return javax.swing.JCheckBox
|
805 |
*/
|
806 |
private javax.swing.JRadioButton getRbHorizontal() {
|
807 |
if (rbHorizontal == null) { |
808 |
rbHorizontal = new javax.swing.JRadioButton();
|
809 |
rbHorizontal.setText(PluginServices.getText(this, "horizontal")); |
810 |
rbHorizontal |
811 |
.addActionListener(new java.awt.event.ActionListener() {
|
812 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
813 |
isLand = true;
|
814 |
double iz = izq;
|
815 |
izq = inf; |
816 |
inf = der; |
817 |
der = sup; |
818 |
sup = iz; |
819 |
|
820 |
setMargin(margin); |
821 |
|
822 |
if (type == Attributes.CUSTOM) { |
823 |
Attributes.CUSTOM_PAPER_SIZE =
|
824 |
new Size(Double.valueOf( |
825 |
getTAlto().getText()).doubleValue(), |
826 |
Double.valueOf(getTAncho().getText())
|
827 |
.doubleValue()); |
828 |
} |
829 |
|
830 |
Size size = |
831 |
m_layout.getLayoutContext().getAttributes() |
832 |
.getSizeinUnits(isLand, type); |
833 |
getTAncho().setText( |
834 |
String.valueOf(nf.format(size.getAncho())));
|
835 |
getTAlto().setText( |
836 |
String.valueOf(nf.format(size.getAlto())));
|
837 |
} |
838 |
}); |
839 |
} |
840 |
|
841 |
return rbHorizontal;
|
842 |
} |
843 |
|
844 |
/**
|
845 |
* This method initializes chbVertical
|
846 |
*
|
847 |
* @return javax.swing.JCheckBox
|
848 |
*/
|
849 |
private javax.swing.JRadioButton getRbVertical() { if (rbVertical == null) { |
850 |
rbVertical = new javax.swing.JRadioButton();
|
851 |
rbVertical.setText(PluginServices.getText(this, "vertical")); |
852 |
rbVertical.addActionListener(new java.awt.event.ActionListener() {
|
853 |
|
854 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
855 |
isLand = false;
|
856 |
double in = inf;
|
857 |
inf = izq; |
858 |
izq = sup; |
859 |
sup = der; |
860 |
der = in; |
861 |
|
862 |
setMargin(margin); |
863 |
|
864 |
if (type == Attributes.CUSTOM) { |
865 |
Attributes.CUSTOM_PAPER_SIZE =
|
866 |
new Size(Double.valueOf(getTAlto().getText()) |
867 |
.doubleValue(), Double.valueOf(
|
868 |
getTAncho().getText()).doubleValue()); |
869 |
} |
870 |
|
871 |
Size size = |
872 |
m_layout.getLayoutContext().getAttributes() |
873 |
.getSizeinUnits(isLand, type); |
874 |
getTAncho().setText( |
875 |
String.valueOf(nf.format(size.getAncho())));
|
876 |
getTAlto().setText( |
877 |
String.valueOf(nf.format(size.getAlto())));
|
878 |
} |
879 |
}); |
880 |
} |
881 |
|
882 |
return rbVertical;
|
883 |
} |
884 |
|
885 |
/**
|
886 |
* This method initializes liVistas
|
887 |
*
|
888 |
* @return javax.swing.JList
|
889 |
*/
|
890 |
private javax.swing.JList getViewList() {
|
891 |
if (liViews == null) { |
892 |
ListViewModel listModel = new ListViewModel();
|
893 |
listModel.addCreateNewViewObj(); |
894 |
if (listModel.addViews()) {
|
895 |
JOptionPane.showMessageDialog(
|
896 |
ApplicationLocator.getManager().getRootComponent(), |
897 |
Messages.getText("_Some_views_excluded_from_list_because_have_editing_layers"),
|
898 |
Messages.getText("Preparar_pagina"),
|
899 |
JOptionPane.WARNING_MESSAGE);
|
900 |
} |
901 |
|
902 |
liViews = new javax.swing.JList(listModel);
|
903 |
liViews.setSelectedIndex(0);
|
904 |
} |
905 |
return liViews;
|
906 |
} |
907 |
|
908 |
private JScrollPane getViewScrollPane(){ |
909 |
if (jViewScrollPane==null) { |
910 |
jViewScrollPane = new javax.swing.JScrollPane();
|
911 |
jViewScrollPane.setViewportView(getViewList()); |
912 |
jViewScrollPane.setPreferredSize(new java.awt.Dimension(300, 100)); |
913 |
} |
914 |
return jViewScrollPane;
|
915 |
} |
916 |
|
917 |
private JButton getBtConfigView() { |
918 |
if (btConfigView==null) { |
919 |
UsabilitySwingManager manager = org.gvsig.tools.swing.api.ToolsSwingLocator.getUsabilitySwingManager(); |
920 |
btConfigView = manager.createJButton(Messages.getText("Configure_view"));
|
921 |
btConfigView.addActionListener(new ActionListener() { |
922 |
public void actionPerformed(ActionEvent e) { |
923 |
ViewDocument view = FConfigLayoutDialog.this.getSelectedView(); |
924 |
if (view!=null) { |
925 |
IWindow propWin = view.getPropertiesWindow(); |
926 |
ApplicationManager manager = ApplicationLocator.getManager(); |
927 |
manager.getUIManager().addWindow(propWin); |
928 |
} |
929 |
} |
930 |
}); |
931 |
} |
932 |
return btConfigView;
|
933 |
} |
934 |
|
935 |
protected ViewDocument getSelectedView() {
|
936 |
Object selected = FConfigLayoutDialog.this.getViewList().getSelectedValue();
|
937 |
ViewDocument view = null;
|
938 |
if (selected instanceof ViewDocument) { |
939 |
view = (ViewDocument) selected; |
940 |
} |
941 |
else if (selected==ListViewModel.CREATE_NEW_VIEW_OBJECT) { |
942 |
if (FConfigLayoutDialog.this.createdView==null) { |
943 |
view = createView(); |
944 |
} |
945 |
else {
|
946 |
view = FConfigLayoutDialog.this.createdView; |
947 |
} |
948 |
} |
949 |
return view;
|
950 |
} |
951 |
|
952 |
private ViewDocument createView() {
|
953 |
ProjectManager projectManager = ApplicationLocator.getProjectManager(); |
954 |
ViewManager viewManager = (ViewManager) projectManager.getDocumentManager(ViewManager.TYPENAME); |
955 |
createdView = (ViewDocument) viewManager.createDocument(); |
956 |
ProjectManager.getInstance().getCurrentProject().addDocument(createdView); |
957 |
return createdView;
|
958 |
} |
959 |
|
960 |
private void deleteView() { |
961 |
ProjectManager projectManager = ApplicationLocator.getProjectManager(); |
962 |
ProjectManager.getInstance().getCurrentProject().removeDocument(createdView); |
963 |
createdView = null;
|
964 |
} |
965 |
|
966 |
/**
|
967 |
* This method initializes lResolucion
|
968 |
*
|
969 |
* @return javax.swing.JLabel
|
970 |
*/
|
971 |
private javax.swing.JCheckBox getChbViews() {
|
972 |
if (chbViews == null) { |
973 |
chbViews = new JCheckBox(PluginServices.getText(this, |
974 |
"Insert_view"));
|
975 |
chbViews.setSelected(true);
|
976 |
} |
977 |
|
978 |
return chbViews;
|
979 |
} |
980 |
|
981 |
/*
|
982 |
* (non-Javadoc)
|
983 |
*
|
984 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
985 |
*/
|
986 |
public WindowInfo getWindowInfo() {
|
987 |
if (windowInfo==null) { |
988 |
windowInfo = new WindowInfo(WindowInfo.RESIZABLE);
|
989 |
if (showViewList) {
|
990 |
windowInfo.setWidth(600);
|
991 |
windowInfo.setHeight(450);
|
992 |
} |
993 |
else {
|
994 |
windowInfo.setWidth(550);
|
995 |
windowInfo.setHeight(300);
|
996 |
} |
997 |
windowInfo.setTitle(PluginServices.getText(this, "Preparar_pagina")); |
998 |
} |
999 |
return windowInfo;
|
1000 |
} |
1001 |
|
1002 |
/**
|
1003 |
* Obtiene el ?rea de los JtextField.
|
1004 |
*/
|
1005 |
private void obtainArea() { |
1006 |
String s = (getTSuperior().getText());
|
1007 |
s = s.replace(',', '.'); |
1008 |
|
1009 |
if (s.length() == 0) { |
1010 |
s = "0";
|
1011 |
} |
1012 |
|
1013 |
sup = |
1014 |
m_layout.getLayoutContext().getAttributes() |
1015 |
.fromUnits(Double.valueOf(s).doubleValue());
|
1016 |
s = (getTIzquierdo().getText()); |
1017 |
s = s.replace(',', '.'); |
1018 |
|
1019 |
if (s.length() == 0) { |
1020 |
s = "0";
|
1021 |
} |
1022 |
|
1023 |
izq = |
1024 |
m_layout.getLayoutContext().getAttributes() |
1025 |
.fromUnits(Double.valueOf(s).doubleValue());
|
1026 |
s = (getTInferior().getText()); |
1027 |
s = s.replace(',', '.'); |
1028 |
|
1029 |
if (s.length() == 0) { |
1030 |
s = "0";
|
1031 |
} |
1032 |
|
1033 |
inf = |
1034 |
m_layout.getLayoutContext().getAttributes() |
1035 |
.fromUnits(Double.valueOf(s).doubleValue());
|
1036 |
s = (getTDerecho().getText()); |
1037 |
s = s.replace(',', '.'); |
1038 |
|
1039 |
if (s.length() == 0) { |
1040 |
s = "0";
|
1041 |
} |
1042 |
|
1043 |
der = |
1044 |
m_layout.getLayoutContext().getAttributes() |
1045 |
.fromUnits(Double.valueOf(s).doubleValue());
|
1046 |
} |
1047 |
|
1048 |
public Object getWindowProfile() { |
1049 |
return WindowInfo.DIALOG_PROFILE;
|
1050 |
} |
1051 |
|
1052 |
public Object getWindowModel() { |
1053 |
// necessary for considering them as separate SingletonWindows depending showViewList option
|
1054 |
if (showViewList) {
|
1055 |
return m_layout;
|
1056 |
} |
1057 |
else {
|
1058 |
return m_layout.getLayoutControl();
|
1059 |
} |
1060 |
} |
1061 |
} |