Statistics
| Revision:

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

History | View | Annotate | Download (31.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.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())
272
                                                                        .getSelectedIndex();
273
                                                        if (selectInt != selectIndex) {
274
                                                                selectIndex = selectInt;
275
                                                                if (selectIndex == -1)
276
                                                                        return;
277
                                                                fframeview = (FFrameView) liVistas.getModel()
278
                                                                                .getElementAt(selectInt);
279

    
280
                                                                for (int i = 0; i < m_layout.getFFrames().length; i++) {
281
                                                                        IFFrame f = (IFFrame) m_layout.getFFrame(i);
282

    
283
                                                                        if (f instanceof FFrameView) {
284
                                                                                if (((FFrameView) f).getView() == fframeview
285
                                                                                                .getView()) {
286
                                                                                        fframescalebar
287
                                                                                                        .setFFrameDependence(fframeview);
288
                                                                                }
289
                                                                        }
290
                                                                }
291

    
292
                                                                getTNumIntervalos().setText(
293
                                                                                String.valueOf(fframescalebar
294
                                                                                                .getNumInterval()));
295
                                                                getTDivIzquierda().setText(
296
                                                                                String.valueOf(fframescalebar
297
                                                                                                .getNumLeft()));
298
                                                                getTIntervalo().setText(
299
                                                                                fframescalebar.obtainInterval());
300
                                                                getTfDescripcion().setText(
301
                                                                                fframescalebar.getDescripcion());
302
                                                        }
303
                                                }
304
                                        });
305
                }
306

    
307
                return liVistas;
308
        }
309

    
310
        /**
311
         * This method initializes chbMantenerIntervalo
312
         *
313
         * @return javax.swing.JCheckBox
314
         */
315
        private javax.swing.JCheckBox getChbMantenerIntervalo() {
316
                if (chbMantenerIntervalo == null) {
317
                        chbMantenerIntervalo = new javax.swing.JCheckBox();
318
                        chbMantenerIntervalo.setSelected(fframescalebar.isbIntervalSet());
319
                        chbMantenerIntervalo.setText(PluginServices.getText(this,
320
                                        "mantener_intervalo"));
321
                        chbMantenerIntervalo.setPreferredSize(new java.awt.Dimension(200, 20));
322
                        chbMantenerIntervalo.addActionListener(new java.awt.event.ActionListener() {
323
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
324
                                                fframescalebar.setIntervalSet(getChbMantenerIntervalo()
325
                                                                                                                  .isSelected());
326
                                        }
327
                                });
328
                }
329

    
330
                return chbMantenerIntervalo;
331
        }
332

    
333
        /**
334
         * This method initializes cbEscala
335
         *
336
         * @return javax.swing.JComboBox
337
         */
338
        private javax.swing.JComboBox getCbEscala() {
339
                if (cbEscala == null) {
340
                        //String[] s={"n?merico","barra1","barra2","barra3","barra4"};
341
                        cbEscala = new javax.swing.JComboBox();
342
                        images[0] = inumero;
343
                        images[1] = ibarra1;
344
                        images[2] = ibarra2;
345
                        images[3] = ibarra3;
346

    
347
                        /*  Image img=img = new BufferedImage(100, 25,
348
                           BufferedImage.TYPE_INT_ARGB);
349
                           img.getGraphics().drawImage(images[3].getImage(),0,0,null);
350
                           img.getGraphics().setXORMode(Color.yellow);
351
                            images[3]=new ImageIcon(img);
352
                         */
353
                        ComboBoxRenderer renderer = new ComboBoxRenderer();
354
                        renderer.setPreferredSize(new Dimension(100, 25));
355
                        cbEscala.setRenderer(renderer);
356
                        cbEscala.setMaximumRowCount(4);
357

    
358
                        cbEscala.addItem("0");
359
                        cbEscala.addItem("1");
360
                        cbEscala.addItem("2");
361
                        cbEscala.addItem("3");
362
                        cbEscala.setSelectedIndex(fframescalebar.getStyle());
363
                        cbEscala.setPreferredSize(new java.awt.Dimension(200, 20));
364
                        cbEscala.addActionListener(new java.awt.event.ActionListener() {
365
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
366
                                                fframescalebar.setStyle(getCbEscala().getSelectedIndex());
367

    
368
                                                if (cbEscala.getSelectedIndex() == 0) {
369
                                                        getChbMantenerIntervalo().setEnabled(false);
370
                                                        getChbMostrarUnidades().setEnabled(false);
371
                                                        getChbSobreUnidades().setEnabled(false);
372
                                                        getCbUnidades().setEnabled(false);
373
                                                        getChbEtiquetas().setEnabled(false);
374
                                                        getBBarraColor().setEnabled(false);
375
                                                        getLIntervalo().setEnabled(false);
376
                                                        getTIntervalo().setEnabled(false);
377
                                                        getLNumIntervalos().setEnabled(false);
378
                                                        getTNumIntervalos().setEnabled(false);
379
                                                        getLDivIzquierda().setEnabled(false);
380
                                                        getTDivIzquierda().setEnabled(false);
381
                                                } else {
382
                                                        getChbMantenerIntervalo().setEnabled(true);
383
                                                        getChbMostrarUnidades().setEnabled(true);
384
                                                        getChbSobreUnidades().setEnabled(true);
385
                                                        getCbUnidades().setEnabled(true);
386
                                                        getChbEtiquetas().setEnabled(true);
387
                                                        getBBarraColor().setEnabled(true);
388
                                                        getLIntervalo().setEnabled(true);
389
                                                        getTIntervalo().setEnabled(true);
390
                                                        getLNumIntervalos().setEnabled(true);
391
                                                        getTNumIntervalos().setEnabled(true);
392
                                                        getLDivIzquierda().setEnabled(true);
393
                                                        getTDivIzquierda().setEnabled(true);
394
                                                }
395
                                        }
396
                                });
397
                }
398

    
399
                return cbEscala;
400
        }
401

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

    
422
                return cbUnidades;
423
        }
424

    
425
        /**
426
         * This method initializes lIntervalo
427
         *
428
         * @return javax.swing.JLabel
429
         */
430
        private javax.swing.JLabel getLIntervalo() {
431
                if (lIntervalo == null) {
432
                        lIntervalo = new javax.swing.JLabel();
433
                        lIntervalo.setText(PluginServices.getText(this, "Intervalo"));
434
                        lIntervalo.setPreferredSize(new java.awt.Dimension(90, 20));
435
                }
436

    
437
                return lIntervalo;
438
        }
439

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

    
462
                return tIntervalo;
463
        }
464

    
465
        /**
466
         * This method initializes lNumIntervalos
467
         *
468
         * @return javax.swing.JLabel
469
         */
470
        private javax.swing.JLabel getLNumIntervalos() {
471
                if (lNumIntervalos == null) {
472
                        lNumIntervalos = new javax.swing.JLabel();
473
                        lNumIntervalos.setText(PluginServices.getText(this, "Num_intervalos"));
474
                        lNumIntervalos.setPreferredSize(new java.awt.Dimension(90, 20));
475
                }
476

    
477
                return lNumIntervalos;
478
        }
479

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

    
502
                return tNumIntervalos;
503
        }
504

    
505
        /**
506
         * This method initializes lDivIzquierda
507
         *
508
         * @return javax.swing.JLabel
509
         */
510
        private javax.swing.JLabel getLDivIzquierda() {
511
                if (lDivIzquierda == null) {
512
                        lDivIzquierda = new javax.swing.JLabel();
513
                        lDivIzquierda.setText(PluginServices.getText(this,
514
                                        "divisiones_izquierda"));
515
                        lDivIzquierda.setPreferredSize(new java.awt.Dimension(90, 20));
516
                }
517

    
518
                return lDivIzquierda;
519
        }
520

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

    
543
                return tDivIzquierda;
544
        }
545

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

    
565
                                                fframescalebar.setBarColor(barcolor);
566
                                                fframescalebar.setTextColor(textcolor);
567
                                                fframescalebar.setShowNameUnits(getChbMostrarUnidades()
568
                                                                                                                        .isSelected());
569
                                                fframescalebar.setShowDescription(getJCheckBox()
570
                                                                                                                          .isSelected());
571
                                                fframescalebar.setAboveDescription(getChbSobreDescripcion()
572
                                                                                                                           .isSelected());
573
                                                fframescalebar.setAboveIntervals(getChbEtiquetas()
574
                                                                                                                         .isSelected());
575
                                                fframescalebar.setAboveName(getChbSobreUnidades()
576
                                                                                                                .isSelected());
577
                                                fframescalebar.setDescripcion(getTfDescripcion()
578
                                                                                                                  .getText());
579
                                                fframescalebar.setRotation(getPRotation().getRotation());
580
                                                fframescalebar.setNumDec(Integer.parseInt(getNumDec().getText()));
581
                                                PluginServices.getMDIManager().closeView(FFrameScaleBarDialog.this);
582
                                                m_layout.refresh();
583
                                                isAcepted = true;
584
                                        }
585
                                });
586
                }
587

    
588
                return bAceptar;
589
        }
590

    
591
        /**
592
         * This method initializes bCancelar
593
         *
594
         * @return javax.swing.JButton
595
         */
596
        private javax.swing.JButton getBCancelar() {
597
                if (bCancelar == null) {
598
                        bCancelar = new javax.swing.JButton();
599
                        bCancelar.setSize(85, 26);
600
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
601
                        bCancelar.setLocation(297, 347);
602
                        bCancelar.setPreferredSize(new java.awt.Dimension(85, 23));
603
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
604
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
605
                                                PluginServices.getMDIManager().closeView(FFrameScaleBarDialog.this);
606
                                        }
607
                                });
608
                }
609

    
610
                return bCancelar;
611
        }
612

    
613
        /* (non-Javadoc)
614
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
615
         */
616
        public ViewInfo getViewInfo() {
617
                ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
618
                m_viewinfo.setTitle(PluginServices.getText(this,
619
                                "Propiedades_escala_grafica"));
620

    
621
                return m_viewinfo;
622
        }
623

    
624
        /**
625
         * @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
626
         */
627
        public boolean getIsAcepted() {
628
                return isAcepted;
629
        }
630

    
631
        /**
632
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
633
         */
634
        public void viewActivated() {
635
        }
636

    
637
        /**
638
         * This method initializes bFuente
639
         *
640
         * @return javax.swing.JButton
641
         */
642
        private javax.swing.JButton getBFuente() {
643
                if (bFuente == null) {
644
                        bFuente = new javax.swing.JButton();
645
                        bFuente.setText(PluginServices.getText(this, "fuente"));
646
                        bFuente.addActionListener(new java.awt.event.ActionListener() {
647
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
648
                                                fframescalebar.setFont(FontChooser.showDialog(
649
                                                                PluginServices.getText(this, "seleccion_fuente"),
650
                                                                fframescalebar.getFont())); // fchoser=new FontChooser();
651
                                        }
652
                                });
653
                }
654

    
655
                return bFuente;
656
        }
657

    
658
        /**
659
         * This method initializes pMarcoVista
660
         *
661
         * @return javax.swing.JPanel
662
         */
663
        private JPanel getPMarcoVista() {
664
                if (pMarcoVista == null) {
665
                        pMarcoVista = new JPanel();
666
                        pMarcoVista.setBounds(7, 9, 240, 86);
667
                        pMarcoVista.setBorder(javax.swing.BorderFactory.createTitledBorder(
668
                                        null, PluginServices.getText(this,PluginServices.getText(this,"marco_vista")),
669
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
670
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
671
                        pMarcoVista.add(getJScrollPane(), null);
672
                }
673

    
674
                return pMarcoVista;
675
        }
676

    
677
        /**
678
         * This method initializes pDescripcion
679
         *
680
         * @return javax.swing.JPanel
681
         */
682
        private JPanel getPDescripcion() {
683
                if (pDescripcion == null) {
684
                        pDescripcion = new JPanel();
685
                        pDescripcion.setBounds(256, 9, 216, 110);
686
                        pDescripcion.setBorder(javax.swing.BorderFactory.createTitledBorder(
687
                                        null, PluginServices.getText(this,"descripcion"),
688
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
689
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
690
                        pDescripcion.add(getTfDescripcion(), null);
691
                        pDescripcion.add(getJCheckBox(), null);
692
                        pDescripcion.add(getChbSobreDescripcion(), null);
693
                }
694

    
695
                return pDescripcion;
696
        }
697

    
698
        /**
699
         * This method initializes tfDescripcion
700
         *
701
         * @return javax.swing.JTextField
702
         */
703
        private JTextField getTfDescripcion() {
704
                if (tfDescripcion == null) {
705
                        tfDescripcion = new JTextField();
706
                        tfDescripcion.setPreferredSize(new java.awt.Dimension(190, 20));
707

    
708
                        /*if (fframeview!=null){
709
                           getTfDescripcion().setText("escala 1:"+String.valueOf(fframeview.getScale()));
710
                           }
711
                         */
712
                        tfDescripcion.setText(fframescalebar.getDescripcion());
713
                }
714

    
715
                return tfDescripcion;
716
        }
717

    
718
        /**
719
         * This method initializes pUnidades
720
         *
721
         * @return javax.swing.JPanel
722
         */
723
        private JPanel getPUnidades() {
724
                if (pUnidades == null) {
725
                        pUnidades = new JPanel();
726
                        pUnidades.setLocation(255, 129);
727
                        pUnidades.setSize(216, 107);
728
                        pUnidades.setBorder(javax.swing.BorderFactory.createTitledBorder(
729
                                        null, PluginServices.getText(this, "unidades"),
730
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
731
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
732
                        pUnidades.add(getCbUnidades(), null);
733
                        pUnidades.add(getChbMostrarUnidades(), null);
734
                        pUnidades.add(getChbSobreUnidades(), null);
735
                }
736

    
737
                return pUnidades;
738
        }
739

    
740
        /**
741
         * This method initializes chbSobreDescripcion
742
         *
743
         * @return javax.swing.JCheckBox
744
         */
745
        private JCheckBox getChbSobreDescripcion() {
746
                if (chbSobreDescripcion == null) {
747
                        chbSobreDescripcion = new JCheckBox();
748
                        chbSobreDescripcion.setSelected(fframescalebar.isAboveDescription());
749
                        chbSobreDescripcion.setText(PluginServices.getText(this,"sobre_la_barra"));
750
                }
751

    
752
                return chbSobreDescripcion;
753
        }
754

    
755
        /**
756
         * This method initializes chbMostrarUnidades
757
         *
758
         * @return javax.swing.JCheckBox
759
         */
760
        private JCheckBox getChbMostrarUnidades() {
761
                if (chbMostrarUnidades == null) {
762
                        chbMostrarUnidades = new JCheckBox();
763
                        chbMostrarUnidades.setText(PluginServices.getText(this,"mostrar_unidades"));
764
                        chbMostrarUnidades.setSelected(fframescalebar.isShowNameUnits());
765
                        chbMostrarUnidades.setPreferredSize(new java.awt.Dimension(150, 24));
766
                }
767

    
768
                return chbMostrarUnidades;
769
        }
770

    
771
        /**
772
         * This method initializes chbSobreUnidades
773
         *
774
         * @return javax.swing.JCheckBox
775
         */
776
        private JCheckBox getChbSobreUnidades() {
777
                if (chbSobreUnidades == null) {
778
                        chbSobreUnidades = new JCheckBox();
779
                        chbSobreUnidades.setSelected(fframescalebar.isAboveName());
780
                        chbSobreUnidades.setText(PluginServices.getText(this,"sobre_la_barra"));
781
                        chbSobreUnidades.setPreferredSize(new java.awt.Dimension(150, 24));
782
                }
783

    
784
                return chbSobreUnidades;
785
        }
786

    
787
        /**
788
         * This method initializes pEtiquetas
789
         *
790
         * @return javax.swing.JPanel
791
         */
792
        private JPanel getPEtiquetas() {
793
                if (pEtiquetas == null) {
794
                        pEtiquetas = new JPanel();
795
                        pEtiquetas.setBorder(javax.swing.BorderFactory.createTitledBorder(
796
                                        null, PluginServices.getText(this, "etiquetas"),
797
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
798
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
799
                        pEtiquetas.setBounds(257, 246, 216, 93);
800
                        pEtiquetas.add(getChbEtiquetas(), null);
801
                        pEtiquetas.add(getJPanel2(), null);
802
                }
803

    
804
                return pEtiquetas;
805
        }
806

    
807
        /**
808
         * This method initializes chbEtiquetas
809
         *
810
         * @return javax.swing.JCheckBox
811
         */
812
        private JCheckBox getChbEtiquetas() {
813
                if (chbEtiquetas == null) {
814
                        chbEtiquetas = new JCheckBox();
815
                        chbEtiquetas.setSelected(fframescalebar.isAboveIntervals());
816
                        chbEtiquetas.setText(PluginServices.getText(this,"sobre_la_barra"));
817
                }
818

    
819
                return chbEtiquetas;
820
        }
821

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

    
851
                return pBarra;
852
        }
853

    
854
        /**
855
         * This method initializes jPanel5
856
         *
857
         * @return javax.swing.JPanel
858
         */
859
        private JPanel getJPanel5() {
860
                if (jPanel5 == null) {
861
                        jPanel5 = new JPanel();
862
                        jPanel5.setPreferredSize(new java.awt.Dimension(200, 30));
863
                        jPanel5.add(getLIntervalo(), null);
864
                        jPanel5.add(getTIntervalo(), null);
865
                }
866

    
867
                return jPanel5;
868
        }
869

    
870
        /**
871
         * This method initializes jPanel6
872
         *
873
         * @return javax.swing.JPanel
874
         */
875
        private JPanel getJPanel6() {
876
                if (jPanel6 == null) {
877
                        jPanel6 = new JPanel();
878
                        jPanel6.add(getLDivIzquierda(), null);
879
                        jPanel6.add(getTDivIzquierda(), null);
880
                }
881

    
882
                return jPanel6;
883
        }
884

    
885
        /**
886
         * This method initializes jPanel7
887
         *
888
         * @return javax.swing.JPanel
889
         */
890
        private JPanel getJPanel7() {
891
                if (jPanel7 == null) {
892
                        jPanel7 = new JPanel();
893
                        jPanel7.add(getLNumIntervalos(), null);
894
                        jPanel7.add(getTNumIntervalos(), null);
895
                }
896

    
897
                return jPanel7;
898
        }
899

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

    
921
                                                textcolor = (Color) colorChooser.getColor();
922

    
923
                                                //getJPanel1().setBackground(textcolor);
924
                                                bUnidadesColor.setBackground(textcolor);
925
                                        }
926
                                });
927
                }
928

    
929
                return bUnidadesColor;
930
        }
931

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

    
953
                                                barcolor = (Color) colorChooser.getColor();
954

    
955
                                                //getJPanel().setBackground(barcolor);
956
                                                bBarraColor.setBackground(barcolor);
957
                                        }
958
                                });
959
                }
960

    
961
                return bBarraColor;
962
        }
963

    
964
        /**
965
         * This method initializes jPanel
966
         *
967
         * @return javax.swing.JPanel
968
         */
969

    
970
        /*private JPanel getJPanel() {
971
           if (jPanel == null) {
972
                   jPanel = new JPanel();
973
                   jPanel.setPreferredSize(new java.awt.Dimension(44,24));
974
                   jPanel.setForeground(barcolor);
975
                   jPanel.setBackground(barcolor);
976
           }
977
           return jPanel;
978
           }
979
         */
980

    
981
        /**
982
         * This method initializes jPanel1
983
         *
984
         * @return javax.swing.JPanel
985
         */
986

    
987
        /*        private JPanel getJPanel1() {
988
           if (jPanel1 == null) {
989
                   jPanel1 = new JPanel();
990
                   jPanel1.setBackground(textcolor);
991
                   jPanel1.setPreferredSize(new java.awt.Dimension(44,24));
992
           }
993
           return jPanel1;
994
           }
995
         */
996

    
997
        /**
998
         * This method initializes jPanel2
999
         *
1000
         * @return javax.swing.JPanel
1001
         */
1002
        private JPanel getJPanel2() {
1003
                if (jPanel2 == null) {
1004
                        lblLabelColor = new JLabel();
1005
                        lblLabelColor.setText(PluginServices.getText(this,"color"));
1006
                        jPanel2 = new JPanel();
1007
                        jPanel2.add(getBFuente(), null);
1008
                        jPanel2.add(lblLabelColor, null);
1009
                        jPanel2.add(getBUnidadesColor(), null);
1010

    
1011
                        //jPanel2.add(getJPanel1(), null);
1012
                }
1013

    
1014
                return jPanel2;
1015
        }
1016

    
1017
        /**
1018
         * This method initializes jCheckBox
1019
         *
1020
         * @return javax.swing.JCheckBox
1021
         */
1022
        private JCheckBox getJCheckBox() {
1023
                if (jCheckBox == null) {
1024
                        jCheckBox = new JCheckBox();
1025
                        jCheckBox.setSelected(fframescalebar.isShowDescription());
1026
                        jCheckBox.setText(PluginServices.getText(this,"mostrar_descripcion"));
1027
                }
1028

    
1029
                return jCheckBox;
1030
        }
1031

    
1032
        /**
1033
         * DOCUMENT ME!
1034
         *
1035
         * @author Vicente Caballero Navarro
1036
         */
1037
        class ComboBoxRenderer extends JLabel implements ListCellRenderer {
1038
                /**
1039
                 * Crea un nuevo ComboBoxRenderer.
1040
                 */
1041
                public ComboBoxRenderer() {
1042
                        setOpaque(true);
1043
                        setHorizontalAlignment(CENTER);
1044
                        setVerticalAlignment(CENTER);
1045
                }
1046

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

    
1065
                        ImageIcon icon = images[Integer.parseInt((String) value)];
1066
                        setIcon(icon);
1067

    
1068
                        return this;
1069
                }
1070
        }
1071

    
1072
        /**
1073
         * This method initializes pRotation
1074
         *
1075
         * @return javax.swing.JPanel
1076
         */
1077
        private JPRotation getPRotation() {
1078
                if (pRotation == null) {
1079
                        pRotation = new JPRotation();
1080
                        pRotation.setBounds(480, 10, 120, 120);
1081
                }
1082
                return pRotation;
1083
        }
1084

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