Statistics
| Revision:

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

History | View | Annotate | Download (12.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.geom.Rectangle2D;
59

    
60
import javax.swing.JList;
61
import javax.swing.JPanel;
62

    
63

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

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

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

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

    
123
        /**
124
         * This method initializes jContentPane
125
         *
126
         * @return javax.swing.JPanel
127
         */
128
        private javax.swing.JPanel getJContentPane() {
129
                if (jContentPane == null) {
130
                        jContentPane = new javax.swing.JPanel();
131
                        jContentPane.setLayout(null);
132
                        jContentPane.add(getLMarcoVista(), null);
133
                        jContentPane.add(getJScrollPane(), null);
134
                        jContentPane.add(getLVisualizacion(), null);
135
                        jContentPane.add(getCbVisualizacion(), null);
136
                        jContentPane.add(getLCalidad(), null);
137
                        jContentPane.add(getCbCalidad(), null);
138
                        jContentPane.add(getBAceptar(), null);
139
                        jContentPane.add(getBCancelar(), null);
140
                        jContentPane.add(getBFuente(), null);
141
                        jContentPane.setBounds(3, 1, 524, 188);
142
                        jContentPane.add(getPRotation(), null);
143
                        //jContentPane.add(lblNumColum, null);
144
                }
145

    
146
                return jContentPane;
147
        }
148

    
149
        /**
150
         * This method initializes lMarcoVista
151
         *
152
         * @return javax.swing.JLabel
153
         */
154
        private javax.swing.JLabel getLMarcoVista() {
155
                if (lMarcoVista == null) {
156
                        lMarcoVista = new javax.swing.JLabel();
157
                        lMarcoVista.setSize(156, 63);
158
                        lMarcoVista.setText(PluginServices.getText(this, "marco_vista"));
159
                        lMarcoVista.setLocation(5, 10);
160
                }
161

    
162
                return lMarcoVista;
163
        }
164

    
165
        /**
166
         * This method initializes jScrollPane
167
         *
168
         * @return javax.swing.JScrollPane
169
         */
170
        private javax.swing.JScrollPane getJScrollPane() {
171
                if (jScrollPane == null) {
172
                        jScrollPane = new javax.swing.JScrollPane();
173
                        jScrollPane.setViewportView(getLiVistas());
174
                        jScrollPane.setSize(217, 65);
175
                        jScrollPane.setPreferredSize(new java.awt.Dimension(70, 60));
176
                        jScrollPane.setLocation(167, 10);
177
                }
178

    
179
                return jScrollPane;
180
        }
181

    
182
        /**
183
         * This method initializes lVisualizacion
184
         *
185
         * @return javax.swing.JLabel
186
         */
187
        private javax.swing.JLabel getLVisualizacion() {
188
                if (lVisualizacion == null) {
189
                        lVisualizacion = new javax.swing.JLabel();
190
                        lVisualizacion.setSize(99, 16);
191
                        lVisualizacion.setText(PluginServices.getText(this, "visualizacion"));
192
                        lVisualizacion.setLocation(6, 83);
193
                }
194

    
195
                return lVisualizacion;
196
        }
197

    
198
        /**
199
         * This method initializes cbVisualizacion
200
         *
201
         * @return javax.swing.JComboBox
202
         */
203
        private javax.swing.JComboBox getCbVisualizacion() {
204
                if (cbVisualizacion == null) {
205
                        cbVisualizacion = new javax.swing.JComboBox();
206
                        cbVisualizacion.addItem(PluginServices.getText(this, "cuando_activo"));
207
                        cbVisualizacion.addItem(PluginServices.getText(this, "siempre"));
208
                        cbVisualizacion.setSelectedIndex(fframelegend.getViewing());
209
                        cbVisualizacion.setSize(179, 20);
210
                        cbVisualizacion.setPreferredSize(new java.awt.Dimension(200, 20));
211
                        cbVisualizacion.setLocation(111, 83);
212
                        cbVisualizacion.setEnabled(false);
213
                }
214

    
215
                return cbVisualizacion;
216
        }
217

    
218
        /**
219
         * This method initializes lCalidad
220
         *
221
         * @return javax.swing.JLabel
222
         */
223
        private javax.swing.JLabel getLCalidad() {
224
                if (lCalidad == null) {
225
                        lCalidad = new javax.swing.JLabel();
226
                        lCalidad.setSize(99, 16);
227
                        lCalidad.setText(PluginServices.getText(this, "calidad"));
228
                        lCalidad.setLocation(6, 103);
229
                }
230

    
231
                return lCalidad;
232
        }
233

    
234
        /**
235
         * This method initializes cbCalidad
236
         *
237
         * @return javax.swing.JComboBox
238
         */
239
        private javax.swing.JComboBox getCbCalidad() {
240
                if (cbCalidad == null) {
241
                        cbCalidad = new javax.swing.JComboBox();
242
                        cbCalidad.addItem(PluginServices.getText(this, "presentacion"));
243
                        cbCalidad.addItem(PluginServices.getText(this, "borrador"));
244
                        cbCalidad.setSelectedIndex(fframelegend.getQuality());
245
                        cbCalidad.setSize(179, 20);
246
                        cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20));
247
                        cbCalidad.setLocation(111, 103);
248
                }
249

    
250
                return cbCalidad;
251
        }
252

    
253
        /**
254
         * This method initializes bAceptar
255
         *
256
         * @return javax.swing.JButton
257
         */
258
        private javax.swing.JButton getBAceptar() {
259
                if (bAceptar == null) {
260
                        bAceptar = new javax.swing.JButton();
261
                        bAceptar.setSize(79, 26);
262
                        bAceptar.setText(PluginServices.getText(this, "Aceptar"));
263
                        bAceptar.setLocation(77, 145);
264
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
265
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
266
                                                for (int i = 0; i < m_layout.getFFrames().length;
267
                                                                i++) {
268
                                                        IFFrame f = (IFFrame) m_layout.getFFrame(i);
269

    
270
                                                        if (f instanceof FFrameView &&
271
                                                                        (fframeview != null)) {
272
                                                                //if (f.getName().compareTo(m_projectView.getName())==0){
273
                                                                //Esto cambia para que la escala se calcule en fframeview y no en fframescalebar.
274
                                                                ///        fframelegend.setFMap(((FFrameView)f).getFMap());
275
                                                                fframelegend.setName("Leyenda de " +
276
                                                                        ((FFrameView) f).toString());
277

    
278
                                                                ///fframescalebar.setScaleView(((FFrameView)f).getScale());
279
                                                                //}
280
                                                        }
281
                                                }
282

    
283
                                                /*if (m_projectView!=null){
284
                                                   fframelegend.setLayers(m_projectView.getMapContext().getLayers());
285
                                                   }
286
                                                 */
287
                                                fframelegend.setViewing(cbVisualizacion.getSelectedIndex());
288
                                                fframelegend.setQuality(cbCalidad.getSelectedIndex());
289
                                                fframelegend.setBoundBox(FLayoutUtilities.toSheetRect(
290
                                                                rect, m_layout.getAT()));
291
                                                fframelegend.setRotation(getPRotation().getRotation());
292
                                                PluginServices.getMDIManager().closeView(FFrameLegendDialog.this);
293
                                                m_layout.refresh();
294
                                                isAcepted = true;
295
                                        }
296
                                });
297
                }
298

    
299
                return bAceptar;
300
        }
301

    
302
        /**
303
         * This method initializes bCancelar
304
         *
305
         * @return javax.swing.JButton
306
         */
307
        private javax.swing.JButton getBCancelar() {
308
                if (bCancelar == null) {
309
                        bCancelar = new javax.swing.JButton();
310
                        bCancelar.setSize(85, 26);
311
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
312
                        bCancelar.setLocation(233, 145);
313
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
314
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
315
                                                PluginServices.getMDIManager().closeView(FFrameLegendDialog.this);
316
                                        }
317
                                });
318
                }
319

    
320
                return bCancelar;
321
        }
322

    
323
        /**
324
         * This method initializes liVistas
325
         *
326
         * @return javax.swing.JList
327
         */
328
        private javax.swing.JList getLiVistas() {
329
                if (liVistas == null) {
330
                        ListViewModel listmodel = new ListViewModel();
331

    
332
                        //listmodel.addViews();
333
                        listmodel.addViews(m_layout);
334

    
335
                        ///ArrayList list = listmodel.getViews();
336
                        liVistas = new javax.swing.JList();
337
                        liVistas.setModel(listmodel);
338

    
339
                        for (int i = 0; i < liVistas.getModel().getSize(); i++) {
340
                                if (fframelegend.getFFrameDependence() != null) {
341
                                        fframeview = (FFrameView) liVistas.getModel().getElementAt(i);
342

    
343
                                        if (fframeview == fframelegend.getFFrameDependence()) {
344
                                                liVistas.setSelectedIndex(i);
345
                                        }
346

    
347
                                        /*m_projectView=(ProjectView)liVistas.getModel().getElementAt(i);
348
                                           if (m_projectView.getMapContext()==fframelegend.getFMap()){
349
                                                   liVistas.setSelectedIndex(i);
350
                                           }
351
                                         */
352
                                }
353
                        }
354

    
355
                        liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
356
                                        private int selectIndex=-1;
357
                                        public void valueChanged(
358
                                                                javax.swing.event.ListSelectionEvent e) {
359
                                                        /*
360
                                                         * int selectInt=(int)e.getFirstIndex();
361
                                                         * m_projectView=(ProjectView)liVistas.getModel().getElementAt(selectInt);
362
                                                         */
363
                                                        int selectInt = (int) ((JList) e.getSource())
364
                                                                        .getSelectedIndex();
365
                                                        if (selectInt != selectIndex) {
366
                                                                selectIndex = selectInt;
367
                                                                if (selectIndex == -1)
368
                                                                        return;
369
                                                                fframeview = (FFrameView) liVistas.getModel()
370
                                                                                .getElementAt(selectInt);
371

    
372
                                                                for (int i = 0; i < m_layout.getFFrames().length; i++) {
373
                                                                        IFFrame f = (IFFrame) m_layout.getFFrame(i);
374

    
375
                                                                        if (f instanceof FFrameView) {
376
                                                                                if (((FFrameView) f).getView() == fframeview
377
                                                                                                .getView()) {
378
                                                                                        fframelegend
379
                                                                                                        .setFFrameDependence(fframeview);
380
                                                                                }
381
                                                                        }
382
                                                                }
383

    
384
                                                                // fframelegend.setFFrameView(fframeview);
385
                                                        }
386
                                                }
387
                                        });
388
                }
389

    
390
                return liVistas;
391
        }
392

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

    
401
                return m_viewinfo;
402
        }
403

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

    
411
        /**
412
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
413
         */
414
        public void viewActivated() {
415
        }
416

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

    
444
                return bFuente;
445
        }
446

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

    
460
}  //  @jve:decl-index=0:visual-constraint="10,10"