Statistics
| Revision:

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

History | View | Annotate | Download (16.7 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.gui.layout.fframes.dialogs;
46

    
47
import com.iver.andami.PluginServices;
48
import com.iver.andami.ui.mdiManager.ViewInfo;
49

    
50
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities;
51
import com.iver.cit.gvsig.gui.layout.Layout;
52
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView;
53
import com.iver.cit.gvsig.gui.layout.fframes.ListViewModel;
54
import com.iver.cit.gvsig.project.ProjectView;
55

    
56
import java.awt.geom.Rectangle2D;
57

    
58
import javax.swing.JList;
59
import javax.swing.JPanel;
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, 273);
112

    
113
                if (!fframeview.getLinked()) {
114
                        getTEscalaNumerica().setEnabled(true);
115
                }
116
                getPRotation().setRotation(fframeview.getRotation());
117
        }
118

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

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

    
158
                return jContentPane;
159
        }
160

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

    
174
                return lVistas;
175
        }
176

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

    
190
                return jScrollPane;
191
        }
192

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

    
207
                                        ProjectView pvaux= (ProjectView) liVistas.getModel()
208
                                                                                                                  .getElementAt(i);
209

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

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

    
228
                                                fframeview.setBoundBox(FLayoutUtilities.toSheetRect(
229
                                                                rect, m_layout.getAT()));
230
                                                fframeview.setView((ProjectView) m_projectView);
231

    
232
                                                fframeview.setMapUnits(m_projectView.getMapContext()
233
                                                                                                                        .getViewPort()
234
                                                                                                                        .getMapUnits());
235
                                                getTEscalaNumerica().setText(String.valueOf(
236
                                                                fframeview.getScale()));
237
                                        }
238
                                        }
239
                                });
240
                }
241

    
242
                return liVistas;
243
        }
244

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

    
265
                return chbEnlaceVivo;
266
        }
267

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

    
281
                return lEscala;
282
        }
283

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

    
300
                        if (fframeview.getTypeScale() != 0) {
301
                                getTEscalaNumerica().setEnabled(true);
302
                        }
303

    
304
                        cbEscala.setPreferredSize(new java.awt.Dimension(200, 20));
305
                        cbEscala.setLocation(100, 105);
306
                        cbEscala.addActionListener(new java.awt.event.ActionListener() {
307
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
308
                                                if (cbEscala.getSelectedIndex() == 2) {
309
                                                        getTEscalaNumerica().setEnabled(true);
310
                                                } else {
311
                                                        getTEscalaNumerica().setEnabled(false);
312
                                                }
313
                                        }
314
                                });
315
                }
316

    
317
                return cbEscala;
318
        }
319

    
320
        /**
321
         * This method initializes lEscalaNumerica
322
         *
323
         * @return javax.swing.JLabel
324
         */
325
        private javax.swing.JLabel getLEscalaNumerica() {
326
                if (lEscalaNumerica == null) {
327
                        lEscalaNumerica = new javax.swing.JLabel();
328
                        lEscalaNumerica.setSize(86, 16);
329
                        lEscalaNumerica.setText("1:");
330
                        lEscalaNumerica.setLocation(10, 130);
331
                }
332

    
333
                return lEscalaNumerica;
334
        }
335

    
336
        /**
337
         * This method initializes tEscalaNumerica
338
         *
339
         * @return javax.swing.JTextField
340
         */
341
        private javax.swing.JTextField getTEscalaNumerica() {
342
                if (tEscalaNumerica == null) {
343
                        tEscalaNumerica = new javax.swing.JTextField();
344
                        tEscalaNumerica.setSize(220, 20);
345
                        tEscalaNumerica.setPreferredSize(new java.awt.Dimension(200, 20));
346

    
347
                        if (m_projectView != null) {
348
                                tEscalaNumerica.setText(String.valueOf(fframeview.getScale()));
349
                        }
350

    
351
                        tEscalaNumerica.setLocation(100, 130);
352
                        tEscalaNumerica.setEnabled(false);
353
                }
354

    
355
                return tEscalaNumerica;
356
        }
357

    
358
        /**
359
         * This method initializes lExtension
360
         *
361
         * @return javax.swing.JLabel
362
         */
363
        private javax.swing.JLabel getLExtension() {
364
                if (lExtension == null) {
365
                        lExtension = new javax.swing.JLabel();
366
                        lExtension.setSize(86, 16);
367
                        lExtension.setText(PluginServices.getText(this, "extension"));
368
                        lExtension.setLocation(10, 155);
369
                }
370

    
371
                return lExtension;
372
        }
373

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

    
388
                        cbExtension.setPreferredSize(new java.awt.Dimension(200, 20));
389
                        cbExtension.setLocation(100, 155);
390
                        cbExtension.setEnabled(false);
391
                }
392

    
393
                return cbExtension;
394
        }
395

    
396
        /**
397
         * This method initializes jLabel4
398
         *
399
         * @return javax.swing.JLabel
400
         */
401
        private javax.swing.JLabel getLVisualizacion() {
402
                if (lVisualizacion == null) {
403
                        lVisualizacion = new javax.swing.JLabel();
404
                        lVisualizacion.setSize(86, 16);
405
                        lVisualizacion.setText(PluginServices.getText(this, "visualizacion"));
406
                        lVisualizacion.setLocation(10, 180);
407
                }
408

    
409
                return lVisualizacion;
410
        }
411

    
412
        /**
413
         * This method initializes cbVisualizacion
414
         *
415
         * @return javax.swing.JComboBox
416
         */
417
        private javax.swing.JComboBox getCbVisualizacion() {
418
                if (cbVisualizacion == null) {
419
                        //String[] s={"Cuando activo","Siempre"};
420
                        cbVisualizacion = new javax.swing.JComboBox();
421
                        cbVisualizacion.setSize(220, 20);
422
                        cbVisualizacion.addItem(PluginServices.getText(this, "cuando_activo"));
423
                        cbVisualizacion.addItem(PluginServices.getText(this, "siempre"));
424
                        cbVisualizacion.setSelectedIndex(fframeview.getViewing());
425
                        cbVisualizacion.setPreferredSize(new java.awt.Dimension(200, 20));
426
                        cbVisualizacion.setLocation(100, 180);
427
                        cbVisualizacion.setEnabled(false);
428
                }
429

    
430
                return cbVisualizacion;
431
        }
432

    
433
        /**
434
         * This method initializes jButton
435
         *
436
         * @return javax.swing.JButton
437
         */
438
        private javax.swing.JButton getbAceptar() {
439
                if (bAceptar == null) {
440
                        bAceptar = new javax.swing.JButton();
441
                        bAceptar.setSize(85, 26);
442
                        bAceptar.setText(PluginServices.getText(this, "Aceptar"));
443
                        bAceptar.setLocation(55, 229);
444
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
445
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
446
                                                fframeview.setBoundBox(FLayoutUtilities.toSheetRect(
447
                                                                rect, m_layout.getAT()));
448

    
449
                                                if (m_projectView != null) {
450
                                                        fframeview.setLinked(getChbEnlaceVivo().isSelected());
451
                                                        fframeview.setName(m_projectView.getName());
452

    
453
                                                        fframeview.setTypeScale(getCbEscala()
454
                                                                                                                .getSelectedIndex());
455
                                                        fframeview.setScale(Double.parseDouble(
456
                                                                        getTEscalaNumerica().getText()));
457
                                                        fframeview.setView((ProjectView) m_projectView);
458

    
459
                                                        //fframeview.setFMap(m_projectView.getMapContext());
460
                                                        fframeview.setExtension(getCbExtension()
461
                                                                                                                .getSelectedIndex());
462
                                                        fframeview.setViewing(getCbVisualizacion()
463
                                                                                                          .getSelectedIndex());
464
                                                        fframeview.setQuality(getCbCalidad()
465
                                                                                                          .getSelectedIndex());
466
                                                        fframeview.setBoundBox(FLayoutUtilities.toSheetRect(
467
                                                                        rect, m_layout.getAT()));
468
                                                        fframeview.setRotation(getPRotation().getRotation());
469
                                                        /*        for (int i=0;i<m_layout.getFFrames().size();i++){
470
                                                           IFFrame fframe=(IFFrame)m_layout.getFFrames().get(i);
471
                                                           if (fframe instanceof FFrameScaleBar){
472
                                                                   if (((FFrameScaleBar)fframe).getFFrameView()==fframeview){
473
                                                                   if (getJComboBox().getSelectedIndex()!=0){
474
                                                                   ((FFrameScaleBar)fframe).setIsFixed(true);
475
                                                                   ((FFrameScaleBar)fframe).setScaleView(Long.parseLong(getJTextField().getText()));
476
                                                                   }else{
477
                                                                           ((FFrameScaleBar)fframe).setIsFixed(false);
478
                                                                   }
479

480
                                                                   }
481
                                                           }
482

483

484
                                                           }
485
                                                         */
486
                                                }
487

    
488
                                                isAcepted = true;
489

    
490
                                                //}else{
491
                                                //        isAcepted=false;
492
                                                //}
493
                                                PluginServices.getMDIManager().closeView(FFrameViewDialog.this);
494
                                                fframeview.refresh();
495
                                                m_layout.refresh();
496
                                        }
497
                                });
498
                }
499

    
500
                return bAceptar;
501
        }
502

    
503
        /**
504
         * This method initializes bCancelar
505
         *
506
         * @return javax.swing.JButton
507
         */
508
        private javax.swing.JButton getBCancelar() {
509
                if (bCancelar == null) {
510
                        bCancelar = new javax.swing.JButton();
511
                        bCancelar.setSize(85, 26);
512
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
513
                        bCancelar.setLocation(195, 229);
514
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
515
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
516
                                                PluginServices.getMDIManager().closeView(FFrameViewDialog.this);
517
                                        }
518
                                });
519
                }
520

    
521
                return bCancelar;
522
        }
523

    
524
        /**
525
         * This method initializes lCalidad
526
         *
527
         * @return javax.swing.JLabel
528
         */
529
        private javax.swing.JLabel getLCalidad() {
530
                if (lCalidad == null) {
531
                        lCalidad = new javax.swing.JLabel();
532
                        lCalidad.setSize(86, 16);
533
                        lCalidad.setText(PluginServices.getText(this, "calidad"));
534
                        lCalidad.setLocation(10, 205);
535
                }
536

    
537
                return lCalidad;
538
        }
539

    
540
        /**
541
         * This method initializes cbCalidad
542
         *
543
         * @return javax.swing.JComboBox
544
         */
545
        private javax.swing.JComboBox getCbCalidad() {
546
                if (cbCalidad == null) {
547
                        //String[] s={"Presentaci?n","Borrador"};
548
                        cbCalidad = new javax.swing.JComboBox();
549
                        cbCalidad.setSize(220, 20);
550
                        cbCalidad.addItem(PluginServices.getText(this, "presentacion"));
551
                        cbCalidad.addItem(PluginServices.getText(this, "borrador"));
552
                        cbCalidad.setSelectedIndex(fframeview.getQuality());
553
                        cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20));
554
                        cbCalidad.setLocation(100, 205);
555
                }
556

    
557
                return cbCalidad;
558
        }
559

    
560
        /* (non-Javadoc)
561
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
562
         */
563
        public ViewInfo getViewInfo() {
564
                ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
565

    
566
                //vi.setResizable(false);
567
                m_viewinfo.setTitle(PluginServices.getText(this,
568
                                "propiedades_marco_vista"));
569

    
570
                return m_viewinfo;
571
        }
572

    
573
        /**
574
         * @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
575
         */
576
        public boolean getIsAcepted() {
577
                return isAcepted;
578
        }
579

    
580
        /**
581
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
582
         */
583
        public void viewActivated() {
584
        }
585

    
586
        /**
587
         * This method initializes rotation
588
         *
589
         * @return javax.swing.JPanel
590
         */
591
        private JPRotation getPRotation() {
592
                if (rotation == null) {
593
                        rotation = new JPRotation();
594
                        rotation.setBounds(332, 105, 120, 120);
595
                }
596
                return rotation;
597
        }
598
}  //  @jve:decl-index=0:visual-constraint="10,10"