Statistics
| Revision:

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

History | View | Annotate | Download (31.6 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.WindowInfo;
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
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
60

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

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

    
79

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

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

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

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

    
157
                if (fframescalebar.getFFrameDependence() != null && fframescalebar.getDescription().equals("")) {
158
                        getTfNumberScale().setText("1:" +
159
                                String.valueOf(((FFrameView)fframescalebar.getFFrameDependence()).getScale()));
160
                }
161

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

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

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

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

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

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

    
224
                return jContentPane;
225
        }
226

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

    
239
                return jScrollPane;
240
        }
241

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

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

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

    
256
                        liVistas.setModel(listmodel);
257

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

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

    
268
                        liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
269
                                        private int selectIndex=-1;
270
                                        public void valueChanged(
271
                                                                javax.swing.event.ListSelectionEvent e) {
272
                                                IFFrame[] fframes=m_layout.getFFrames();
273
                                                        int selectInt = ((JList) e.getSource())
274
                                                                        .getSelectedIndex();
275
                                                        if (selectInt != selectIndex) {
276
                                                                selectIndex = selectInt;
277
                                                                if (selectIndex == -1)
278
                                                                        return;
279
                                                                fframeview = (FFrameView) liVistas.getModel()
280
                                                                                .getElementAt(selectInt);
281

    
282
                                                                for (int i = 0; i < fframes.length; i++) {
283
                                                                        IFFrame f = fframes[i];
284

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

    
294
                                                                getTNumIntervalos().setText(
295
                                                                                String.valueOf(fframescalebar
296
                                                                                                .getNumInterval()));
297
                                                                getTDivIzquierda().setText(
298
                                                                                String.valueOf(fframescalebar
299
                                                                                                .getNumLeft()));
300
                                                                getTIntervalo().setText(
301
                                                                                fframescalebar.obtainInterval());
302
                                                                getTfNumberScale().setText(
303
                                                                                fframescalebar.getDescription());
304
                                                        }
305
                                                }
306
                                        });
307
                }
308

    
309
                return liVistas;
310
        }
311

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

    
332
                return chbMantenerIntervalo;
333
        }
334

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

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

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

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

    
401
                return cbEscala;
402
        }
403

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

    
424
                return cbUnidades;
425
        }
426

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

    
439
                return lIntervalo;
440
        }
441

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

    
464
                return tIntervalo;
465
        }
466

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

    
479
                return lNumIntervalos;
480
        }
481

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

    
504
                return tNumIntervalos;
505
        }
506

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

    
520
                return lDivIzquierda;
521
        }
522

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

    
545
                return tDivIzquierda;
546
        }
547

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

    
567
                                                fframescalebar.setBarColor(barcolor);
568
                                                fframescalebar.setTextColor(textcolor);
569
                                                fframescalebar.setShowNameUnits(getChbMostrarUnidades()
570
                                                                                                                        .isSelected());
571
                                                fframescalebar.setShowDescription(getJCheckBox()
572
                                                                                                                          .isSelected());
573
                                                fframescalebar.setAboveDescription(getChbSobreDescripcion()
574
                                                                                                                           .isSelected());
575
                                                fframescalebar.setAboveIntervals(getChbEtiquetas()
576
                                                                                                                         .isSelected());
577
                                                fframescalebar.setAboveName(getChbSobreUnidades()
578
                                                                                                                .isSelected());
579
                                                fframescalebar.setRotation(getPRotation().getRotation());
580
                                                fframescalebar.setNumDec(Integer.parseInt(getNumDec().getText()));
581
                                                PluginServices.getMDIManager().closeWindow(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().closeWindow(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 WindowInfo getWindowInfo() {
617
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.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.IWindow#windowActivated()
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(null, PluginServices.getText(this,"Escala"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.black));
687
                        pDescripcion.add(getTfNumberScale(), null);
688
                        pDescripcion.add(getJCheckBox(), null);
689
                        pDescripcion.add(getChbSobreDescripcion(), null);
690
                }
691

    
692
                return pDescripcion;
693
        }
694

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

    
705
                        tfDescripcion.setEditable(false);
706
                        /*if (fframeview!=null){
707
                           getTfDescripcion().setText("escala 1:"+String.valueOf(fframeview.getScale()));
708
                           }
709
                         */
710
                        tfDescripcion.setText(fframescalebar.getDescription());
711
                }
712

    
713
                return tfDescripcion;
714
        }
715

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

    
735
                return pUnidades;
736
        }
737

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

    
750
                return chbSobreDescripcion;
751
        }
752

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

    
766
                return chbMostrarUnidades;
767
        }
768

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

    
782
                return chbSobreUnidades;
783
        }
784

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

    
802
                return pEtiquetas;
803
        }
804

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

    
817
                return chbEtiquetas;
818
        }
819

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

    
849
                return pBarra;
850
        }
851

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

    
865
                return jPanel5;
866
        }
867

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

    
880
                return jPanel6;
881
        }
882

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

    
895
                return jPanel7;
896
        }
897

    
898
        /**
899
         * This method initializes bUnidadesColor
900
         *
901
         * @return javax.swing.JButton
902
         */
903
        private ColorChooserPanel getBUnidadesColor() {
904
                if (bUnidadesColor == null) {
905
                        bUnidadesColor = new ColorChooserPanel();
906
                        bUnidadesColor.setAlpha(255);
907
                        bUnidadesColor.setColor(textcolor);
908
                        bUnidadesColor.setPreferredSize(new java.awt.Dimension(100,25));
909
                        bUnidadesColor.addActionListener(new java.awt.event.ActionListener() {
910
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
911
                                                textcolor = getBUnidadesColor().getColor();
912
                                        }
913
                                });
914
                }
915

    
916
                return bUnidadesColor;
917
        }
918

    
919
        /**
920
         * This method initializes bBarraColor
921
         *
922
         * @return javax.swing.JButton
923
         */
924
        private ColorChooserPanel getBBarraColor() {
925
                if (bBarraColor == null) {
926
                        bBarraColor = new ColorChooserPanel();
927
                        bBarraColor.setPreferredSize(new java.awt.Dimension(100,25));
928
                        bBarraColor.setAlpha(255);
929
                        bBarraColor.setColor(barcolor);
930
                        bBarraColor.addActionListener(new java.awt.event.ActionListener() {
931
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
932
//                                                JDialog dlg;
933
//                                                JColorChooser colorChooser;
934
//                                                colorChooser = new JColorChooser();
935
//                                                dlg = JColorChooser.createDialog((JFrame) null,
936
//                                                                PluginServices.getText(this, "Elegir_Color"),
937
//                                                                true, colorChooser, null, null);
938
//                                                dlg.show(true);
939
//
940
                                                barcolor = getBBarraColor().getColor();
941

    
942
//                                                bBarraColor.setBackground(barcolor);
943
//                                                bBarraColor.setForeground(barcolor);
944
                                        }
945
                                });
946
                }
947

    
948
                return bBarraColor;
949
        }
950

    
951
        /**
952
         * This method initializes jPanel
953
         *
954
         * @return javax.swing.JPanel
955
         */
956

    
957
        /*private JPanel getJPanel() {
958
           if (jPanel == null) {
959
                   jPanel = new JPanel();
960
                   jPanel.setPreferredSize(new java.awt.Dimension(44,24));
961
                   jPanel.setForeground(barcolor);
962
                   jPanel.setBackground(barcolor);
963
           }
964
           return jPanel;
965
           }
966
         */
967

    
968
        /**
969
         * This method initializes jPanel1
970
         *
971
         * @return javax.swing.JPanel
972
         */
973

    
974
        /*        private JPanel getJPanel1() {
975
           if (jPanel1 == null) {
976
                   jPanel1 = new JPanel();
977
                   jPanel1.setBackground(textcolor);
978
                   jPanel1.setPreferredSize(new java.awt.Dimension(44,24));
979
           }
980
           return jPanel1;
981
           }
982
         */
983

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

    
998
                        //jPanel2.add(getJPanel1(), null);
999
                }
1000

    
1001
                return jPanel2;
1002
        }
1003

    
1004
        /**
1005
         * This method initializes jCheckBox
1006
         *
1007
         * @return javax.swing.JCheckBox
1008
         */
1009
        private JCheckBox getJCheckBox() {
1010
                if (jCheckBox == null) {
1011
                        jCheckBox = new JCheckBox();
1012
                        jCheckBox.setSelected(fframescalebar.isShowDescription());
1013
                        jCheckBox.setText(PluginServices.getText(this,"mostrar_escala_numerica"));
1014
                }
1015

    
1016
                return jCheckBox;
1017
        }
1018

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

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

    
1052
                        ImageIcon icon = images[Integer.parseInt((String) value)];
1053
                        setIcon(icon);
1054

    
1055
                        return this;
1056
                }
1057
        }
1058

    
1059
        /**
1060
         * This method initializes pRotation
1061
         *
1062
         * @return javax.swing.JPanel
1063
         */
1064
        private JPRotation getPRotation() {
1065
                if (pRotation == null) {
1066
                        pRotation = new JPRotation();
1067
                        pRotation.setBounds(480, 10, 120, 120);
1068
                }
1069
                return pRotation;
1070
        }
1071

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