Statistics
| Revision:

svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / fframes / gui / dialogs / FFrameScaleBarDialog.java @ 717

History | View | Annotate | Download (41.6 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.project.documents.layout.fframes.gui.dialogs;
23

    
24
import java.awt.Color;
25
import java.awt.Component;
26
import java.awt.Dimension;
27
import java.awt.FlowLayout;
28
import java.awt.Font;
29
import java.awt.event.ActionEvent;
30
import java.awt.event.KeyEvent;
31
import java.awt.geom.Rectangle2D;
32
import java.text.ParseException;
33

    
34
import javax.swing.ImageIcon;
35
import javax.swing.JCheckBox;
36
import javax.swing.JLabel;
37
import javax.swing.JList;
38
import javax.swing.JPanel;
39
import javax.swing.JTextField;
40
import javax.swing.ListCellRenderer;
41

    
42
import org.gvsig.andami.PluginServices;
43
import org.gvsig.andami.ui.mdiManager.WindowInfo;
44
import org.gvsig.app.gui.panels.ColorChooserPanel;
45
import org.gvsig.app.gui.utils.FontChooser;
46
import org.gvsig.app.project.documents.layout.FLayoutUtilities;
47
import org.gvsig.app.project.documents.layout.fframes.FFrameScaleBar;
48
import org.gvsig.app.project.documents.layout.fframes.FFrameView;
49
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
50
import org.gvsig.app.project.documents.layout.fframes.ListViewModel;
51
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation;
52
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
53
import org.gvsig.fmap.mapcontext.MapContext;
54

    
55
/**
56
 * Dialogo para a�adir una barra de escala al Layout.
57
 * 
58
 * @author Vicente Caballero Navarro
59
 */
60
public class FFrameScaleBarDialog extends AbstractFFrameDialog implements
61
    IFFrameDialog {
62

    
63
    private static final long serialVersionUID = 484826623711988784L;
64

    
65
    private static final ImageIcon inumero = PluginServices.getIconTheme().get(
66
        "numero-icon");
67

    
68
    private static final ImageIcon ibarra1 = PluginServices.getIconTheme().get(
69
        "barra1-icon");
70

    
71
    private static final ImageIcon ibarra2 = PluginServices.getIconTheme().get(
72
        "barra2-icon");
73

    
74
    private static final ImageIcon ibarra3 = PluginServices.getIconTheme().get(
75
        "barra3-icon");
76

    
77
    private javax.swing.JPanel jContentPane = null;
78
    private javax.swing.JScrollPane jScrollPane = null;
79
    private javax.swing.JList liVistas = null;
80
    private javax.swing.JCheckBox chbMantenerIntervalo = null;
81
    private javax.swing.JComboBox cbEscala = null;
82
    private javax.swing.JComboBox cbUnidades = null;
83
    private javax.swing.JLabel lIntervalo = null;
84
    private javax.swing.JTextField tIntervalo = null;
85
    private javax.swing.JLabel lNumIntervalos = null;
86
    private javax.swing.JTextField tNumIntervalos = null;
87
    private javax.swing.JLabel lDivIzquierda = null;
88
    private javax.swing.JTextField tDivIzquierda = null;
89
    private javax.swing.JButton bAceptar = null;
90
    private javax.swing.JButton bCancelar = null;
91

    
92
    // private ProjectView m_projectView=null;
93
    private FFrameView fframeview = null;
94
    private Rectangle2D rect = new Rectangle2D.Double();
95
    private FFrameScaleBar fframescalebar = null; // new FFrameScaleBar();
96
    private boolean isAcepted = false;
97
    private ImageIcon[] images = new ImageIcon[4];
98
    private javax.swing.JButton bFuente = null;
99
    private JPanel pMarcoVista = null;
100
    private JPanel pDescripcion = null;
101
    private JTextField tfDescripcion = null;
102
    private JPanel pUnidades = null;
103
    private JCheckBox chbSobreDescripcion = null;
104
    private JCheckBox chbMostrarUnidades = null;
105
    private JCheckBox chbSobreUnidades = null;
106
    private JPanel pEtiquetas = null;
107
    private JCheckBox chbEtiquetas = null;
108
    private JPanel pBarra = null;
109
    private JPanel jPanel5 = null;
110
    private JPanel jPanel6 = null;
111
    private JPanel jPanel7 = null;
112
    private ColorChooserPanel bUnidadesColor = null;
113
    private ColorChooserPanel bBarraColor = null;
114
    private Color barcolor = null;
115
    private Color textcolor = null;
116

    
117
    // private JPanel jPanel = null;
118
    // private JPanel jPanel1 = null;
119
    private JPanel jPanel2 = null;
120
    private JCheckBox jCheckBox = null;
121
    private JPRotation pRotation = null;
122
    private JLabel lblBarColor = null;
123
    private JTextField txtNumDec = null;
124
    private JLabel lblNumDec = null;
125

    
126
    /**
127
     * This is the default constructor
128
     * 
129
     * @param layoutPanel
130
     *            DOCUMENT ME!
131
     * @param fframe
132
     *            DOCUMENT ME!
133
     * @throws CloneNotSupportedException
134
     */
135
    public FFrameScaleBarDialog(LayoutPanel layoutPanel, IFFrame frame)
136
        throws CloneNotSupportedException {
137
        super(layoutPanel, frame);
138
        fframescalebar = (FFrameScaleBar) frame.clone();
139
        barcolor = fframescalebar.getBarColor();
140
        textcolor = fframescalebar.getTextColor();
141

    
142
        if (fframescalebar.getFFrameDependence() != null
143
            && fframescalebar.getDescription().equals("")) {
144
            getTfNumberScale().setText(
145
                "1:"
146
                    + String.valueOf(((FFrameView) fframescalebar
147
                        .getFFrameDependence()[0]).getScale()));
148
        }
149

    
150
        initialize();
151
    }
152

    
153
    /**
154
     * DOCUMENT ME!
155
     * 
156
     * @param r
157
     *            DOCUMENT ME!
158
     */
159
    public void setRectangle(Rectangle2D r) {
160
        rect.setRect(r);
161
    }
162

    
163
    /**
164
     * This method initializes this
165
     */
166
    private void initialize() {
167
        this.setLayout(null);
168
        this.add(getJContentPane(), null);
169
        this.setSize(621, 400);
170

    
171
        if (fframescalebar.getStyle() == 0) {
172
            getChbMantenerIntervalo().setEnabled(false);
173

    
174
            // /getLUnidades().setEnabled(false);
175
            getCbUnidades().setEnabled(false);
176
            getChbEtiquetas().setEnabled(false);
177
            getBBarraColor().setEnabled(false);
178
            getChbMostrarUnidades().setEnabled(false);
179
            getChbSobreUnidades().setEnabled(false);
180
            getLIntervalo().setEnabled(false);
181
            getTIntervalo().setEnabled(false);
182
            getLNumIntervalos().setEnabled(false);
183
            getTNumIntervalos().setEnabled(false);
184
            getLDivIzquierda().setEnabled(false);
185
            getTDivIzquierda().setEnabled(false);
186
            getJCheckBox().setEnabled(false);
187
            getChbSobreDescripcion().setEnabled(false);
188
        }
189
        getPRotation().setRotation(fframescalebar.getRotation());
190
    }
191

    
192
    /**
193
     * This method initializes jContentPane
194
     * 
195
     * @return javax.swing.JPanel
196
     */
197
    private javax.swing.JPanel getJContentPane() {
198
        if (jContentPane == null) {
199
            jContentPane = new javax.swing.JPanel();
200
            jContentPane.setLayout(null);
201
            jContentPane.add(getBAceptar(), null);
202
            jContentPane.add(getBCancelar(), null);
203
            jContentPane.add(getPRotation(), null);
204
            jContentPane.setSize(617, 386);
205
            jContentPane.setPreferredSize(new java.awt.Dimension(50, 50));
206
            jContentPane.setLocation(0, 6);
207
            jContentPane.add(getPMarcoVista(), null);
208
            jContentPane.add(getPDescripcion(), null);
209
            jContentPane.add(getPUnidades(), null);
210
            jContentPane.add(getPBarra(), null);
211
            jContentPane.add(getPEtiquetas(), null);
212
        }
213

    
214
        return jContentPane;
215
    }
216

    
217
    /**
218
     * This method initializes jScrollPane
219
     * 
220
     * @return javax.swing.JScrollPane
221
     */
222
    private javax.swing.JScrollPane getJScrollPane() {
223
        if (jScrollPane == null) {
224
            jScrollPane = new javax.swing.JScrollPane();
225
            jScrollPane.setPreferredSize(new java.awt.Dimension(250, 55));
226
            jScrollPane.setViewportView(getLiVistas());
227
        }
228

    
229
        return jScrollPane;
230
    }
231

    
232
    /**
233
     * This method initializes liVistas
234
     * 
235
     * @return javax.swing.JList
236
     */
237
    private javax.swing.JList getLiVistas() {
238
        if (liVistas == null) {
239
            ListViewModel listmodel = new ListViewModel();
240
            listmodel.addViews(layoutPanel);
241

    
242
            // /ArrayList list = listmodel.getViews();
243

    
244
            liVistas = new javax.swing.JList();
245

    
246
            liVistas.setSize(new java.awt.Dimension(250, 52));
247
            liVistas.setModel(listmodel);
248

    
249
            for (int i = 0; i < liVistas.getModel().getSize(); i++) {
250
                if (fframescalebar.getFFrameDependence() != null) {
251
                    FFrameView fframeviewAux =
252
                        (FFrameView) liVistas.getModel().getElementAt(i);
253

    
254
                    if (fframeviewAux == fframescalebar.getFFrameDependence()[0]) {
255
                        liVistas.setSelectedIndex(i);
256
                        fframeview = fframeviewAux;
257
                    }
258
                }
259
            }
260

    
261
            liVistas
262
                .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
263

    
264
                    private int selectIndex = -1;
265

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

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

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

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

    
308
        return liVistas;
309
    }
310

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

    
327
                    public void actionPerformed(java.awt.event.ActionEvent e) {
328
                        fframescalebar.setIntervalSet(getChbMantenerIntervalo()
329
                            .isSelected());
330
                    }
331
                });
332
        }
333

    
334
        return chbMantenerIntervalo;
335
    }
336

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

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

    
363
            cbEscala.addItem("0");
364
            cbEscala.addItem("1");
365
            cbEscala.addItem("2");
366
            cbEscala.addItem("3");
367
            cbEscala.setSelectedIndex(fframescalebar.getStyle());
368
            cbEscala.setPreferredSize(new java.awt.Dimension(200, 20));
369
            cbEscala.addActionListener(new java.awt.event.ActionListener() {
370

    
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[]
420
            // s={"Kil�metros","metros","cent�metros","mil�metros","millas","yardas","pies","pulgadas"};
421
            String[] names = MapContext.getDistanceNames();
422
            for (int i = 0; i < names.length; i++) {
423
                names[i] = PluginServices.getText(this, names[i]);
424
            }
425
            cbUnidades = new javax.swing.JComboBox(names);
426
            cbUnidades.setSelectedIndex(fframescalebar.getUnits());
427
            cbUnidades.setPreferredSize(new java.awt.Dimension(150, 20));
428
            cbUnidades.addActionListener(new java.awt.event.ActionListener() {
429

    
430
                public void actionPerformed(java.awt.event.ActionEvent e) {
431
                    fframescalebar.setUnits(getCbUnidades().getSelectedIndex());
432
                    getTIntervalo().setText(fframescalebar.obtainInterval());
433
                }
434
            });
435
        }
436

    
437
        return cbUnidades;
438
    }
439

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

    
452
        return lIntervalo;
453
    }
454

    
455
    /**
456
     * This method initializes tIntervalo
457
     * 
458
     * @return javax.swing.JTextField
459
     */
460
    private javax.swing.JTextField getTIntervalo() {
461
        if (tIntervalo == null) {
462
            tIntervalo = new javax.swing.JTextField();
463
            tIntervalo.setPreferredSize(new java.awt.Dimension(80, 20));
464
            tIntervalo.setText(fframescalebar.getInterval());
465
            tIntervalo.addKeyListener(new java.awt.event.KeyAdapter() {
466

    
467
                public void keyReleased(java.awt.event.KeyEvent e) {
468
                    if (!tIntervalo.getText().toString().equals("")) {
469
                        String s = tIntervalo.getText().toString();
470
                        try {
471
                            fframescalebar
472
                                .setInterval(FFrameScaleBar.numberFormat.parse(
473
                                    s).doubleValue());
474
                        } catch (ParseException e1) {
475
                            e1.printStackTrace();
476
                        }
477
                        getTNumIntervalos().setText(
478
                            String.valueOf(fframescalebar.getNumInterval()));
479
                    }
480
                }
481
            });
482
        }
483

    
484
        return tIntervalo;
485
    }
486

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

    
500
        return lNumIntervalos;
501
    }
502

    
503
    /**
504
     * This method initializes tNumIntervalos
505
     * 
506
     * @return javax.swing.JTextField
507
     */
508
    private javax.swing.JTextField getTNumIntervalos() {
509
        if (tNumIntervalos == null) {
510
            tNumIntervalos = new javax.swing.JTextField();
511
            tNumIntervalos.setPreferredSize(new java.awt.Dimension(80, 20));
512
            tNumIntervalos.setText(Integer.toString(fframescalebar
513
                .getNumInterval()));
514
            tNumIntervalos.addKeyListener(new java.awt.event.KeyAdapter() {
515

    
516
                public void keyReleased(java.awt.event.KeyEvent e) {
517
                    if (!tNumIntervalos.getText().toString().equals("")) {
518
                        fframescalebar.setNumInterval(Integer
519
                            .parseInt(tNumIntervalos.getText().toString()));
520
                        getTIntervalo()
521
                            .setText(fframescalebar.obtainInterval());
522
                    }
523
                }
524
            });
525
        }
526

    
527
        return tNumIntervalos;
528
    }
529

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

    
543
        return lDivIzquierda;
544
    }
545

    
546
    /**
547
     * This method initializes tDivIzquierda
548
     * 
549
     * @return javax.swing.JTextField
550
     */
551
    private javax.swing.JTextField getTDivIzquierda() {
552
        if (tDivIzquierda == null) {
553
            tDivIzquierda = new javax.swing.JTextField();
554
            tDivIzquierda.setPreferredSize(new java.awt.Dimension(80, 20));
555
            tDivIzquierda
556
                .setText(Integer.toString(fframescalebar.getNumLeft()));
557
            tDivIzquierda.addKeyListener(new java.awt.event.KeyAdapter() {
558

    
559
                public void keyReleased(java.awt.event.KeyEvent e) {
560
                    if (tDivIzquierda.getText().toString().equals("")) {
561
                        tDivIzquierda.setText("0");
562
                    } else {
563
                        fframescalebar.setNumLeft(Integer
564
                            .parseInt(tDivIzquierda.getText()));
565
                    }
566
                }
567
            });
568
        }
569

    
570
        return tDivIzquierda;
571
    }
572

    
573
    /**
574
     * This method initializes bAceptar
575
     * 
576
     * @return javax.swing.JButton
577
     */
578
    private javax.swing.JButton getBAceptar() {
579
        if (bAceptar == null) {
580
            bAceptar = new javax.swing.JButton();
581
            bAceptar.setSize(85, 26);
582
            bAceptar.setText(PluginServices.getText(this, "Aceptar"));
583
            bAceptar.setLocation(106, 347);
584
            bAceptar.setPreferredSize(new java.awt.Dimension(79, 23));
585
            bAceptar.addActionListener(new java.awt.event.ActionListener() {
586

    
587
                public void actionPerformed(java.awt.event.ActionEvent e) {
588
                    fframescalebar.setUnits(getCbUnidades().getSelectedIndex());
589
                    fframescalebar.setBoundBox(FLayoutUtilities.toSheetRect(
590
                        rect, layoutPanel.getLayoutControl().getAT()));
591
                    fframescalebar.setFFrameDependence(fframeview);
592
                    fframescalebar.setBarColor(barcolor);
593
                    fframescalebar.setTextColor(textcolor);
594
                    fframescalebar.setShowNameUnits(getChbMostrarUnidades()
595
                        .isSelected());
596
                    fframescalebar.setShowDescription(getJCheckBox()
597
                        .isSelected());
598
                    fframescalebar.setAboveDescription(getChbSobreDescripcion()
599
                        .isSelected());
600
                    fframescalebar.setAboveIntervals(getChbEtiquetas()
601
                        .isSelected());
602
                    fframescalebar.setAboveName(getChbSobreUnidades()
603
                        .isSelected());
604
                    fframescalebar.setRotation(getPRotation().getRotation());
605
                    fframescalebar.setNumDec(Integer.parseInt(getNumDec()
606
                        .getText()));
607
                    fframescalebar.setNumLeft(Integer
608
                        .parseInt(getTDivIzquierda().getText()));
609
                    isAcepted = true;
610
                    PluginServices.getMDIManager().closeWindow(
611
                        FFrameScaleBarDialog.this);
612
                    notifyDialogClosed();
613
                    layoutPanel.getLayoutControl().setDefaultTool();
614
                    fireActionEvent(new ActionEvent(FFrameScaleBarDialog.this, 1, "accept"));
615
                }
616
            });
617
        }
618

    
619
        return bAceptar;
620
    }
621

    
622
    /**
623
     * This method initializes bCancelar
624
     * 
625
     * @return javax.swing.JButton
626
     */
627
    private javax.swing.JButton getBCancelar() {
628
        if (bCancelar == null) {
629
            bCancelar = new javax.swing.JButton();
630
            bCancelar.setSize(85, 26);
631
            bCancelar.setText(PluginServices.getText(this, "Cancelar"));
632
            bCancelar.setLocation(297, 347);
633
            bCancelar.setPreferredSize(new java.awt.Dimension(85, 23));
634
            bCancelar.addActionListener(new java.awt.event.ActionListener() {
635

    
636
                public void actionPerformed(java.awt.event.ActionEvent e) {
637
                    fframescalebar = null;
638
                    PluginServices.getMDIManager().closeWindow(
639
                        FFrameScaleBarDialog.this);
640
                    notifyDialogClosed();
641
                }
642
            });
643
        }
644

    
645
        return bCancelar;
646
    }
647

    
648
    /*
649
     * (non-Javadoc)
650
     * 
651
     * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
652
     */
653
    public WindowInfo getWindowInfo() {
654
        WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
655
        m_viewinfo.setTitle(PluginServices.getText(this,
656
            "Propiedades_escala_grafica"));
657

    
658
        return m_viewinfo;
659
    }
660

    
661
    /**
662
     * @see org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
663
     */
664
    public boolean getIsAcepted() {
665
        return isAcepted;
666
    }
667

    
668
    /**
669
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
670
     */
671
    public void viewActivated() {
672
    }
673

    
674
    /**
675
     * This method initializes bFuente
676
     * 
677
     * @return javax.swing.JButton
678
     */
679
    private javax.swing.JButton getBFuente() {
680
        if (bFuente == null) {
681
            bFuente = new javax.swing.JButton();
682
            bFuente.setText(PluginServices.getText(this, "fuente"));
683
            bFuente.addActionListener(new java.awt.event.ActionListener() {
684

    
685
                public void actionPerformed(java.awt.event.ActionEvent e) {
686
                    Font font =
687
                        FontChooser.showDialog(
688
                            PluginServices.getText(this, "seleccion_fuente"),
689
                            fframescalebar.getFont());
690
                    if (font != null) {
691
                        fframescalebar.setFont(font); // fchoser=new
692
                                                      // FontChooser();
693
                    }
694
                }
695
            });
696
        }
697

    
698
        return bFuente;
699
    }
700

    
701
    /**
702
     * This method initializes pMarcoVista
703
     * 
704
     * @return javax.swing.JPanel
705
     */
706
    private JPanel getPMarcoVista() {
707
        if (pMarcoVista == null) {
708
            pMarcoVista = new JPanel();
709
            pMarcoVista.setBounds(7, 9, 263, 86);
710
            pMarcoVista.setBorder(javax.swing.BorderFactory.createTitledBorder(
711
                null,
712
                PluginServices.getText(this,
713
                    PluginServices.getText(this, "marco_vista")),
714
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
715
                javax.swing.border.TitledBorder.DEFAULT_POSITION,
716
                new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
717
                java.awt.Color.black));
718
            pMarcoVista.add(getJScrollPane(), null);
719
        }
720

    
721
        return pMarcoVista;
722
    }
723

    
724
    /**
725
     * This method initializes pDescripcion
726
     * 
727
     * @return javax.swing.JPanel
728
     */
729
    private JPanel getPDescripcion() {
730
        if (pDescripcion == null) {
731
            FlowLayout flowLayout1 = new FlowLayout();
732
            flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
733
            pDescripcion = new JPanel();
734
            pDescripcion.setLayout(flowLayout1);
735
            pDescripcion.setBounds(275, 9, 204, 110);
736
            pDescripcion.setBorder(javax.swing.BorderFactory
737
                .createTitledBorder(null,
738
                    PluginServices.getText(this, "Escala"),
739
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
740
                    javax.swing.border.TitledBorder.DEFAULT_POSITION,
741
                    new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
742
                    java.awt.Color.black));
743
            pDescripcion.add(getTfNumberScale(), null);
744
            pDescripcion.add(getJCheckBox(), null);
745
            pDescripcion.add(getChbSobreDescripcion(), null);
746
        }
747

    
748
        return pDescripcion;
749
    }
750

    
751
    /**
752
     * This method initializes tfDescripcion
753
     * 
754
     * @return javax.swing.JTextField
755
     */
756
    private JTextField getTfNumberScale() {
757
        if (tfDescripcion == null) {
758
            tfDescripcion = new JTextField();
759
            tfDescripcion.setPreferredSize(new java.awt.Dimension(180, 20));
760

    
761
            tfDescripcion.setEditable(false);
762
            /*
763
             * if (fframeview!=null){
764
             * getTfDescripcion().setText("escala 1:"+String.valueOf(fframeview.
765
             * getScale()));
766
             * }
767
             */
768
            tfDescripcion.setText(fframescalebar.getDescription());
769
        }
770

    
771
        return tfDescripcion;
772
    }
773

    
774
    /**
775
     * This method initializes pUnidades
776
     * 
777
     * @return javax.swing.JPanel
778
     */
779
    private JPanel getPUnidades() {
780
        if (pUnidades == null) {
781
            FlowLayout flowLayout = new FlowLayout();
782
            flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
783
            pUnidades = new JPanel();
784
            pUnidades.setLayout(flowLayout);
785
            pUnidades.setLocation(274, 122);
786
            pUnidades.setSize(204, 110);
787
            pUnidades.setBorder(javax.swing.BorderFactory.createTitledBorder(
788
                null, PluginServices.getText(this, "unidades"),
789
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
790
                javax.swing.border.TitledBorder.DEFAULT_POSITION,
791
                new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
792
                java.awt.Color.black));
793
            pUnidades.add(getCbUnidades(), null);
794
            pUnidades.add(getChbMostrarUnidades(), null);
795
            pUnidades.add(getChbSobreUnidades(), null);
796
        }
797

    
798
        return pUnidades;
799
    }
800

    
801
    /**
802
     * This method initializes chbSobreDescripcion
803
     * 
804
     * @return javax.swing.JCheckBox
805
     */
806
    private JCheckBox getChbSobreDescripcion() {
807
        if (chbSobreDescripcion == null) {
808
            chbSobreDescripcion = new JCheckBox();
809
            chbSobreDescripcion
810
                .setSelected(fframescalebar.isAboveDescription());
811
            chbSobreDescripcion
812
                .setPreferredSize(new java.awt.Dimension(180, 24));
813
            chbSobreDescripcion.setText(PluginServices.getText(this,
814
                "sobre_la_barra"));
815
        }
816

    
817
        return chbSobreDescripcion;
818
    }
819

    
820
    /**
821
     * This method initializes chbMostrarUnidades
822
     * 
823
     * @return javax.swing.JCheckBox
824
     */
825
    private JCheckBox getChbMostrarUnidades() {
826
        if (chbMostrarUnidades == null) {
827
            chbMostrarUnidades = new JCheckBox();
828
            chbMostrarUnidades.setText(PluginServices.getText(this,
829
                "mostrar_unidades"));
830
            chbMostrarUnidades.setSelected(fframescalebar.isShowNameUnits());
831
            chbMostrarUnidades
832
                .setPreferredSize(new java.awt.Dimension(150, 24));
833
        }
834

    
835
        return chbMostrarUnidades;
836
    }
837

    
838
    /**
839
     * This method initializes chbSobreUnidades
840
     * 
841
     * @return javax.swing.JCheckBox
842
     */
843
    private JCheckBox getChbSobreUnidades() {
844
        if (chbSobreUnidades == null) {
845
            chbSobreUnidades = new JCheckBox();
846
            chbSobreUnidades.setSelected(fframescalebar.isAboveName());
847
            chbSobreUnidades.setText(PluginServices.getText(this,
848
                "sobre_la_barra"));
849
            chbSobreUnidades.setPreferredSize(new java.awt.Dimension(150, 24));
850
        }
851

    
852
        return chbSobreUnidades;
853
    }
854

    
855
    /**
856
     * This method initializes pEtiquetas
857
     * 
858
     * @return javax.swing.JPanel
859
     */
860
    private JPanel getPEtiquetas() {
861
        if (pEtiquetas == null) {
862
            FlowLayout flowLayout2 = new FlowLayout();
863
            flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
864
            pEtiquetas = new JPanel();
865
            pEtiquetas.setLayout(flowLayout2);
866
            pEtiquetas.setBorder(javax.swing.BorderFactory.createTitledBorder(
867
                null, PluginServices.getText(this, "etiquetas"),
868
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
869
                javax.swing.border.TitledBorder.DEFAULT_POSITION,
870
                new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
871
                java.awt.Color.black));
872
            pEtiquetas.setBounds(276, 235, 204, 104);
873
            pEtiquetas.add(getChbEtiquetas(), null);
874
            pEtiquetas.add(getJPanel2(), null);
875
        }
876

    
877
        return pEtiquetas;
878
    }
879

    
880
    /**
881
     * This method initializes chbEtiquetas
882
     * 
883
     * @return javax.swing.JCheckBox
884
     */
885
    private JCheckBox getChbEtiquetas() {
886
        if (chbEtiquetas == null) {
887
            chbEtiquetas = new JCheckBox();
888
            chbEtiquetas.setSelected(fframescalebar.isAboveIntervals());
889
            chbEtiquetas
890
                .setText(PluginServices.getText(this, "sobre_la_barra"));
891
        }
892

    
893
        return chbEtiquetas;
894
    }
895

    
896
    /**
897
     * This method initializes pBarra
898
     * 
899
     * @return javax.swing.JPanel
900
     */
901
    private JPanel getPBarra() {
902
        if (pBarra == null) {
903
            FlowLayout flowLayout3 = new FlowLayout();
904
            flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
905
            lblNumDec = new JLabel();
906
            lblNumDec.setText(PluginServices.getText(this,
907
                "numero_decimales_mostrar"));
908
            lblBarColor = new JLabel();
909
            lblBarColor.setText(PluginServices.getText(this, "color"));
910
            pBarra = new JPanel();
911
            pBarra.setLayout(flowLayout3);
912
            pBarra.setBounds(8, 98, 263, 241);
913
            pBarra.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
914
                PluginServices.getText(this, "barra"),
915
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
916
                javax.swing.border.TitledBorder.DEFAULT_POSITION,
917
                new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
918
                java.awt.Color.black));
919
            pBarra.add(getChbMantenerIntervalo(), null);
920
            pBarra.add(getCbEscala(), null);
921
            pBarra.add(lblNumDec, null);
922
            pBarra.add(getNumDec(), null);
923
            pBarra.add(getJPanel5(), null);
924
            pBarra.add(getJPanel7(), null);
925
            pBarra.add(getJPanel6(), null);
926
            pBarra.add(lblBarColor, null);
927
            pBarra.add(getBBarraColor(), null);
928
        }
929

    
930
        return pBarra;
931
    }
932

    
933
    /**
934
     * This method initializes jPanel5
935
     * 
936
     * @return javax.swing.JPanel
937
     */
938
    private JPanel getJPanel5() {
939
        if (jPanel5 == null) {
940
            jPanel5 = new JPanel();
941
            jPanel5.setPreferredSize(new java.awt.Dimension(245, 30));
942
            jPanel5.add(getLIntervalo(), null);
943
            jPanel5.add(getTIntervalo(), null);
944
        }
945

    
946
        return jPanel5;
947
    }
948

    
949
    /**
950
     * This method initializes jPanel6
951
     * 
952
     * @return javax.swing.JPanel
953
     */
954
    private JPanel getJPanel6() {
955
        if (jPanel6 == null) {
956
            jPanel6 = new JPanel();
957
            jPanel6.setPreferredSize(new java.awt.Dimension(245, 30));
958
            jPanel6.add(getLDivIzquierda(), null);
959
            jPanel6.add(getTDivIzquierda(), null);
960
        }
961

    
962
        return jPanel6;
963
    }
964

    
965
    /**
966
     * This method initializes jPanel7
967
     * 
968
     * @return javax.swing.JPanel
969
     */
970
    private JPanel getJPanel7() {
971
        if (jPanel7 == null) {
972
            jPanel7 = new JPanel();
973
            jPanel7.setPreferredSize(new java.awt.Dimension(245, 30));
974
            jPanel7.add(getLNumIntervalos(), null);
975
            jPanel7.add(getTNumIntervalos(), null);
976
        }
977

    
978
        return jPanel7;
979
    }
980

    
981
    /**
982
     * This method initializes bUnidadesColor
983
     * 
984
     * @return javax.swing.JButton
985
     */
986
    private ColorChooserPanel getBUnidadesColor() {
987
        if (bUnidadesColor == null) {
988
            bUnidadesColor = new ColorChooserPanel();
989
            bUnidadesColor.setAlpha(255);
990
            bUnidadesColor.setColor(textcolor);
991
            bUnidadesColor.setPreferredSize(new java.awt.Dimension(100, 25));
992
            bUnidadesColor
993
                .addActionListener(new java.awt.event.ActionListener() {
994

    
995
                    public void actionPerformed(java.awt.event.ActionEvent e) {
996
                        textcolor = getBUnidadesColor().getColor();
997
                    }
998
                });
999
        }
1000

    
1001
        return bUnidadesColor;
1002
    }
1003

    
1004
    /**
1005
     * This method initializes bBarraColor
1006
     * 
1007
     * @return javax.swing.JButton
1008
     */
1009
    private ColorChooserPanel getBBarraColor() {
1010
        if (bBarraColor == null) {
1011
            bBarraColor = new ColorChooserPanel();
1012
            bBarraColor.setPreferredSize(new java.awt.Dimension(100, 25));
1013
            bBarraColor.setAlpha(255);
1014
            bBarraColor.setColor(barcolor);
1015
            bBarraColor.addActionListener(new java.awt.event.ActionListener() {
1016

    
1017
                public void actionPerformed(java.awt.event.ActionEvent e) {
1018
                    // JDialog dlg;
1019
                    // JColorChooser colorChooser;
1020
                    // colorChooser = new JColorChooser();
1021
                    // dlg = JColorChooser.createDialog((JFrame) null,
1022
                    // PluginServices.getText(this, "Elegir_Color"),
1023
                    // true, colorChooser, null, null);
1024
                    // dlg.show(true);
1025
                    //
1026
                    barcolor = getBBarraColor().getColor();
1027

    
1028
                    // bBarraColor.setBackground(barcolor);
1029
                    // bBarraColor.setForeground(barcolor);
1030
                }
1031
            });
1032
        }
1033

    
1034
        return bBarraColor;
1035
    }
1036

    
1037
    /**
1038
     * This method initializes jPanel
1039
     * 
1040
     * @return javax.swing.JPanel
1041
     */
1042

    
1043
    /*
1044
     * private JPanel getJPanel() {
1045
     * if (jPanel == null) {
1046
     * jPanel = new JPanel();
1047
     * jPanel.setPreferredSize(new java.awt.Dimension(44,24));
1048
     * jPanel.setForeground(barcolor);
1049
     * jPanel.setBackground(barcolor);
1050
     * }
1051
     * return jPanel;
1052
     * }
1053
     */
1054

    
1055
    /**
1056
     * This method initializes jPanel1
1057
     * 
1058
     * @return javax.swing.JPanel
1059
     */
1060

    
1061
    /*
1062
     * private JPanel getJPanel1() {
1063
     * if (jPanel1 == null) {
1064
     * jPanel1 = new JPanel();
1065
     * jPanel1.setBackground(textcolor);
1066
     * jPanel1.setPreferredSize(new java.awt.Dimension(44,24));
1067
     * }
1068
     * return jPanel1;
1069
     * }
1070
     */
1071

    
1072
    /**
1073
     * This method initializes jPanel2
1074
     * 
1075
     * @return javax.swing.JPanel
1076
     */
1077
    private JPanel getJPanel2() {
1078
        if (jPanel2 == null) {
1079
            jPanel2 = new JPanel();
1080
            jPanel2.add(getBFuente(), null);
1081
            jPanel2.add(getBUnidadesColor(), null);
1082

    
1083
            // jPanel2.add(getJPanel1(), null);
1084
        }
1085

    
1086
        return jPanel2;
1087
    }
1088

    
1089
    /**
1090
     * This method initializes jCheckBox
1091
     * 
1092
     * @return javax.swing.JCheckBox
1093
     */
1094
    private JCheckBox getJCheckBox() {
1095
        if (jCheckBox == null) {
1096
            jCheckBox = new JCheckBox();
1097
            jCheckBox.setSelected(fframescalebar.isShowDescription());
1098
            jCheckBox.setPreferredSize(new java.awt.Dimension(180, 24));
1099
            jCheckBox.setText(PluginServices.getText(this,
1100
                "mostrar_escala_numerica"));
1101
        }
1102

    
1103
        return jCheckBox;
1104
    }
1105

    
1106
    /**
1107
     * DOCUMENT ME!
1108
     * 
1109
     * @author Vicente Caballero Navarro
1110
     */
1111
    class ComboBoxRenderer extends JLabel implements ListCellRenderer {
1112

    
1113
        private static final long serialVersionUID = -3169953982752103303L;
1114

    
1115
        /**
1116
         * Crea un nuevo ComboBoxRenderer.
1117
         */
1118
        public ComboBoxRenderer() {
1119
            setOpaque(true);
1120
            setHorizontalAlignment(CENTER);
1121
            setVerticalAlignment(CENTER);
1122
        }
1123

    
1124
        /*
1125
         * This method finds the image and text corresponding
1126
         * to the selected value and returns the label, set up
1127
         * to display the text and image.
1128
         */
1129
        public Component getListCellRendererComponent(JList list, Object value,
1130
            int index, boolean isSelected, boolean cellHasFocus) {
1131
            // Get the selected index. (The index param isn't
1132
            // always valid, so just use the value.)
1133
            // /int selectedIndex = ((Integer)value).intValue();
1134
            if (isSelected) {
1135
                setBackground(list.getSelectionBackground());
1136
                setForeground(list.getSelectionForeground());
1137
            } else {
1138
                setBackground(list.getBackground());
1139
                setForeground(list.getForeground());
1140
            }
1141

    
1142
            ImageIcon icon = images[Integer.parseInt((String) value)];
1143
            setIcon(icon);
1144

    
1145
            return this;
1146
        }
1147
    }
1148

    
1149
    /**
1150
     * This method initializes pRotation
1151
     * 
1152
     * @return javax.swing.JPanel
1153
     */
1154
    private JPRotation getPRotation() {
1155
        if (pRotation == null) {
1156
            pRotation = new JPRotation();
1157
            pRotation.setBounds(480, 10, 120, 120);
1158
        }
1159
        return pRotation;
1160
    }
1161

    
1162
    /**
1163
     * This method initializes numDec
1164
     * 
1165
     * @return javax.swing.JTextField
1166
     */
1167
    private JTextField getNumDec() {
1168
        if (txtNumDec == null) {
1169
            txtNumDec = new JTextField();
1170
            txtNumDec.setPreferredSize(new java.awt.Dimension(30, 20));
1171
            txtNumDec.setText(String.valueOf(fframescalebar.getNumDec()));
1172
            txtNumDec.addKeyListener(new java.awt.event.KeyAdapter() {
1173

    
1174
                public void keyReleased(KeyEvent arg0) {
1175
                    super.keyReleased(arg0);
1176
                    if (!getNumDec().getText().toString().equals("")) {
1177
                        fframescalebar.setNumDec(Integer.parseInt(getNumDec()
1178
                            .getText().toString()));
1179
                        getTIntervalo()
1180
                            .setText(fframescalebar.obtainInterval());
1181
                    }
1182
                }
1183
            });
1184
        }
1185
        return txtNumDec;
1186
    }
1187

    
1188
    public IFFrame getFFrame() {
1189
        return fframescalebar;
1190
    }
1191

    
1192
    public Object getWindowProfile() {
1193
        return WindowInfo.DIALOG_PROFILE;
1194
    }
1195

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