Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / layout / fframes / gui / dialogs / FFrameScaleBarDialog.java @ 31496

History | View | Annotate | Download (33.3 KB)

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

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

    
64
import org.gvsig.andami.PluginServices;
65
import org.gvsig.andami.ui.mdiManager.WindowInfo;
66
import org.gvsig.app.gui.panels.ColorChooserPanel;
67
import org.gvsig.app.gui.utils.FontChooser;
68
import org.gvsig.app.project.documents.layout.FLayoutUtilities;
69
import org.gvsig.app.project.documents.layout.fframes.FFrameScaleBar;
70
import org.gvsig.app.project.documents.layout.fframes.FFrameView;
71
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
72
import org.gvsig.app.project.documents.layout.fframes.ListViewModel;
73
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation;
74
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
75
import org.gvsig.fmap.mapcontext.MapContext;
76

    
77

    
78

    
79
/**
80
 * Dialogo para a�adir una barra de escala al Layout.
81
 *
82
 * @author Vicente Caballero Navarro
83
 */
84
public class FFrameScaleBarDialog extends JPanel implements IFFrameDialog {
85
        private static final ImageIcon inumero = PluginServices.getIconTheme()
86
                .get("numero-icon");
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
228
                return jContentPane;
229
        }
230

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

    
243
                return jScrollPane;
244
        }
245

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

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

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

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

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

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

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

    
289
                                                                for (int i = 0; i < fframes.length; i++) {
290
                                                                        IFFrame f = fframes[i];
291

    
292
                                                                        if (f instanceof FFrameView) {
293
                                                                                if (((FFrameView) f).getView() == fframeview
294
                                                                                                .getView()) {
295
                                                                                        fframescalebar
296
                                                                                                        .setFFrameDependence(fframeview);
297
                                                                                }
298
                                                                        }
299
                                                                }
300

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

    
316
                return liVistas;
317
        }
318

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

    
339
                return chbMantenerIntervalo;
340
        }
341

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

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

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

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

    
412
                return cbEscala;
413
        }
414

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

    
439
                return cbUnidades;
440
        }
441

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

    
454
                return lIntervalo;
455
        }
456

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

    
483
                return tIntervalo;
484
        }
485

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

    
498
                return lNumIntervalos;
499
        }
500

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

    
523
                return tNumIntervalos;
524
        }
525

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

    
539
                return lDivIzquierda;
540
        }
541

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

    
564
                return tDivIzquierda;
565
        }
566

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

    
608
                return bAceptar;
609
        }
610

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

    
631
                return bCancelar;
632
        }
633

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

    
642
                return m_viewinfo;
643
        }
644

    
645
        /**
646
         * @see org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
647
         */
648
        public boolean getIsAcepted() {
649
                return isAcepted;
650
        }
651

    
652
        /**
653
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
654
         */
655
        public void viewActivated() {
656
        }
657

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

    
679
                return bFuente;
680
        }
681

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

    
696
                return pMarcoVista;
697
        }
698

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

    
717
                return pDescripcion;
718
        }
719

    
720
        /**
721
         * This method initializes tfDescripcion
722
         *
723
         * @return javax.swing.JTextField
724
         */
725
        private JTextField getTfNumberScale() {
726
                if (tfDescripcion == null) {
727
                        tfDescripcion = new JTextField();
728
                        tfDescripcion.setPreferredSize(new java.awt.Dimension(180,20));
729

    
730
                        tfDescripcion.setEditable(false);
731
                        /*if (fframeview!=null){
732
                           getTfDescripcion().setText("escala 1:"+String.valueOf(fframeview.getScale()));
733
                           }
734
                         */
735
                        tfDescripcion.setText(fframescalebar.getDescription());
736
                }
737

    
738
                return tfDescripcion;
739
        }
740

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

    
761
                return pUnidades;
762
        }
763

    
764
        /**
765
         * This method initializes chbSobreDescripcion
766
         *
767
         * @return javax.swing.JCheckBox
768
         */
769
        private JCheckBox getChbSobreDescripcion() {
770
                if (chbSobreDescripcion == null) {
771
                        chbSobreDescripcion = new JCheckBox();
772
                        chbSobreDescripcion.setSelected(fframescalebar.isAboveDescription());
773
                        chbSobreDescripcion.setPreferredSize(new java.awt.Dimension(180,24));
774
                        chbSobreDescripcion.setText(PluginServices.getText(this,"sobre_la_barra"));
775
                }
776

    
777
                return chbSobreDescripcion;
778
        }
779

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

    
793
                return chbMostrarUnidades;
794
        }
795

    
796
        /**
797
         * This method initializes chbSobreUnidades
798
         *
799
         * @return javax.swing.JCheckBox
800
         */
801
        private JCheckBox getChbSobreUnidades() {
802
                if (chbSobreUnidades == null) {
803
                        chbSobreUnidades = new JCheckBox();
804
                        chbSobreUnidades.setSelected(fframescalebar.isAboveName());
805
                        chbSobreUnidades.setText(PluginServices.getText(this,"sobre_la_barra"));
806
                        chbSobreUnidades.setPreferredSize(new java.awt.Dimension(150, 24));
807
                }
808

    
809
                return chbSobreUnidades;
810
        }
811

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

    
830
                return pEtiquetas;
831
        }
832

    
833
        /**
834
         * This method initializes chbEtiquetas
835
         *
836
         * @return javax.swing.JCheckBox
837
         */
838
        private JCheckBox getChbEtiquetas() {
839
                if (chbEtiquetas == null) {
840
                        chbEtiquetas = new JCheckBox();
841
                        chbEtiquetas.setSelected(fframescalebar.isAboveIntervals());
842
                        chbEtiquetas.setText(PluginServices.getText(this,"sobre_la_barra"));
843
                }
844

    
845
                return chbEtiquetas;
846
        }
847

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

    
877
                return pBarra;
878
        }
879

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

    
893
                return jPanel5;
894
        }
895

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

    
909
                return jPanel6;
910
        }
911

    
912
        /**
913
         * This method initializes jPanel7
914
         *
915
         * @return javax.swing.JPanel
916
         */
917
        private JPanel getJPanel7() {
918
                if (jPanel7 == null) {
919
                        jPanel7 = new JPanel();
920
                        jPanel7.setPreferredSize(new java.awt.Dimension(245,30));
921
                        jPanel7.add(getLNumIntervalos(), null);
922
                        jPanel7.add(getTNumIntervalos(), null);
923
                }
924

    
925
                return jPanel7;
926
        }
927

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

    
946
                return bUnidadesColor;
947
        }
948

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

    
972
//                                                bBarraColor.setBackground(barcolor);
973
//                                                bBarraColor.setForeground(barcolor);
974
                                        }
975
                                });
976
                }
977

    
978
                return bBarraColor;
979
        }
980

    
981
        /**
982
         * This method initializes jPanel
983
         *
984
         * @return javax.swing.JPanel
985
         */
986

    
987
        /*private JPanel getJPanel() {
988
           if (jPanel == null) {
989
                   jPanel = new JPanel();
990
                   jPanel.setPreferredSize(new java.awt.Dimension(44,24));
991
                   jPanel.setForeground(barcolor);
992
                   jPanel.setBackground(barcolor);
993
           }
994
           return jPanel;
995
           }
996
         */
997

    
998
        /**
999
         * This method initializes jPanel1
1000
         *
1001
         * @return javax.swing.JPanel
1002
         */
1003

    
1004
        /*        private JPanel getJPanel1() {
1005
           if (jPanel1 == null) {
1006
                   jPanel1 = new JPanel();
1007
                   jPanel1.setBackground(textcolor);
1008
                   jPanel1.setPreferredSize(new java.awt.Dimension(44,24));
1009
           }
1010
           return jPanel1;
1011
           }
1012
         */
1013

    
1014
        /**
1015
         * This method initializes jPanel2
1016
         *
1017
         * @return javax.swing.JPanel
1018
         */
1019
        private JPanel getJPanel2() {
1020
                if (jPanel2 == null) {
1021
                        jPanel2 = new JPanel();
1022
                        jPanel2.add(getBFuente(), null);
1023
                        jPanel2.add(getBUnidadesColor(), null);
1024

    
1025
                        //jPanel2.add(getJPanel1(), null);
1026
                }
1027

    
1028
                return jPanel2;
1029
        }
1030

    
1031
        /**
1032
         * This method initializes jCheckBox
1033
         *
1034
         * @return javax.swing.JCheckBox
1035
         */
1036
        private JCheckBox getJCheckBox() {
1037
                if (jCheckBox == null) {
1038
                        jCheckBox = new JCheckBox();
1039
                        jCheckBox.setSelected(fframescalebar.isShowDescription());
1040
                        jCheckBox.setPreferredSize(new java.awt.Dimension(180,24));
1041
                        jCheckBox.setText(PluginServices.getText(this,"mostrar_escala_numerica"));
1042
                }
1043

    
1044
                return jCheckBox;
1045
        }
1046

    
1047
        /**
1048
         * DOCUMENT ME!
1049
         *
1050
         * @author Vicente Caballero Navarro
1051
         */
1052
        class ComboBoxRenderer extends JLabel implements ListCellRenderer {
1053
                /**
1054
                 * Crea un nuevo ComboBoxRenderer.
1055
                 */
1056
                public ComboBoxRenderer() {
1057
                        setOpaque(true);
1058
                        setHorizontalAlignment(CENTER);
1059
                        setVerticalAlignment(CENTER);
1060
                }
1061

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

    
1080
                        ImageIcon icon = images[Integer.parseInt((String) value)];
1081
                        setIcon(icon);
1082

    
1083
                        return this;
1084
                }
1085
        }
1086

    
1087
        /**
1088
         * This method initializes pRotation
1089
         *
1090
         * @return javax.swing.JPanel
1091
         */
1092
        private JPRotation getPRotation() {
1093
                if (pRotation == null) {
1094
                        pRotation = new JPRotation();
1095
                        pRotation.setBounds(480, 10, 120, 120);
1096
                }
1097
                return pRotation;
1098
        }
1099

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

    
1124
        public IFFrame getFFrame() {
1125
                return fframescalebar;
1126
        }
1127

    
1128

    
1129
        public Object getWindowProfile() {
1130
                return WindowInfo.DIALOG_PROFILE;
1131
        }
1132

    
1133
} //  @jve:decl-index=0:visual-constraint="17,10"
1134
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"