Statistics
| Revision:

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 @ 215

History | View | Annotate | Download (35.2 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.SingletonWindow;
43
import org.gvsig.andami.ui.mdiManager.WindowInfo;
44
import org.gvsig.app.ApplicationLocator;
45
import org.gvsig.app.ApplicationManager;
46
import org.gvsig.app.project.ProjectManager;
47
import org.gvsig.app.project.documents.layout.Attributes;
48
import org.gvsig.app.project.documents.layout.LayoutContext;
49
import org.gvsig.app.project.documents.layout.LayoutManager;
50
import org.gvsig.app.project.documents.layout.Size;
51
import org.gvsig.app.project.documents.layout.fframes.FFrameView;
52
import org.gvsig.app.project.documents.layout.fframes.ListViewModel;
53
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
54
import org.gvsig.app.project.documents.view.ViewDocument;
55
import org.gvsig.app.project.documents.view.ViewManager;
56
import org.gvsig.fmap.mapcontext.MapContext;
57
import org.gvsig.i18n.Messages;
58
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager;
59

    
60
/**
61
 * Clase para configurar el Layout.
62
 * 
63
 * @author Vicente Caballero Navarro
64
 */
65
public class FConfigLayoutDialog extends JPanel implements SingletonWindow {
66

    
67
    private static final long serialVersionUID = -425263925680280142L;
68
    private javax.swing.JLabel lTamPag = null;
69
    private javax.swing.JComboBox cbTipoFolio = null;
70
    private javax.swing.JComboBox cbUnidades = null;
71
    private javax.swing.JLabel lAnchura = null;
72
    private javax.swing.JLabel lAltura = null;
73
    private javax.swing.JTextField tAncho = null;
74
    private javax.swing.JTextField tAlto = null;
75
    private javax.swing.JLabel lOrientacion = null;
76
    private javax.swing.JLabel lMargenes = null;
77
    private javax.swing.JCheckBox chbMargenes = null;
78
    private javax.swing.JLabel lSuperior = null;
79
    private javax.swing.JTextField tSuperior = null;
80
    private javax.swing.JLabel lIzquierdo = null;
81
    private javax.swing.JTextField tIzquierdo = null;
82
    private javax.swing.JLabel lInferior = null;
83
    private javax.swing.JTextField tInferior = null;
84
    private javax.swing.JLabel lDerecho = null;
85
    private javax.swing.JTextField tDerecho = null;
86
    private javax.swing.JLabel lResolucion = null;
87
    private javax.swing.JComboBox cbResolucion = null;
88
    private javax.swing.JButton bAceptar = null;
89
    private javax.swing.JButton bCancelar = null;
90
    private LayoutPanel m_layout = null;
91
    private JPanel pOrientation = null;
92
    private javax.swing.JRadioButton rbHorizontal = null;
93
    private javax.swing.JRadioButton rbVertical = 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
        private JList liViews = null;
105
        private boolean showViewList;
106
        private JCheckBox chbViews = null;
107
        private JButton btConfigView = null;
108
        private ViewDocument createdView = null;
109
        private JScrollPane jViewScrollPane = null;
110

    
111
    /**
112
     * This is the default constructor
113
     * 
114
     * @param layout
115
     *            Referencia al Layout.
116
     */
117
    public FConfigLayoutDialog(LayoutPanel layout) {
118
            this(layout, false);
119
    }
120
    
121
    /**
122
     * This is the default constructor
123
     * 
124
     * @param layout
125
     *            Referencia al Layout.
126
     */
127
    public FConfigLayoutDialog(LayoutPanel layout, boolean showViewList) {
128
        super();
129
        m_layout = layout;
130
        this.showViewList = showViewList;
131
        initialize();
132
    }
133

    
134
    /**
135
     * This method initializes this
136
     */
137
    private void initialize() {
138
            int row = 0;
139
        nf.setMaximumFractionDigits(2);
140
        this.setLayout(new GridBagLayout());
141
        GridBagConstraints c = new GridBagConstraints();
142
        type = m_layout.getLayoutContext().getAttributes().getType();
143
        unit = m_layout.getLayoutContext().getAttributes().getSelTypeUnit();
144
        isLand = m_layout.getLayoutContext().getAttributes().isLandscape();
145
        sup = m_layout.getLayoutContext().getAttributes().getAreaInsets()[0];
146
        inf = m_layout.getLayoutContext().getAttributes().getAreaInsets()[1];
147
        izq = m_layout.getLayoutContext().getAttributes().getAreaInsets()[2];
148
        der = m_layout.getLayoutContext().getAttributes().getAreaInsets()[3];
149
        c.fill = GridBagConstraints.HORIZONTAL;
150
        c.anchor = GridBagConstraints.LINE_START;
151
        c.insets = new Insets(5, 5, 5, 5);
152
        c.gridx = 0;
153
        c.gridy = row++;
154
        c.gridwidth = 1;
155
        this.add(getLTamPag(), c);
156
        c.gridx = GridBagConstraints.RELATIVE;
157
        c.fill = GridBagConstraints.HORIZONTAL;
158
        c.gridwidth = GridBagConstraints.REMAINDER;
159
        this.add(getCbTipoFolio(), c);
160
        c.gridx = 0;
161
        c.gridy = row++;
162
        c.gridwidth = 1;
163
        c.fill = GridBagConstraints.NONE;
164
        this.add(getLAnchura(), c);
165
        c.gridx = 1;
166
        this.add(getTAncho(), c);
167
        c.gridx = 2;
168
        this.add(getLAltura(), c);
169
        c.gridx = 3;
170
        this.add(getTAlto(), c);
171
        c.gridx = 4;
172
        c.gridwidth = GridBagConstraints.REMAINDER;
173
        c.fill = GridBagConstraints.HORIZONTAL;
174
        this.add(getCbUnidades(), c);
175
        c.gridx = 0;
176
        c.gridy = row++;
177
        c.gridwidth = 1;
178
        this.add(getLOrientacion(), c);
179
        c.gridx = GridBagConstraints.RELATIVE;
180
        c.gridwidth = GridBagConstraints.REMAINDER;
181
        this.add(getOrientationPanel(), c);
182
        c.gridy = row++;
183
        c.gridx = 0;
184
        c.gridwidth = 1;
185
        this.add(getLResolucion(), c);
186
        c.gridx = GridBagConstraints.RELATIVE;
187
        c.gridwidth = GridBagConstraints.REMAINDER;
188
        this.add(getCbResolucion(), c);
189
        if (this.showViewList) {
190
                c.gridy = row++;
191
            c.gridx = 0;
192
            c.gridwidth = 1;
193
            c.anchor = GridBagConstraints.PAGE_START;
194
            this.add(getChbViews(), c);
195
            c.gridx = 1;
196
            c.gridwidth = GridBagConstraints.REMAINDER;
197
            this.add(getViewScrollPane(), c);
198
            c.anchor = GridBagConstraints.LINE_START;
199
            c.gridy = row++;
200
            c.gridx = 1;
201
            c.gridwidth = 1;
202
            this.add(getBtConfigView(), c);
203
        }
204
        c.gridy = row++;
205
        c.gridx = 0;
206
        c.gridwidth = GridBagConstraints.REMAINDER;
207
        this.add(getChbMargenes(), c);
208
        c.fill = GridBagConstraints.NONE;
209
        c.gridy = row++;
210
        c.gridx = 0;
211
        c.gridwidth = 1;
212
        this.add(getLSuperior(), c);
213
        c.gridx = GridBagConstraints.RELATIVE;
214
        this.add(getTSuperior(), c);
215
        c.gridx = GridBagConstraints.RELATIVE;
216
        this.add(getLIzquierdo(), c);
217
        this.add(getTIzquierdo(), c);
218
        c.gridy = row++;
219
        c.gridx = 0;
220
        this.add(getLInferior(), c);
221
        c.gridx = GridBagConstraints.RELATIVE;
222
        this.add(getTInferior(), c);
223
        this.add(getLDerecho(), c);
224
        this.add(getTDerecho(), c);
225
        c.gridy = row++;
226
        c.gridx = 3;
227
        c.insets = new Insets(15, 5, 10, 5);
228
        this.add(getBAceptar(), c);
229
        c.gridx = GridBagConstraints.RELATIVE;
230
        this.add(getBCancelar(), c);
231
    }
232

    
233
    /**
234
     * This method initializes lTamPag
235
     * 
236
     * @return javax.swing.JLabel
237
     */
238
    private javax.swing.JLabel getLTamPag() {
239
        if (lTamPag == null) {
240
            lTamPag = new javax.swing.JLabel();
241
            lTamPag
242
                .setText(PluginServices.getText(this, "tamano_pagina"));
243
        }
244

    
245
        return lTamPag;
246
    }
247

    
248
    /**
249
     * This method initializes cbTipoFolio
250
     * 
251
     * @return javax.swing.JComboBox
252
     */
253
    private javax.swing.JComboBox getCbTipoFolio() {
254
        if (cbTipoFolio == null) {
255
            cbTipoFolio = new javax.swing.JComboBox();
256
            cbTipoFolio.addItem(PluginServices.getText(this,
257
                "Igual_que_la_impresora"));
258
            cbTipoFolio.addItem(PluginServices.getText(this, "A4"));
259
            cbTipoFolio.addItem(PluginServices.getText(this, "A3"));
260
            cbTipoFolio.addItem(PluginServices.getText(this, "A2"));
261
            cbTipoFolio.addItem(PluginServices.getText(this, "A1"));
262
            cbTipoFolio.addItem(PluginServices.getText(this, "A0"));
263
            cbTipoFolio.addItem(PluginServices.getText(this, "Personalizado"));
264

    
265
            cbTipoFolio.setSelectedIndex(m_layout.getLayoutContext()
266
                .getAttributes().getType());
267
            cbTipoFolio.addActionListener(new java.awt.event.ActionListener() {
268

    
269
                public void actionPerformed(java.awt.event.ActionEvent e) {
270
                    type = cbTipoFolio.getSelectedIndex();
271

    
272
                    Size size =
273
                        m_layout.getLayoutContext().getAttributes()
274
                            .getSizeinUnits(isLand, type);
275
                    getTAlto().setText(
276
                        String.valueOf(nf.format(size.getAlto())));
277
                    getTAncho().setText(
278
                        String.valueOf(nf.format(size.getAncho())));
279
                    setMargin(margin);
280
                    if (cbTipoFolio.getSelectedItem().equals(
281
                        PluginServices.getText(this, "Personalizado"))) {
282
                        getTAlto().setEnabled(true);
283
                        getTAncho().setEnabled(true);
284
                        getRbVertical().setSelected(true);
285
                        isLand = false;
286
                        getRbVertical().setEnabled(false);
287
                        getRbHorizontal().setEnabled(false);
288
                    } else {
289
                        getTAlto().setEnabled(false);
290
                        getTAncho().setEnabled(false);
291
                        getRbVertical().setEnabled(true);
292
                        getRbHorizontal().setEnabled(true);
293
                    }
294
                }
295
            });
296
        }
297

    
298
        return cbTipoFolio;
299
    }
300

    
301
    /**
302
     * This method initializes cbUnidades
303
     * 
304
     * @return javax.swing.JComboBox
305
     */
306
    private javax.swing.JComboBox getCbUnidades() {
307
        if (cbUnidades == null) {
308
            cbUnidades = new javax.swing.JComboBox();
309
            String[] names = MapContext.getDistanceNames();
310
            for (int i = 0; i < names.length; i++) {
311
                cbUnidades.addItem(PluginServices.getText(this, names[i]));
312
            }
313
            cbUnidades.setSelectedIndex(m_layout.getLayoutContext()
314
                .getAttributes().getSelTypeUnit());
315
            cbUnidades.addActionListener(new java.awt.event.ActionListener() {
316

    
317
                public void actionPerformed(java.awt.event.ActionEvent e) {
318
                    unit = cbUnidades.getSelectedIndex();
319
                    m_layout.getLayoutContext().getAttributes().setUnit(unit);
320

    
321
                    Size size =
322
                        m_layout.getLayoutContext().getAttributes()
323
                            .getSizeinUnits(isLand, type);
324
                    getTAlto().setText(
325
                        String.valueOf(nf.format(size.getAncho())));
326
                    getTAncho().setText(
327
                        String.valueOf(nf.format(size.getAlto())));
328
                    setMargin(margin);
329
                }
330
            });
331
        }
332

    
333
        return cbUnidades;
334
    }
335

    
336
    /**
337
     * This method initializes lAnchura
338
     * 
339
     * @return javax.swing.JLabel
340
     */
341
    private javax.swing.JLabel getLAnchura() {
342
        if (lAnchura == null) {
343
            lAnchura = new javax.swing.JLabel();
344
            lAnchura.setText(PluginServices.getText(this, "anchura"));
345
        }
346
        return lAnchura;
347
    }
348

    
349
    /**
350
     * This method initializes lAltura
351
     * 
352
     * @return javax.swing.JLabel
353
     */
354
    private javax.swing.JLabel getLAltura() {
355
        if (lAltura == null) {
356
            lAltura = new javax.swing.JLabel();
357
            lAltura.setText(PluginServices.getText(this, "altura"));
358
        }
359
        return lAltura;
360
    }
361

    
362
    /**
363
     * This method initializes tAncho
364
     * 
365
     * @return javax.swing.JTextField
366
     */
367
    private javax.swing.JTextField getTAncho() {
368
        if (tAncho == null) {
369
            tAncho = new javax.swing.JTextField(4);
370
            Size size =
371
                m_layout.getLayoutContext().getAttributes()
372
                    .getSizeinUnits(isLand, type);
373
            String s = String.valueOf(nf.format(size.getAncho()));
374
            tAncho.setText(s);
375
            if (getCbTipoFolio().getSelectedItem().equals(
376
                PluginServices.getText(this, "Personalizado"))) {
377
                    tAncho.setEnabled(true);
378
            } else {
379
                    tAncho.setEnabled(false);
380
            }
381
        }
382

    
383
        return tAncho;
384
    }
385

    
386
    /**
387
     * This method initializes tAlto
388
     * 
389
     * @return javax.swing.JTextField
390
     */
391
    private javax.swing.JTextField getTAlto() {
392
        if (tAlto == null) {
393
            tAlto = new javax.swing.JTextField(4);
394
            Size size =
395
                m_layout.getLayoutContext().getAttributes()
396
                    .getSizeinUnits(isLand, type);
397
            String s = String.valueOf(nf.format(size.getAlto()));
398
            tAlto.setText(s);
399
            if (getCbTipoFolio().getSelectedItem().equals(
400
                PluginServices.getText(this, "Personalizado"))) {
401
                    tAlto.setEnabled(true);
402
            } else {
403
                    tAlto.setEnabled(false);
404
            }
405
        }
406

    
407
        return tAlto;
408
    }
409

    
410
    /**
411
     * This method initializes lOrientacion
412
     * 
413
     * @return javax.swing.JLabel
414
     */
415
    private javax.swing.JLabel getLOrientacion() {
416
        if (lOrientacion == null) {
417
            lOrientacion = new javax.swing.JLabel();
418
            lOrientacion.setText(PluginServices.getText(this, "orientacion"));
419
        }
420

    
421
        return lOrientacion;
422
    }
423

    
424
    /**
425
     * This method initializes lMargenes
426
     * 
427
     * @return javax.swing.JLabel
428
     */
429
    private javax.swing.JLabel getLMargenes() {
430
        if (lMargenes == null) {
431
            lMargenes = new javax.swing.JLabel();
432
            lMargenes.setText(PluginServices.getText(this, "margenes"));
433
        }
434

    
435
        return lMargenes;
436
    }
437

    
438
    /**
439
     * Inserta si se dibuja los margenes sobre el Layout o no.
440
     * 
441
     * @param b
442
     *            True si se tiene que dibujar los margenes.
443
     */
444
    private void setMargin(boolean b) {
445
        margin = b;
446

    
447
        if (b) {
448
            getTSuperior().setText(
449
                String.valueOf(nf.format(m_layout.getLayoutContext()
450
                    .getAttributes().toUnits(sup))));
451
            getTIzquierdo().setText(
452
                String.valueOf(nf.format(m_layout.getLayoutContext()
453
                    .getAttributes().toUnits(izq))));
454
            getTInferior().setText(
455
                String.valueOf(nf.format(m_layout.getLayoutContext()
456
                    .getAttributes().toUnits(inf))));
457
            getTDerecho().setText(
458
                String.valueOf(nf.format(m_layout.getLayoutContext()
459
                    .getAttributes().toUnits(der))));
460
            getTSuperior().setEnabled(true);
461
            getTIzquierdo().setEnabled(true);
462
            getTInferior().setEnabled(true);
463
            getTDerecho().setEnabled(true);
464
        } else {
465
            getTSuperior().setText("");
466
            getTIzquierdo().setText("");
467
            getTInferior().setText("");
468
            getTDerecho().setText("");
469
            getTSuperior().setEnabled(false);
470
            getTIzquierdo().setEnabled(false);
471
            getTInferior().setEnabled(false);
472
            getTDerecho().setEnabled(false);
473
        }
474
    }
475

    
476
    /**
477
     * This method initializes chbMargenes
478
     * 
479
     * @return javax.swing.JCheckBox
480
     */
481
    private javax.swing.JCheckBox getChbMargenes() {
482
        if (chbMargenes == null) {
483
            chbMargenes = new javax.swing.JCheckBox();
484
            chbMargenes.setText(PluginServices.getText(this,
485
                "personalizar_margenes"));
486
            chbMargenes.setSelected(m_layout.getLayoutContext().getAttributes()
487
                .isMargin());
488
            setMargin(m_layout.getLayoutContext().getAttributes().isMargin());
489
            chbMargenes.addActionListener(new java.awt.event.ActionListener() {
490

    
491
                public void actionPerformed(java.awt.event.ActionEvent e) {
492
                    if (chbMargenes.isSelected()) {
493
                        margin = true;
494
                    } else {
495
                        margin = false;
496
                    }
497

    
498
                    setMargin(margin);
499
                }
500
            });
501
        }
502

    
503
        return chbMargenes;
504
    }
505

    
506
    /**
507
     * This method initializes lSuperior
508
     * 
509
     * @return javax.swing.JLabel
510
     */
511
    private javax.swing.JLabel getLSuperior() {
512
        if (lSuperior == null) {
513
            lSuperior = new javax.swing.JLabel();
514
            lSuperior.setText(PluginServices.getText(this, "Superior"));
515
        }
516

    
517
        return lSuperior;
518
    }
519

    
520
    /**
521
     * This method initializes tSuperior
522
     * 
523
     * @return javax.swing.JTextField
524
     */
525
    private javax.swing.JTextField getTSuperior() {
526
        if (tSuperior == null) {
527
            tSuperior = new javax.swing.JTextField(4);
528
            if (m_layout.getLayoutContext().getAttributes().isMargin()) {
529
                tSuperior.setText(String.valueOf(nf.format(m_layout
530
                    .getLayoutContext().getAttributes().toUnits(sup))));
531
            }
532
        }
533

    
534
        return tSuperior;
535
    }
536

    
537
    /**
538
     * This method initializes lIzquierdo
539
     * 
540
     * @return javax.swing.JLabel
541
     */
542
    private javax.swing.JLabel getLIzquierdo() {
543
        if (lIzquierdo == null) {
544
            lIzquierdo = new javax.swing.JLabel();
545
            lIzquierdo.setText(PluginServices.getText(this, "Izquierdo"));
546
        }
547

    
548
        return lIzquierdo;
549
    }
550

    
551
    /**
552
     * This method initializes tIzquierdo
553
     * 
554
     * @return javax.swing.JTextField
555
     */
556
    private javax.swing.JTextField getTIzquierdo() {
557
        if (tIzquierdo == null) {
558
            tIzquierdo = new javax.swing.JTextField(4);
559
            if (m_layout.getLayoutContext().getAttributes().isMargin()) {
560
                tIzquierdo.setText(String.valueOf(nf.format(m_layout
561
                    .getLayoutContext().getAttributes().toUnits(izq))));
562
            }
563
        }
564

    
565
        return tIzquierdo;
566
    }
567

    
568
    /**
569
     * This method initializes lInferior
570
     * 
571
     * @return javax.swing.JLabel
572
     */
573
    private javax.swing.JLabel getLInferior() {
574
        if (lInferior == null) {
575
            lInferior = new javax.swing.JLabel();
576
            lInferior.setText(PluginServices.getText(this, "Inferior"));
577
        }
578

    
579
        return lInferior;
580
    }
581

    
582
    /**
583
     * This method initializes tInferior
584
     * 
585
     * @return javax.swing.JTextField
586
     */
587
    private javax.swing.JTextField getTInferior() {
588
        if (tInferior == null) {
589
            tInferior = new javax.swing.JTextField(4);
590
            if (m_layout.getLayoutContext().getAttributes().isMargin()) {
591
                tInferior.setText(String.valueOf(nf.format(m_layout
592
                    .getLayoutContext().getAttributes().toUnits(inf))));
593
            }
594
        }
595

    
596
        return tInferior;
597
    }
598

    
599
    /**
600
     * This method initializes lDerecho
601
     * 
602
     * @return javax.swing.JLabel
603
     */
604
    private javax.swing.JLabel getLDerecho() {
605
        if (lDerecho == null) {
606
            lDerecho = new javax.swing.JLabel();
607
            lDerecho.setText(PluginServices.getText(this, "Derecho"));
608
        }
609

    
610
        return lDerecho;
611
    }
612

    
613
    /**
614
     * This method initializes tDerecho
615
     * 
616
     * @return javax.swing.JTextField
617
     */
618
    private javax.swing.JTextField getTDerecho() {
619
        if (tDerecho == null) {
620
            tDerecho = new javax.swing.JTextField(4);
621
            if (m_layout.getLayoutContext().getAttributes().isMargin()) {
622
                tDerecho.setText(String.valueOf(nf.format(m_layout
623
                    .getLayoutContext().getAttributes().toUnits(der))));
624
            }
625
        }
626

    
627
        return tDerecho;
628
    }
629

    
630
    /**
631
     * This method initializes lResolucion
632
     * 
633
     * @return javax.swing.JLabel
634
     */
635
    private javax.swing.JLabel getLResolucion() {
636
        if (lResolucion == null) {
637
            lResolucion = new javax.swing.JLabel();
638
            lResolucion.setText(PluginServices.getText(this,
639
                "resolucion_resultado"));
640
        }
641

    
642
        return lResolucion;
643
    }
644

    
645
    /**
646
     * This method initializes cbResolucion
647
     * 
648
     * @return javax.swing.JComboBox
649
     */
650
    private javax.swing.JComboBox getCbResolucion() {
651
        if (cbResolucion == null) {
652
            cbResolucion = new javax.swing.JComboBox();
653
            cbResolucion.addItem(PluginServices.getText(this, "High_600_dpi"));
654
            cbResolucion.addItem(PluginServices.getText(this, "Normal_300_dpi"));
655
            cbResolucion.addItem(PluginServices.getText(this, "Low_72_dpi"));
656
            cbResolucion.setSelectedIndex(m_layout.getLayoutContext()
657
                .getAttributes().getResolution());
658
            cbResolucion.addActionListener(new java.awt.event.ActionListener() {
659

    
660
                public void actionPerformed(java.awt.event.ActionEvent e) {
661
                    resolution = cbResolucion.getSelectedIndex();
662
                }
663
            });
664
        }
665

    
666
        return cbResolucion;
667
    }
668

    
669
    /**
670
     * This method initializes bAceptar
671
     * 
672
     * @return javax.swing.JButton
673
     */
674
    private javax.swing.JButton getBAceptar() {
675
        if (bAceptar == null) {
676
            bAceptar = new javax.swing.JButton();
677
            bAceptar.setText(PluginServices.getText(this, "Aceptar"));
678
            bAceptar.addActionListener(new java.awt.event.ActionListener() {
679

    
680
                public void actionPerformed(java.awt.event.ActionEvent e) {
681
                        Attributes attributes = m_layout.getLayoutContext().getAttributes();
682
                        attributes.setUnit(unit);
683

    
684
                    if (isLand) {
685
                            attributes.setIsLandScape(true);
686
                    } else {
687
                            attributes.setIsLandScape(false);
688
                    }
689

    
690
                    attributes.setType(type);
691
                    attributes.resetSizeinUnits(isLand);
692
                    obtainArea();
693

    
694
                    double[] area = { sup, inf, izq, der };
695

    
696
                    if (type == Attributes.CUSTOM) {
697
                        String width = getTAncho().getText().replace(',', '.');
698
                        String height = getTAlto().getText().replace(',', '.');
699
                        Attributes.CUSTOM_PAPER_SIZE =
700
                            new Size(
701
                                Double.valueOf(height).doubleValue(),
702
                                Double.valueOf(width).doubleValue());
703
                        attributes.m_sizePaper =
704
                            Attributes.CUSTOM_PAPER_SIZE;
705
                    }
706
                    attributes.setType(type);
707
                    m_layout.obtainRect(false);
708
                    m_layout
709
                        .getLayoutContext()
710
                        .getAttributes()
711
                        .setSelectedOptions(type, unit, isLand, margin,
712
                            resolution, area);
713
                    if (showViewList && getChbViews().isSelected()) { // a view has been selected
714
                            ViewDocument vd = getSelectedView();
715
                            ProjectManager projectManager = ApplicationLocator.getProjectManager();
716
                        LayoutManager layoutManager = (LayoutManager) projectManager.getDocumentManager(LayoutManager.TYPENAME);
717
                        FFrameView ffv = (FFrameView) layoutManager.createFrame(FFrameView.PERSISTENCE_DEFINITION_NAME);
718
                        ffv.setDocument(m_layout.getDocument());
719
                        LayoutContext lctxt = m_layout.getLayoutContext();
720
                        ffv.setLayoutContext(lctxt);
721
                            ffv.setBoundBox(new Rectangle2D.Double(izq, sup, attributes.getPaperSize().getAncho()-(izq+der), attributes.getPaperSize().getAlto()-(sup+inf)));
722
                            ffv.setView(vd);
723
                            lctxt.addFFrame(ffv, true, true);
724
                    }
725
                    if (createdView!=null && createdView!=getSelectedView()) { // a view was created but later de-selected
726
                            deleteView();
727
                    }
728
                    PluginServices.getMDIManager().closeWindow(
729
                        FConfigLayoutDialog.this);
730
                    m_layout.getLayoutControl().fullRect();
731
                }
732
            });
733
        }
734

    
735
        return bAceptar;
736
    }
737

    
738
    /**
739
     * This method initializes bCancelar
740
     * 
741
     * @return javax.swing.JButton
742
     */
743
    private javax.swing.JButton getBCancelar() {
744
        if (bCancelar == null) {
745
            bCancelar = new javax.swing.JButton();
746
            bCancelar.setText(PluginServices.getText(this, "Cancelar"));
747
            bCancelar.addActionListener(new java.awt.event.ActionListener() {
748

    
749
                public void actionPerformed(java.awt.event.ActionEvent e) {
750
                    if (createdView!=null) {
751
                            deleteView();
752
                    }
753
                    PluginServices.getMDIManager().closeWindow(
754
                        FConfigLayoutDialog.this);
755
                }
756
            });
757
        }
758

    
759
        return bCancelar;
760
    }
761

    
762
    private JPanel getOrientationPanel() {
763
            if (pOrientation == null) {
764
                    pOrientation = new JPanel(new GridBagLayout());
765
                    GridBagConstraints c = new GridBagConstraints();
766
                c.anchor = GridBagConstraints.WEST;
767
                c.gridx = 0;
768
                c.gridy = 0;
769
                c.insets = new Insets(0, 0, 0, 10);
770
                pOrientation.add(getRbHorizontal(), c);
771
                c.gridx = 1;
772
                c.insets = new Insets(0, 0, 0, 0);
773
                c.weightx = 1.0;
774
                c.fill = GridBagConstraints.HORIZONTAL;
775
                pOrientation.add(getRbVertical(), c);
776
                // add the radios to the button group
777
                ButtonGroup bgOrientation = new ButtonGroup();
778
                bgOrientation.add(getRbHorizontal());
779
                bgOrientation.add(getRbVertical());
780
                if (isLand) {
781
                        getRbHorizontal().setSelected(true);
782
                }
783
                else {
784
                        getRbVertical().setSelected(true);
785
                }
786
                if (getCbTipoFolio().getSelectedItem().equals(
787
                                PluginServices.getText(this, "Personalizado"))) {
788
                        rbHorizontal.setEnabled(false);
789
                        rbVertical.setEnabled(false);
790
                rbVertical.setSelected(true);
791
                        isLand = false;
792
                }
793
            }
794
            return pOrientation;
795
    }
796
    
797
    /**
798
     * This method initializes chbHorizontal
799
     * 
800
     * @return javax.swing.JCheckBox
801
     */
802
    private javax.swing.JRadioButton getRbHorizontal() {
803
        if (rbHorizontal == null) {
804
            rbHorizontal = new javax.swing.JRadioButton();
805
            rbHorizontal.setText(PluginServices.getText(this, "horizontal"));
806
            rbHorizontal
807
            .addActionListener(new java.awt.event.ActionListener() {
808
                    public void actionPerformed(java.awt.event.ActionEvent e) {
809
                            isLand = true;
810
                            double iz = izq;
811
                            izq = inf;
812
                            inf = der;
813
                            der = sup;
814
                            sup = iz;
815

    
816
                            setMargin(margin);
817

    
818
                            if (type == Attributes.CUSTOM) {
819
                                    Attributes.CUSTOM_PAPER_SIZE =
820
                                                    new Size(Double.valueOf(
821
                                                                    getTAlto().getText()).doubleValue(),
822
                                                                    Double.valueOf(getTAncho().getText())
823
                                                                    .doubleValue());
824
                            }
825

    
826
                            Size size =
827
                                            m_layout.getLayoutContext().getAttributes()
828
                                            .getSizeinUnits(isLand, type);
829
                            getTAncho().setText(
830
                                            String.valueOf(nf.format(size.getAncho())));
831
                            getTAlto().setText(
832
                                            String.valueOf(nf.format(size.getAlto())));
833
                    }
834
            });
835
        }
836

    
837
        return rbHorizontal;
838
    }
839

    
840
    /**
841
     * This method initializes chbVertical
842
     * 
843
     * @return javax.swing.JCheckBox
844
     */
845
    private javax.swing.JRadioButton getRbVertical() {        if (rbVertical == null) {
846
                rbVertical = new javax.swing.JRadioButton();
847
                rbVertical.setText(PluginServices.getText(this, "vertical"));
848
                rbVertical.addActionListener(new java.awt.event.ActionListener() {
849

    
850
                        public void actionPerformed(java.awt.event.ActionEvent e) {
851
                                isLand = false;
852
                                double in = inf;
853
                                inf = izq;
854
                                izq = sup;
855
                                sup = der;
856
                                der = in;
857

    
858
                                setMargin(margin);
859

    
860
                                if (type == Attributes.CUSTOM) {
861
                                        Attributes.CUSTOM_PAPER_SIZE =
862
                                                        new Size(Double.valueOf(getTAlto().getText())
863
                                                                        .doubleValue(), Double.valueOf(
864
                                                                                        getTAncho().getText()).doubleValue());
865
                                }
866

    
867
                                Size size =
868
                                                m_layout.getLayoutContext().getAttributes()
869
                                                .getSizeinUnits(isLand, type);
870
                                getTAncho().setText(
871
                                                String.valueOf(nf.format(size.getAncho())));
872
                                getTAlto().setText(
873
                                                String.valueOf(nf.format(size.getAlto())));
874
                        }
875
            });
876
        }
877

    
878
        return rbVertical;
879
    }
880

    
881
    /**
882
     * This method initializes liVistas
883
     * 
884
     * @return javax.swing.JList
885
     */
886
    private javax.swing.JList getViewList() {
887
                if (liViews  == null) {
888
            ListViewModel listModel = new ListViewModel();
889
            listModel.addCreateNewViewObj();
890
            if (listModel.addViews()) {
891
               JOptionPane.showMessageDialog(
892
                   ApplicationLocator.getManager().getRootComponent(),
893
                   Messages.getText("_Some_views_excluded_from_list_because_have_editing_layers"),
894
                   Messages.getText("Preparar_pagina"),
895
                   JOptionPane.WARNING_MESSAGE); 
896
            }
897
            
898
            liViews = new javax.swing.JList(listModel);
899
            liViews.setSelectedIndex(0);
900
                }
901
        return liViews;
902
    }
903
    
904
    private JScrollPane getViewScrollPane(){
905
            if (jViewScrollPane==null) {
906
                    jViewScrollPane = new javax.swing.JScrollPane();
907
                    jViewScrollPane.setViewportView(getViewList());
908
                    jViewScrollPane.setPreferredSize(new java.awt.Dimension(300, 100));            
909
            }
910
            return jViewScrollPane;
911
    }
912
    
913
    private JButton getBtConfigView() {
914
            if (btConfigView==null) {
915
                    UsabilitySwingManager manager = org.gvsig.tools.swing.api.ToolsSwingLocator.getUsabilitySwingManager();
916
                    btConfigView = manager.createJButton(Messages.getText("Configure_view"));
917
                    btConfigView.addActionListener(new ActionListener() {
918
                                public void actionPerformed(ActionEvent e) {
919
                                        ViewDocument view = FConfigLayoutDialog.this.getSelectedView();
920
                                        if (view!=null) {
921
                                                IWindow propWin = view.getPropertiesWindow();
922
                                                ApplicationManager manager = ApplicationLocator.getManager();
923
                                                manager.getUIManager().addWindow(propWin);
924
                                        }
925
                                }
926
                    });
927
            }
928
            return btConfigView;
929
    }
930
    
931
    protected ViewDocument getSelectedView() {
932
            Object selected = FConfigLayoutDialog.this.getViewList().getSelectedValue();
933
            ViewDocument view = null;
934
            if (selected instanceof ViewDocument) {
935
                    view = (ViewDocument) selected;
936
            }
937
            else if (selected==ListViewModel.CREATE_NEW_VIEW_OBJECT) {
938
                    if (FConfigLayoutDialog.this.createdView==null) {
939
                            view = createView();
940
                    }
941
                    else {
942
                            view = FConfigLayoutDialog.this.createdView;
943
                    }
944
            }
945
            return view;
946
    }
947
    
948
    private ViewDocument createView() {
949
        ProjectManager projectManager = ApplicationLocator.getProjectManager();
950
        ViewManager viewManager = (ViewManager) projectManager.getDocumentManager(ViewManager.TYPENAME);
951
        createdView = (ViewDocument) viewManager.createDocument();
952
            ProjectManager.getInstance().getCurrentProject().addDocument(createdView);
953
            return createdView;
954
    }
955
    
956
    private void deleteView() {
957
            ProjectManager projectManager = ApplicationLocator.getProjectManager();
958
        ProjectManager.getInstance().getCurrentProject().removeDocument(createdView);
959
        createdView = null;
960
    }
961
    
962
    /**
963
     * This method initializes lResolucion
964
     * 
965
     * @return javax.swing.JLabel
966
     */
967
    private javax.swing.JCheckBox getChbViews() {
968
        if (chbViews == null) {
969
                chbViews = new JCheckBox(PluginServices.getText(this,
970
                    "Insert_view"));
971
        }
972

    
973
        return chbViews;
974
    }
975
    
976
    /*
977
     * (non-Javadoc)
978
     * 
979
     * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
980
     */
981
    public WindowInfo getWindowInfo() {
982
        WindowInfo m_viewinfo = new WindowInfo(WindowInfo.RESIZABLE);
983
        if (showViewList) {
984
                m_viewinfo.setWidth(600);
985
                m_viewinfo.setHeight(500);
986
        }
987
        else {
988
                m_viewinfo.setWidth(550);
989
                m_viewinfo.setHeight(400);                
990
        }
991
        m_viewinfo.setTitle(PluginServices.getText(this, "Preparar_pagina"));
992

    
993
        return m_viewinfo;
994
    }
995

    
996
    /**
997
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
998
     */
999
    public void viewActivated() {
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
                return m_layout;
1054
        }
1055
}