Statistics
| Revision:

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

History | View | Annotate | Download (31.7 KB)

1
/*
2
 * Created on 02-jun-2004
3
 *
4
 */
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
package com.iver.cit.gvsig.project.documents.layout.fframes.gui.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.layout.Layout;
52
import com.iver.cit.gvsig.gui.layout.fframes.FFrameScaleBar;
53
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView;
54
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
55
import com.iver.cit.gvsig.gui.utils.FontChooser;
56
import com.iver.cit.gvsig.project.documents.layout.Attributes;
57
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities;
58
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
59
import com.iver.cit.gvsig.project.documents.layout.fframes.ListViewModel;
60
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.JPRotation;
61

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

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

    
80

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

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

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

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

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

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

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

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

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

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

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

    
225
                return jContentPane;
226
        }
227

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

    
240
                return jScrollPane;
241
        }
242

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

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

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

    
257
                        liVistas.setModel(listmodel);
258

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

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

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

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

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

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

    
310
                return liVistas;
311
        }
312

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

    
333
                return chbMantenerIntervalo;
334
        }
335

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

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

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

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

    
402
                return cbEscala;
403
        }
404

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

    
425
                return cbUnidades;
426
        }
427

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

    
440
                return lIntervalo;
441
        }
442

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

    
465
                return tIntervalo;
466
        }
467

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

    
480
                return lNumIntervalos;
481
        }
482

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

    
505
                return tNumIntervalos;
506
        }
507

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

    
521
                return lDivIzquierda;
522
        }
523

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

    
546
                return tDivIzquierda;
547
        }
548

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

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

    
589
                return bAceptar;
590
        }
591

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

    
611
                return bCancelar;
612
        }
613

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

    
622
                return m_viewinfo;
623
        }
624

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

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

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

    
656
                return bFuente;
657
        }
658

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

    
675
                return pMarcoVista;
676
        }
677

    
678
        /**
679
         * This method initializes pDescripcion
680
         *
681
         * @return javax.swing.JPanel
682
         */
683
        private JPanel getPDescripcion() {
684
                if (pDescripcion == null) {
685
                        pDescripcion = new JPanel();
686
                        pDescripcion.setBounds(256, 9, 216, 110);
687
                        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));
688
                        pDescripcion.add(getTfNumberScale(), null);
689
                        pDescripcion.add(getJCheckBox(), null);
690
                        pDescripcion.add(getChbSobreDescripcion(), null);
691
                }
692

    
693
                return pDescripcion;
694
        }
695

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

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

    
714
                return tfDescripcion;
715
        }
716

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

    
736
                return pUnidades;
737
        }
738

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

    
751
                return chbSobreDescripcion;
752
        }
753

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

    
767
                return chbMostrarUnidades;
768
        }
769

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

    
783
                return chbSobreUnidades;
784
        }
785

    
786
        /**
787
         * This method initializes pEtiquetas
788
         *
789
         * @return javax.swing.JPanel
790
         */
791
        private JPanel getPEtiquetas() {
792
                if (pEtiquetas == null) {
793
                        pEtiquetas = new JPanel();
794
                        pEtiquetas.setBorder(javax.swing.BorderFactory.createTitledBorder(
795
                                        null, PluginServices.getText(this, "etiquetas"),
796
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
797
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
798
                        pEtiquetas.setBounds(257, 246, 216, 93);
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
                        lblNumDec = new JLabel();
829
                        lblNumDec.setText("numero_decimales_mostrar");
830
                        lblBarColor = new JLabel();
831
                        lblBarColor.setText(PluginServices.getText(this,"color"));
832
                        pBarra = new JPanel();
833
                        pBarra.setBounds(8, 104, 240, 235);
834
                        pBarra.setBorder(javax.swing.BorderFactory.createTitledBorder(
835
                                        null, PluginServices.getText(this,"barra"),
836
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
837
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
838
                        pBarra.add(getChbMantenerIntervalo(), null);
839
                        pBarra.add(getCbEscala(), null);
840
                        pBarra.add(lblNumDec, null);
841
                        pBarra.add(getNumDec(), null);
842
                        pBarra.add(getJPanel5(), null);
843
                        pBarra.add(getJPanel7(), null);
844
                        pBarra.add(getJPanel6(), null);
845
                        pBarra.add(lblBarColor, null);
846
                        pBarra.add(getBBarraColor(), null);
847
                        //pBarra.add(getJPanel(), 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(200, 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.add(getLDivIzquierda(), null);
878
                        jPanel6.add(getTDivIzquierda(), null);
879
                }
880

    
881
                return jPanel6;
882
        }
883

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

    
896
                return jPanel7;
897
        }
898

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

    
917
                return bUnidadesColor;
918
        }
919

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

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

    
949
                return bBarraColor;
950
        }
951

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

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

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

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

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

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

    
1002
                return jPanel2;
1003
        }
1004

    
1005
        /**
1006
         * This method initializes jCheckBox
1007
         *
1008
         * @return javax.swing.JCheckBox
1009
         */
1010
        private JCheckBox getJCheckBox() {
1011
                if (jCheckBox == null) {
1012
                        jCheckBox = new JCheckBox();
1013
                        jCheckBox.setSelected(fframescalebar.isShowDescription());
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"