Statistics
| Revision:

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

History | View | Annotate | Download (32.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 java.awt.Color;
48
import java.awt.Component;
49
import java.awt.Dimension;
50
import java.awt.FlowLayout;
51
import java.awt.event.KeyEvent;
52
import java.awt.geom.Rectangle2D;
53

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

    
62
import com.iver.andami.PluginServices;
63
import com.iver.andami.ui.mdiManager.WindowInfo;
64
import com.iver.cit.gvsig.AddLayer;
65
import com.iver.cit.gvsig.gui.layout.Attributes;
66
import com.iver.cit.gvsig.gui.layout.Layout;
67
import com.iver.cit.gvsig.gui.layout.fframes.FFrameScaleBar;
68
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView;
69
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
70
import com.iver.cit.gvsig.gui.utils.FontChooser;
71
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities;
72
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
73
import com.iver.cit.gvsig.project.documents.layout.fframes.ListViewModel;
74
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.JPRotation;
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
                        getJCheckBox().setEnabled(false);
195
                        getChbSobreDescripcion().setEnabled(false);
196
                }
197
                getPRotation().setRotation(fframescalebar.getRotation());
198
        }
199

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

    
222
                return jContentPane;
223
        }
224

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

    
237
                return jScrollPane;
238
        }
239

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

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

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

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

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

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

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

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

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

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

    
308
                return liVistas;
309
        }
310

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

    
331
                return chbMantenerIntervalo;
332
        }
333

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

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

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

    
369
                                                if (cbEscala.getSelectedIndex() == 0) {
370
                                                        getChbMantenerIntervalo().setEnabled(false);
371
                                                        getChbMostrarUnidades().setEnabled(false);
372
                                                        getChbSobreUnidades().setEnabled(false);
373
                                                        getCbUnidades().setEnabled(false);
374
                                                        getChbEtiquetas().setEnabled(false);
375
                                                        getBBarraColor().setEnabled(false);
376
                                                        getLIntervalo().setEnabled(false);
377
                                                        getTIntervalo().setEnabled(false);
378
                                                        getLNumIntervalos().setEnabled(false);
379
                                                        getTNumIntervalos().setEnabled(false);
380
                                                        getLDivIzquierda().setEnabled(false);
381
                                                        getTDivIzquierda().setEnabled(false);
382
                                                        getJCheckBox().setEnabled(false);
383
                                                        getChbSobreDescripcion().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
                                                        getJCheckBox().setEnabled(true);
398
                                                        getChbSobreDescripcion().setEnabled(true);
399
                                                }
400
                                        }
401
                                });
402
                }
403

    
404
                return cbEscala;
405
        }
406

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

    
427
                return cbUnidades;
428
        }
429

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

    
442
                return lIntervalo;
443
        }
444

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

    
467
                return tIntervalo;
468
        }
469

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

    
482
                return lNumIntervalos;
483
        }
484

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

    
507
                return tNumIntervalos;
508
        }
509

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

    
523
                return lDivIzquierda;
524
        }
525

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

    
548
                return tDivIzquierda;
549
        }
550

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

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

    
591
                return bAceptar;
592
        }
593

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

    
613
                return bCancelar;
614
        }
615

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

    
624
                return m_viewinfo;
625
        }
626

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

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

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

    
658
                return bFuente;
659
        }
660

    
661
        /**
662
         * This method initializes pMarcoVista
663
         *
664
         * @return javax.swing.JPanel
665
         */
666
        private JPanel getPMarcoVista() {
667
                if (pMarcoVista == null) {
668
                        pMarcoVista = new JPanel();
669
                        pMarcoVista.setBounds(7, 9, 263, 86);
670
                        pMarcoVista.setBorder(javax.swing.BorderFactory.createTitledBorder(
671
                                        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));
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
                        FlowLayout flowLayout1 = new FlowLayout();
686
                        flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
687
                        pDescripcion = new JPanel();
688
                        pDescripcion.setLayout(flowLayout1);
689
                        pDescripcion.setBounds(275, 9, 204, 110);
690
                        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));
691
                        pDescripcion.add(getTfNumberScale(), null);
692
                        pDescripcion.add(getJCheckBox(), null);
693
                        pDescripcion.add(getChbSobreDescripcion(), null);
694
                }
695

    
696
                return pDescripcion;
697
        }
698

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

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

    
717
                return tfDescripcion;
718
        }
719

    
720
        /**
721
         * This method initializes pUnidades
722
         *
723
         * @return javax.swing.JPanel
724
         */
725
        private JPanel getPUnidades() {
726
                if (pUnidades == null) {
727
                        FlowLayout flowLayout = new FlowLayout();
728
                        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
729
                        pUnidades = new JPanel();
730
                        pUnidades.setLayout(flowLayout);
731
                        pUnidades.setLocation(274, 122);
732
                        pUnidades.setSize(204, 110);
733
                        pUnidades.setBorder(javax.swing.BorderFactory.createTitledBorder(
734
                                        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));
735
                        pUnidades.add(getCbUnidades(), null);
736
                        pUnidades.add(getChbMostrarUnidades(), null);
737
                        pUnidades.add(getChbSobreUnidades(), null);
738
                }
739

    
740
                return pUnidades;
741
        }
742

    
743
        /**
744
         * This method initializes chbSobreDescripcion
745
         *
746
         * @return javax.swing.JCheckBox
747
         */
748
        private JCheckBox getChbSobreDescripcion() {
749
                if (chbSobreDescripcion == null) {
750
                        chbSobreDescripcion = new JCheckBox();
751
                        chbSobreDescripcion.setSelected(fframescalebar.isAboveDescription());
752
                        chbSobreDescripcion.setPreferredSize(new java.awt.Dimension(180,24));
753
                        chbSobreDescripcion.setText(PluginServices.getText(this,"sobre_la_barra"));
754
                }
755

    
756
                return chbSobreDescripcion;
757
        }
758

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

    
772
                return chbMostrarUnidades;
773
        }
774

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

    
788
                return chbSobreUnidades;
789
        }
790

    
791
        /**
792
         * This method initializes pEtiquetas
793
         *
794
         * @return javax.swing.JPanel
795
         */
796
        private JPanel getPEtiquetas() {
797
                if (pEtiquetas == null) {
798
                        FlowLayout flowLayout2 = new FlowLayout();
799
                        flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
800
                        pEtiquetas = new JPanel();
801
                        pEtiquetas.setLayout(flowLayout2);
802
                        pEtiquetas.setBorder(javax.swing.BorderFactory.createTitledBorder(
803
                                        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));
804
                        pEtiquetas.setBounds(276, 235, 204, 104);
805
                        pEtiquetas.add(getChbEtiquetas(), null);
806
                        pEtiquetas.add(getJPanel2(), null);
807
                }
808

    
809
                return pEtiquetas;
810
        }
811

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

    
824
                return chbEtiquetas;
825
        }
826

    
827
        /**
828
         * This method initializes pBarra
829
         *
830
         * @return javax.swing.JPanel
831
         */
832
        private JPanel getPBarra() {
833
                if (pBarra == null) {
834
                        FlowLayout flowLayout3 = new FlowLayout();
835
                        flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
836
                        lblNumDec = new JLabel();
837
                        lblNumDec.setText(PluginServices.getText(this,"numero_decimales_mostrar"));
838
                        lblBarColor = new JLabel();
839
                        lblBarColor.setText(PluginServices.getText(this,"color"));
840
                        pBarra = new JPanel();
841
                        pBarra.setLayout(flowLayout3);
842
                        pBarra.setBounds(8, 98, 263, 241);
843
                        pBarra.setBorder(javax.swing.BorderFactory.createTitledBorder(
844
                                        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));
845
                        pBarra.add(getChbMantenerIntervalo(), null);
846
                        pBarra.add(getCbEscala(), null);
847
                        pBarra.add(lblNumDec, null);
848
                        pBarra.add(getNumDec(), null);
849
                        pBarra.add(getJPanel5(), null);
850
                        pBarra.add(getJPanel7(), null);
851
                        pBarra.add(getJPanel6(), null);
852
                        pBarra.add(lblBarColor, null);
853
                        pBarra.add(getBBarraColor(), null);
854
                }
855

    
856
                return pBarra;
857
        }
858

    
859
        /**
860
         * This method initializes jPanel5
861
         *
862
         * @return javax.swing.JPanel
863
         */
864
        private JPanel getJPanel5() {
865
                if (jPanel5 == null) {
866
                        jPanel5 = new JPanel();
867
                        jPanel5.setPreferredSize(new java.awt.Dimension(245,30));
868
                        jPanel5.add(getLIntervalo(), null);
869
                        jPanel5.add(getTIntervalo(), null);
870
                }
871

    
872
                return jPanel5;
873
        }
874

    
875
        /**
876
         * This method initializes jPanel6
877
         *
878
         * @return javax.swing.JPanel
879
         */
880
        private JPanel getJPanel6() {
881
                if (jPanel6 == null) {
882
                        jPanel6 = new JPanel();
883
                        jPanel6.setPreferredSize(new java.awt.Dimension(245,30));
884
                        jPanel6.add(getLDivIzquierda(), null);
885
                        jPanel6.add(getTDivIzquierda(), null);
886
                }
887

    
888
                return jPanel6;
889
        }
890

    
891
        /**
892
         * This method initializes jPanel7
893
         *
894
         * @return javax.swing.JPanel
895
         */
896
        private JPanel getJPanel7() {
897
                if (jPanel7 == null) {
898
                        jPanel7 = new JPanel();
899
                        jPanel7.setPreferredSize(new java.awt.Dimension(245,30));
900
                        jPanel7.add(getLNumIntervalos(), null);
901
                        jPanel7.add(getTNumIntervalos(), null);
902
                }
903

    
904
                return jPanel7;
905
        }
906

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

    
925
                return bUnidadesColor;
926
        }
927

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

    
951
//                                                bBarraColor.setBackground(barcolor);
952
//                                                bBarraColor.setForeground(barcolor);
953
                                        }
954
                                });
955
                }
956

    
957
                return bBarraColor;
958
        }
959

    
960
        /**
961
         * This method initializes jPanel
962
         *
963
         * @return javax.swing.JPanel
964
         */
965

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

    
977
        /**
978
         * This method initializes jPanel1
979
         *
980
         * @return javax.swing.JPanel
981
         */
982

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

    
993
        /**
994
         * This method initializes jPanel2
995
         *
996
         * @return javax.swing.JPanel
997
         */
998
        private JPanel getJPanel2() {
999
                if (jPanel2 == null) {
1000
                        jPanel2 = new JPanel();
1001
                        jPanel2.add(getBFuente(), null);
1002
                        jPanel2.add(getBUnidadesColor(), null);
1003

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

    
1007
                return jPanel2;
1008
        }
1009

    
1010
        /**
1011
         * This method initializes jCheckBox
1012
         *
1013
         * @return javax.swing.JCheckBox
1014
         */
1015
        private JCheckBox getJCheckBox() {
1016
                if (jCheckBox == null) {
1017
                        jCheckBox = new JCheckBox();
1018
                        jCheckBox.setSelected(fframescalebar.isShowDescription());
1019
                        jCheckBox.setPreferredSize(new java.awt.Dimension(180,24));
1020
                        jCheckBox.setText(PluginServices.getText(this,"mostrar_escala_numerica"));
1021
                }
1022

    
1023
                return jCheckBox;
1024
        }
1025

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

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

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

    
1062
                        return this;
1063
                }
1064
        }
1065

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

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