Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / layout / gui / dialogs / FConfigLayoutDialog.java @ 31496

History | View | Annotate | Download (24.4 KB)

1
/*
2
 * Created on 23-jun-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 org.gvsig.app.project.documents.layout.gui.dialogs;
46

    
47
import java.awt.Dimension;
48
import java.text.NumberFormat;
49

    
50
import javax.swing.JPanel;
51

    
52
import org.gvsig.andami.PluginServices;
53
import org.gvsig.andami.ui.mdiManager.IWindow;
54
import org.gvsig.andami.ui.mdiManager.WindowInfo;
55
import org.gvsig.app.project.documents.layout.Attributes;
56
import org.gvsig.app.project.documents.layout.Size;
57
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
58
import org.gvsig.fmap.mapcontext.MapContext;
59

    
60

    
61

    
62
/**
63
 * Clase para configurar el Layout.
64
 *
65
 * @author Vicente Caballero Navarro
66
 */
67
public class FConfigLayoutDialog extends JPanel implements IWindow {
68
        private javax.swing.JLabel lTamPag = null;
69
        private javax.swing.JComboBox cbTipoFolio = null;
70
        private javax.swing.JLabel lDistancia = null;
71
        private javax.swing.JComboBox cbUnidades = null;
72
        private javax.swing.JLabel lAnchura = null;
73
        private javax.swing.JLabel lAltura = null;
74
        private javax.swing.JTextField tAncho = null;
75
        private javax.swing.JTextField tAlto = null;
76
        private javax.swing.JLabel lOrientacion = null;
77
        private javax.swing.JLabel lMargenes = null;
78
        private javax.swing.JCheckBox chbMargenes = null;
79
        private javax.swing.JLabel lSuperior = null;
80
        private javax.swing.JTextField tSuperior = null;
81
        private javax.swing.JLabel lIzquierdo = null;
82
        private javax.swing.JTextField tIzquierdo = null;
83
        private javax.swing.JLabel lInferior = null;
84
        private javax.swing.JTextField tInferior = null;
85
        private javax.swing.JLabel lDerecho = null;
86
        private javax.swing.JTextField tDerecho = null;
87
        private javax.swing.JLabel lResolucion = null;
88
        private javax.swing.JComboBox cbResolucion = null;
89
        private javax.swing.JButton bAceptar = null;
90
        private javax.swing.JButton bCancelar = null;
91
        private LayoutPanel m_layout = null;
92
        private javax.swing.JCheckBox chbHorizontal = null;
93
        private javax.swing.JCheckBox chbVertical = null;
94
        private int unit = 2;
95
        private int type = 0;
96
        private boolean isLand = true;
97
        private boolean margin = false;
98
        private int resolution = 1;
99
        private double der = 2.54;
100
        private double izq = 2.54;
101
        private double sup = 2.54;
102
        private double inf = 2.54;
103
        private NumberFormat nf = NumberFormat.getInstance();
104

    
105
        /**
106
         * This is the default constructor
107
         *
108
         * @param layout Referencia al Layout.
109
         */
110
        public FConfigLayoutDialog(LayoutPanel layout) {
111
                super();
112
                m_layout = layout;
113
                initialize();
114
        }
115

    
116
        /**
117
         * This method initializes this
118
         */
119
        private void initialize() {
120
                nf.setMaximumFractionDigits(2);
121
                this.setLayout(null);
122
                type = m_layout.getLayoutContext().getAttributes().getType();
123
                unit = m_layout.getLayoutContext().getAttributes().getSelTypeUnit();
124
                isLand = m_layout.getLayoutContext().getAttributes().isLandSpace();
125
                sup = m_layout.getLayoutContext().getAttributes().m_area[0];
126
                inf = m_layout.getLayoutContext().getAttributes().m_area[1];
127
                izq = m_layout.getLayoutContext().getAttributes().m_area[2];
128
                der = m_layout.getLayoutContext().getAttributes().m_area[3];
129
                this.add(getLTamPag(), null);
130
                this.add(getCbTipoFolio(), null);
131
                this.add(getLDistancia(), null);
132
                this.add(getCbUnidades(), null);
133
                this.add(getLAnchura(), null);
134
                this.add(getLAltura(), null);
135
                this.add(getTAncho(), null);
136
                this.add(getTAlto(), null);
137
                this.add(getLOrientacion(), null);
138
                this.add(getLMargenes(), null);
139
                this.add(getChbMargenes(), null);
140
                this.add(getLSuperior(), null);
141
                this.add(getTSuperior(), null);
142
                this.add(getLIzquierdo(), null);
143
                this.add(getTIzquierdo(), null);
144
                this.add(getLInferior(), null);
145
                this.add(getTInferior(), null);
146
                this.add(getLDerecho(), null);
147
                this.add(getTDerecho(), null);
148
                this.add(getLResolucion(), null);
149
                this.add(getCbResolucion(), null);
150
                this.add(getBAceptar(), null);
151
                this.add(getBCancelar(), null);
152
                this.add(getChbHorizontal(), null);
153
                this.add(getChbVertical(), null);
154
                this.setPreferredSize(new Dimension(371, 300));
155
        }
156

    
157
        /**
158
         * This method initializes lTamPag
159
         *
160
         * @return javax.swing.JLabel
161
         */
162
        private javax.swing.JLabel getLTamPag() {
163
                if (lTamPag == null) {
164
                        lTamPag = new javax.swing.JLabel();
165
                        lTamPag.setSize(134, 20);
166
                        lTamPag.setText(PluginServices.getText(this, "tamano_pagina") +
167
                                ":");
168
                        lTamPag.setLocation(25, 15);
169
                }
170

    
171
                return lTamPag;
172
        }
173

    
174
        /**
175
         * This method initializes cbTipoFolio
176
         *
177
         * @return javax.swing.JComboBox
178
         */
179
        private javax.swing.JComboBox getCbTipoFolio() {
180
                if (cbTipoFolio == null) {
181
                        cbTipoFolio = new javax.swing.JComboBox();
182
                        cbTipoFolio.setSize(175, 20);
183
                        cbTipoFolio.setPreferredSize(new java.awt.Dimension(130, 20));
184
                        cbTipoFolio.setLocation(175, 15);
185
                        cbTipoFolio.addItem(PluginServices.getText(this,
186
                                        "Igual_que_la_impresora"));
187
                        cbTipoFolio.addItem(PluginServices.getText(this, "A4"));
188
                        cbTipoFolio.addItem(PluginServices.getText(this, "A3"));
189
                        cbTipoFolio.addItem(PluginServices.getText(this, "A2"));
190
                        cbTipoFolio.addItem(PluginServices.getText(this, "A1"));
191
                        cbTipoFolio.addItem(PluginServices.getText(this, "A0"));
192
                        cbTipoFolio.addItem(PluginServices.getText(this, "Personalizado"));
193

    
194
                        cbTipoFolio.setSelectedIndex(m_layout.getLayoutContext().getAttributes().getType());
195
                        cbTipoFolio.addActionListener(new java.awt.event.ActionListener() {
196
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
197
                                                type = cbTipoFolio.getSelectedIndex();
198

    
199
                                                Size size = m_layout.getLayoutContext().getAttributes().getSizeinUnits(isLand,
200
                                                                type);
201
                                                getTAlto().setText(String.valueOf(nf.format(
202
                                                                        size.getAlto())));
203
                                                getTAncho().setText(String.valueOf(nf.format(
204
                                                                        size.getAncho())));
205
                                                setMargin(margin);
206
                                                if (cbTipoFolio.getSelectedItem().equals(PluginServices.getText(this,"Personalizado"))) {
207
                                                        getTAlto().setEnabled(true);
208
                                                        getTAncho().setEnabled(true);
209
                                                        getChbVertical().setSelected(true);
210
                                                        isLand=false;
211
                                                        getChbHorizontal().setSelected(false);
212
                                                        getChbVertical().setEnabled(false);
213
                                                        getChbHorizontal().setEnabled(false);
214
                                                }else {
215
                                                        getTAlto().setEnabled(false);
216
                                                        getTAncho().setEnabled(false);
217
                                                        getChbVertical().setEnabled(true);
218
                                                        getChbHorizontal().setEnabled(true);
219
                                                }
220
                                        }
221
                                });
222
                }
223

    
224
                return cbTipoFolio;
225
        }
226

    
227
        /**
228
         * This method initializes lDistancia
229
         *
230
         * @return javax.swing.JLabel
231
         */
232
        private javax.swing.JLabel getLDistancia() {
233
                if (lDistancia == null) {
234
                        lDistancia = new javax.swing.JLabel();
235
                        lDistancia.setSize(137, 19);
236
                        lDistancia.setText(PluginServices.getText(this, "distance_units"));
237
                        lDistancia.setLocation(25, 40);
238
                }
239

    
240
                return lDistancia;
241
        }
242

    
243
        /**
244
         * This method initializes cbUnidades
245
         *
246
         * @return javax.swing.JComboBox
247
         */
248
        private javax.swing.JComboBox getCbUnidades() {
249
                if (cbUnidades == null) {
250
                        cbUnidades = new javax.swing.JComboBox();
251
                        String[] names= MapContext.getDistanceNames();
252
                        for (int i=0;i<names.length;i++) {
253
                                cbUnidades.addItem(PluginServices.getText(this,names[i]));
254
                        }
255
                        cbUnidades.setSize(175, 20);
256
                        cbUnidades.setLocation(175, 40);
257
                        cbUnidades.setSelectedIndex(m_layout.getLayoutContext().getAttributes().getSelTypeUnit());
258
                        cbUnidades.addActionListener(new java.awt.event.ActionListener() {
259
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
260
                                                unit = cbUnidades.getSelectedIndex();
261
                                                m_layout.getLayoutContext().getAttributes().setUnit(unit);
262

    
263
                                                Size size = m_layout.getLayoutContext().getAttributes().getSizeinUnits(isLand,
264
                                                                type);
265
                                                getTAlto().setText(String.valueOf(nf.format(
266
                                                                        size.getAncho())));
267
                                                getTAncho().setText(String.valueOf(nf.format(
268
                                                                        size.getAlto())));
269
                                                setMargin(margin);
270
                                        }
271
                                });
272
                }
273

    
274
                return cbUnidades;
275
        }
276

    
277
        /**
278
         * This method initializes lAnchura
279
         *
280
         * @return javax.swing.JLabel
281
         */
282
        private javax.swing.JLabel getLAnchura() {
283
                if (lAnchura == null) {
284
                        lAnchura = new javax.swing.JLabel();
285
                        lAnchura.setSize(81, 21);
286
                        lAnchura.setText(PluginServices.getText(this, "anchura"));
287
                        lAnchura.setLocation(25, 65);
288
                }
289

    
290
                return lAnchura;
291
        }
292

    
293
        /**
294
         * This method initializes lAltura
295
         *
296
         * @return javax.swing.JLabel
297
         */
298
        private javax.swing.JLabel getLAltura() {
299
                if (lAltura == null) {
300
                        lAltura = new javax.swing.JLabel();
301
                        lAltura.setSize(90, 21);
302
                        lAltura.setText(PluginServices.getText(this, "altura"));
303
                        lAltura.setLocation(180, 65);
304
                }
305

    
306
                return lAltura;
307
        }
308

    
309
        /**
310
         * This method initializes tAncho
311
         *
312
         * @return javax.swing.JTextField
313
         */
314
        private javax.swing.JTextField getTAncho() {
315
                if (tAncho == null) {
316
                        tAncho = new javax.swing.JTextField();
317
                        tAncho.setSize(60, 20);
318
                        tAncho.setLocation(110, 65);
319

    
320
                        Size size = m_layout.getLayoutContext().getAttributes().getSizeinUnits(isLand, type);
321
                        String s = String.valueOf(nf.format(size.getAncho()));
322
                        tAncho.setText(s);
323
                        if (getCbTipoFolio().getSelectedItem().equals(PluginServices.getText(this,"Personalizado"))) {
324
                                getTAncho().setEnabled(true);
325
                        }else {
326
                                getTAncho().setEnabled(false);
327
                        }
328
                }
329

    
330
                return tAncho;
331
        }
332

    
333
        /**
334
         * This method initializes tAlto
335
         *
336
         * @return javax.swing.JTextField
337
         */
338
        private javax.swing.JTextField getTAlto() {
339
                if (tAlto == null) {
340
                        tAlto = new javax.swing.JTextField();
341
                        tAlto.setSize(60, 20);
342
                        tAlto.setLocation(280, 65);
343

    
344
                        Size size = m_layout.getLayoutContext().getAttributes().getSizeinUnits(isLand, type);
345
                        String s = String.valueOf(nf.format(size.getAlto()));
346
                        tAlto.setText(s);
347
                        if (getCbTipoFolio().getSelectedItem().equals(PluginServices.getText(this,"Personalizado"))) {
348
                                getTAlto().setEnabled(true);
349
                        }else {
350
                                getTAlto().setEnabled(false);
351
                        }
352
                }
353

    
354
                return tAlto;
355
        }
356

    
357
        /**
358
         * This method initializes lOrientacion
359
         *
360
         * @return javax.swing.JLabel
361
         */
362
        private javax.swing.JLabel getLOrientacion() {
363
                if (lOrientacion == null) {
364
                        lOrientacion = new javax.swing.JLabel();
365
                        lOrientacion.setSize(102, 38);
366
                        lOrientacion.setText(PluginServices.getText(this, "orientacion"));
367
                        lOrientacion.setLocation(25, 100);
368
                }
369

    
370
                return lOrientacion;
371
        }
372

    
373
        /**
374
         * This method initializes lMargenes
375
         *
376
         * @return javax.swing.JLabel
377
         */
378
        private javax.swing.JLabel getLMargenes() {
379
                if (lMargenes == null) {
380
                        lMargenes = new javax.swing.JLabel();
381
                        lMargenes.setSize(95, 20);
382
                        lMargenes.setText(PluginServices.getText(this, "margenes"));
383
                        lMargenes.setLocation(25, 145);
384
                }
385

    
386
                return lMargenes;
387
        }
388

    
389
        /**
390
         * Inserta si se dibuja los margenes sobre el Layout o no.
391
         *
392
         * @param b True si se tiene que dibujar los margenes.
393
         */
394
        private void setMargin(boolean b) {
395
                margin = b;
396

    
397
                if (b) {
398
                        getTSuperior().setText(String.valueOf(nf.format(
399
                                                m_layout.getLayoutContext().getAttributes().toUnits(sup))));
400
                        getTIzquierdo().setText(String.valueOf(nf.format(
401
                                                m_layout.getLayoutContext().getAttributes().toUnits(izq))));
402
                        getTInferior().setText(String.valueOf(nf.format(
403
                                                m_layout.getLayoutContext().getAttributes().toUnits(inf))));
404
                        getTDerecho().setText(String.valueOf(nf.format(
405
                                                m_layout.getLayoutContext().getAttributes().toUnits(der))));
406
                        getTSuperior().setEnabled(true);
407
                        getTIzquierdo().setEnabled(true);
408
                        getTInferior().setEnabled(true);
409
                        getTDerecho().setEnabled(true);
410
                } else {
411
                        getTSuperior().setText("");
412
                        getTIzquierdo().setText("");
413
                        getTInferior().setText("");
414
                        getTDerecho().setText("");
415
                        getTSuperior().setEnabled(false);
416
                        getTIzquierdo().setEnabled(false);
417
                        getTInferior().setEnabled(false);
418
                        getTDerecho().setEnabled(false);
419
                }
420
        }
421

    
422
        /**
423
         * This method initializes chbMargenes
424
         *
425
         * @return javax.swing.JCheckBox
426
         */
427
        private javax.swing.JCheckBox getChbMargenes() {
428
                if (chbMargenes == null) {
429
                        chbMargenes = new javax.swing.JCheckBox();
430
                        chbMargenes.setSize(230, 21);
431
                        chbMargenes.setText(PluginServices.getText(this,"personalizar_margenes"));
432
                        chbMargenes.setLocation(125, 145);
433
                        chbMargenes.setSelected(m_layout.getLayoutContext().getAttributes().isMargin());
434
                        setMargin(m_layout.getLayoutContext().getAttributes().isMargin());
435
                        chbMargenes.addActionListener(new java.awt.event.ActionListener() {
436
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
437
                                                if (chbMargenes.isSelected()) {
438
                                                        margin = true;
439
                                                } else {
440
                                                        margin = false;
441
                                                }
442

    
443
                                                setMargin(margin);
444
                                        }
445
                                });
446
                }
447

    
448
                return chbMargenes;
449
        }
450

    
451
        /**
452
         * This method initializes lSuperior
453
         *
454
         * @return javax.swing.JLabel
455
         */
456
        private javax.swing.JLabel getLSuperior() {
457
                if (lSuperior == null) {
458
                        lSuperior = new javax.swing.JLabel();
459
                        lSuperior.setSize(81, 20);
460
                        lSuperior.setText(PluginServices.getText(this, "Superior"));
461
                        lSuperior.setLocation(25, 167);
462
                }
463

    
464
                return lSuperior;
465
        }
466

    
467
        /**
468
         * This method initializes tSuperior
469
         *
470
         * @return javax.swing.JTextField
471
         */
472
        private javax.swing.JTextField getTSuperior() {
473
                if (tSuperior == null) {
474
                        tSuperior = new javax.swing.JTextField();
475
                        tSuperior.setSize(60, 20);
476
                        tSuperior.setLocation(110, 167);
477

    
478
                        if (m_layout.getLayoutContext().getAttributes().isMargin()) {
479
                                tSuperior.setText(String.valueOf(nf.format(
480
                                                        m_layout.getLayoutContext().getAttributes().toUnits(sup))));
481
                        }
482
                }
483

    
484
                return tSuperior;
485
        }
486

    
487
        /**
488
         * This method initializes lIzquierdo
489
         *
490
         * @return javax.swing.JLabel
491
         */
492
        private javax.swing.JLabel getLIzquierdo() {
493
                if (lIzquierdo == null) {
494
                        lIzquierdo = new javax.swing.JLabel();
495
                        lIzquierdo.setSize(88, 20);
496
                        lIzquierdo.setText(PluginServices.getText(this, "Izquierdo"));
497
                        lIzquierdo.setLocation(180, 167);
498
                }
499

    
500
                return lIzquierdo;
501
        }
502

    
503
        /**
504
         * This method initializes tIzquierdo
505
         *
506
         * @return javax.swing.JTextField
507
         */
508
        private javax.swing.JTextField getTIzquierdo() {
509
                if (tIzquierdo == null) {
510
                        tIzquierdo = new javax.swing.JTextField();
511
                        tIzquierdo.setSize(60, 20);
512
                        tIzquierdo.setLocation(280, 167);
513

    
514
                        if (m_layout.getLayoutContext().getAttributes().isMargin()) {
515
                                tIzquierdo.setText(String.valueOf(nf.format(
516
                                                        m_layout.getLayoutContext().getAttributes().toUnits(izq))));
517
                        }
518
                }
519

    
520
                return tIzquierdo;
521
        }
522

    
523
        /**
524
         * This method initializes lInferior
525
         *
526
         * @return javax.swing.JLabel
527
         */
528
        private javax.swing.JLabel getLInferior() {
529
                if (lInferior == null) {
530
                        lInferior = new javax.swing.JLabel();
531
                        lInferior.setSize(81, 21);
532
                        lInferior.setText(PluginServices.getText(this, "Inferior"));
533
                        lInferior.setLocation(25, 190);
534
                }
535

    
536
                return lInferior;
537
        }
538

    
539
        /**
540
         * This method initializes tInferior
541
         *
542
         * @return javax.swing.JTextField
543
         */
544
        private javax.swing.JTextField getTInferior() {
545
                if (tInferior == null) {
546
                        tInferior = new javax.swing.JTextField();
547
                        tInferior.setSize(60, 20);
548
                        tInferior.setLocation(110, 190);
549

    
550
                        if (m_layout.getLayoutContext().getAttributes().isMargin()) {
551
                                tInferior.setText(String.valueOf(nf.format(
552
                                                        m_layout.getLayoutContext().getAttributes().toUnits(inf))));
553
                        }
554
                }
555

    
556
                return tInferior;
557
        }
558

    
559
        /**
560
         * This method initializes lDerecho
561
         *
562
         * @return javax.swing.JLabel
563
         */
564
        private javax.swing.JLabel getLDerecho() {
565
                if (lDerecho == null) {
566
                        lDerecho = new javax.swing.JLabel();
567
                        lDerecho.setSize(87, 21);
568
                        lDerecho.setText(PluginServices.getText(this, "Derecho"));
569
                        lDerecho.setLocation(180, 190);
570
                }
571

    
572
                return lDerecho;
573
        }
574

    
575
        /**
576
         * This method initializes tDerecho
577
         *
578
         * @return javax.swing.JTextField
579
         */
580
        private javax.swing.JTextField getTDerecho() {
581
                if (tDerecho == null) {
582
                        tDerecho = new javax.swing.JTextField();
583
                        tDerecho.setSize(60, 20);
584
                        tDerecho.setLocation(280, 190);
585

    
586
                        if (m_layout.getLayoutContext().getAttributes().isMargin()) {
587
                                tDerecho.setText(String.valueOf(nf.format(
588
                                                        m_layout.getLayoutContext().getAttributes().toUnits(der))));
589
                        }
590
                }
591

    
592
                return tDerecho;
593
        }
594

    
595
        /**
596
         * This method initializes lResolucion
597
         *
598
         * @return javax.swing.JLabel
599
         */
600
        private javax.swing.JLabel getLResolucion() {
601
                if (lResolucion == null) {
602
                        lResolucion = new javax.swing.JLabel();
603
                        lResolucion.setSize(164, 21);
604
                        lResolucion.setText(PluginServices.getText(this,
605
                                        "resolucion_resultado"));
606
                        lResolucion.setLocation(25, 215);
607
                }
608

    
609
                return lResolucion;
610
        }
611

    
612
        /**
613
         * This method initializes cbResolucion
614
         *
615
         * @return javax.swing.JComboBox
616
         */
617
        private javax.swing.JComboBox getCbResolucion() {
618
                if (cbResolucion == null) {
619
                        cbResolucion = new javax.swing.JComboBox();
620
                        cbResolucion.setSize(150, 20);
621
                        cbResolucion.setLocation(195, 215);
622
                        cbResolucion.addItem(PluginServices.getText(this, "alta"));
623
                        cbResolucion.addItem(PluginServices.getText(this, "normal"));
624
                        cbResolucion.addItem(PluginServices.getText(this, "baja"));
625
                        cbResolucion.setSelectedIndex(m_layout.getLayoutContext().getAttributes().getResolution());
626
                        cbResolucion.addActionListener(new java.awt.event.ActionListener() {
627
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
628
                                                resolution = cbResolucion.getSelectedIndex();
629
                                        }
630
                                });
631
                }
632

    
633
                return cbResolucion;
634
        }
635

    
636
        /**
637
         * This method initializes bAceptar
638
         *
639
         * @return javax.swing.JButton
640
         */
641
        private javax.swing.JButton getBAceptar() {
642
                if (bAceptar == null) {
643
                        bAceptar = new javax.swing.JButton();
644
                        bAceptar.setSize(84, 23);
645
                        bAceptar.setText(PluginServices.getText(this, "Aceptar"));
646
                        bAceptar.setLocation(130, 245);
647
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
648
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
649
                                                m_layout.getLayoutContext().getAttributes().setUnit(unit);
650

    
651
                                                if (isLand) {
652
                                                        m_layout.getLayoutContext().getAttributes().setIsLandScape(true);
653
                                                } else {
654
                                                        m_layout.getLayoutContext().getAttributes().setIsLandScape(false);
655
                                                }
656

    
657
                                                m_layout.getLayoutContext().getAttributes().setType(type);
658
                                                m_layout.getLayoutContext().getAttributes().setSizeinUnits(isLand);
659
                                                obtainArea();
660

    
661
                                                double[] area = { sup, inf, izq, der };
662

    
663
                                                if (type == Attributes.CUSTOM) {
664
                                                        String width=getTAncho().getText().replace(',','.');
665
                                                        String height=getTAlto().getText().replace(',','.');
666
                                                        Attributes.CUSTOM_PAPER_SIZE = new Size(Double.valueOf(
667
                                                                                width).doubleValue(),
668
                                                                        Double.valueOf(height)
669
                                                                                  .doubleValue());
670
                                                        m_layout.getLayoutContext().getAttributes().m_sizePaper=Attributes.CUSTOM_PAPER_SIZE;
671
                                                }
672
                                                m_layout.getLayoutContext().getAttributes().setType(type);
673
                                                m_layout.obtainRect(false);
674
                                                m_layout.getLayoutContext().getAttributes().setSelectedOptions(type, unit,
675
                                                        isLand, margin, resolution, area);
676
                                                PluginServices.getMDIManager().closeWindow(FConfigLayoutDialog.this);
677
                                                m_layout.getLayoutControl().fullRect();
678
                                                //m_layout.refresh();
679
                                        }
680
                                });
681
                }
682

    
683
                return bAceptar;
684
        }
685

    
686
        /**
687
         * This method initializes bCancelar
688
         *
689
         * @return javax.swing.JButton
690
         */
691
        private javax.swing.JButton getBCancelar() {
692
                if (bCancelar == null) {
693
                        bCancelar = new javax.swing.JButton();
694
                        bCancelar.setSize(85, 23);
695
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
696
                        bCancelar.setLocation(245, 245);
697
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
698
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
699
                                                //setVisible(false);
700
                                                PluginServices.getMDIManager().closeWindow(FConfigLayoutDialog.this);
701
                                        }
702
                                });
703
                }
704

    
705
                return bCancelar;
706
        }
707

    
708
        /**
709
         * This method initializes chbHorizontal
710
         *
711
         * @return javax.swing.JCheckBox
712
         */
713
        private javax.swing.JCheckBox getChbHorizontal() {
714
                if (chbHorizontal == null) {
715
                        chbHorizontal = new javax.swing.JCheckBox();
716
                        chbHorizontal.setSize(99, 21);
717
                        chbHorizontal.setText(PluginServices.getText(this, "horizontal"));
718
                        chbHorizontal.setLocation(130, 110);
719
                        chbHorizontal.setSelected(isLand);
720
                        if (getCbTipoFolio().getSelectedItem().equals(PluginServices.getText(this,"Personalizado"))) {
721
                                chbHorizontal.setEnabled(false);
722
                                chbHorizontal.setSelected(false);
723
                                isLand=false;
724
                        }
725
                        chbHorizontal.addActionListener(new java.awt.event.ActionListener() {
726
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
727
                                                isLand = true;
728
                                                getChbVertical().setSelected(false);
729

    
730
                                                if (chbHorizontal.isSelected()) {
731
                                                        double iz = izq;
732
                                                        izq = inf;
733
                                                        inf = der;
734
                                                        der = sup;
735
                                                        sup = iz;
736

    
737
                                                        setMargin(margin);
738

    
739
                                                        //}else{
740
                                                        if (type == Attributes.CUSTOM) {
741
                                                                Attributes.CUSTOM_PAPER_SIZE = new Size(Double.valueOf(
742
                                                                                        getTAlto().getText()).doubleValue(),
743
                                                                                Double.valueOf(getTAncho().getText())
744
                                                                                          .doubleValue());
745
                                                        }
746

    
747
                                                        Size size = m_layout.getLayoutContext().getAttributes().getSizeinUnits(isLand,
748
                                                                        type);
749
                                                        getTAncho().setText(String.valueOf(nf.format(
750
                                                                                size.getAncho())));
751
                                                        getTAlto().setText(String.valueOf(nf.format(
752
                                                                                size.getAlto())));
753
                                                }
754

    
755
                                                chbHorizontal.setSelected(true);
756
                                        }
757
                                });
758
                }
759

    
760
                return chbHorizontal;
761
        }
762

    
763
        /**
764
         * This method initializes chbVertical
765
         *
766
         * @return javax.swing.JCheckBox
767
         */
768
        private javax.swing.JCheckBox getChbVertical() {
769
                if (chbVertical == null) {
770
                        chbVertical = new javax.swing.JCheckBox();
771
                        chbVertical.setSize(94, 23);
772
                        chbVertical.setText(PluginServices.getText(this, "vertical"));
773
                        chbVertical.setLocation(245, 110);
774
                        chbVertical.setSelected(!isLand);
775
                        if (getCbTipoFolio().getSelectedItem().equals(PluginServices.getText(this,"Personalizado"))) {
776
                                chbVertical.setEnabled(false);
777
                                chbVertical.setSelected(true);
778
                                isLand=false;
779
                        }
780
                        chbVertical.addActionListener(new java.awt.event.ActionListener() {
781
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
782
                                                isLand = false;
783
                                                getChbHorizontal().setSelected(false);
784

    
785
                                                if (chbVertical.isSelected()) {
786
                                                        double in = inf;
787
                                                        inf = izq;
788
                                                        izq = sup;
789
                                                        sup = der;
790
                                                        der = in;
791

    
792
                                                        setMargin(margin);
793

    
794
                                                        //}else{
795
                                                        if (type == Attributes.CUSTOM) {
796
                                                                Attributes.CUSTOM_PAPER_SIZE = new Size(Double.valueOf(
797
                                                                                        getTAncho().getText()).doubleValue(),
798
                                                                                Double.valueOf(getTAlto().getText())
799
                                                                                          .doubleValue());
800
                                                        }
801

    
802
                                                        Size size = m_layout.getLayoutContext().getAttributes().getSizeinUnits(isLand,
803
                                                                        type);
804
                                                        getTAncho().setText(String.valueOf(nf.format(
805
                                                                                size.getAncho())));
806
                                                        getTAlto().setText(String.valueOf(nf.format(
807
                                                                                size.getAlto())));
808
                                                }
809

    
810
                                                chbVertical.setSelected(true);
811
                                        }
812
                                });
813
                }
814

    
815
                return chbVertical;
816
        }
817

    
818
        /* (non-Javadoc)
819
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
820
         */
821
        public WindowInfo getWindowInfo() {
822
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
823
                m_viewinfo.setWidth(371);
824
                m_viewinfo.setHeight(300);
825
                m_viewinfo.setTitle(PluginServices.getText(this, "Preparar_pagina"));
826

    
827
                return m_viewinfo;
828
        }
829

    
830
        /**
831
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
832
         */
833
        public void viewActivated() {
834
        }
835

    
836
        /**
837
         * Obtiene el ?rea de los JtextField.
838
         */
839
        private void obtainArea() {
840
                String s = (getTSuperior().getText());
841
                s = s.replace(',', '.');
842

    
843
                if (s.length() == 0) {
844
                        s = "0";
845
                }
846

    
847
                sup = m_layout.getLayoutContext().getAttributes().fromUnits(Double.valueOf(s).doubleValue());
848
                s = (getTIzquierdo().getText());
849
                s = s.replace(',', '.');
850

    
851
                if (s.length() == 0) {
852
                        s = "0";
853
                }
854

    
855
                izq = m_layout.getLayoutContext().getAttributes().fromUnits(Double.valueOf(s).doubleValue());
856
                s = (getTInferior().getText());
857
                s = s.replace(',', '.');
858

    
859
                if (s.length() == 0) {
860
                        s = "0";
861
                }
862

    
863
                inf = m_layout.getLayoutContext().getAttributes().fromUnits(Double.valueOf(s).doubleValue());
864
                s = (getTDerecho().getText());
865
                s = s.replace(',', '.');
866

    
867
                if (s.length() == 0) {
868
                        s = "0";
869
                }
870

    
871
                der = m_layout.getLayoutContext().getAttributes().fromUnits(Double.valueOf(s).doubleValue());
872
        }
873
        public Object getWindowProfile() {
874
                return WindowInfo.DIALOG_PROFILE;
875
        }
876

    
877
}