Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / gui / dialogs / FFrameScaleBarDialog.java @ 24962

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 org.gvsig.fmap.mapcontext.MapContext;
64

    
65
import com.iver.andami.PluginServices;
66
import com.iver.andami.ui.mdiManager.WindowInfo;
67
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
68
import com.iver.cit.gvsig.gui.utils.FontChooser;
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 = PluginServices.getIconTheme()
85
                .get("numero-icon");
86

    
87
        private static final ImageIcon ibarra1 = PluginServices.getIconTheme()
88
                .get("barra1-icon");
89

    
90
        private static final ImageIcon ibarra2 = PluginServices.getIconTheme()
91
                .get("barra2-icon");
92

    
93
        private static final ImageIcon ibarra3 = PluginServices.getIconTheme()
94
                .get("barra3-icon");
95

    
96
        private javax.swing.JPanel jContentPane = null;
97
        private javax.swing.JScrollPane jScrollPane = null;
98
        private javax.swing.JList liVistas = null;
99
        private javax.swing.JCheckBox chbMantenerIntervalo = null;
100
        private javax.swing.JComboBox cbEscala = null;
101
        private javax.swing.JComboBox cbUnidades = null;
102
        private javax.swing.JLabel lIntervalo = null;
103
        private javax.swing.JTextField tIntervalo = null;
104
        private javax.swing.JLabel lNumIntervalos = null;
105
        private javax.swing.JTextField tNumIntervalos = null;
106
        private javax.swing.JLabel lDivIzquierda = null;
107
        private javax.swing.JTextField tDivIzquierda = null;
108
        private javax.swing.JButton bAceptar = null;
109
        private javax.swing.JButton bCancelar = null;
110

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

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

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

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

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

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

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

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

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

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

    
227
                return jContentPane;
228
        }
229

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

    
242
                return jScrollPane;
243
        }
244

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

    
255
                        ///ArrayList list = listmodel.getViews();
256

    
257
                        liVistas = new javax.swing.JList();
258

    
259
                        liVistas.setSize(new java.awt.Dimension(250,52));
260
                        liVistas.setModel(listmodel);
261

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

    
266
                                        if (fframeview == fframescalebar.getFFrameDependence()[0]) {
267
                                                liVistas.setSelectedIndex(i);
268
                                        }
269
                                }
270
                        }
271

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

    
286
                                                                for (int i = 0; i < fframes.length; i++) {
287
                                                                        IFFrame f = fframes[i];
288

    
289
                                                                        if (f instanceof FFrameView) {
290
                                                                                if (((FFrameView) f).getView() == fframeview
291
                                                                                                .getView()) {
292
                                                                                        fframescalebar
293
                                                                                                        .setFFrameDependence(fframeview);
294
                                                                                }
295
                                                                        }
296
                                                                }
297

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

    
313
                return liVistas;
314
        }
315

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

    
336
                return chbMantenerIntervalo;
337
        }
338

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

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

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

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

    
409
                return cbEscala;
410
        }
411

    
412
        /**
413
         * This method initializes cbUnidades
414
         *
415
         * @return javax.swing.JComboBox
416
         */
417
        private javax.swing.JComboBox getCbUnidades() {
418
                if (cbUnidades == null) {
419
                        //String[] s={"Kil�metros","metros","cent�metros","mil�metros","millas","yardas","pies","pulgadas"};
420
                        String[] names = MapContext.getDistanceNames();
421
                        for (int i = 0; i < names.length; i++) {
422
                                names[i]=PluginServices.getText(this,names[i]);
423
                        }
424
                        cbUnidades = new javax.swing.JComboBox(names);
425
                        cbUnidades.setSelectedIndex(fframescalebar.getUnits());
426
                        cbUnidades.setPreferredSize(new java.awt.Dimension(150, 20));
427
                        cbUnidades.addActionListener(new java.awt.event.ActionListener() {
428
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
429
                                                fframescalebar.setUnits(getCbUnidades()
430
                                                                                                        .getSelectedIndex());
431
                                                getTIntervalo().setText(fframescalebar.obtainInterval());
432
                                        }
433
                                });
434
                }
435

    
436
                return cbUnidades;
437
        }
438

    
439
        /**
440
         * This method initializes lIntervalo
441
         *
442
         * @return javax.swing.JLabel
443
         */
444
        private javax.swing.JLabel getLIntervalo() {
445
                if (lIntervalo == null) {
446
                        lIntervalo = new javax.swing.JLabel();
447
                        lIntervalo.setText(PluginServices.getText(this, "Intervalo"));
448
                        lIntervalo.setPreferredSize(new java.awt.Dimension(155,20));
449
                }
450

    
451
                return lIntervalo;
452
        }
453

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

    
480
                return tIntervalo;
481
        }
482

    
483
        /**
484
         * This method initializes lNumIntervalos
485
         *
486
         * @return javax.swing.JLabel
487
         */
488
        private javax.swing.JLabel getLNumIntervalos() {
489
                if (lNumIntervalos == null) {
490
                        lNumIntervalos = new javax.swing.JLabel();
491
                        lNumIntervalos.setText(PluginServices.getText(this, "Num_intervalos"));
492
                        lNumIntervalos.setPreferredSize(new java.awt.Dimension(155,20));
493
                }
494

    
495
                return lNumIntervalos;
496
        }
497

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

    
520
                return tNumIntervalos;
521
        }
522

    
523
        /**
524
         * This method initializes lDivIzquierda
525
         *
526
         * @return javax.swing.JLabel
527
         */
528
        private javax.swing.JLabel getLDivIzquierda() {
529
                if (lDivIzquierda == null) {
530
                        lDivIzquierda = new javax.swing.JLabel();
531
                        lDivIzquierda.setText(PluginServices.getText(this,
532
                                        "divisiones_izquierda"));
533
                        lDivIzquierda.setPreferredSize(new java.awt.Dimension(155,20));
534
                }
535

    
536
                return lDivIzquierda;
537
        }
538

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

    
561
                return tDivIzquierda;
562
        }
563

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

    
605
                return bAceptar;
606
        }
607

    
608
        /**
609
         * This method initializes bCancelar
610
         *
611
         * @return javax.swing.JButton
612
         */
613
        private javax.swing.JButton getBCancelar() {
614
                if (bCancelar == null) {
615
                        bCancelar = new javax.swing.JButton();
616
                        bCancelar.setSize(85, 26);
617
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
618
                        bCancelar.setLocation(297, 347);
619
                        bCancelar.setPreferredSize(new java.awt.Dimension(85, 23));
620
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
621
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
622
                                                fframescalebar=null;
623
                                                PluginServices.getMDIManager().closeWindow(FFrameScaleBarDialog.this);
624
                                        }
625
                                });
626
                }
627

    
628
                return bCancelar;
629
        }
630

    
631
        /* (non-Javadoc)
632
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
633
         */
634
        public WindowInfo getWindowInfo() {
635
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
636
                m_viewinfo.setTitle(PluginServices.getText(this,
637
                                "Propiedades_escala_grafica"));
638

    
639
                return m_viewinfo;
640
        }
641

    
642
        /**
643
         * @see com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
644
         */
645
        public boolean getIsAcepted() {
646
                return isAcepted;
647
        }
648

    
649
        /**
650
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
651
         */
652
        public void viewActivated() {
653
        }
654

    
655
        /**
656
         * This method initializes bFuente
657
         *
658
         * @return javax.swing.JButton
659
         */
660
        private javax.swing.JButton getBFuente() {
661
                if (bFuente == null) {
662
                        bFuente = new javax.swing.JButton();
663
                        bFuente.setText(PluginServices.getText(this, "fuente"));
664
                        bFuente.addActionListener(new java.awt.event.ActionListener() {
665
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
666
                                                fframescalebar.setFont(FontChooser.showDialog(
667
                                                                PluginServices.getText(this, "seleccion_fuente"),
668
                                                                fframescalebar.getFont())); // fchoser=new FontChooser();
669
                                        }
670
                                });
671
                }
672

    
673
                return bFuente;
674
        }
675

    
676
        /**
677
         * This method initializes pMarcoVista
678
         *
679
         * @return javax.swing.JPanel
680
         */
681
        private JPanel getPMarcoVista() {
682
                if (pMarcoVista == null) {
683
                        pMarcoVista = new JPanel();
684
                        pMarcoVista.setBounds(7, 9, 263, 86);
685
                        pMarcoVista.setBorder(javax.swing.BorderFactory.createTitledBorder(
686
                                        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));
687
                        pMarcoVista.add(getJScrollPane(), null);
688
                }
689

    
690
                return pMarcoVista;
691
        }
692

    
693
        /**
694
         * This method initializes pDescripcion
695
         *
696
         * @return javax.swing.JPanel
697
         */
698
        private JPanel getPDescripcion() {
699
                if (pDescripcion == null) {
700
                        FlowLayout flowLayout1 = new FlowLayout();
701
                        flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
702
                        pDescripcion = new JPanel();
703
                        pDescripcion.setLayout(flowLayout1);
704
                        pDescripcion.setBounds(275, 9, 204, 110);
705
                        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));
706
                        pDescripcion.add(getTfNumberScale(), null);
707
                        pDescripcion.add(getJCheckBox(), null);
708
                        pDescripcion.add(getChbSobreDescripcion(), null);
709
                }
710

    
711
                return pDescripcion;
712
        }
713

    
714
        /**
715
         * This method initializes tfDescripcion
716
         *
717
         * @return javax.swing.JTextField
718
         */
719
        private JTextField getTfNumberScale() {
720
                if (tfDescripcion == null) {
721
                        tfDescripcion = new JTextField();
722
                        tfDescripcion.setPreferredSize(new java.awt.Dimension(180,20));
723

    
724
                        tfDescripcion.setEditable(false);
725
                        /*if (fframeview!=null){
726
                           getTfDescripcion().setText("escala 1:"+String.valueOf(fframeview.getScale()));
727
                           }
728
                         */
729
                        tfDescripcion.setText(fframescalebar.getDescription());
730
                }
731

    
732
                return tfDescripcion;
733
        }
734

    
735
        /**
736
         * This method initializes pUnidades
737
         *
738
         * @return javax.swing.JPanel
739
         */
740
        private JPanel getPUnidades() {
741
                if (pUnidades == null) {
742
                        FlowLayout flowLayout = new FlowLayout();
743
                        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
744
                        pUnidades = new JPanel();
745
                        pUnidades.setLayout(flowLayout);
746
                        pUnidades.setLocation(274, 122);
747
                        pUnidades.setSize(204, 110);
748
                        pUnidades.setBorder(javax.swing.BorderFactory.createTitledBorder(
749
                                        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));
750
                        pUnidades.add(getCbUnidades(), null);
751
                        pUnidades.add(getChbMostrarUnidades(), null);
752
                        pUnidades.add(getChbSobreUnidades(), null);
753
                }
754

    
755
                return pUnidades;
756
        }
757

    
758
        /**
759
         * This method initializes chbSobreDescripcion
760
         *
761
         * @return javax.swing.JCheckBox
762
         */
763
        private JCheckBox getChbSobreDescripcion() {
764
                if (chbSobreDescripcion == null) {
765
                        chbSobreDescripcion = new JCheckBox();
766
                        chbSobreDescripcion.setSelected(fframescalebar.isAboveDescription());
767
                        chbSobreDescripcion.setPreferredSize(new java.awt.Dimension(180,24));
768
                        chbSobreDescripcion.setText(PluginServices.getText(this,"sobre_la_barra"));
769
                }
770

    
771
                return chbSobreDescripcion;
772
        }
773

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

    
787
                return chbMostrarUnidades;
788
        }
789

    
790
        /**
791
         * This method initializes chbSobreUnidades
792
         *
793
         * @return javax.swing.JCheckBox
794
         */
795
        private JCheckBox getChbSobreUnidades() {
796
                if (chbSobreUnidades == null) {
797
                        chbSobreUnidades = new JCheckBox();
798
                        chbSobreUnidades.setSelected(fframescalebar.isAboveName());
799
                        chbSobreUnidades.setText(PluginServices.getText(this,"sobre_la_barra"));
800
                        chbSobreUnidades.setPreferredSize(new java.awt.Dimension(150, 24));
801
                }
802

    
803
                return chbSobreUnidades;
804
        }
805

    
806
        /**
807
         * This method initializes pEtiquetas
808
         *
809
         * @return javax.swing.JPanel
810
         */
811
        private JPanel getPEtiquetas() {
812
                if (pEtiquetas == null) {
813
                        FlowLayout flowLayout2 = new FlowLayout();
814
                        flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
815
                        pEtiquetas = new JPanel();
816
                        pEtiquetas.setLayout(flowLayout2);
817
                        pEtiquetas.setBorder(javax.swing.BorderFactory.createTitledBorder(
818
                                        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));
819
                        pEtiquetas.setBounds(276, 235, 204, 104);
820
                        pEtiquetas.add(getChbEtiquetas(), null);
821
                        pEtiquetas.add(getJPanel2(), null);
822
                }
823

    
824
                return pEtiquetas;
825
        }
826

    
827
        /**
828
         * This method initializes chbEtiquetas
829
         *
830
         * @return javax.swing.JCheckBox
831
         */
832
        private JCheckBox getChbEtiquetas() {
833
                if (chbEtiquetas == null) {
834
                        chbEtiquetas = new JCheckBox();
835
                        chbEtiquetas.setSelected(fframescalebar.isAboveIntervals());
836
                        chbEtiquetas.setText(PluginServices.getText(this,"sobre_la_barra"));
837
                }
838

    
839
                return chbEtiquetas;
840
        }
841

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

    
871
                return pBarra;
872
        }
873

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

    
887
                return jPanel5;
888
        }
889

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

    
903
                return jPanel6;
904
        }
905

    
906
        /**
907
         * This method initializes jPanel7
908
         *
909
         * @return javax.swing.JPanel
910
         */
911
        private JPanel getJPanel7() {
912
                if (jPanel7 == null) {
913
                        jPanel7 = new JPanel();
914
                        jPanel7.setPreferredSize(new java.awt.Dimension(245,30));
915
                        jPanel7.add(getLNumIntervalos(), null);
916
                        jPanel7.add(getTNumIntervalos(), null);
917
                }
918

    
919
                return jPanel7;
920
        }
921

    
922
        /**
923
         * This method initializes bUnidadesColor
924
         *
925
         * @return javax.swing.JButton
926
         */
927
        private ColorChooserPanel getBUnidadesColor() {
928
                if (bUnidadesColor == null) {
929
                        bUnidadesColor = new ColorChooserPanel();
930
                        bUnidadesColor.setAlpha(255);
931
                        bUnidadesColor.setColor(textcolor);
932
                        bUnidadesColor.setPreferredSize(new java.awt.Dimension(100,25));
933
                        bUnidadesColor.addActionListener(new java.awt.event.ActionListener() {
934
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
935
                                                textcolor = getBUnidadesColor().getColor();
936
                                        }
937
                                });
938
                }
939

    
940
                return bUnidadesColor;
941
        }
942

    
943
        /**
944
         * This method initializes bBarraColor
945
         *
946
         * @return javax.swing.JButton
947
         */
948
        private ColorChooserPanel getBBarraColor() {
949
                if (bBarraColor == null) {
950
                        bBarraColor = new ColorChooserPanel();
951
                        bBarraColor.setPreferredSize(new java.awt.Dimension(100,25));
952
                        bBarraColor.setAlpha(255);
953
                        bBarraColor.setColor(barcolor);
954
                        bBarraColor.addActionListener(new java.awt.event.ActionListener() {
955
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
956
//                                                JDialog dlg;
957
//                                                JColorChooser colorChooser;
958
//                                                colorChooser = new JColorChooser();
959
//                                                dlg = JColorChooser.createDialog((JFrame) null,
960
//                                                                PluginServices.getText(this, "Elegir_Color"),
961
//                                                                true, colorChooser, null, null);
962
//                                                dlg.show(true);
963
//
964
                                                barcolor = getBBarraColor().getColor();
965

    
966
//                                                bBarraColor.setBackground(barcolor);
967
//                                                bBarraColor.setForeground(barcolor);
968
                                        }
969
                                });
970
                }
971

    
972
                return bBarraColor;
973
        }
974

    
975
        /**
976
         * This method initializes jPanel
977
         *
978
         * @return javax.swing.JPanel
979
         */
980

    
981
        /*private JPanel getJPanel() {
982
           if (jPanel == null) {
983
                   jPanel = new JPanel();
984
                   jPanel.setPreferredSize(new java.awt.Dimension(44,24));
985
                   jPanel.setForeground(barcolor);
986
                   jPanel.setBackground(barcolor);
987
           }
988
           return jPanel;
989
           }
990
         */
991

    
992
        /**
993
         * This method initializes jPanel1
994
         *
995
         * @return javax.swing.JPanel
996
         */
997

    
998
        /*        private JPanel getJPanel1() {
999
           if (jPanel1 == null) {
1000
                   jPanel1 = new JPanel();
1001
                   jPanel1.setBackground(textcolor);
1002
                   jPanel1.setPreferredSize(new java.awt.Dimension(44,24));
1003
           }
1004
           return jPanel1;
1005
           }
1006
         */
1007

    
1008
        /**
1009
         * This method initializes jPanel2
1010
         *
1011
         * @return javax.swing.JPanel
1012
         */
1013
        private JPanel getJPanel2() {
1014
                if (jPanel2 == null) {
1015
                        jPanel2 = new JPanel();
1016
                        jPanel2.add(getBFuente(), null);
1017
                        jPanel2.add(getBUnidadesColor(), null);
1018

    
1019
                        //jPanel2.add(getJPanel1(), null);
1020
                }
1021

    
1022
                return jPanel2;
1023
        }
1024

    
1025
        /**
1026
         * This method initializes jCheckBox
1027
         *
1028
         * @return javax.swing.JCheckBox
1029
         */
1030
        private JCheckBox getJCheckBox() {
1031
                if (jCheckBox == null) {
1032
                        jCheckBox = new JCheckBox();
1033
                        jCheckBox.setSelected(fframescalebar.isShowDescription());
1034
                        jCheckBox.setPreferredSize(new java.awt.Dimension(180,24));
1035
                        jCheckBox.setText(PluginServices.getText(this,"mostrar_escala_numerica"));
1036
                }
1037

    
1038
                return jCheckBox;
1039
        }
1040

    
1041
        /**
1042
         * DOCUMENT ME!
1043
         *
1044
         * @author Vicente Caballero Navarro
1045
         */
1046
        class ComboBoxRenderer extends JLabel implements ListCellRenderer {
1047
                /**
1048
                 * Crea un nuevo ComboBoxRenderer.
1049
                 */
1050
                public ComboBoxRenderer() {
1051
                        setOpaque(true);
1052
                        setHorizontalAlignment(CENTER);
1053
                        setVerticalAlignment(CENTER);
1054
                }
1055

    
1056
                /*
1057
                 * This method finds the image and text corresponding
1058
                 * to the selected value and returns the label, set up
1059
                 * to display the text and image.
1060
                 */
1061
                public Component getListCellRendererComponent(JList list, Object value,
1062
                        int index, boolean isSelected, boolean cellHasFocus) {
1063
                        //Get the selected index. (The index param isn't
1064
                        //always valid, so just use the value.)
1065
                        ///int selectedIndex = ((Integer)value).intValue();
1066
                        if (isSelected) {
1067
                                setBackground(list.getSelectionBackground());
1068
                                setForeground(list.getSelectionForeground());
1069
                        } else {
1070
                                setBackground(list.getBackground());
1071
                                setForeground(list.getForeground());
1072
                        }
1073

    
1074
                        ImageIcon icon = images[Integer.parseInt((String) value)];
1075
                        setIcon(icon);
1076

    
1077
                        return this;
1078
                }
1079
        }
1080

    
1081
        /**
1082
         * This method initializes pRotation
1083
         *
1084
         * @return javax.swing.JPanel
1085
         */
1086
        private JPRotation getPRotation() {
1087
                if (pRotation == null) {
1088
                        pRotation = new JPRotation();
1089
                        pRotation.setBounds(480, 10, 120, 120);
1090
                }
1091
                return pRotation;
1092
        }
1093

    
1094
        /**
1095
         * This method initializes numDec
1096
         *
1097
         * @return javax.swing.JTextField
1098
         */
1099
        private JTextField getNumDec() {
1100
                if (txtNumDec == null) {
1101
                        txtNumDec = new JTextField();
1102
                        txtNumDec.setPreferredSize(new java.awt.Dimension(30,20));
1103
                        txtNumDec.setText(String.valueOf(fframescalebar.getNumDec()));
1104
                        txtNumDec.addKeyListener(new java.awt.event.KeyAdapter() {
1105
                                public void keyReleased(KeyEvent arg0) {
1106
                                        super.keyReleased(arg0);
1107
                                        if (!getNumDec().getText().toString().equals("")) {
1108
                                                fframescalebar.setNumDec(Integer.parseInt(
1109
                                                                getNumDec().getText().toString()));
1110
                                                getTIntervalo().setText(fframescalebar.obtainInterval());
1111
                                        }
1112
                                }
1113
                        });
1114
                }
1115
                return txtNumDec;
1116
        }
1117

    
1118
        public IFFrame getFFrame() {
1119
                return fframescalebar;
1120
        }
1121
} //  @jve:decl-index=0:visual-constraint="17,10"
1122
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"