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 312 fernando
/*
2
 * Created on 02-jun-2004
3
 *
4
 */
5 1103 fjp
/* 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 312 fernando
package com.iver.cit.gvsig.gui.layout.fframes.dialogs;
46
47 596 fernando
import com.iver.andami.PluginServices;
48
import com.iver.andami.ui.mdiManager.ViewInfo;
49 1074 vcaballero
50 312 fernando
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 1074 vcaballero
import java.awt.geom.Rectangle2D;
59 3239 caballero
60
import javax.swing.JList;
61 1074 vcaballero
import javax.swing.JPanel;
62
63
64 312 fernando
/**
65
 * Dialogo para a?adir la leyenda de alguna vista al Layout.
66 1074 vcaballero
 *
67 312 fernando
 * @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 1074 vcaballero
        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 312 fernando
        private javax.swing.JButton bFuente = null;
85 1074 vcaballero
        private FFrameView fframeview = null;
86 2305 vcaballero
        private JPRotation pRotation = null;
87 5729 caballero
        //private JLabel lblNumColum = null;
88
        //private JTextField txtNumColum = null;
89
        //private ColumPanel pNumColum = null;
90 1074 vcaballero
91 312 fernando
        /**
92
         * This is the default constructor
93 1074 vcaballero
         *
94
         * @param layout Referencia al Layout.
95
         * @param fframe Referencia al FFrameLegend.
96 312 fernando
         */
97 1074 vcaballero
        public FFrameLegendDialog(Layout layout, FFrameLegend fframe) {
98 312 fernando
                super();
99 1074 vcaballero
                m_layout = layout;
100
                fframelegend = fframe;
101 312 fernando
                initialize();
102
        }
103 1074 vcaballero
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 312 fernando
                rect.setRect(r);
111 1074 vcaballero
        }
112
113 312 fernando
        /**
114
         * This method initializes this
115
         */
116
        private void initialize() {
117
                this.setLayout(null);
118
                this.add(getJContentPane(), null);
119 3715 caballero
                this.setSize(531, 190);
120 2305 vcaballero
                getPRotation().setRotation(fframelegend.getRotation());
121 312 fernando
        }
122 1074 vcaballero
123 312 fernando
        /**
124
         * This method initializes jContentPane
125 1074 vcaballero
         *
126 312 fernando
         * @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 3715 caballero
                        jContentPane.setBounds(3, 1, 524, 188);
142 2305 vcaballero
                        jContentPane.add(getPRotation(), null);
143 4257 caballero
                        //jContentPane.add(lblNumColum, null);
144 312 fernando
                }
145 1074 vcaballero
146 312 fernando
                return jContentPane;
147
        }
148 1074 vcaballero
149 312 fernando
        /**
150
         * This method initializes lMarcoVista
151 1074 vcaballero
         *
152 312 fernando
         * @return javax.swing.JLabel
153
         */
154
        private javax.swing.JLabel getLMarcoVista() {
155 1074 vcaballero
                if (lMarcoVista == null) {
156 312 fernando
                        lMarcoVista = new javax.swing.JLabel();
157
                        lMarcoVista.setSize(156, 63);
158 1074 vcaballero
                        lMarcoVista.setText(PluginServices.getText(this, "marco_vista"));
159 312 fernando
                        lMarcoVista.setLocation(5, 10);
160
                }
161 1074 vcaballero
162 312 fernando
                return lMarcoVista;
163
        }
164 1074 vcaballero
165 312 fernando
        /**
166
         * This method initializes jScrollPane
167 1074 vcaballero
         *
168 312 fernando
         * @return javax.swing.JScrollPane
169
         */
170
        private javax.swing.JScrollPane getJScrollPane() {
171 1074 vcaballero
                if (jScrollPane == null) {
172 312 fernando
                        jScrollPane = new javax.swing.JScrollPane();
173
                        jScrollPane.setViewportView(getLiVistas());
174
                        jScrollPane.setSize(217, 65);
175 1074 vcaballero
                        jScrollPane.setPreferredSize(new java.awt.Dimension(70, 60));
176 312 fernando
                        jScrollPane.setLocation(167, 10);
177
                }
178 1074 vcaballero
179 312 fernando
                return jScrollPane;
180
        }
181 1074 vcaballero
182 312 fernando
        /**
183
         * This method initializes lVisualizacion
184 1074 vcaballero
         *
185 312 fernando
         * @return javax.swing.JLabel
186
         */
187
        private javax.swing.JLabel getLVisualizacion() {
188 1074 vcaballero
                if (lVisualizacion == null) {
189 312 fernando
                        lVisualizacion = new javax.swing.JLabel();
190
                        lVisualizacion.setSize(99, 16);
191 1074 vcaballero
                        lVisualizacion.setText(PluginServices.getText(this, "visualizacion"));
192 312 fernando
                        lVisualizacion.setLocation(6, 83);
193
                }
194 1074 vcaballero
195 312 fernando
                return lVisualizacion;
196
        }
197 1074 vcaballero
198 312 fernando
        /**
199
         * This method initializes cbVisualizacion
200 1074 vcaballero
         *
201 312 fernando
         * @return javax.swing.JComboBox
202
         */
203
        private javax.swing.JComboBox getCbVisualizacion() {
204 1074 vcaballero
                if (cbVisualizacion == null) {
205 312 fernando
                        cbVisualizacion = new javax.swing.JComboBox();
206 1074 vcaballero
                        cbVisualizacion.addItem(PluginServices.getText(this, "cuando_activo"));
207
                        cbVisualizacion.addItem(PluginServices.getText(this, "siempre"));
208 312 fernando
                        cbVisualizacion.setSelectedIndex(fframelegend.getViewing());
209
                        cbVisualizacion.setSize(179, 20);
210 1074 vcaballero
                        cbVisualizacion.setPreferredSize(new java.awt.Dimension(200, 20));
211 312 fernando
                        cbVisualizacion.setLocation(111, 83);
212
                        cbVisualizacion.setEnabled(false);
213
                }
214 1074 vcaballero
215 312 fernando
                return cbVisualizacion;
216
        }
217 1074 vcaballero
218 312 fernando
        /**
219
         * This method initializes lCalidad
220 1074 vcaballero
         *
221 312 fernando
         * @return javax.swing.JLabel
222
         */
223
        private javax.swing.JLabel getLCalidad() {
224 1074 vcaballero
                if (lCalidad == null) {
225 312 fernando
                        lCalidad = new javax.swing.JLabel();
226
                        lCalidad.setSize(99, 16);
227 1074 vcaballero
                        lCalidad.setText(PluginServices.getText(this, "calidad"));
228 312 fernando
                        lCalidad.setLocation(6, 103);
229
                }
230 1074 vcaballero
231 312 fernando
                return lCalidad;
232
        }
233 1074 vcaballero
234 312 fernando
        /**
235
         * This method initializes cbCalidad
236 1074 vcaballero
         *
237 312 fernando
         * @return javax.swing.JComboBox
238
         */
239
        private javax.swing.JComboBox getCbCalidad() {
240 1074 vcaballero
                if (cbCalidad == null) {
241 312 fernando
                        cbCalidad = new javax.swing.JComboBox();
242 1074 vcaballero
                        cbCalidad.addItem(PluginServices.getText(this, "presentacion"));
243
                        cbCalidad.addItem(PluginServices.getText(this, "borrador"));
244 312 fernando
                        cbCalidad.setSelectedIndex(fframelegend.getQuality());
245
                        cbCalidad.setSize(179, 20);
246 1074 vcaballero
                        cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20));
247 312 fernando
                        cbCalidad.setLocation(111, 103);
248
                }
249 1074 vcaballero
250 312 fernando
                return cbCalidad;
251
        }
252 1074 vcaballero
253 312 fernando
        /**
254
         * This method initializes bAceptar
255 1074 vcaballero
         *
256 312 fernando
         * @return javax.swing.JButton
257
         */
258
        private javax.swing.JButton getBAceptar() {
259 1074 vcaballero
                if (bAceptar == null) {
260 312 fernando
                        bAceptar = new javax.swing.JButton();
261
                        bAceptar.setSize(79, 26);
262 1074 vcaballero
                        bAceptar.setText(PluginServices.getText(this, "Aceptar"));
263 3715 caballero
                        bAceptar.setLocation(77, 145);
264 1074 vcaballero
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
265
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
266 3553 caballero
                                                for (int i = 0; i < m_layout.getFFrames().length;
267 1074 vcaballero
                                                                i++) {
268 3553 caballero
                                                        IFFrame f = (IFFrame) m_layout.getFFrame(i);
269 1074 vcaballero
270
                                                        if (f instanceof FFrameView &&
271
                                                                        (fframeview != null)) {
272
                                                                //if (f.getName().compareTo(m_projectView.getName())==0){
273 312 fernando
                                                                //Esto cambia para que la escala se calcule en fframeview y no en fframescalebar.
274 1074 vcaballero
                                                                ///        fframelegend.setFMap(((FFrameView)f).getFMap());
275
                                                                fframelegend.setName("Leyenda de " +
276
                                                                        ((FFrameView) f).toString());
277
278 312 fernando
                                                                ///fframescalebar.setScaleView(((FFrameView)f).getScale());
279 1074 vcaballero
                                                                //}
280
                                                        }
281 312 fernando
                                                }
282 1074 vcaballero
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 2305 vcaballero
                                                fframelegend.setRotation(getPRotation().getRotation());
292 1074 vcaballero
                                                PluginServices.getMDIManager().closeView(FFrameLegendDialog.this);
293
                                                m_layout.refresh();
294
                                                isAcepted = true;
295 312 fernando
                                        }
296 1074 vcaballero
                                });
297 312 fernando
                }
298 1074 vcaballero
299 312 fernando
                return bAceptar;
300
        }
301 1074 vcaballero
302 312 fernando
        /**
303
         * This method initializes bCancelar
304 1074 vcaballero
         *
305 312 fernando
         * @return javax.swing.JButton
306
         */
307
        private javax.swing.JButton getBCancelar() {
308 1074 vcaballero
                if (bCancelar == null) {
309 312 fernando
                        bCancelar = new javax.swing.JButton();
310
                        bCancelar.setSize(85, 26);
311 1074 vcaballero
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
312 3715 caballero
                        bCancelar.setLocation(233, 145);
313 1074 vcaballero
                        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 312 fernando
                }
319 1074 vcaballero
320 312 fernando
                return bCancelar;
321
        }
322 1074 vcaballero
323 312 fernando
        /**
324
         * This method initializes liVistas
325 1074 vcaballero
         *
326 312 fernando
         * @return javax.swing.JList
327
         */
328
        private javax.swing.JList getLiVistas() {
329 1074 vcaballero
                if (liVistas == null) {
330
                        ListViewModel listmodel = new ListViewModel();
331
332 3715 caballero
                        //listmodel.addViews();
333 2915 caballero
                        listmodel.addViews(m_layout);
334 1074 vcaballero
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 3114 caballero
                                if (fframelegend.getFFrameDependence() != null) {
341 1074 vcaballero
                                        fframeview = (FFrameView) liVistas.getModel().getElementAt(i);
342
343 3114 caballero
                                        if (fframeview == fframelegend.getFFrameDependence()) {
344 1074 vcaballero
                                                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 3239 caballero
                                        private int selectIndex=-1;
357 1074 vcaballero
                                        public void valueChanged(
358 4778 caballero
                                                                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 1074 vcaballero
372 4778 caballero
                                                                for (int i = 0; i < m_layout.getFFrames().length; i++) {
373
                                                                        IFFrame f = (IFFrame) m_layout.getFFrame(i);
374 1074 vcaballero
375 4778 caballero
                                                                        if (f instanceof FFrameView) {
376
                                                                                if (((FFrameView) f).getView() == fframeview
377
                                                                                                .getView()) {
378
                                                                                        fframelegend
379
                                                                                                        .setFFrameDependence(fframeview);
380
                                                                                }
381
                                                                        }
382 1074 vcaballero
                                                                }
383 4778 caballero
384
                                                                // fframelegend.setFFrameView(fframeview);
385 312 fernando
                                                        }
386
                                                }
387 4778 caballero
                                        });
388 312 fernando
                }
389 1074 vcaballero
390 312 fernando
                return liVistas;
391
        }
392 1074 vcaballero
393 312 fernando
        /* (non-Javadoc)
394
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
395
         */
396
        public ViewInfo getViewInfo() {
397 1074 vcaballero
                ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
398
                m_viewinfo.setTitle(PluginServices.getText(this,
399
                                "propiedades_marco_leyenda"));
400
401 312 fernando
                return m_viewinfo;
402 1074 vcaballero
        }
403
404 312 fernando
        /**
405
         * @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
406
         */
407
        public boolean getIsAcepted() {
408
                return isAcepted;
409
        }
410 1074 vcaballero
411 312 fernando
        /**
412
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
413
         */
414
        public void viewActivated() {
415
        }
416 1074 vcaballero
417 312 fernando
        /**
418
         * This method initializes bFuente
419 1074 vcaballero
         *
420 312 fernando
         * @return javax.swing.JButton
421
         */
422
        private javax.swing.JButton getBFuente() {
423 1074 vcaballero
                if (bFuente == null) {
424 312 fernando
                        bFuente = new javax.swing.JButton();
425
                        bFuente.setSize(90, 23);
426 1074 vcaballero
                        bFuente.setText(PluginServices.getText(this, "fuente"));
427 312 fernando
                        bFuente.setLocation(297, 89);
428 1074 vcaballero
                        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 3715 caballero
                                                                        fframelegend.getFont())); // fchoser=new FontChooser();
435 1074 vcaballero
                                                } else {
436
                                                        fframelegend.setFont(FontChooser.showDialog(
437
                                                                        PluginServices.getText(this,
438
                                                                                "seleccion_fuente"), getFont()));
439
                                                }
440 312 fernando
                                        }
441 1074 vcaballero
                                });
442 312 fernando
                }
443 1074 vcaballero
444 312 fernando
                return bFuente;
445
        }
446 2305 vcaballero
447
        /**
448 3715 caballero
         * This method initializes pRotation
449
         *
450
         * @return javax.swing.JPanel
451
         */
452 2305 vcaballero
        private JPRotation getPRotation() {
453
                if (pRotation == null) {
454
                        pRotation = new JPRotation();
455
                        pRotation.setBounds(400, 19, 120, 120);
456
                }
457
                return pRotation;
458
        }
459 3553 caballero
460 3715 caballero
}  //  @jve:decl-index=0:visual-constraint="10,10"