Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / dialogs / FFrameViewDialog.java @ 6877

History | View | Annotate | Download (16.9 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.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, 270);
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.getFMap() != null) {
208

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

    
212
                                        if (pvaux.getMapContext().equals(fframeview.getFMap())) {
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
                }
375

    
376
                return lExtension;
377
        }
378

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

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

    
398
                return cbExtension;
399
        }
400

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

    
414
                return lVisualizacion;
415
        }
416

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

    
435
                return cbVisualizacion;
436
        }
437

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

    
458
                                                        fframeview.setTypeScale(getCbEscala()
459
                                                                                                                .getSelectedIndex());
460
                                                        fframeview.setScale(Double.parseDouble(
461
                                                                        getTEscalaNumerica().getText()));
462
                                                        fframeview.setView(m_projectView);
463

    
464
                                                        //fframeview.setFMap(m_projectView.getMapContext());
465
                                                        fframeview.setExtension(getCbExtension()
466
                                                                                                                .getSelectedIndex());
467
                                                        fframeview.setViewing(getCbVisualizacion()
468
                                                                                                          .getSelectedIndex());
469
                                                        fframeview.setQuality(getCbCalidad()
470
                                                                                                          .getSelectedIndex());
471
                                                        fframeview.setBoundBox(FLayoutUtilities.toSheetRect(
472
                                                                        rect, m_layout.getAT()));
473

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

485
                                                                   }
486
                                                           }
487

488

489
                                                           }
490
                                                         */
491
                                                }
492

    
493
                                                isAcepted = true;
494

    
495
                                                //}else{
496
                                                //        isAcepted=false;
497
                                                //}
498
                                                PluginServices.getMDIManager().closeView(FFrameViewDialog.this);
499
                                                fframeview.refresh();
500
                                                m_layout.refresh();
501
                                        }
502
                                });
503
                }
504

    
505
                return bAceptar;
506
        }
507

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

    
526
                return bCancelar;
527
        }
528

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

    
542
                return lCalidad;
543
        }
544

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

    
562
                return cbCalidad;
563
        }
564

    
565
        /* (non-Javadoc)
566
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
567
         */
568
        public ViewInfo getViewInfo() {
569
                ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
570

    
571
                //vi.setResizable(false);
572
                m_viewinfo.setTitle(PluginServices.getText(this,
573
                                "propiedades_marco_vista"));
574

    
575
                return m_viewinfo;
576
        }
577

    
578
        /**
579
         * @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
580
         */
581
        public boolean getIsAcepted() {
582
                return isAcepted;
583
        }
584

    
585
        /**
586
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#viewActivated()
587
         */
588
        public void viewActivated() {
589
        }
590

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