Statistics
| Revision:

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

History | View | Annotate | Download (33.2 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
import java.text.ParseException;
54

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

    
63
import com.iver.andami.PluginServices;
64
import com.iver.andami.ui.mdiManager.WindowInfo;
65
import com.iver.cit.gvsig.AddLayer;
66
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
67
import com.iver.cit.gvsig.gui.utils.FontChooser;
68
import com.iver.cit.gvsig.project.documents.layout.Attributes;
69
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities;
70
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameScaleBar;
71
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameView;
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
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
76

    
77

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

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

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

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

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

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

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

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

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

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

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

    
223
                return jContentPane;
224
        }
225

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

    
238
                return jScrollPane;
239
        }
240

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

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

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

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

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

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

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

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

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

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

    
309
                return liVistas;
310
        }
311

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

    
332
                return chbMantenerIntervalo;
333
        }
334

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

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

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

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

    
405
                return cbEscala;
406
        }
407

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

    
428
                return cbUnidades;
429
        }
430

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

    
443
                return lIntervalo;
444
        }
445

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

    
472
                return tIntervalo;
473
        }
474

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

    
487
                return lNumIntervalos;
488
        }
489

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

    
512
                return tNumIntervalos;
513
        }
514

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

    
528
                return lDivIzquierda;
529
        }
530

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

    
553
                return tDivIzquierda;
554
        }
555

    
556
        /**
557
         * This method initializes bAceptar
558
         *
559
         * @return javax.swing.JButton
560
         */
561
        private javax.swing.JButton getBAceptar() {
562
                if (bAceptar == null) {
563
                        bAceptar = new javax.swing.JButton();
564
                        bAceptar.setSize(85, 26);
565
                        bAceptar.setText(PluginServices.getText(this, "Aceptar"));
566
                        bAceptar.setLocation(106, 347);
567
                        bAceptar.setPreferredSize(new java.awt.Dimension(79, 23));
568
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
569
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
570
                                                fframescalebar.setUnits(getCbUnidades()
571
                                                                                                        .getSelectedIndex());
572
                                                fframescalebar.setBoundBox(FLayoutUtilities.toSheetRect(
573
                                                                rect, m_layout.getLayoutControl().getAT()));
574
                                                fframescalebar.setFFrameDependence(fframeview);
575
                                                fframescalebar.setBarColor(barcolor);
576
                                                fframescalebar.setTextColor(textcolor);
577
                                                fframescalebar.setShowNameUnits(getChbMostrarUnidades()
578
                                                                                                                        .isSelected());
579
                                                fframescalebar.setShowDescription(getJCheckBox()
580
                                                                                                                          .isSelected());
581
                                                fframescalebar.setAboveDescription(getChbSobreDescripcion()
582
                                                                                                                           .isSelected());
583
                                                fframescalebar.setAboveIntervals(getChbEtiquetas()
584
                                                                                                                         .isSelected());
585
                                                fframescalebar.setAboveName(getChbSobreUnidades()
586
                                                                                                                .isSelected());
587
                                                fframescalebar.setRotation(getPRotation().getRotation());
588
                                                fframescalebar.setNumDec(Integer.parseInt(getNumDec().getText()));
589
                                                PluginServices.getMDIManager().closeWindow(FFrameScaleBarDialog.this);
590
                                                //m_layout.refresh();
591
                                                isAcepted = true;
592
                                        }
593
                                });
594
                }
595

    
596
                return bAceptar;
597
        }
598

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

    
619
                return bCancelar;
620
        }
621

    
622
        /* (non-Javadoc)
623
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
624
         */
625
        public WindowInfo getWindowInfo() {
626
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
627
                m_viewinfo.setTitle(PluginServices.getText(this,
628
                                "Propiedades_escala_grafica"));
629

    
630
                return m_viewinfo;
631
        }
632

    
633
        /**
634
         * @see com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
635
         */
636
        public boolean getIsAcepted() {
637
                return isAcepted;
638
        }
639

    
640
        /**
641
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
642
         */
643
        public void viewActivated() {
644
        }
645

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

    
664
                return bFuente;
665
        }
666

    
667
        /**
668
         * This method initializes pMarcoVista
669
         *
670
         * @return javax.swing.JPanel
671
         */
672
        private JPanel getPMarcoVista() {
673
                if (pMarcoVista == null) {
674
                        pMarcoVista = new JPanel();
675
                        pMarcoVista.setBounds(7, 9, 263, 86);
676
                        pMarcoVista.setBorder(javax.swing.BorderFactory.createTitledBorder(
677
                                        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));
678
                        pMarcoVista.add(getJScrollPane(), null);
679
                }
680

    
681
                return pMarcoVista;
682
        }
683

    
684
        /**
685
         * This method initializes pDescripcion
686
         *
687
         * @return javax.swing.JPanel
688
         */
689
        private JPanel getPDescripcion() {
690
                if (pDescripcion == null) {
691
                        FlowLayout flowLayout1 = new FlowLayout();
692
                        flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
693
                        pDescripcion = new JPanel();
694
                        pDescripcion.setLayout(flowLayout1);
695
                        pDescripcion.setBounds(275, 9, 204, 110);
696
                        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));
697
                        pDescripcion.add(getTfNumberScale(), null);
698
                        pDescripcion.add(getJCheckBox(), null);
699
                        pDescripcion.add(getChbSobreDescripcion(), null);
700
                }
701

    
702
                return pDescripcion;
703
        }
704

    
705
        /**
706
         * This method initializes tfDescripcion
707
         *
708
         * @return javax.swing.JTextField
709
         */
710
        private JTextField getTfNumberScale() {
711
                if (tfDescripcion == null) {
712
                        tfDescripcion = new JTextField();
713
                        tfDescripcion.setPreferredSize(new java.awt.Dimension(180,20));
714

    
715
                        tfDescripcion.setEditable(false);
716
                        /*if (fframeview!=null){
717
                           getTfDescripcion().setText("escala 1:"+String.valueOf(fframeview.getScale()));
718
                           }
719
                         */
720
                        tfDescripcion.setText(fframescalebar.getDescription());
721
                }
722

    
723
                return tfDescripcion;
724
        }
725

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

    
746
                return pUnidades;
747
        }
748

    
749
        /**
750
         * This method initializes chbSobreDescripcion
751
         *
752
         * @return javax.swing.JCheckBox
753
         */
754
        private JCheckBox getChbSobreDescripcion() {
755
                if (chbSobreDescripcion == null) {
756
                        chbSobreDescripcion = new JCheckBox();
757
                        chbSobreDescripcion.setSelected(fframescalebar.isAboveDescription());
758
                        chbSobreDescripcion.setPreferredSize(new java.awt.Dimension(180,24));
759
                        chbSobreDescripcion.setText(PluginServices.getText(this,"sobre_la_barra"));
760
                }
761

    
762
                return chbSobreDescripcion;
763
        }
764

    
765
        /**
766
         * This method initializes chbMostrarUnidades
767
         *
768
         * @return javax.swing.JCheckBox
769
         */
770
        private JCheckBox getChbMostrarUnidades() {
771
                if (chbMostrarUnidades == null) {
772
                        chbMostrarUnidades = new JCheckBox();
773
                        chbMostrarUnidades.setText(PluginServices.getText(this,"mostrar_unidades"));
774
                        chbMostrarUnidades.setSelected(fframescalebar.isShowNameUnits());
775
                        chbMostrarUnidades.setPreferredSize(new java.awt.Dimension(150, 24));
776
                }
777

    
778
                return chbMostrarUnidades;
779
        }
780

    
781
        /**
782
         * This method initializes chbSobreUnidades
783
         *
784
         * @return javax.swing.JCheckBox
785
         */
786
        private JCheckBox getChbSobreUnidades() {
787
                if (chbSobreUnidades == null) {
788
                        chbSobreUnidades = new JCheckBox();
789
                        chbSobreUnidades.setSelected(fframescalebar.isAboveName());
790
                        chbSobreUnidades.setText(PluginServices.getText(this,"sobre_la_barra"));
791
                        chbSobreUnidades.setPreferredSize(new java.awt.Dimension(150, 24));
792
                }
793

    
794
                return chbSobreUnidades;
795
        }
796

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

    
815
                return pEtiquetas;
816
        }
817

    
818
        /**
819
         * This method initializes chbEtiquetas
820
         *
821
         * @return javax.swing.JCheckBox
822
         */
823
        private JCheckBox getChbEtiquetas() {
824
                if (chbEtiquetas == null) {
825
                        chbEtiquetas = new JCheckBox();
826
                        chbEtiquetas.setSelected(fframescalebar.isAboveIntervals());
827
                        chbEtiquetas.setText(PluginServices.getText(this,"sobre_la_barra"));
828
                }
829

    
830
                return chbEtiquetas;
831
        }
832

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

    
862
                return pBarra;
863
        }
864

    
865
        /**
866
         * This method initializes jPanel5
867
         *
868
         * @return javax.swing.JPanel
869
         */
870
        private JPanel getJPanel5() {
871
                if (jPanel5 == null) {
872
                        jPanel5 = new JPanel();
873
                        jPanel5.setPreferredSize(new java.awt.Dimension(245,30));
874
                        jPanel5.add(getLIntervalo(), null);
875
                        jPanel5.add(getTIntervalo(), null);
876
                }
877

    
878
                return jPanel5;
879
        }
880

    
881
        /**
882
         * This method initializes jPanel6
883
         *
884
         * @return javax.swing.JPanel
885
         */
886
        private JPanel getJPanel6() {
887
                if (jPanel6 == null) {
888
                        jPanel6 = new JPanel();
889
                        jPanel6.setPreferredSize(new java.awt.Dimension(245,30));
890
                        jPanel6.add(getLDivIzquierda(), null);
891
                        jPanel6.add(getTDivIzquierda(), null);
892
                }
893

    
894
                return jPanel6;
895
        }
896

    
897
        /**
898
         * This method initializes jPanel7
899
         *
900
         * @return javax.swing.JPanel
901
         */
902
        private JPanel getJPanel7() {
903
                if (jPanel7 == null) {
904
                        jPanel7 = new JPanel();
905
                        jPanel7.setPreferredSize(new java.awt.Dimension(245,30));
906
                        jPanel7.add(getLNumIntervalos(), null);
907
                        jPanel7.add(getTNumIntervalos(), null);
908
                }
909

    
910
                return jPanel7;
911
        }
912

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

    
931
                return bUnidadesColor;
932
        }
933

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

    
957
//                                                bBarraColor.setBackground(barcolor);
958
//                                                bBarraColor.setForeground(barcolor);
959
                                        }
960
                                });
961
                }
962

    
963
                return bBarraColor;
964
        }
965

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

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

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

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

    
999
        /**
1000
         * This method initializes jPanel2
1001
         *
1002
         * @return javax.swing.JPanel
1003
         */
1004
        private JPanel getJPanel2() {
1005
                if (jPanel2 == null) {
1006
                        jPanel2 = new JPanel();
1007
                        jPanel2.add(getBFuente(), null);
1008
                        jPanel2.add(getBUnidadesColor(), null);
1009

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

    
1013
                return jPanel2;
1014
        }
1015

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

    
1029
                return jCheckBox;
1030
        }
1031

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

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

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

    
1068
                        return this;
1069
                }
1070
        }
1071

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

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

    
1109
        public IFFrame getFFrame() {
1110
                return fframescalebar;
1111
        }
1112
} //  @jve:decl-index=0:visual-constraint="17,10"
1113
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"