Statistics
| Revision:

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

History | View | Annotate | Download (31.7 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.AddLayer;
51
import com.iver.cit.gvsig.gui.Dialogs.FontChooser;
52
import com.iver.cit.gvsig.gui.layout.Attributes;
53
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities;
54
import com.iver.cit.gvsig.gui.layout.Layout;
55
import com.iver.cit.gvsig.gui.layout.fframes.FFrameScaleBar;
56
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView;
57
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame;
58
import com.iver.cit.gvsig.gui.layout.fframes.ListViewModel;
59

    
60
import java.awt.Color;
61
import java.awt.Component;
62
import java.awt.Dimension;
63
import java.awt.event.KeyEvent;
64
import java.awt.geom.Rectangle2D;
65

    
66
import javax.swing.ImageIcon;
67
import javax.swing.JButton;
68
import javax.swing.JCheckBox;
69
import javax.swing.JColorChooser;
70
import javax.swing.JDialog;
71
import javax.swing.JFrame;
72
import javax.swing.JLabel;
73
import javax.swing.JList;
74
import javax.swing.JPanel;
75
import javax.swing.JTextField;
76
import javax.swing.ListCellRenderer;
77

    
78

    
79
/**
80
 * Dialogo para a?adir una barra de escala al Layout.
81
 *
82
 * @author Vicente Caballero Navarro
83
 */
84
public class FFrameScaleBarDialog extends JPanel implements IFFrameDialog {
85
        private static final ImageIcon inumero = new ImageIcon(AddLayer.class.getClassLoader()
86
                                                                                                                                          .getResource("images/numero.png"));
87
        private static final ImageIcon ibarra1 = new ImageIcon(AddLayer.class.getClassLoader()
88
                                                                                                                                          .getResource("images/barra1.png"));
89
        private static final ImageIcon ibarra2 = new ImageIcon(AddLayer.class.getClassLoader()
90
                                                                                                                                          .getResource("images/barra2.png"));
91
        private static final ImageIcon ibarra3 = new ImageIcon(AddLayer.class.getClassLoader()
92
                                                                                                                                          .getResource("images/barra3.png"));
93
        private javax.swing.JPanel jContentPane = null;
94
        private javax.swing.JScrollPane jScrollPane = null;
95
        private javax.swing.JList liVistas = null;
96
        private javax.swing.JCheckBox chbMantenerIntervalo = null;
97
        private javax.swing.JComboBox cbEscala = null;
98
        private javax.swing.JComboBox cbUnidades = null;
99
        private javax.swing.JLabel lIntervalo = null;
100
        private javax.swing.JTextField tIntervalo = null;
101
        private javax.swing.JLabel lNumIntervalos = null;
102
        private javax.swing.JTextField tNumIntervalos = null;
103
        private javax.swing.JLabel lDivIzquierda = null;
104
        private javax.swing.JTextField tDivIzquierda = null;
105
        private javax.swing.JButton bAceptar = null;
106
        private javax.swing.JButton bCancelar = null;
107

    
108
        //private ProjectView m_projectView=null;
109
        private FFrameView fframeview = null;
110
        private Rectangle2D rect = new Rectangle2D.Double();
111
        private Layout m_layout = null;
112
        private FFrameScaleBar fframescalebar = null; //new FFrameScaleBar();
113
        private boolean isAcepted = false;
114
        private ImageIcon[] images = new ImageIcon[4];
115
        private javax.swing.JButton bFuente = null;
116
        private JPanel pMarcoVista = null;
117
        private JPanel pDescripcion = null;
118
        private JTextField tfDescripcion = null;
119
        private JPanel pUnidades = null;
120
        private JCheckBox chbSobreDescripcion = null;
121
        private JCheckBox chbMostrarUnidades = null;
122
        private JCheckBox chbSobreUnidades = null;
123
        private JPanel pEtiquetas = null;
124
        private JCheckBox chbEtiquetas = null;
125
        private JPanel pBarra = null;
126
        private JPanel jPanel5 = null;
127
        private JPanel jPanel6 = null;
128
        private JPanel jPanel7 = null;
129
        private JButton bUnidadesColor = null;
130
        private JButton bBarraColor = null;
131
        private Color barcolor = null;
132
        private Color textcolor = null;
133

    
134
        //private JPanel jPanel = null;
135
        //private JPanel jPanel1 = null;
136
        private JPanel jPanel2 = null;
137
        private JCheckBox jCheckBox = null;
138
        private JPRotation pRotation = null;
139
        private JLabel lblBarColor = null;
140
        private JLabel lblLabelColor = null;
141
        private JTextField txtNumDec = null;
142
        private JLabel lblNumDec = null;
143

    
144
        /**
145
         * This is the default constructor
146
         *
147
         * @param layout DOCUMENT ME!
148
         * @param fframe DOCUMENT ME!
149
         */
150
        public FFrameScaleBarDialog(Layout layout, FFrameScaleBar fframe) {
151
                super();
152
                fframescalebar = fframe;
153
                barcolor = fframescalebar.getBarColor();
154
                textcolor = fframescalebar.getTextColor();
155

    
156
                if (fframescalebar.getFFrameDependence() != null && fframescalebar.getDescripcion().equals("")) {
157
                        getTfDescripcion().setText("escala 1:" +
158
                                String.valueOf(((FFrameView)fframescalebar.getFFrameDependence()).getScale()));
159
                }
160

    
161
                m_layout = layout;
162
                initialize();
163
        }
164

    
165
        /**
166
         * DOCUMENT ME!
167
         *
168
         * @param r DOCUMENT ME!
169
         */
170
        public void setRectangle(Rectangle2D r) {
171
                rect.setRect(r);
172
        }
173

    
174
        /**
175
         * This method initializes this
176
         */
177
        private void initialize() {
178
                this.setLayout(null);
179
                this.add(getJContentPane(), null);
180
                this.setSize(621, 400);
181

    
182
                if (fframescalebar.getStyle() == 0) {
183
                        getChbMantenerIntervalo().setEnabled(false);
184

    
185
                        ///getLUnidades().setEnabled(false);
186
                        getCbUnidades().setEnabled(false);
187
                        getChbEtiquetas().setEnabled(false);
188
                        getBBarraColor().setEnabled(false);
189
                        getChbMostrarUnidades().setEnabled(false);
190
                        getChbSobreUnidades().setEnabled(false);
191
                        getLIntervalo().setEnabled(false);
192
                        getTIntervalo().setEnabled(false);
193
                        getLNumIntervalos().setEnabled(false);
194
                        getTNumIntervalos().setEnabled(false);
195
                        getLDivIzquierda().setEnabled(false);
196
                        getTDivIzquierda().setEnabled(false);
197
                }
198
                getPRotation().setRotation(fframescalebar.getRotation());
199
        }
200

    
201
        /**
202
         * This method initializes jContentPane
203
         *
204
         * @return javax.swing.JPanel
205
         */
206
        private javax.swing.JPanel getJContentPane() {
207
                if (jContentPane == null) {
208
                        jContentPane = new javax.swing.JPanel();
209
                        jContentPane.setLayout(null);
210
                        jContentPane.add(getBAceptar(), null);
211
                        jContentPane.add(getBCancelar(), null);
212
                        jContentPane.add(getPRotation(), null);
213
                        jContentPane.setSize(617, 386);
214
                        jContentPane.setPreferredSize(new java.awt.Dimension(50, 50));
215
                        jContentPane.setLocation(0, 6);
216
                        jContentPane.add(getPMarcoVista(), null);
217
                        jContentPane.add(getPDescripcion(), null);
218
                        jContentPane.add(getPUnidades(), null);
219
                        jContentPane.add(getPBarra(), null);
220
                        jContentPane.add(getPEtiquetas(), null);
221
                }
222

    
223
                return jContentPane;
224
        }
225

    
226
        /**
227
         * This method initializes jScrollPane
228
         *
229
         * @return javax.swing.JScrollPane
230
         */
231
        private javax.swing.JScrollPane getJScrollPane() {
232
                if (jScrollPane == null) {
233
                        jScrollPane = new javax.swing.JScrollPane();
234
                        jScrollPane.setPreferredSize(new java.awt.Dimension(220, 50));
235
                        jScrollPane.setViewportView(getLiVistas());
236
                }
237

    
238
                return jScrollPane;
239
        }
240

    
241
        /**
242
         * This method initializes liVistas
243
         *
244
         * @return javax.swing.JList
245
         */
246
        private javax.swing.JList getLiVistas() {
247
                if (liVistas == null) {
248
                        ListViewModel listmodel = new ListViewModel();
249
                        listmodel.addViews(m_layout);
250

    
251
                        ///ArrayList list = listmodel.getViews();
252

    
253
                        liVistas = new javax.swing.JList();
254

    
255
                        liVistas.setModel(listmodel);
256

    
257
                        for (int i = 0; i < liVistas.getModel().getSize(); i++) {
258
                                if (fframescalebar.getFFrameDependence() != null) {
259
                                        fframeview = (FFrameView) liVistas.getModel().getElementAt(i);
260

    
261
                                        if (fframeview == fframescalebar.getFFrameDependence()) {
262
                                                liVistas.setSelectedIndex(i);
263
                                        }
264
                                }
265
                        }
266

    
267
                        liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
268
                                        private int selectIndex=-1;
269
                                        public void valueChanged(
270
                                                javax.swing.event.ListSelectionEvent e) {
271
                                                int selectInt = (int) ((JList)e.getSource()).getSelectedIndex();
272
                                                if (selectInt!=selectIndex){
273
                                                        selectIndex=selectInt;
274
                                                fframeview = (FFrameView) liVistas.getModel()
275
                                                                                                                  .getElementAt(selectInt);
276

    
277
                                                for (int i = 0; i < m_layout.getFFrames().size();
278
                                                                i++) {
279
                                                        IFFrame f = (IFFrame) m_layout.getFFrames().get(i);
280

    
281
                                                        if (f instanceof FFrameView) {
282
                                                                if (((FFrameView) f).getView() == fframeview.getView()) {
283
                                                                        fframescalebar.setFFrameDependence(fframeview);
284
                                                                }
285
                                                        }
286
                                                }
287

    
288
                                                getTNumIntervalos().setText(String.valueOf(
289
                                                                fframescalebar.getNumInterval()));
290
                                                getTDivIzquierda().setText(String.valueOf(
291
                                                                fframescalebar.getNumLeft()));
292
                                                getTIntervalo().setText(fframescalebar.obtainInterval());
293
                                                getTfDescripcion().setText(fframescalebar.getDescripcion());
294
                                        }
295
                                        }
296
                                });
297
                }
298

    
299
                return liVistas;
300
        }
301

    
302
        /**
303
         * This method initializes chbMantenerIntervalo
304
         *
305
         * @return javax.swing.JCheckBox
306
         */
307
        private javax.swing.JCheckBox getChbMantenerIntervalo() {
308
                if (chbMantenerIntervalo == null) {
309
                        chbMantenerIntervalo = new javax.swing.JCheckBox();
310
                        chbMantenerIntervalo.setSelected(fframescalebar.isbIntervalSet());
311
                        chbMantenerIntervalo.setText(PluginServices.getText(this,
312
                                        "mantener_intervalo"));
313
                        chbMantenerIntervalo.setPreferredSize(new java.awt.Dimension(200, 20));
314
                        chbMantenerIntervalo.addActionListener(new java.awt.event.ActionListener() {
315
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
316
                                                fframescalebar.setIntervalSet(getChbMantenerIntervalo()
317
                                                                                                                  .isSelected());
318
                                        }
319
                                });
320
                }
321

    
322
                return chbMantenerIntervalo;
323
        }
324

    
325
        /**
326
         * This method initializes cbEscala
327
         *
328
         * @return javax.swing.JComboBox
329
         */
330
        private javax.swing.JComboBox getCbEscala() {
331
                if (cbEscala == null) {
332
                        //String[] s={"n?merico","barra1","barra2","barra3","barra4"};
333
                        cbEscala = new javax.swing.JComboBox();
334
                        images[0] = inumero;
335
                        images[1] = ibarra1;
336
                        images[2] = ibarra2;
337
                        images[3] = ibarra3;
338

    
339
                        /*  Image img=img = new BufferedImage(100, 25,
340
                           BufferedImage.TYPE_INT_ARGB);
341
                           img.getGraphics().drawImage(images[3].getImage(),0,0,null);
342
                           img.getGraphics().setXORMode(Color.yellow);
343
                            images[3]=new ImageIcon(img);
344
                         */
345
                        ComboBoxRenderer renderer = new ComboBoxRenderer();
346
                        renderer.setPreferredSize(new Dimension(100, 25));
347
                        cbEscala.setRenderer(renderer);
348
                        cbEscala.setMaximumRowCount(4);
349

    
350
                        cbEscala.addItem("0");
351
                        cbEscala.addItem("1");
352
                        cbEscala.addItem("2");
353
                        cbEscala.addItem("3");
354
                        cbEscala.setSelectedIndex(fframescalebar.getStyle());
355
                        cbEscala.setPreferredSize(new java.awt.Dimension(200, 20));
356
                        cbEscala.addActionListener(new java.awt.event.ActionListener() {
357
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
358
                                                fframescalebar.setStyle(getCbEscala().getSelectedIndex());
359

    
360
                                                if (cbEscala.getSelectedIndex() == 0) {
361
                                                        getChbMantenerIntervalo().setEnabled(false);
362
                                                        getChbMostrarUnidades().setEnabled(false);
363
                                                        getChbSobreUnidades().setEnabled(false);
364
                                                        getCbUnidades().setEnabled(false);
365
                                                        getChbEtiquetas().setEnabled(false);
366
                                                        getBBarraColor().setEnabled(false);
367
                                                        getLIntervalo().setEnabled(false);
368
                                                        getTIntervalo().setEnabled(false);
369
                                                        getLNumIntervalos().setEnabled(false);
370
                                                        getTNumIntervalos().setEnabled(false);
371
                                                        getLDivIzquierda().setEnabled(false);
372
                                                        getTDivIzquierda().setEnabled(false);
373
                                                } else {
374
                                                        getChbMantenerIntervalo().setEnabled(true);
375
                                                        getChbMostrarUnidades().setEnabled(true);
376
                                                        getChbSobreUnidades().setEnabled(true);
377
                                                        getCbUnidades().setEnabled(true);
378
                                                        getChbEtiquetas().setEnabled(true);
379
                                                        getBBarraColor().setEnabled(true);
380
                                                        getLIntervalo().setEnabled(true);
381
                                                        getTIntervalo().setEnabled(true);
382
                                                        getLNumIntervalos().setEnabled(true);
383
                                                        getTNumIntervalos().setEnabled(true);
384
                                                        getLDivIzquierda().setEnabled(true);
385
                                                        getTDivIzquierda().setEnabled(true);
386
                                                }
387
                                        }
388
                                });
389
                }
390

    
391
                return cbEscala;
392
        }
393

    
394
        /**
395
         * This method initializes cbUnidades
396
         *
397
         * @return javax.swing.JComboBox
398
         */
399
        private javax.swing.JComboBox getCbUnidades() {
400
                if (cbUnidades == null) {
401
                        //String[] s={"Kil?metros","metros","cent?metros","mil?metros","millas","yardas","pies","pulgadas"};
402
                        cbUnidades = new javax.swing.JComboBox(Attributes.NAMES);
403
                        cbUnidades.setSelectedIndex(fframescalebar.getUnits());
404
                        cbUnidades.setPreferredSize(new java.awt.Dimension(150, 20));
405
                        cbUnidades.addActionListener(new java.awt.event.ActionListener() {
406
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
407
                                                fframescalebar.setUnits(getCbUnidades()
408
                                                                                                        .getSelectedIndex());
409
                                                getTIntervalo().setText(fframescalebar.obtainInterval());
410
                                        }
411
                                });
412
                }
413

    
414
                return cbUnidades;
415
        }
416

    
417
        /**
418
         * This method initializes lIntervalo
419
         *
420
         * @return javax.swing.JLabel
421
         */
422
        private javax.swing.JLabel getLIntervalo() {
423
                if (lIntervalo == null) {
424
                        lIntervalo = new javax.swing.JLabel();
425
                        lIntervalo.setText(PluginServices.getText(this, "Intervalo"));
426
                        lIntervalo.setPreferredSize(new java.awt.Dimension(90, 20));
427
                }
428

    
429
                return lIntervalo;
430
        }
431

    
432
        /**
433
         * This method initializes tIntervalo
434
         *
435
         * @return javax.swing.JTextField
436
         */
437
        private javax.swing.JTextField getTIntervalo() {
438
                if (tIntervalo == null) {
439
                        tIntervalo = new javax.swing.JTextField();
440
                        tIntervalo.setPreferredSize(new java.awt.Dimension(90, 20));
441
                        tIntervalo.setText(fframescalebar.getInterval());
442
                        tIntervalo.addKeyListener(new java.awt.event.KeyAdapter() {
443
                                        public void keyReleased(java.awt.event.KeyEvent e) {
444
                                                if (!tIntervalo.getText().toString().equals("")) {
445
                                                        fframescalebar.setInterval(Double.parseDouble(
446
                                                                        tIntervalo.getText().toString()));
447
                                                        getTNumIntervalos().setText(String.valueOf(
448
                                                                        fframescalebar.getNumInterval()));
449
                                                }
450
                                        }
451
                                });
452
                }
453

    
454
                return tIntervalo;
455
        }
456

    
457
        /**
458
         * This method initializes lNumIntervalos
459
         *
460
         * @return javax.swing.JLabel
461
         */
462
        private javax.swing.JLabel getLNumIntervalos() {
463
                if (lNumIntervalos == null) {
464
                        lNumIntervalos = new javax.swing.JLabel();
465
                        lNumIntervalos.setText(PluginServices.getText(this, "N?m_intervalos"));
466
                        lNumIntervalos.setPreferredSize(new java.awt.Dimension(90, 20));
467
                }
468

    
469
                return lNumIntervalos;
470
        }
471

    
472
        /**
473
         * This method initializes tNumIntervalos
474
         *
475
         * @return javax.swing.JTextField
476
         */
477
        private javax.swing.JTextField getTNumIntervalos() {
478
                if (tNumIntervalos == null) {
479
                        tNumIntervalos = new javax.swing.JTextField();
480
                        tNumIntervalos.setPreferredSize(new java.awt.Dimension(90, 20));
481
                        tNumIntervalos.setText(Integer.toString(
482
                                        fframescalebar.getNumInterval()));
483
                        tNumIntervalos.addKeyListener(new java.awt.event.KeyAdapter() {
484
                                        public void keyReleased(java.awt.event.KeyEvent e) {
485
                                                if (!tNumIntervalos.getText().toString().equals("")) {
486
                                                        fframescalebar.setNumInterval(Integer.parseInt(
487
                                                                        tNumIntervalos.getText().toString()));
488
                                                        getTIntervalo().setText(fframescalebar.obtainInterval());
489
                                                }
490
                                        }
491
                                });
492
                }
493

    
494
                return tNumIntervalos;
495
        }
496

    
497
        /**
498
         * This method initializes lDivIzquierda
499
         *
500
         * @return javax.swing.JLabel
501
         */
502
        private javax.swing.JLabel getLDivIzquierda() {
503
                if (lDivIzquierda == null) {
504
                        lDivIzquierda = new javax.swing.JLabel();
505
                        lDivIzquierda.setText(PluginServices.getText(this,
506
                                        "divisiones_izquierda"));
507
                        lDivIzquierda.setPreferredSize(new java.awt.Dimension(90, 20));
508
                }
509

    
510
                return lDivIzquierda;
511
        }
512

    
513
        /**
514
         * This method initializes tDivIzquierda
515
         *
516
         * @return javax.swing.JTextField
517
         */
518
        private javax.swing.JTextField getTDivIzquierda() {
519
                if (tDivIzquierda == null) {
520
                        tDivIzquierda = new javax.swing.JTextField();
521
                        tDivIzquierda.setPreferredSize(new java.awt.Dimension(90, 20));
522
                        tDivIzquierda.setText(Integer.toString(fframescalebar.getNumLeft()));
523
                        tDivIzquierda.addKeyListener(new java.awt.event.KeyAdapter() {
524
                                        public void keyReleased(java.awt.event.KeyEvent e) {
525
                                                if (tDivIzquierda.getText().toString().equals("")) {
526
                                                        tDivIzquierda.setText("0");
527
                                                } else {
528
                                                        fframescalebar.setNumLeft(Integer.parseInt(
529
                                                                        tDivIzquierda.getText()));
530
                                                }
531
                                        }
532
                                });
533
                }
534

    
535
                return tDivIzquierda;
536
        }
537

    
538
        /**
539
         * This method initializes bAceptar
540
         *
541
         * @return javax.swing.JButton
542
         */
543
        private javax.swing.JButton getBAceptar() {
544
                if (bAceptar == null) {
545
                        bAceptar = new javax.swing.JButton();
546
                        bAceptar.setSize(85, 26);
547
                        bAceptar.setText(PluginServices.getText(this, "Aceptar"));
548
                        bAceptar.setLocation(106, 347);
549
                        bAceptar.setPreferredSize(new java.awt.Dimension(79, 23));
550
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
551
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
552
                                                fframescalebar.setUnits(getCbUnidades()
553
                                                                                                        .getSelectedIndex());
554
                                                fframescalebar.setBoundBox(FLayoutUtilities.toSheetRect(
555
                                                                rect, m_layout.getAT()));
556

    
557
                                                fframescalebar.setBarColor(barcolor);
558
                                                fframescalebar.setTextColor(textcolor);
559
                                                fframescalebar.setShowNameUnits(getChbMostrarUnidades()
560
                                                                                                                        .isSelected());
561
                                                fframescalebar.setShowDescription(getJCheckBox()
562
                                                                                                                          .isSelected());
563
                                                fframescalebar.setAboveDescription(getChbSobreDescripcion()
564
                                                                                                                           .isSelected());
565
                                                fframescalebar.setAboveIntervals(getChbEtiquetas()
566
                                                                                                                         .isSelected());
567
                                                fframescalebar.setAboveName(getChbSobreUnidades()
568
                                                                                                                .isSelected());
569
                                                fframescalebar.setDescripcion(getTfDescripcion()
570
                                                                                                                  .getText());
571
                                                fframescalebar.setRotation(getPRotation().getRotation());
572
                                                fframescalebar.setNumDec(Integer.parseInt(getNumDec().getText()));
573
                                                PluginServices.getMDIManager().closeView(FFrameScaleBarDialog.this);
574
                                                m_layout.refresh();
575
                                                isAcepted = true;
576
                                        }
577
                                });
578
                }
579

    
580
                return bAceptar;
581
        }
582

    
583
        /**
584
         * This method initializes bCancelar
585
         *
586
         * @return javax.swing.JButton
587
         */
588
        private javax.swing.JButton getBCancelar() {
589
                if (bCancelar == null) {
590
                        bCancelar = new javax.swing.JButton();
591
                        bCancelar.setSize(85, 26);
592
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
593
                        bCancelar.setLocation(297, 347);
594
                        bCancelar.setPreferredSize(new java.awt.Dimension(85, 23));
595
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
596
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
597
                                                PluginServices.getMDIManager().closeView(FFrameScaleBarDialog.this);
598
                                        }
599
                                });
600
                }
601

    
602
                return bCancelar;
603
        }
604

    
605
        /* (non-Javadoc)
606
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
607
         */
608
        public ViewInfo getViewInfo() {
609
                ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
610
                m_viewinfo.setTitle(PluginServices.getText(this,
611
                                "Propiedades_escala_grafica"));
612

    
613
                return m_viewinfo;
614
        }
615

    
616
        /**
617
         * @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
618
         */
619
        public boolean getIsAcepted() {
620
                return isAcepted;
621
        }
622

    
623
        /**
624
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
625
         */
626
        public void viewActivated() {
627
        }
628

    
629
        /**
630
         * This method initializes bFuente
631
         *
632
         * @return javax.swing.JButton
633
         */
634
        private javax.swing.JButton getBFuente() {
635
                if (bFuente == null) {
636
                        bFuente = new javax.swing.JButton();
637
                        bFuente.setText(PluginServices.getText(this, "fuente"));
638
                        bFuente.addActionListener(new java.awt.event.ActionListener() {
639
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
640
                                                fframescalebar.setFont(FontChooser.showDialog(
641
                                                                PluginServices.getText(this, "seleccion_fuente"),
642
                                                                fframescalebar.getFont())); // fchoser=new FontChooser();
643
                                        }
644
                                });
645
                }
646

    
647
                return bFuente;
648
        }
649

    
650
        /**
651
         * This method initializes pMarcoVista
652
         *
653
         * @return javax.swing.JPanel
654
         */
655
        private JPanel getPMarcoVista() {
656
                if (pMarcoVista == null) {
657
                        pMarcoVista = new JPanel();
658
                        pMarcoVista.setBounds(7, 9, 240, 86);
659
                        pMarcoVista.setBorder(javax.swing.BorderFactory.createTitledBorder(
660
                                        null, PluginServices.getText(this,PluginServices.getText(this,"marco_vista")),
661
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
662
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
663
                        pMarcoVista.add(getJScrollPane(), null);
664
                }
665

    
666
                return pMarcoVista;
667
        }
668

    
669
        /**
670
         * This method initializes pDescripcion
671
         *
672
         * @return javax.swing.JPanel
673
         */
674
        private JPanel getPDescripcion() {
675
                if (pDescripcion == null) {
676
                        pDescripcion = new JPanel();
677
                        pDescripcion.setBounds(256, 9, 216, 110);
678
                        pDescripcion.setBorder(javax.swing.BorderFactory.createTitledBorder(
679
                                        null, PluginServices.getText(this,"descripcion"),
680
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
681
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
682
                        pDescripcion.add(getTfDescripcion(), null);
683
                        pDescripcion.add(getJCheckBox(), null);
684
                        pDescripcion.add(getChbSobreDescripcion(), null);
685
                }
686

    
687
                return pDescripcion;
688
        }
689

    
690
        /**
691
         * This method initializes tfDescripcion
692
         *
693
         * @return javax.swing.JTextField
694
         */
695
        private JTextField getTfDescripcion() {
696
                if (tfDescripcion == null) {
697
                        tfDescripcion = new JTextField();
698
                        tfDescripcion.setPreferredSize(new java.awt.Dimension(190, 20));
699

    
700
                        /*if (fframeview!=null){
701
                           getTfDescripcion().setText("escala 1:"+String.valueOf(fframeview.getScale()));
702
                           }
703
                         */
704
                        tfDescripcion.setText(fframescalebar.getDescripcion());
705
                }
706

    
707
                return tfDescripcion;
708
        }
709

    
710
        /**
711
         * This method initializes pUnidades
712
         *
713
         * @return javax.swing.JPanel
714
         */
715
        private JPanel getPUnidades() {
716
                if (pUnidades == null) {
717
                        pUnidades = new JPanel();
718
                        pUnidades.setLocation(255, 129);
719
                        pUnidades.setSize(216, 107);
720
                        pUnidades.setBorder(javax.swing.BorderFactory.createTitledBorder(
721
                                        null, PluginServices.getText(this, "unidades"),
722
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
723
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
724
                        pUnidades.add(getCbUnidades(), null);
725
                        pUnidades.add(getChbMostrarUnidades(), null);
726
                        pUnidades.add(getChbSobreUnidades(), null);
727
                }
728

    
729
                return pUnidades;
730
        }
731

    
732
        /**
733
         * This method initializes chbSobreDescripcion
734
         *
735
         * @return javax.swing.JCheckBox
736
         */
737
        private JCheckBox getChbSobreDescripcion() {
738
                if (chbSobreDescripcion == null) {
739
                        chbSobreDescripcion = new JCheckBox();
740
                        chbSobreDescripcion.setSelected(fframescalebar.isAboveDescription());
741
                        chbSobreDescripcion.setText(PluginServices.getText(this,"sobre_la_barra"));
742
                }
743

    
744
                return chbSobreDescripcion;
745
        }
746

    
747
        /**
748
         * This method initializes chbMostrarUnidades
749
         *
750
         * @return javax.swing.JCheckBox
751
         */
752
        private JCheckBox getChbMostrarUnidades() {
753
                if (chbMostrarUnidades == null) {
754
                        chbMostrarUnidades = new JCheckBox();
755
                        chbMostrarUnidades.setText(PluginServices.getText(this,"mostrar_unidades"));
756
                        chbMostrarUnidades.setSelected(fframescalebar.isShowNameUnits());
757
                        chbMostrarUnidades.setPreferredSize(new java.awt.Dimension(150, 24));
758
                }
759

    
760
                return chbMostrarUnidades;
761
        }
762

    
763
        /**
764
         * This method initializes chbSobreUnidades
765
         *
766
         * @return javax.swing.JCheckBox
767
         */
768
        private JCheckBox getChbSobreUnidades() {
769
                if (chbSobreUnidades == null) {
770
                        chbSobreUnidades = new JCheckBox();
771
                        chbSobreUnidades.setSelected(fframescalebar.isAboveName());
772
                        chbSobreUnidades.setText(PluginServices.getText(this,"sobre_la_barra"));
773
                        chbSobreUnidades.setPreferredSize(new java.awt.Dimension(150, 24));
774
                }
775

    
776
                return chbSobreUnidades;
777
        }
778

    
779
        /**
780
         * This method initializes pEtiquetas
781
         *
782
         * @return javax.swing.JPanel
783
         */
784
        private JPanel getPEtiquetas() {
785
                if (pEtiquetas == null) {
786
                        pEtiquetas = new JPanel();
787
                        pEtiquetas.setBorder(javax.swing.BorderFactory.createTitledBorder(
788
                                        null, PluginServices.getText(this, "etiquetas"),
789
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
790
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
791
                        pEtiquetas.setBounds(257, 246, 216, 93);
792
                        pEtiquetas.add(getChbEtiquetas(), null);
793
                        pEtiquetas.add(getJPanel2(), null);
794
                }
795

    
796
                return pEtiquetas;
797
        }
798

    
799
        /**
800
         * This method initializes chbEtiquetas
801
         *
802
         * @return javax.swing.JCheckBox
803
         */
804
        private JCheckBox getChbEtiquetas() {
805
                if (chbEtiquetas == null) {
806
                        chbEtiquetas = new JCheckBox();
807
                        chbEtiquetas.setSelected(fframescalebar.isAboveIntervals());
808
                        chbEtiquetas.setText(PluginServices.getText(this,"sobre_la_barra"));
809
                }
810

    
811
                return chbEtiquetas;
812
        }
813

    
814
        /**
815
         * This method initializes pBarra
816
         *
817
         * @return javax.swing.JPanel
818
         */
819
        private JPanel getPBarra() {
820
                if (pBarra == null) {
821
                        lblNumDec = new JLabel();
822
                        lblNumDec.setText("numero_decimales_mostrar");
823
                        lblBarColor = new JLabel();
824
                        lblBarColor.setText(PluginServices.getText(this,"color"));
825
                        pBarra = new JPanel();
826
                        pBarra.setBounds(8, 104, 240, 235);
827
                        pBarra.setBorder(javax.swing.BorderFactory.createTitledBorder(
828
                                        null, PluginServices.getText(this,"barra"),
829
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
830
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
831
                        pBarra.add(getCbEscala(), null);
832
                        pBarra.add(lblNumDec, null);
833
                        pBarra.add(getNumDec(), null);
834
                        pBarra.add(getJPanel5(), null);
835
                        pBarra.add(getChbMantenerIntervalo(), null);
836
                        pBarra.add(getJPanel7(), null);
837
                        pBarra.add(getJPanel6(), null);
838
                        pBarra.add(lblBarColor, null);
839
                        pBarra.add(getBBarraColor(), null);
840
                        //pBarra.add(getJPanel(), null);
841
                }
842

    
843
                return pBarra;
844
        }
845

    
846
        /**
847
         * This method initializes jPanel5
848
         *
849
         * @return javax.swing.JPanel
850
         */
851
        private JPanel getJPanel5() {
852
                if (jPanel5 == null) {
853
                        jPanel5 = new JPanel();
854
                        jPanel5.setPreferredSize(new java.awt.Dimension(200, 30));
855
                        jPanel5.add(getLIntervalo(), null);
856
                        jPanel5.add(getTIntervalo(), null);
857
                }
858

    
859
                return jPanel5;
860
        }
861

    
862
        /**
863
         * This method initializes jPanel6
864
         *
865
         * @return javax.swing.JPanel
866
         */
867
        private JPanel getJPanel6() {
868
                if (jPanel6 == null) {
869
                        jPanel6 = new JPanel();
870
                        jPanel6.add(getLDivIzquierda(), null);
871
                        jPanel6.add(getTDivIzquierda(), null);
872
                }
873

    
874
                return jPanel6;
875
        }
876

    
877
        /**
878
         * This method initializes jPanel7
879
         *
880
         * @return javax.swing.JPanel
881
         */
882
        private JPanel getJPanel7() {
883
                if (jPanel7 == null) {
884
                        jPanel7 = new JPanel();
885
                        jPanel7.add(getLNumIntervalos(), null);
886
                        jPanel7.add(getTNumIntervalos(), null);
887
                }
888

    
889
                return jPanel7;
890
        }
891

    
892
        /**
893
         * This method initializes bUnidadesColor
894
         *
895
         * @return javax.swing.JButton
896
         */
897
        private JButton getBUnidadesColor() {
898
                if (bUnidadesColor == null) {
899
                        bUnidadesColor = new JButton();
900
                        bUnidadesColor.setForeground(Color.white);
901
                        bUnidadesColor.setPreferredSize(new java.awt.Dimension(25,25));
902
                        bUnidadesColor.setBackground(textcolor);
903
                        bUnidadesColor.addActionListener(new java.awt.event.ActionListener() {
904
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
905
                                                JDialog dlg;
906
                                                JColorChooser colorChooser;
907
                                                colorChooser = new JColorChooser();
908
                                                dlg = JColorChooser.createDialog((JFrame) null,
909
                                                                PluginServices.getText(this, "Elegir_Color"),
910
                                                                true, colorChooser, null, null);
911
                                                dlg.show(true);
912

    
913
                                                textcolor = (Color) colorChooser.getColor();
914

    
915
                                                //getJPanel1().setBackground(textcolor);
916
                                                bUnidadesColor.setBackground(textcolor);
917
                                        }
918
                                });
919
                }
920

    
921
                return bUnidadesColor;
922
        }
923

    
924
        /**
925
         * This method initializes bBarraColor
926
         *
927
         * @return javax.swing.JButton
928
         */
929
        private JButton getBBarraColor() {
930
                if (bBarraColor == null) {
931
                        bBarraColor = new JButton();
932
                        bBarraColor.setForeground(Color.white);
933
                        bBarraColor.setPreferredSize(new java.awt.Dimension(25,25));
934
                        bBarraColor.setBackground(barcolor);
935
                        bBarraColor.addActionListener(new java.awt.event.ActionListener() {
936
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
937
                                                JDialog dlg;
938
                                                JColorChooser colorChooser;
939
                                                colorChooser = new JColorChooser();
940
                                                dlg = JColorChooser.createDialog((JFrame) null,
941
                                                                PluginServices.getText(this, "Elegir_Color"),
942
                                                                true, colorChooser, null, null);
943
                                                dlg.show(true);
944

    
945
                                                barcolor = (Color) colorChooser.getColor();
946

    
947
                                                //getJPanel().setBackground(barcolor);
948
                                                bBarraColor.setBackground(barcolor);
949
                                        }
950
                                });
951
                }
952

    
953
                return bBarraColor;
954
        }
955

    
956
        /**
957
         * This method initializes jPanel
958
         *
959
         * @return javax.swing.JPanel
960
         */
961

    
962
        /*private JPanel getJPanel() {
963
           if (jPanel == null) {
964
                   jPanel = new JPanel();
965
                   jPanel.setPreferredSize(new java.awt.Dimension(44,24));
966
                   jPanel.setForeground(barcolor);
967
                   jPanel.setBackground(barcolor);
968
           }
969
           return jPanel;
970
           }
971
         */
972

    
973
        /**
974
         * This method initializes jPanel1
975
         *
976
         * @return javax.swing.JPanel
977
         */
978

    
979
        /*        private JPanel getJPanel1() {
980
           if (jPanel1 == null) {
981
                   jPanel1 = new JPanel();
982
                   jPanel1.setBackground(textcolor);
983
                   jPanel1.setPreferredSize(new java.awt.Dimension(44,24));
984
           }
985
           return jPanel1;
986
           }
987
         */
988

    
989
        /**
990
         * This method initializes jPanel2
991
         *
992
         * @return javax.swing.JPanel
993
         */
994
        private JPanel getJPanel2() {
995
                if (jPanel2 == null) {
996
                        lblLabelColor = new JLabel();
997
                        lblLabelColor.setText(PluginServices.getText(this,"color"));
998
                        jPanel2 = new JPanel();
999
                        jPanel2.add(getBFuente(), null);
1000
                        jPanel2.add(lblLabelColor, null);
1001
                        jPanel2.add(getBUnidadesColor(), null);
1002

    
1003
                        //jPanel2.add(getJPanel1(), null);
1004
                }
1005

    
1006
                return jPanel2;
1007
        }
1008

    
1009
        /**
1010
         * This method initializes jCheckBox
1011
         *
1012
         * @return javax.swing.JCheckBox
1013
         */
1014
        private JCheckBox getJCheckBox() {
1015
                if (jCheckBox == null) {
1016
                        jCheckBox = new JCheckBox();
1017
                        jCheckBox.setSelected(fframescalebar.isShowDescription());
1018
                        jCheckBox.setText(PluginServices.getText(this,"mostrar_descripcion"));
1019
                }
1020

    
1021
                return jCheckBox;
1022
        }
1023

    
1024
        /**
1025
         * DOCUMENT ME!
1026
         *
1027
         * @author Vicente Caballero Navarro
1028
         */
1029
        class ComboBoxRenderer extends JLabel implements ListCellRenderer {
1030
                /**
1031
                 * Crea un nuevo ComboBoxRenderer.
1032
                 */
1033
                public ComboBoxRenderer() {
1034
                        setOpaque(true);
1035
                        setHorizontalAlignment(CENTER);
1036
                        setVerticalAlignment(CENTER);
1037
                }
1038

    
1039
                /*
1040
                 * This method finds the image and text corresponding
1041
                 * to the selected value and returns the label, set up
1042
                 * to display the text and image.
1043
                 */
1044
                public Component getListCellRendererComponent(JList list, Object value,
1045
                        int index, boolean isSelected, boolean cellHasFocus) {
1046
                        //Get the selected index. (The index param isn't
1047
                        //always valid, so just use the value.)
1048
                        ///int selectedIndex = ((Integer)value).intValue();
1049
                        if (isSelected) {
1050
                                setBackground(list.getSelectionBackground());
1051
                                setForeground(list.getSelectionForeground());
1052
                        } else {
1053
                                setBackground(list.getBackground());
1054
                                setForeground(list.getForeground());
1055
                        }
1056

    
1057
                        ImageIcon icon = images[Integer.parseInt((String) value)];
1058
                        setIcon(icon);
1059

    
1060
                        return this;
1061
                }
1062
        }
1063

    
1064
        /**
1065
         * This method initializes pRotation        
1066
         *         
1067
         * @return javax.swing.JPanel        
1068
         */    
1069
        private JPRotation getPRotation() {
1070
                if (pRotation == null) {
1071
                        pRotation = new JPRotation();
1072
                        pRotation.setBounds(480, 10, 120, 120);
1073
                }
1074
                return pRotation;
1075
        }
1076

    
1077
        /**
1078
         * This method initializes numDec        
1079
         *         
1080
         * @return javax.swing.JTextField        
1081
         */
1082
        private JTextField getNumDec() {
1083
                if (txtNumDec == null) {
1084
                        txtNumDec = new JTextField();
1085
                        txtNumDec.setPreferredSize(new java.awt.Dimension(30,20));
1086
                        txtNumDec.setText(String.valueOf(fframescalebar.getNumDec()));
1087
                        txtNumDec.addKeyListener(new java.awt.event.KeyAdapter() {
1088
                                public void keyReleased(KeyEvent arg0) {
1089
                                        super.keyReleased(arg0);
1090
                                        if (!getNumDec().getText().toString().equals("")) {
1091
                                                fframescalebar.setNumDec(Integer.parseInt(
1092
                                                                getNumDec().getText().toString()));
1093
                                                getTIntervalo().setText(fframescalebar.obtainInterval());
1094
                                        }
1095
                                }
1096
                        });
1097
                }
1098
                return txtNumDec;
1099
        }
1100
} //  @jve:decl-index=0:visual-constraint="17,10"
1101
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"