Statistics
| Revision:

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

History | View | Annotate | Download (13.8 KB)

1
/*
2
 * Created on 02-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.Dialogs.FontChooser;
51
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities;
52
import com.iver.cit.gvsig.gui.layout.Layout;
53
import com.iver.cit.gvsig.gui.layout.fframes.FFrameLegend;
54
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView;
55
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame;
56
import com.iver.cit.gvsig.gui.layout.fframes.ListViewModel;
57

    
58
import java.awt.event.KeyEvent;
59
import java.awt.geom.Rectangle2D;
60

    
61
import javax.swing.JList;
62
import javax.swing.JPanel;
63
import javax.swing.JLabel;
64
import javax.swing.JTextField;
65

    
66

    
67
/**
68
 * Dialogo para a?adir la leyenda de alguna vista al Layout.
69
 *
70
 * @author Vicente Caballero Navarro
71
 */
72
public class FFrameLegendDialog extends JPanel implements IFFrameDialog {
73
        private javax.swing.JPanel jContentPane = null;
74
        private javax.swing.JLabel lMarcoVista = null;
75
        private javax.swing.JScrollPane jScrollPane = null;
76
        private javax.swing.JLabel lVisualizacion = null;
77
        private javax.swing.JComboBox cbVisualizacion = null;
78
        private javax.swing.JLabel lCalidad = null;
79
        private javax.swing.JComboBox cbCalidad = null;
80
        private javax.swing.JButton bAceptar = null;
81
        private javax.swing.JButton bCancelar = null;
82
        private javax.swing.JList liVistas = null;
83
        private Rectangle2D rect = new Rectangle2D.Double();
84
        private Layout m_layout = null; //  @jve:visual-info  decl-index=0 visual-constraint="393,10"
85
        private FFrameLegend fframelegend = null; //new FFrameLegend();
86
        private boolean isAcepted = false;
87
        private javax.swing.JButton bFuente = null;
88
        private FFrameView fframeview = null;
89
        private JPRotation pRotation = null;
90
        private JLabel lblNumColum = null;
91
        private JTextField txtNumColum = null;
92
        private ColumPanel pNumColum = null;
93

    
94
        /**
95
         * This is the default constructor
96
         *
97
         * @param layout Referencia al Layout.
98
         * @param fframe Referencia al FFrameLegend.
99
         */
100
        public FFrameLegendDialog(Layout layout, FFrameLegend fframe) {
101
                super();
102
                m_layout = layout;
103
                fframelegend = fframe;
104
                initialize();
105
        }
106

    
107
        /**
108
         * Inserta el rect?ngulo que ocupar? el fframe de leyenda.
109
         *
110
         * @param r extent.
111
         */
112
        public void setRectangle(Rectangle2D r) {
113
                rect.setRect(r);
114
        }
115

    
116
        /**
117
         * This method initializes this
118
         */
119
        private void initialize() {
120
                this.setLayout(null);
121
                this.add(getJContentPane(), null);
122
                this.setSize(531, 292);
123
                getPRotation().setRotation(fframelegend.getRotation());
124
        }
125

    
126
        /**
127
         * This method initializes jContentPane
128
         *
129
         * @return javax.swing.JPanel
130
         */
131
        private javax.swing.JPanel getJContentPane() {
132
                if (jContentPane == null) {
133
                        lblNumColum = new JLabel();
134
                        lblNumColum.setBounds(new java.awt.Rectangle(14,135,133,25));
135
                        lblNumColum.setText("num_columnas");
136
                        jContentPane = new javax.swing.JPanel();
137
                        jContentPane.setLayout(null);
138
                        jContentPane.add(getLMarcoVista(), null);
139
                        jContentPane.add(getJScrollPane(), null);
140
                        jContentPane.add(getLVisualizacion(), null);
141
                        jContentPane.add(getCbVisualizacion(), null);
142
                        jContentPane.add(getLCalidad(), null);
143
                        jContentPane.add(getCbCalidad(), null);
144
                        jContentPane.add(getBAceptar(), null);
145
                        jContentPane.add(getBCancelar(), null);
146
                        jContentPane.add(getBFuente(), null);
147
                        jContentPane.setBounds(3, 1, 524, 289);
148
                        jContentPane.add(getPRotation(), null);
149
                        jContentPane.add(lblNumColum, null);
150
                        jContentPane.add(getTxtNumColum(), null);
151
                        jContentPane.add(getPNumColum(), null);
152
                }
153

    
154
                return jContentPane;
155
        }
156

    
157
        /**
158
         * This method initializes lMarcoVista
159
         *
160
         * @return javax.swing.JLabel
161
         */
162
        private javax.swing.JLabel getLMarcoVista() {
163
                if (lMarcoVista == null) {
164
                        lMarcoVista = new javax.swing.JLabel();
165
                        lMarcoVista.setSize(156, 63);
166
                        lMarcoVista.setText(PluginServices.getText(this, "marco_vista"));
167
                        lMarcoVista.setLocation(5, 10);
168
                }
169

    
170
                return lMarcoVista;
171
        }
172

    
173
        /**
174
         * This method initializes jScrollPane
175
         *
176
         * @return javax.swing.JScrollPane
177
         */
178
        private javax.swing.JScrollPane getJScrollPane() {
179
                if (jScrollPane == null) {
180
                        jScrollPane = new javax.swing.JScrollPane();
181
                        jScrollPane.setViewportView(getLiVistas());
182
                        jScrollPane.setSize(217, 65);
183
                        jScrollPane.setPreferredSize(new java.awt.Dimension(70, 60));
184
                        jScrollPane.setLocation(167, 10);
185
                }
186

    
187
                return jScrollPane;
188
        }
189

    
190
        /**
191
         * This method initializes lVisualizacion
192
         *
193
         * @return javax.swing.JLabel
194
         */
195
        private javax.swing.JLabel getLVisualizacion() {
196
                if (lVisualizacion == null) {
197
                        lVisualizacion = new javax.swing.JLabel();
198
                        lVisualizacion.setSize(99, 16);
199
                        lVisualizacion.setText(PluginServices.getText(this, "visualizacion"));
200
                        lVisualizacion.setLocation(6, 83);
201
                }
202

    
203
                return lVisualizacion;
204
        }
205

    
206
        /**
207
         * This method initializes cbVisualizacion
208
         *
209
         * @return javax.swing.JComboBox
210
         */
211
        private javax.swing.JComboBox getCbVisualizacion() {
212
                if (cbVisualizacion == null) {
213
                        cbVisualizacion = new javax.swing.JComboBox();
214
                        cbVisualizacion.addItem(PluginServices.getText(this, "cuando_activo"));
215
                        cbVisualizacion.addItem(PluginServices.getText(this, "siempre"));
216
                        cbVisualizacion.setSelectedIndex(fframelegend.getViewing());
217
                        cbVisualizacion.setSize(179, 20);
218
                        cbVisualizacion.setPreferredSize(new java.awt.Dimension(200, 20));
219
                        cbVisualizacion.setLocation(111, 83);
220
                        cbVisualizacion.setEnabled(false);
221
                }
222

    
223
                return cbVisualizacion;
224
        }
225

    
226
        /**
227
         * This method initializes lCalidad
228
         *
229
         * @return javax.swing.JLabel
230
         */
231
        private javax.swing.JLabel getLCalidad() {
232
                if (lCalidad == null) {
233
                        lCalidad = new javax.swing.JLabel();
234
                        lCalidad.setSize(99, 16);
235
                        lCalidad.setText(PluginServices.getText(this, "calidad"));
236
                        lCalidad.setLocation(6, 103);
237
                }
238

    
239
                return lCalidad;
240
        }
241

    
242
        /**
243
         * This method initializes cbCalidad
244
         *
245
         * @return javax.swing.JComboBox
246
         */
247
        private javax.swing.JComboBox getCbCalidad() {
248
                if (cbCalidad == null) {
249
                        cbCalidad = new javax.swing.JComboBox();
250
                        cbCalidad.addItem(PluginServices.getText(this, "presentacion"));
251
                        cbCalidad.addItem(PluginServices.getText(this, "borrador"));
252
                        cbCalidad.setSelectedIndex(fframelegend.getQuality());
253
                        cbCalidad.setSize(179, 20);
254
                        cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20));
255
                        cbCalidad.setLocation(111, 103);
256
                }
257

    
258
                return cbCalidad;
259
        }
260

    
261
        /**
262
         * This method initializes bAceptar
263
         *
264
         * @return javax.swing.JButton
265
         */
266
        private javax.swing.JButton getBAceptar() {
267
                if (bAceptar == null) {
268
                        bAceptar = new javax.swing.JButton();
269
                        bAceptar.setSize(79, 26);
270
                        bAceptar.setText(PluginServices.getText(this, "Aceptar"));
271
                        bAceptar.setLocation(77, 247);
272
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
273
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
274
                                                for (int i = 0; i < m_layout.getFFrames().length;
275
                                                                i++) {
276
                                                        IFFrame f = (IFFrame) m_layout.getFFrame(i);
277

    
278
                                                        if (f instanceof FFrameView &&
279
                                                                        (fframeview != null)) {
280
                                                                //if (f.getName().compareTo(m_projectView.getName())==0){
281
                                                                //Esto cambia para que la escala se calcule en fframeview y no en fframescalebar.
282
                                                                ///        fframelegend.setFMap(((FFrameView)f).getFMap());
283
                                                                fframelegend.setName("Leyenda de " +
284
                                                                        ((FFrameView) f).toString());
285

    
286
                                                                ///fframescalebar.setScaleView(((FFrameView)f).getScale());
287
                                                                //}
288
                                                        }
289
                                                }
290

    
291
                                                /*if (m_projectView!=null){
292
                                                   fframelegend.setLayers(m_projectView.getMapContext().getLayers());
293
                                                   }
294
                                                 */
295
                                                fframelegend.setViewing(cbVisualizacion.getSelectedIndex());
296
                                                fframelegend.setQuality(cbCalidad.getSelectedIndex());
297
                                                fframelegend.setBoundBox(FLayoutUtilities.toSheetRect(
298
                                                                rect, m_layout.getAT()));
299
                                                fframelegend.setRotation(getPRotation().getRotation());
300
                                                PluginServices.getMDIManager().closeView(FFrameLegendDialog.this);
301
                                                m_layout.refresh();
302
                                                isAcepted = true;
303
                                        }
304
                                });
305
                }
306

    
307
                return bAceptar;
308
        }
309

    
310
        /**
311
         * This method initializes bCancelar
312
         *
313
         * @return javax.swing.JButton
314
         */
315
        private javax.swing.JButton getBCancelar() {
316
                if (bCancelar == null) {
317
                        bCancelar = new javax.swing.JButton();
318
                        bCancelar.setSize(85, 26);
319
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
320
                        bCancelar.setLocation(233, 247);
321
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
322
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
323
                                                PluginServices.getMDIManager().closeView(FFrameLegendDialog.this);
324
                                        }
325
                                });
326
                }
327

    
328
                return bCancelar;
329
        }
330

    
331
        /**
332
         * This method initializes liVistas
333
         *
334
         * @return javax.swing.JList
335
         */
336
        private javax.swing.JList getLiVistas() {
337
                if (liVistas == null) {
338
                        ListViewModel listmodel = new ListViewModel();
339

    
340
                        //listmodel.addViews();        
341
                        listmodel.addViews(m_layout);
342

    
343
                        ///ArrayList list = listmodel.getViews();
344
                        liVistas = new javax.swing.JList();
345
                        liVistas.setModel(listmodel);
346

    
347
                        for (int i = 0; i < liVistas.getModel().getSize(); i++) {
348
                                if (fframelegend.getFFrameDependence() != null) {
349
                                        fframeview = (FFrameView) liVistas.getModel().getElementAt(i);
350

    
351
                                        if (fframeview == fframelegend.getFFrameDependence()) {
352
                                                liVistas.setSelectedIndex(i);
353
                                        }
354

    
355
                                        /*m_projectView=(ProjectView)liVistas.getModel().getElementAt(i);
356
                                           if (m_projectView.getMapContext()==fframelegend.getFMap()){
357
                                                   liVistas.setSelectedIndex(i);
358
                                           }
359
                                         */
360
                                }
361
                        }
362

    
363
                        liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
364
                                        private int selectIndex=-1;
365
                                        public void valueChanged(
366
                                                javax.swing.event.ListSelectionEvent e) {
367
                                                /*                        int selectInt=(int)e.getFirstIndex();
368
                                                   m_projectView=(ProjectView)liVistas.getModel().getElementAt(selectInt);
369
                                                 */
370
                                                int selectInt = (int) ((JList)e.getSource()).getSelectedIndex();
371
                                                if (selectInt!=selectIndex){
372
                                                        selectIndex=selectInt;
373
                                                fframeview = (FFrameView) liVistas.getModel()
374
                                                                                                                  .getElementAt(selectInt);
375

    
376
                                                for (int i = 0; i < m_layout.getFFrames().length;
377
                                                                i++) {
378
                                                        IFFrame f = (IFFrame) m_layout.getFFrame(i);
379

    
380
                                                        if (f instanceof FFrameView) {
381
                                                                if (((FFrameView) f).getView() == fframeview.getView()) {
382
                                                                        fframelegend.setFFrameDependence(fframeview);
383
                                                                }
384
                                                        }
385
                                                }
386

    
387
                                                //fframelegend.setFFrameView(fframeview);
388
                                        }
389
                                        }
390
                                });
391
                }
392

    
393
                return liVistas;
394
        }
395

    
396
        /* (non-Javadoc)
397
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
398
         */
399
        public ViewInfo getViewInfo() {
400
                ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
401
                m_viewinfo.setTitle(PluginServices.getText(this,
402
                                "propiedades_marco_leyenda"));
403

    
404
                return m_viewinfo;
405
        }
406

    
407
        /**
408
         * @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
409
         */
410
        public boolean getIsAcepted() {
411
                return isAcepted;
412
        }
413

    
414
        /**
415
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
416
         */
417
        public void viewActivated() {
418
        }
419

    
420
        /**
421
         * This method initializes bFuente
422
         *
423
         * @return javax.swing.JButton
424
         */
425
        private javax.swing.JButton getBFuente() {
426
                if (bFuente == null) {
427
                        bFuente = new javax.swing.JButton();
428
                        bFuente.setSize(90, 23);
429
                        bFuente.setText(PluginServices.getText(this, "fuente"));
430
                        bFuente.setLocation(297, 89);
431
                        bFuente.addActionListener(new java.awt.event.ActionListener() {
432
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
433
                                                if (fframelegend.getFont() != null) {
434
                                                        fframelegend.setFont(FontChooser.showDialog(
435
                                                                        PluginServices.getText(this,
436
                                                                                "seleccion_fuente"),
437
                                                                        fframelegend.getFont())); // fchoser=new FontChooser();        
438
                                                } else {
439
                                                        fframelegend.setFont(FontChooser.showDialog(
440
                                                                        PluginServices.getText(this,
441
                                                                                "seleccion_fuente"), getFont()));
442
                                                }
443
                                        }
444
                                });
445
                }
446

    
447
                return bFuente;
448
        }
449

    
450
        /**
451
         * This method initializes pRotation        
452
         *         
453
         * @return javax.swing.JPanel        
454
         */    
455
        private JPRotation getPRotation() {
456
                if (pRotation == null) {
457
                        pRotation = new JPRotation();
458
                        pRotation.setBounds(400, 19, 120, 120);
459
                }
460
                return pRotation;
461
        }
462

    
463
        /**
464
         * This method initializes txtNumColum        
465
         *         
466
         * @return javax.swing.JTextField        
467
         */
468
        private JTextField getTxtNumColum() {
469
                if (txtNumColum == null) {
470
                        txtNumColum = new JTextField();
471
                        txtNumColum.setBounds(new java.awt.Rectangle(162,135,36,23));
472
                        txtNumColum.addKeyListener(new java.awt.event.KeyAdapter() {
473
                                public void keyReleased(KeyEvent arg0) {
474
                                        getPNumColum().setNumColum(Integer.parseInt(getTxtNumColum().getText()));
475
                                }
476
                        });
477
                }
478
                return txtNumColum;
479
        }
480

    
481
        /**
482
         * This method initializes pNumColum        
483
         *         
484
         * @return javax.swing.JPanel        
485
         */
486
        private ColumPanel getPNumColum() {
487
                if (pNumColum == null) {
488
                        pNumColum = new ColumPanel();
489
                        
490
                }
491
                return pNumColum;
492
        }
493
}  //  @jve:decl-index=0:visual-constraint="10,10"