Statistics
| Revision:

root / tags / v10_RC2c / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / dialogs / FFrameScaleBarDialog.java @ 8745

History | View | Annotate | Download (32.3 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

    
48
import java.awt.Color;
49
import java.awt.Component;
50
import java.awt.Dimension;
51
import java.awt.FlowLayout;
52
import java.awt.event.KeyEvent;
53
import java.awt.geom.Rectangle2D;
54

    
55
import javax.swing.ImageIcon;
56
import javax.swing.JCheckBox;
57
import javax.swing.JLabel;
58
import javax.swing.JList;
59
import javax.swing.JPanel;
60
import javax.swing.JTextField;
61
import javax.swing.ListCellRenderer;
62

    
63
import com.iver.andami.PluginServices;
64
import com.iver.andami.ui.mdiManager.WindowInfo;
65
import com.iver.cit.gvsig.AddLayer;
66
import com.iver.cit.gvsig.gui.dialogs.FontChooser;
67
import com.iver.cit.gvsig.gui.layout.Attributes;
68
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities;
69
import com.iver.cit.gvsig.gui.layout.Layout;
70
import com.iver.cit.gvsig.gui.layout.fframes.FFrameScaleBar;
71
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView;
72
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame;
73
import com.iver.cit.gvsig.gui.layout.fframes.ListViewModel;
74
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
75

    
76

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

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

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

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

    
153
                if (fframescalebar.getFFrameDependence() != null && fframescalebar.getDescription().equals("")) {
154
                        getTfNumberScale().setText("1:" +
155
                                String.valueOf(((FFrameView)fframescalebar.getFFrameDependence()).getScale()));
156
                }
157

    
158
                m_layout = layout;
159
                initialize();
160
        }
161

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

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

    
179
                if (fframescalebar.getStyle() == 0) {
180
                        getChbMantenerIntervalo().setEnabled(false);
181

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

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

    
220
                return jContentPane;
221
        }
222

    
223
        /**
224
         * This method initializes jScrollPane
225
         *
226
         * @return javax.swing.JScrollPane
227
         */
228
        private javax.swing.JScrollPane getJScrollPane() {
229
                if (jScrollPane == null) {
230
                        jScrollPane = new javax.swing.JScrollPane();
231
                        jScrollPane.setPreferredSize(new java.awt.Dimension(250,55));
232
                        jScrollPane.setViewportView(getLiVistas());
233
                }
234

    
235
                return jScrollPane;
236
        }
237

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

    
248
                        ///ArrayList list = listmodel.getViews();
249

    
250
                        liVistas = new javax.swing.JList();
251

    
252
                        liVistas.setSize(new java.awt.Dimension(250,52));
253
                        liVistas.setModel(listmodel);
254

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

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

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

    
279
                                                                for (int i = 0; i < fframes.length; i++) {
280
                                                                        IFFrame f = fframes[i];
281

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

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

    
306
                return liVistas;
307
        }
308

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

    
329
                return chbMantenerIntervalo;
330
        }
331

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

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

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

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

    
398
                return cbEscala;
399
        }
400

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

    
421
                return cbUnidades;
422
        }
423

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

    
436
                return lIntervalo;
437
        }
438

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

    
461
                return tIntervalo;
462
        }
463

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

    
476
                return lNumIntervalos;
477
        }
478

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

    
501
                return tNumIntervalos;
502
        }
503

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

    
517
                return lDivIzquierda;
518
        }
519

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

    
542
                return tDivIzquierda;
543
        }
544

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

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

    
585
                return bAceptar;
586
        }
587

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

    
607
                return bCancelar;
608
        }
609

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

    
618
                return m_viewinfo;
619
        }
620

    
621
        /**
622
         * @see com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
623
         */
624
        public boolean getIsAcepted() {
625
                return isAcepted;
626
        }
627

    
628
        /**
629
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
630
         */
631
        public void viewActivated() {
632
        }
633

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

    
652
                return bFuente;
653
        }
654

    
655
        /**
656
         * This method initializes pMarcoVista
657
         *
658
         * @return javax.swing.JPanel
659
         */
660
        private JPanel getPMarcoVista() {
661
                if (pMarcoVista == null) {
662
                        pMarcoVista = new JPanel();
663
                        pMarcoVista.setBounds(7, 9, 263, 86);
664
                        pMarcoVista.setBorder(javax.swing.BorderFactory.createTitledBorder(
665
                                        null, PluginServices.getText(this,PluginServices.getText(this,"marco_vista")),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));
666
                        pMarcoVista.add(getJScrollPane(), null);
667
                }
668

    
669
                return pMarcoVista;
670
        }
671

    
672
        /**
673
         * This method initializes pDescripcion
674
         *
675
         * @return javax.swing.JPanel
676
         */
677
        private JPanel getPDescripcion() {
678
                if (pDescripcion == null) {
679
                        FlowLayout flowLayout1 = new FlowLayout();
680
                        flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
681
                        pDescripcion = new JPanel();
682
                        pDescripcion.setLayout(flowLayout1);
683
                        pDescripcion.setBounds(275, 9, 204, 110);
684
                        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));
685
                        pDescripcion.add(getTfNumberScale(), null);
686
                        pDescripcion.add(getJCheckBox(), null);
687
                        pDescripcion.add(getChbSobreDescripcion(), null);
688
                }
689

    
690
                return pDescripcion;
691
        }
692

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

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

    
711
                return tfDescripcion;
712
        }
713

    
714
        /**
715
         * This method initializes pUnidades
716
         *
717
         * @return javax.swing.JPanel
718
         */
719
        private JPanel getPUnidades() {
720
                if (pUnidades == null) {
721
                        FlowLayout flowLayout = new FlowLayout();
722
                        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
723
                        pUnidades = new JPanel();
724
                        pUnidades.setLayout(flowLayout);
725
                        pUnidades.setLocation(274, 122);
726
                        pUnidades.setSize(204, 110);
727
                        pUnidades.setBorder(javax.swing.BorderFactory.createTitledBorder(
728
                                        null, PluginServices.getText(this, "unidades"),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));
729
                        pUnidades.add(getCbUnidades(), null);
730
                        pUnidades.add(getChbMostrarUnidades(), null);
731
                        pUnidades.add(getChbSobreUnidades(), null);
732
                }
733

    
734
                return pUnidades;
735
        }
736

    
737
        /**
738
         * This method initializes chbSobreDescripcion
739
         *
740
         * @return javax.swing.JCheckBox
741
         */
742
        private JCheckBox getChbSobreDescripcion() {
743
                if (chbSobreDescripcion == null) {
744
                        chbSobreDescripcion = new JCheckBox();
745
                        chbSobreDescripcion.setSelected(fframescalebar.isAboveDescription());
746
                        chbSobreDescripcion.setPreferredSize(new java.awt.Dimension(180,24));
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
                        FlowLayout flowLayout2 = new FlowLayout();
793
                        flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
794
                        pEtiquetas = new JPanel();
795
                        pEtiquetas.setLayout(flowLayout2);
796
                        pEtiquetas.setBorder(javax.swing.BorderFactory.createTitledBorder(
797
                                        null, PluginServices.getText(this, "etiquetas"),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));
798
                        pEtiquetas.setBounds(276, 235, 204, 104);
799
                        pEtiquetas.add(getChbEtiquetas(), null);
800
                        pEtiquetas.add(getJPanel2(), null);
801
                }
802

    
803
                return pEtiquetas;
804
        }
805

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

    
818
                return chbEtiquetas;
819
        }
820

    
821
        /**
822
         * This method initializes pBarra
823
         *
824
         * @return javax.swing.JPanel
825
         */
826
        private JPanel getPBarra() {
827
                if (pBarra == null) {
828
                        FlowLayout flowLayout3 = new FlowLayout();
829
                        flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
830
                        lblNumDec = new JLabel();
831
                        lblNumDec.setText(PluginServices.getText(this,"numero_decimales_mostrar"));
832
                        lblBarColor = new JLabel();
833
                        lblBarColor.setText(PluginServices.getText(this,"color"));
834
                        pBarra = new JPanel();
835
                        pBarra.setLayout(flowLayout3);
836
                        pBarra.setBounds(8, 98, 263, 241);
837
                        pBarra.setBorder(javax.swing.BorderFactory.createTitledBorder(
838
                                        null, PluginServices.getText(this,"barra"),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));
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
                }
849

    
850
                return pBarra;
851
        }
852

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

    
866
                return jPanel5;
867
        }
868

    
869
        /**
870
         * This method initializes jPanel6
871
         *
872
         * @return javax.swing.JPanel
873
         */
874
        private JPanel getJPanel6() {
875
                if (jPanel6 == null) {
876
                        jPanel6 = new JPanel();
877
                        jPanel6.setPreferredSize(new java.awt.Dimension(245,30));
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.setPreferredSize(new java.awt.Dimension(245,30));
894
                        jPanel7.add(getLNumIntervalos(), null);
895
                        jPanel7.add(getTNumIntervalos(), null);
896
                }
897

    
898
                return jPanel7;
899
        }
900

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

    
919
                return bUnidadesColor;
920
        }
921

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

    
945
//                                                bBarraColor.setBackground(barcolor);
946
//                                                bBarraColor.setForeground(barcolor);
947
                                        }
948
                                });
949
                }
950

    
951
                return bBarraColor;
952
        }
953

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

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

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

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

    
987
        /**
988
         * This method initializes jPanel2
989
         *
990
         * @return javax.swing.JPanel
991
         */
992
        private JPanel getJPanel2() {
993
                if (jPanel2 == null) {
994
                        jPanel2 = new JPanel();
995
                        jPanel2.add(getBFuente(), 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.setPreferredSize(new java.awt.Dimension(180,24));
1014
                        jCheckBox.setText(PluginServices.getText(this,"mostrar_escala_numerica"));
1015
                }
1016

    
1017
                return jCheckBox;
1018
        }
1019

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

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

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

    
1056
                        return this;
1057
                }
1058
        }
1059

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

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