Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / gui / dialogs / FFrameViewDialog.java @ 7906

History | View | Annotate | Download (17.2 KB)

1
/*
2
 * Created on 01-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 com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs;
46

    
47
import java.awt.geom.Rectangle2D;
48

    
49
import javax.swing.JList;
50
import javax.swing.JPanel;
51

    
52
import com.iver.andami.PluginServices;
53
import com.iver.andami.ui.mdiManager.WindowInfo;
54
import com.iver.cit.gvsig.gui.layout.Layout;
55
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView;
56
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities;
57
import com.iver.cit.gvsig.project.documents.layout.fframes.ListViewModel;
58
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.JPRotation;
59
import com.iver.cit.gvsig.project.documents.view.ProjectView;
60

    
61

    
62
/**
63
 * Di?logo para a?adir una vista al Layout.
64
 *
65
 * @author Vicente Caballero Navarro
66
 */
67
public class FFrameViewDialog extends JPanel implements IFFrameDialog {
68
        private javax.swing.JPanel jContentPane = null;
69
        private javax.swing.JLabel lVistas = null;
70
        private javax.swing.JScrollPane jScrollPane = null;
71
        private javax.swing.JList liVistas = null; //  @jve:visual-info  decl-index=0 visual-constraint="98,-3"
72
        private javax.swing.JCheckBox chbEnlaceVivo = null;
73
        private javax.swing.JLabel lEscala = null;
74
        private javax.swing.JComboBox cbEscala = null;
75
        private javax.swing.JLabel lEscalaNumerica = null;
76
        private javax.swing.JTextField tEscalaNumerica = null;
77
        private javax.swing.JLabel lExtension = null;
78
        private javax.swing.JComboBox cbExtension = null;
79
        private javax.swing.JLabel lVisualizacion = null;
80
        private javax.swing.JComboBox cbVisualizacion = null;
81
        private javax.swing.JButton bAceptar = null;
82
        private javax.swing.JButton bCancelar = null;
83
        private javax.swing.JLabel lCalidad = null;
84
        private javax.swing.JComboBox cbCalidad = null;
85
        private ProjectView m_projectView = null;
86
        private Rectangle2D rect = new Rectangle2D.Double();
87
        private FFrameView fframeview = null; //new FFrameView();
88
        private Layout m_layout = null;
89
        private boolean isAcepted = false;
90
        private JPRotation rotation = null;
91

    
92
        /**
93
         * This is the default constructor
94
         *
95
         * @param layout Referencia al Layout.
96
         * @param fframe Referencia al fframe vista.
97
         */
98
        public FFrameViewDialog(Layout layout, FFrameView fframe) {
99
                super();
100
                fframeview = fframe;
101
                m_layout = layout;
102
                initialize();
103
        }
104

    
105
        /**
106
         * This method initializes this
107
         */
108
        private void initialize() {
109
                this.setLayout(null);
110
                this.add(getJContentPane(), null);
111
                this.setSize(463, 222);
112

    
113
                if (fframeview.getTypeScale() == 0 || fframeview.getTypeScale() == 1) {
114
                                getTEscalaNumerica().setEnabled(false);
115
                        }else{
116
                                getTEscalaNumerica().setEnabled(true);
117
                        }
118
                getPRotation().setRotation(fframeview.getRotation());
119
        }
120

    
121
        /**
122
         * Inserta el rect?ngulo que ocupar? el fframe vista.
123
         *
124
         * @param r Rect?ngulo.
125
         */
126
        public void setRectangle(Rectangle2D r) {
127
                rect.setRect(r);
128
        }
129

    
130
        /**
131
         * This method initializes jContentPane
132
         *
133
         * @return javax.swing.JPanel
134
         */
135
        private javax.swing.JPanel getJContentPane() {
136
                if (jContentPane == null) {
137
                        jContentPane = new javax.swing.JPanel();
138
                        jContentPane.setLayout(null);
139
                        jContentPane.add(getLVistas(), null);
140
                        jContentPane.add(getJScrollPane(), null);
141
                        jContentPane.add(getChbEnlaceVivo(), null);
142
                        jContentPane.add(getLEscala(), null);
143
                        jContentPane.add(getCbEscala(), null);
144
                        jContentPane.add(getLEscalaNumerica(), null);
145
                        jContentPane.add(getTEscalaNumerica(), null);
146
                        jContentPane.add(getLExtension(), null);
147
                        jContentPane.add(getCbExtension(), null);
148
                        jContentPane.add(getLVisualizacion(), null);
149
                        jContentPane.add(getCbVisualizacion(), null);
150
                        jContentPane.add(getLCalidad(), null);
151
                        jContentPane.add(getCbCalidad(), null);
152
                        jContentPane.add(getbAceptar(), null);
153
                        jContentPane.add(getBCancelar(), null);
154
                        jContentPane.setSize(462, 220);
155
                        jContentPane.setPreferredSize(new java.awt.Dimension(60, 60));
156
                        jContentPane.setLocation(0, 0);
157
                        jContentPane.add(getPRotation(), null);
158
                }
159

    
160
                return jContentPane;
161
        }
162

    
163
        /**
164
         * This method initializes lVistas
165
         *
166
         * @return javax.swing.JLabel
167
         */
168
        private javax.swing.JLabel getLVistas() {
169
                if (lVistas == null) {
170
                        lVistas = new javax.swing.JLabel();
171
                        lVistas.setSize(85, 19);
172
                        lVistas.setText(PluginServices.getText(this, "Vista"));
173
                        lVistas.setLocation(10, 10);
174
                }
175

    
176
                return lVistas;
177
        }
178

    
179
        /**
180
         * This method initializes jScrollPane
181
         *
182
         * @return javax.swing.JScrollPane
183
         */
184
        private javax.swing.JScrollPane getJScrollPane() {
185
                if (jScrollPane == null) {
186
                        jScrollPane = new javax.swing.JScrollPane();
187
                        jScrollPane.setViewportView(getLiVistas());
188
                        jScrollPane.setBounds(99, 8, 224, 64);
189
                        jScrollPane.setPreferredSize(new java.awt.Dimension(250, 60));
190
                }
191

    
192
                return jScrollPane;
193
        }
194

    
195
        /**
196
         * This method initializes liVistas
197
         *
198
         * @return javax.swing.JList
199
         */
200
        private javax.swing.JList getLiVistas() {
201
                if (liVistas == null) {
202
                        ListViewModel listmodel = new ListViewModel();
203
                        listmodel.addViews();
204
                        liVistas = new javax.swing.JList();
205
                        liVistas.setModel(listmodel);
206
                        for (int i = 0; i < liVistas.getModel().getSize(); i++) {
207
                                if (fframeview.getMapContext() != null) {
208

    
209
                                        ProjectView pvaux= (ProjectView) liVistas.getModel()
210
                                                                                                                  .getElementAt(i);
211

    
212
                                        if (pvaux.getMapContext().equals(fframeview.getMapContext())) {
213
                                                liVistas.setSelectedIndex(i);
214
                                                m_projectView= (ProjectView) liVistas.getModel()
215
                                                  .getElementAt(i);
216
                                        }
217
                                }
218
                        }
219

    
220
                        liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
221
                                        private int selectIndex=-1;
222
                                        public void valueChanged(
223
                                                javax.swing.event.ListSelectionEvent e) {
224
                                                int selectInt = ((JList)e.getSource()).getSelectedIndex();
225
                                                if (selectInt!=selectIndex){
226
                                                        selectIndex=selectInt;
227
                                                        if (selectIndex==-1)
228
                                                                return;
229
                                                m_projectView = (ProjectView) liVistas.getModel()
230
                                                                                                                          .getElementAt(selectInt);
231

    
232
                                                fframeview.setBoundBox(FLayoutUtilities.toSheetRect(
233
                                                                rect, m_layout.getAT()));
234
                                                fframeview.setView(m_projectView);
235

    
236
                                                fframeview.setMapUnits(m_projectView.getMapContext()
237
                                                                                                                        .getViewPort()
238
                                                                                                                        .getMapUnits());
239
                                                getTEscalaNumerica().setText(String.valueOf(
240
                                                                fframeview.getScale()));
241
                                        }
242
                                        }
243
                                });
244
                }
245

    
246
                return liVistas;
247
        }
248

    
249
        /**
250
         * This method initializes chbEnlaceVivo
251
         *
252
         * @return javax.swing.JCheckBox
253
         */
254
        private javax.swing.JCheckBox getChbEnlaceVivo() {
255
                if (chbEnlaceVivo == null) {
256
                        chbEnlaceVivo = new javax.swing.JCheckBox();
257
                        chbEnlaceVivo.setSize(88, 24);
258
                        chbEnlaceVivo.setText(PluginServices.getText(this, "enlace_vivo"));
259
                        chbEnlaceVivo.setSelected(fframeview.getLinked());
260
                        chbEnlaceVivo.setLocation(10, 75);
261
                        chbEnlaceVivo.setEnabled(true);
262
                        chbEnlaceVivo.addActionListener(new java.awt.event.ActionListener() {
263
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
264
                                                System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
265
                                        }
266
                                });
267
                }
268

    
269
                return chbEnlaceVivo;
270
        }
271

    
272
        /**
273
         * This method initializes lEscala
274
         *
275
         * @return javax.swing.JLabel
276
         */
277
        private javax.swing.JLabel getLEscala() {
278
                if (lEscala == null) {
279
                        lEscala = new javax.swing.JLabel();
280
                        lEscala.setSize(86, 16);
281
                        lEscala.setText(PluginServices.getText(this, "escala"));
282
                        lEscala.setLocation(10, 105);
283
                }
284

    
285
                return lEscala;
286
        }
287

    
288
        /**
289
         * This method initializes cbEscala
290
         *
291
         * @return javax.swing.JComboBox
292
         */
293
        private javax.swing.JComboBox getCbEscala() {
294
                if (cbEscala == null) {
295
                        //String[] s={"Autom?tico","Conservar escala de visualizaci?n","Escala especificada por el usuario"};
296
                        cbEscala = new javax.swing.JComboBox();
297
                        cbEscala.setSize(220, 20);
298
                        cbEscala.addItem(PluginServices.getText(this, "automatico"));
299
                        cbEscala.addItem(PluginServices.getText(this,
300
                                        "conservar_escala_visualizacion"));
301
                        cbEscala.addItem(PluginServices.getText(this, "escala_usuario"));
302
                        cbEscala.setSelectedIndex(fframeview.getTypeScale());
303

    
304
                        if (fframeview.getTypeScale() == 0 || fframeview.getTypeScale() == 1) {
305
                                getTEscalaNumerica().setEnabled(false);
306
                        }else{
307
                                getTEscalaNumerica().setEnabled(true);
308
                        }
309

    
310
                        cbEscala.setPreferredSize(new java.awt.Dimension(200, 20));
311
                        cbEscala.setLocation(100, 105);
312
                        cbEscala.addActionListener(new java.awt.event.ActionListener() {
313
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
314
                                                if (cbEscala.getSelectedIndex() == 2) {
315
                                                        getTEscalaNumerica().setEnabled(true);
316
                                                } else {
317
                                                        getTEscalaNumerica().setEnabled(false);
318
                                                }
319
                                        }
320
                                });
321
                }
322

    
323
                return cbEscala;
324
        }
325

    
326
        /**
327
         * This method initializes lEscalaNumerica
328
         *
329
         * @return javax.swing.JLabel
330
         */
331
        private javax.swing.JLabel getLEscalaNumerica() {
332
                if (lEscalaNumerica == null) {
333
                        lEscalaNumerica = new javax.swing.JLabel();
334
                        lEscalaNumerica.setSize(86, 16);
335
                        lEscalaNumerica.setText("1:");
336
                        lEscalaNumerica.setLocation(10, 130);
337
                }
338

    
339
                return lEscalaNumerica;
340
        }
341

    
342
        /**
343
         * This method initializes tEscalaNumerica
344
         *
345
         * @return javax.swing.JTextField
346
         */
347
        private javax.swing.JTextField getTEscalaNumerica() {
348
                if (tEscalaNumerica == null) {
349
                        tEscalaNumerica = new javax.swing.JTextField();
350
                        tEscalaNumerica.setSize(220, 20);
351
                        tEscalaNumerica.setPreferredSize(new java.awt.Dimension(200, 20));
352

    
353
                        if (m_projectView != null) {
354
                                tEscalaNumerica.setText(String.valueOf(fframeview.getScale()));
355
                        }
356
                        tEscalaNumerica.setLocation(100, 130);
357
                        tEscalaNumerica.setEnabled(false);
358
                }
359

    
360
                return tEscalaNumerica;
361
        }
362

    
363
        /**
364
         * This method initializes lExtension
365
         *
366
         * @return javax.swing.JLabel
367
         */
368
        private javax.swing.JLabel getLExtension() {
369
                if (lExtension == null) {
370
                        lExtension = new javax.swing.JLabel();
371
                        lExtension.setSize(86, 16);
372
                        lExtension.setText(PluginServices.getText(this, "extension"));
373
                        lExtension.setLocation(10, 155);
374
                        lExtension.setVisible(false);
375
                }
376

    
377
                return lExtension;
378
        }
379

    
380
        /**
381
         * This method initializes cbExtension
382
         *
383
         * @return javax.swing.JComboBox
384
         */
385
        private javax.swing.JComboBox getCbExtension() {
386
                if (cbExtension == null) {
387
                        //String[] s={"Rellenar marco de la vista","Recorte a vista"};
388
                        cbExtension = new javax.swing.JComboBox();
389
                        cbExtension.setSize(220, 20);
390
                        cbExtension.addItem(PluginServices.getText(this,
391
                                        "rellenar_marco_vista"));
392
                        cbExtension.addItem(PluginServices.getText(this, "recorte_vista"));
393

    
394
                        cbExtension.setPreferredSize(new java.awt.Dimension(200, 20));
395
                        cbExtension.setLocation(100, 155);
396
                        cbExtension.setEnabled(false);
397
                        cbExtension.setVisible(false);
398
                }
399

    
400
                return cbExtension;
401
        }
402

    
403
        /**
404
         * This method initializes jLabel4
405
         *
406
         * @return javax.swing.JLabel
407
         */
408
        private javax.swing.JLabel getLVisualizacion() {
409
                if (lVisualizacion == null) {
410
                        lVisualizacion = new javax.swing.JLabel();
411
                        lVisualizacion.setSize(86, 16);
412
                        lVisualizacion.setText(PluginServices.getText(this, "visualizacion"));
413
                        lVisualizacion.setLocation(10, 180);
414
                        lVisualizacion.setVisible(false);
415
                }
416

    
417
                return lVisualizacion;
418
        }
419

    
420
        /**
421
         * This method initializes cbVisualizacion
422
         *
423
         * @return javax.swing.JComboBox
424
         */
425
        private javax.swing.JComboBox getCbVisualizacion() {
426
                if (cbVisualizacion == null) {
427
                        //String[] s={"Cuando activo","Siempre"};
428
                        cbVisualizacion = new javax.swing.JComboBox();
429
                        cbVisualizacion.setSize(220, 20);
430
                        cbVisualizacion.addItem(PluginServices.getText(this, "cuando_activo"));
431
                        cbVisualizacion.addItem(PluginServices.getText(this, "siempre"));
432
                        cbVisualizacion.setSelectedIndex(fframeview.getViewing());
433
                        cbVisualizacion.setPreferredSize(new java.awt.Dimension(200, 20));
434
                        cbVisualizacion.setLocation(100, 180);
435
                        cbVisualizacion.setEnabled(false);
436
                        cbVisualizacion.setVisible(false);
437
                }
438

    
439
                return cbVisualizacion;
440
        }
441

    
442
        /**
443
         * This method initializes jButton
444
         *
445
         * @return javax.swing.JButton
446
         */
447
        private javax.swing.JButton getbAceptar() {
448
                if (bAceptar == null) {
449
                        bAceptar = new javax.swing.JButton();
450
                        bAceptar.setSize(85, 26);
451
                        bAceptar.setText(PluginServices.getText(this, "Aceptar"));
452
                        bAceptar.setLocation(55, 179);
453
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
454
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
455
                                                fframeview.setBoundBox(FLayoutUtilities.toSheetRect(
456
                                                                rect, m_layout.getAT()));
457
                                                fframeview.setRotation(getPRotation().getRotation());
458
                                                if (m_projectView != null) {
459
                                                        fframeview.setLinked(getChbEnlaceVivo().isSelected());
460
                                                        fframeview.setName(m_projectView.getName());
461

    
462
                                                        fframeview.setTypeScale(getCbEscala()
463
                                                                                                                .getSelectedIndex());
464
                                                        fframeview.setScale(Double.parseDouble(
465
                                                                        getTEscalaNumerica().getText()));
466
                                                        fframeview.setView(m_projectView);
467

    
468
                                                        //fframeview.setFMap(m_projectView.getMapContext());
469
                                                        fframeview.setExtension(getCbExtension()
470
                                                                                                                .getSelectedIndex());
471
                                                        fframeview.setViewing(getCbVisualizacion()
472
                                                                                                          .getSelectedIndex());
473
                                                        fframeview.setQuality(getCbCalidad()
474
                                                                                                          .getSelectedIndex());
475
                                                        fframeview.setBoundBox(FLayoutUtilities.toSheetRect(
476
                                                                        rect, m_layout.getAT()));
477

    
478
                                                        /*        for (int i=0;i<m_layout.getFFrames().size();i++){
479
                                                           IFFrame fframe=(IFFrame)m_layout.getFFrames().get(i);
480
                                                           if (fframe instanceof FFrameScaleBar){
481
                                                                   if (((FFrameScaleBar)fframe).getFFrameView()==fframeview){
482
                                                                   if (getJComboBox().getSelectedIndex()!=0){
483
                                                                   ((FFrameScaleBar)fframe).setIsFixed(true);
484
                                                                   ((FFrameScaleBar)fframe).setScaleView(Long.parseLong(getJTextField().getText()));
485
                                                                   }else{
486
                                                                           ((FFrameScaleBar)fframe).setIsFixed(false);
487
                                                                   }
488

489
                                                                   }
490
                                                           }
491

492

493
                                                           }
494
                                                         */
495
                                                }
496

    
497
                                                isAcepted = true;
498

    
499
                                                //}else{
500
                                                //        isAcepted=false;
501
                                                //}
502
                                                PluginServices.getMDIManager().closeWindow(FFrameViewDialog.this);
503
                                                fframeview.refresh();
504
                                                m_layout.refresh();
505
                                        }
506
                                });
507
                }
508

    
509
                return bAceptar;
510
        }
511

    
512
        /**
513
         * This method initializes bCancelar
514
         *
515
         * @return javax.swing.JButton
516
         */
517
        private javax.swing.JButton getBCancelar() {
518
                if (bCancelar == null) {
519
                        bCancelar = new javax.swing.JButton();
520
                        bCancelar.setSize(85, 26);
521
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
522
                        bCancelar.setLocation(195, 179);
523
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
524
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
525
                                                PluginServices.getMDIManager().closeWindow(FFrameViewDialog.this);
526
                                        }
527
                                });
528
                }
529

    
530
                return bCancelar;
531
        }
532

    
533
        /**
534
         * This method initializes lCalidad
535
         *
536
         * @return javax.swing.JLabel
537
         */
538
        private javax.swing.JLabel getLCalidad() {
539
                if (lCalidad == null) {
540
                        lCalidad = new javax.swing.JLabel();
541
                        lCalidad.setSize(86, 16);
542
                        lCalidad.setText(PluginServices.getText(this, "calidad"));
543
                        lCalidad.setLocation(10, 155);
544
                }
545

    
546
                return lCalidad;
547
        }
548

    
549
        /**
550
         * This method initializes cbCalidad
551
         *
552
         * @return javax.swing.JComboBox
553
         */
554
        private javax.swing.JComboBox getCbCalidad() {
555
                if (cbCalidad == null) {
556
                        //String[] s={"Presentaci?n","Borrador"};
557
                        cbCalidad = new javax.swing.JComboBox();
558
                        cbCalidad.setSize(220, 20);
559
                        cbCalidad.addItem(PluginServices.getText(this, "presentacion"));
560
                        cbCalidad.addItem(PluginServices.getText(this, "borrador"));
561
                        cbCalidad.setSelectedIndex(fframeview.getQuality());
562
                        cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20));
563
                        cbCalidad.setLocation(100, 155);
564
                }
565

    
566
                return cbCalidad;
567
        }
568

    
569
        /* (non-Javadoc)
570
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
571
         */
572
        public WindowInfo getWindowInfo() {
573
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
574

    
575
                //vi.setResizable(false);
576
                m_viewinfo.setTitle(PluginServices.getText(this,
577
                                "propiedades_marco_vista"));
578

    
579
                return m_viewinfo;
580
        }
581

    
582
        /**
583
         * @see com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
584
         */
585
        public boolean getIsAcepted() {
586
                return isAcepted;
587
        }
588

    
589
        /**
590
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
591
         */
592
        public void viewActivated() {
593
        }
594

    
595
        /**
596
         * This method initializes rotation
597
         *
598
         * @return javax.swing.JPanel
599
         */
600
        private JPRotation getPRotation() {
601
                if (rotation == null) {
602
                        rotation = new JPRotation();
603
                        rotation.setBounds(330, 90, 120, 120);
604
                }
605
                return rotation;
606
        }
607
}  //  @jve:decl-index=0:visual-constraint="10,10"