Statistics
| Revision:

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

History | View | Annotate | Download (33.2 KB)

1 7304 caballero
/*
2
 * Created on 02-jun-2004
3
 *
4
 */
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
package com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs;
46
47 7671 caballero
import java.awt.Color;
48
import java.awt.Component;
49
import java.awt.Dimension;
50
import java.awt.FlowLayout;
51
import java.awt.event.KeyEvent;
52
import java.awt.geom.Rectangle2D;
53 9163 caballero
import java.text.ParseException;
54 7671 caballero
55
import javax.swing.ImageIcon;
56
import javax.swing.JCheckBox;
57
import javax.swing.JLabel;
58
import javax.swing.JList;
59
import javax.swing.JPanel;
60
import javax.swing.JTextField;
61
import javax.swing.ListCellRenderer;
62
63 7304 caballero
import com.iver.andami.PluginServices;
64
import com.iver.andami.ui.mdiManager.WindowInfo;
65
import com.iver.cit.gvsig.AddLayer;
66 11548 jaume
import com.iver.cit.gvsig.fmap.MapContext;
67 7304 caballero
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
68
import com.iver.cit.gvsig.gui.utils.FontChooser;
69
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities;
70 9392 caballero
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameScaleBar;
71
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameView;
72 7304 caballero
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
73
import com.iver.cit.gvsig.project.documents.layout.fframes.ListViewModel;
74
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.JPRotation;
75 9392 caballero
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
76 7304 caballero
77
78
/**
79
 * Dialogo para a?adir una barra de escala al Layout.
80
 *
81
 * @author Vicente Caballero Navarro
82
 */
83
public class FFrameScaleBarDialog extends JPanel implements IFFrameDialog {
84
        private static final ImageIcon inumero = new ImageIcon(AddLayer.class.getClassLoader()
85
                                                                                                                                          .getResource("images/numero.png"));
86
        private static final ImageIcon ibarra1 = new ImageIcon(AddLayer.class.getClassLoader()
87
                                                                                                                                          .getResource("images/barra1.png"));
88
        private static final ImageIcon ibarra2 = new ImageIcon(AddLayer.class.getClassLoader()
89
                                                                                                                                          .getResource("images/barra2.png"));
90
        private static final ImageIcon ibarra3 = new ImageIcon(AddLayer.class.getClassLoader()
91
                                                                                                                                          .getResource("images/barra3.png"));
92
        private javax.swing.JPanel jContentPane = null;
93
        private javax.swing.JScrollPane jScrollPane = null;
94
        private javax.swing.JList liVistas = null;
95
        private javax.swing.JCheckBox chbMantenerIntervalo = null;
96
        private javax.swing.JComboBox cbEscala = null;
97
        private javax.swing.JComboBox cbUnidades = null;
98
        private javax.swing.JLabel lIntervalo = null;
99
        private javax.swing.JTextField tIntervalo = null;
100
        private javax.swing.JLabel lNumIntervalos = null;
101
        private javax.swing.JTextField tNumIntervalos = null;
102
        private javax.swing.JLabel lDivIzquierda = null;
103
        private javax.swing.JTextField tDivIzquierda = null;
104
        private javax.swing.JButton bAceptar = null;
105
        private javax.swing.JButton bCancelar = null;
106
107
        //private ProjectView m_projectView=null;
108
        private FFrameView fframeview = null;
109
        private Rectangle2D rect = new Rectangle2D.Double();
110
        private Layout m_layout = null;
111
        private FFrameScaleBar fframescalebar = null; //new FFrameScaleBar();
112
        private boolean isAcepted = false;
113
        private ImageIcon[] images = new ImageIcon[4];
114
        private javax.swing.JButton bFuente = null;
115
        private JPanel pMarcoVista = null;
116
        private JPanel pDescripcion = null;
117
        private JTextField tfDescripcion = null;
118
        private JPanel pUnidades = null;
119
        private JCheckBox chbSobreDescripcion = null;
120
        private JCheckBox chbMostrarUnidades = null;
121
        private JCheckBox chbSobreUnidades = null;
122
        private JPanel pEtiquetas = null;
123
        private JCheckBox chbEtiquetas = null;
124
        private JPanel pBarra = null;
125
        private JPanel jPanel5 = null;
126
        private JPanel jPanel6 = null;
127
        private JPanel jPanel7 = null;
128
        private ColorChooserPanel bUnidadesColor = null;
129
        private ColorChooserPanel bBarraColor = null;
130
        private Color barcolor = null;
131
        private Color textcolor = null;
132
133
        //private JPanel jPanel = null;
134
        //private JPanel jPanel1 = null;
135
        private JPanel jPanel2 = null;
136
        private JCheckBox jCheckBox = null;
137
        private JPRotation pRotation = null;
138
        private JLabel lblBarColor = null;
139
        private JTextField txtNumDec = null;
140
        private JLabel lblNumDec = null;
141
142
        /**
143
         * This is the default constructor
144
         *
145
         * @param layout DOCUMENT ME!
146
         * @param fframe DOCUMENT ME!
147
         */
148
        public FFrameScaleBarDialog(Layout layout, FFrameScaleBar fframe) {
149
                super();
150 9245 caballero
                fframescalebar = (FFrameScaleBar)fframe.cloneFFrame(layout);
151 7304 caballero
                barcolor = fframescalebar.getBarColor();
152
                textcolor = fframescalebar.getTextColor();
153
154
                if (fframescalebar.getFFrameDependence() != null && fframescalebar.getDescription().equals("")) {
155
                        getTfNumberScale().setText("1:" +
156
                                String.valueOf(((FFrameView)fframescalebar.getFFrameDependence()).getScale()));
157
                }
158
159
                m_layout = layout;
160
                initialize();
161
        }
162
163
        /**
164
         * DOCUMENT ME!
165
         *
166
         * @param r DOCUMENT ME!
167
         */
168
        public void setRectangle(Rectangle2D r) {
169
                rect.setRect(r);
170
        }
171
172
        /**
173
         * This method initializes this
174
         */
175
        private void initialize() {
176
                this.setLayout(null);
177
                this.add(getJContentPane(), null);
178
                this.setSize(621, 400);
179
180
                if (fframescalebar.getStyle() == 0) {
181
                        getChbMantenerIntervalo().setEnabled(false);
182
183
                        ///getLUnidades().setEnabled(false);
184
                        getCbUnidades().setEnabled(false);
185
                        getChbEtiquetas().setEnabled(false);
186
                        getBBarraColor().setEnabled(false);
187
                        getChbMostrarUnidades().setEnabled(false);
188
                        getChbSobreUnidades().setEnabled(false);
189
                        getLIntervalo().setEnabled(false);
190
                        getTIntervalo().setEnabled(false);
191
                        getLNumIntervalos().setEnabled(false);
192
                        getTNumIntervalos().setEnabled(false);
193
                        getLDivIzquierda().setEnabled(false);
194
                        getTDivIzquierda().setEnabled(false);
195 8696 caballero
                        getJCheckBox().setEnabled(false);
196
                        getChbSobreDescripcion().setEnabled(false);
197 7304 caballero
                }
198
                getPRotation().setRotation(fframescalebar.getRotation());
199
        }
200
201
        /**
202
         * This method initializes jContentPane
203
         *
204
         * @return javax.swing.JPanel
205
         */
206
        private javax.swing.JPanel getJContentPane() {
207
                if (jContentPane == null) {
208
                        jContentPane = new javax.swing.JPanel();
209
                        jContentPane.setLayout(null);
210
                        jContentPane.add(getBAceptar(), null);
211
                        jContentPane.add(getBCancelar(), null);
212
                        jContentPane.add(getPRotation(), null);
213
                        jContentPane.setSize(617, 386);
214
                        jContentPane.setPreferredSize(new java.awt.Dimension(50, 50));
215
                        jContentPane.setLocation(0, 6);
216
                        jContentPane.add(getPMarcoVista(), null);
217
                        jContentPane.add(getPDescripcion(), null);
218
                        jContentPane.add(getPUnidades(), null);
219
                        jContentPane.add(getPBarra(), null);
220
                        jContentPane.add(getPEtiquetas(), null);
221
                }
222
223
                return jContentPane;
224
        }
225
226
        /**
227
         * This method initializes jScrollPane
228
         *
229
         * @return javax.swing.JScrollPane
230
         */
231
        private javax.swing.JScrollPane getJScrollPane() {
232
                if (jScrollPane == null) {
233
                        jScrollPane = new javax.swing.JScrollPane();
234 7671 caballero
                        jScrollPane.setPreferredSize(new java.awt.Dimension(250,55));
235 7304 caballero
                        jScrollPane.setViewportView(getLiVistas());
236
                }
237
238
                return jScrollPane;
239
        }
240
241
        /**
242
         * This method initializes liVistas
243
         *
244
         * @return javax.swing.JList
245
         */
246
        private javax.swing.JList getLiVistas() {
247
                if (liVistas == null) {
248
                        ListViewModel listmodel = new ListViewModel();
249
                        listmodel.addViews(m_layout);
250
251
                        ///ArrayList list = listmodel.getViews();
252
253
                        liVistas = new javax.swing.JList();
254
255 7671 caballero
                        liVistas.setSize(new java.awt.Dimension(250,52));
256 7304 caballero
                        liVistas.setModel(listmodel);
257
258
                        for (int i = 0; i < liVistas.getModel().getSize(); i++) {
259
                                if (fframescalebar.getFFrameDependence() != null) {
260
                                        fframeview = (FFrameView) liVistas.getModel().getElementAt(i);
261
262
                                        if (fframeview == fframescalebar.getFFrameDependence()) {
263
                                                liVistas.setSelectedIndex(i);
264
                                        }
265
                                }
266
                        }
267
268
                        liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
269
                                        private int selectIndex=-1;
270
                                        public void valueChanged(
271
                                                                javax.swing.event.ListSelectionEvent e) {
272 9392 caballero
                                                IFFrame[] fframes=m_layout.getLayoutContext().getFFrames();
273 7304 caballero
                                                        int selectInt = ((JList) e.getSource())
274
                                                                        .getSelectedIndex();
275
                                                        if (selectInt != selectIndex) {
276
                                                                selectIndex = selectInt;
277
                                                                if (selectIndex == -1)
278
                                                                        return;
279
                                                                fframeview = (FFrameView) liVistas.getModel()
280
                                                                                .getElementAt(selectInt);
281
282
                                                                for (int i = 0; i < fframes.length; i++) {
283
                                                                        IFFrame f = fframes[i];
284
285
                                                                        if (f instanceof FFrameView) {
286
                                                                                if (((FFrameView) f).getView() == fframeview
287
                                                                                                .getView()) {
288
                                                                                        fframescalebar
289
                                                                                                        .setFFrameDependence(fframeview);
290
                                                                                }
291
                                                                        }
292
                                                                }
293
294
                                                                getTNumIntervalos().setText(
295
                                                                                String.valueOf(fframescalebar
296
                                                                                                .getNumInterval()));
297
                                                                getTDivIzquierda().setText(
298
                                                                                String.valueOf(fframescalebar
299
                                                                                                .getNumLeft()));
300
                                                                getTIntervalo().setText(
301
                                                                                fframescalebar.obtainInterval());
302
                                                                getTfNumberScale().setText(
303
                                                                                fframescalebar.getDescription());
304
                                                        }
305
                                                }
306
                                        });
307
                }
308
309
                return liVistas;
310
        }
311
312
        /**
313
         * This method initializes chbMantenerIntervalo
314
         *
315
         * @return javax.swing.JCheckBox
316
         */
317
        private javax.swing.JCheckBox getChbMantenerIntervalo() {
318
                if (chbMantenerIntervalo == null) {
319
                        chbMantenerIntervalo = new javax.swing.JCheckBox();
320
                        chbMantenerIntervalo.setSelected(fframescalebar.isbIntervalSet());
321
                        chbMantenerIntervalo.setText(PluginServices.getText(this,
322
                                        "mantener_intervalo"));
323
                        chbMantenerIntervalo.setPreferredSize(new java.awt.Dimension(200, 20));
324
                        chbMantenerIntervalo.addActionListener(new java.awt.event.ActionListener() {
325
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
326
                                                fframescalebar.setIntervalSet(getChbMantenerIntervalo()
327
                                                                                                                  .isSelected());
328
                                        }
329
                                });
330
                }
331
332
                return chbMantenerIntervalo;
333
        }
334
335
        /**
336
         * This method initializes cbEscala
337
         *
338
         * @return javax.swing.JComboBox
339
         */
340
        private javax.swing.JComboBox getCbEscala() {
341
                if (cbEscala == null) {
342
                        //String[] s={"n?merico","barra1","barra2","barra3","barra4"};
343
                        cbEscala = new javax.swing.JComboBox();
344
                        images[0] = inumero;
345
                        images[1] = ibarra1;
346
                        images[2] = ibarra2;
347
                        images[3] = ibarra3;
348
349
                        /*  Image img=img = new BufferedImage(100, 25,
350
                           BufferedImage.TYPE_INT_ARGB);
351
                           img.getGraphics().drawImage(images[3].getImage(),0,0,null);
352
                           img.getGraphics().setXORMode(Color.yellow);
353
                            images[3]=new ImageIcon(img);
354
                         */
355
                        ComboBoxRenderer renderer = new ComboBoxRenderer();
356
                        renderer.setPreferredSize(new Dimension(100, 25));
357
                        cbEscala.setRenderer(renderer);
358
                        cbEscala.setMaximumRowCount(4);
359
360
                        cbEscala.addItem("0");
361
                        cbEscala.addItem("1");
362
                        cbEscala.addItem("2");
363
                        cbEscala.addItem("3");
364
                        cbEscala.setSelectedIndex(fframescalebar.getStyle());
365
                        cbEscala.setPreferredSize(new java.awt.Dimension(200, 20));
366
                        cbEscala.addActionListener(new java.awt.event.ActionListener() {
367
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
368
                                                fframescalebar.setStyle(getCbEscala().getSelectedIndex());
369
370
                                                if (cbEscala.getSelectedIndex() == 0) {
371
                                                        getChbMantenerIntervalo().setEnabled(false);
372
                                                        getChbMostrarUnidades().setEnabled(false);
373
                                                        getChbSobreUnidades().setEnabled(false);
374
                                                        getCbUnidades().setEnabled(false);
375
                                                        getChbEtiquetas().setEnabled(false);
376
                                                        getBBarraColor().setEnabled(false);
377
                                                        getLIntervalo().setEnabled(false);
378
                                                        getTIntervalo().setEnabled(false);
379
                                                        getLNumIntervalos().setEnabled(false);
380
                                                        getTNumIntervalos().setEnabled(false);
381
                                                        getLDivIzquierda().setEnabled(false);
382
                                                        getTDivIzquierda().setEnabled(false);
383 8696 caballero
                                                        getJCheckBox().setEnabled(false);
384
                                                        getChbSobreDescripcion().setEnabled(false);
385 7304 caballero
                                                } else {
386
                                                        getChbMantenerIntervalo().setEnabled(true);
387
                                                        getChbMostrarUnidades().setEnabled(true);
388
                                                        getChbSobreUnidades().setEnabled(true);
389
                                                        getCbUnidades().setEnabled(true);
390
                                                        getChbEtiquetas().setEnabled(true);
391
                                                        getBBarraColor().setEnabled(true);
392
                                                        getLIntervalo().setEnabled(true);
393
                                                        getTIntervalo().setEnabled(true);
394
                                                        getLNumIntervalos().setEnabled(true);
395
                                                        getTNumIntervalos().setEnabled(true);
396
                                                        getLDivIzquierda().setEnabled(true);
397
                                                        getTDivIzquierda().setEnabled(true);
398 8696 caballero
                                                        getJCheckBox().setEnabled(true);
399
                                                        getChbSobreDescripcion().setEnabled(true);
400 7304 caballero
                                                }
401
                                        }
402
                                });
403
                }
404
405
                return cbEscala;
406
        }
407
408
        /**
409
         * This method initializes cbUnidades
410
         *
411
         * @return javax.swing.JComboBox
412
         */
413
        private javax.swing.JComboBox getCbUnidades() {
414
                if (cbUnidades == null) {
415
                        //String[] s={"Kil?metros","metros","cent?metros","mil?metros","millas","yardas","pies","pulgadas"};
416 11548 jaume
                        cbUnidades = new javax.swing.JComboBox(MapContext.NAMES);
417 7304 caballero
                        cbUnidades.setSelectedIndex(fframescalebar.getUnits());
418
                        cbUnidades.setPreferredSize(new java.awt.Dimension(150, 20));
419
                        cbUnidades.addActionListener(new java.awt.event.ActionListener() {
420
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
421
                                                fframescalebar.setUnits(getCbUnidades()
422
                                                                                                        .getSelectedIndex());
423
                                                getTIntervalo().setText(fframescalebar.obtainInterval());
424
                                        }
425
                                });
426
                }
427
428
                return cbUnidades;
429
        }
430
431
        /**
432
         * This method initializes lIntervalo
433
         *
434
         * @return javax.swing.JLabel
435
         */
436
        private javax.swing.JLabel getLIntervalo() {
437
                if (lIntervalo == null) {
438
                        lIntervalo = new javax.swing.JLabel();
439
                        lIntervalo.setText(PluginServices.getText(this, "Intervalo"));
440 7671 caballero
                        lIntervalo.setPreferredSize(new java.awt.Dimension(155,20));
441 7304 caballero
                }
442
443
                return lIntervalo;
444
        }
445
446
        /**
447
         * This method initializes tIntervalo
448
         *
449
         * @return javax.swing.JTextField
450
         */
451
        private javax.swing.JTextField getTIntervalo() {
452
                if (tIntervalo == null) {
453
                        tIntervalo = new javax.swing.JTextField();
454 7671 caballero
                        tIntervalo.setPreferredSize(new java.awt.Dimension(80,20));
455 7304 caballero
                        tIntervalo.setText(fframescalebar.getInterval());
456
                        tIntervalo.addKeyListener(new java.awt.event.KeyAdapter() {
457
                                        public void keyReleased(java.awt.event.KeyEvent e) {
458
                                                if (!tIntervalo.getText().toString().equals("")) {
459 9163 caballero
                                                        String s=tIntervalo.getText().toString();
460
                                                        try {
461
                                                                fframescalebar.setInterval(FFrameScaleBar.numberFormat.parse(s).doubleValue());
462
                                                        } catch (ParseException e1) {
463
                                                                e1.printStackTrace();
464
                                                        }
465 7304 caballero
                                                        getTNumIntervalos().setText(String.valueOf(
466
                                                                        fframescalebar.getNumInterval()));
467
                                                }
468
                                        }
469
                                });
470
                }
471
472
                return tIntervalo;
473
        }
474
475
        /**
476
         * This method initializes lNumIntervalos
477
         *
478
         * @return javax.swing.JLabel
479
         */
480
        private javax.swing.JLabel getLNumIntervalos() {
481
                if (lNumIntervalos == null) {
482
                        lNumIntervalos = new javax.swing.JLabel();
483
                        lNumIntervalos.setText(PluginServices.getText(this, "Num_intervalos"));
484 7671 caballero
                        lNumIntervalos.setPreferredSize(new java.awt.Dimension(155,20));
485 7304 caballero
                }
486
487
                return lNumIntervalos;
488
        }
489
490
        /**
491
         * This method initializes tNumIntervalos
492
         *
493
         * @return javax.swing.JTextField
494
         */
495
        private javax.swing.JTextField getTNumIntervalos() {
496
                if (tNumIntervalos == null) {
497
                        tNumIntervalos = new javax.swing.JTextField();
498 7671 caballero
                        tNumIntervalos.setPreferredSize(new java.awt.Dimension(80,20));
499 7304 caballero
                        tNumIntervalos.setText(Integer.toString(
500
                                        fframescalebar.getNumInterval()));
501
                        tNumIntervalos.addKeyListener(new java.awt.event.KeyAdapter() {
502
                                        public void keyReleased(java.awt.event.KeyEvent e) {
503
                                                if (!tNumIntervalos.getText().toString().equals("")) {
504
                                                        fframescalebar.setNumInterval(Integer.parseInt(
505
                                                                        tNumIntervalos.getText().toString()));
506
                                                        getTIntervalo().setText(fframescalebar.obtainInterval());
507
                                                }
508
                                        }
509
                                });
510
                }
511
512
                return tNumIntervalos;
513
        }
514
515
        /**
516
         * This method initializes lDivIzquierda
517
         *
518
         * @return javax.swing.JLabel
519
         */
520
        private javax.swing.JLabel getLDivIzquierda() {
521
                if (lDivIzquierda == null) {
522
                        lDivIzquierda = new javax.swing.JLabel();
523
                        lDivIzquierda.setText(PluginServices.getText(this,
524
                                        "divisiones_izquierda"));
525 7671 caballero
                        lDivIzquierda.setPreferredSize(new java.awt.Dimension(155,20));
526 7304 caballero
                }
527
528
                return lDivIzquierda;
529
        }
530
531
        /**
532
         * This method initializes tDivIzquierda
533
         *
534
         * @return javax.swing.JTextField
535
         */
536
        private javax.swing.JTextField getTDivIzquierda() {
537
                if (tDivIzquierda == null) {
538
                        tDivIzquierda = new javax.swing.JTextField();
539 7671 caballero
                        tDivIzquierda.setPreferredSize(new java.awt.Dimension(80,20));
540 7304 caballero
                        tDivIzquierda.setText(Integer.toString(fframescalebar.getNumLeft()));
541
                        tDivIzquierda.addKeyListener(new java.awt.event.KeyAdapter() {
542
                                        public void keyReleased(java.awt.event.KeyEvent e) {
543
                                                if (tDivIzquierda.getText().toString().equals("")) {
544
                                                        tDivIzquierda.setText("0");
545
                                                } else {
546
                                                        fframescalebar.setNumLeft(Integer.parseInt(
547
                                                                        tDivIzquierda.getText()));
548
                                                }
549
                                        }
550
                                });
551
                }
552
553
                return tDivIzquierda;
554
        }
555
556
        /**
557
         * This method initializes bAceptar
558
         *
559
         * @return javax.swing.JButton
560
         */
561
        private javax.swing.JButton getBAceptar() {
562
                if (bAceptar == null) {
563
                        bAceptar = new javax.swing.JButton();
564
                        bAceptar.setSize(85, 26);
565
                        bAceptar.setText(PluginServices.getText(this, "Aceptar"));
566
                        bAceptar.setLocation(106, 347);
567
                        bAceptar.setPreferredSize(new java.awt.Dimension(79, 23));
568
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
569
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
570
                                                fframescalebar.setUnits(getCbUnidades()
571
                                                                                                        .getSelectedIndex());
572
                                                fframescalebar.setBoundBox(FLayoutUtilities.toSheetRect(
573 9392 caballero
                                                                rect, m_layout.getLayoutControl().getAT()));
574 9245 caballero
                                                fframescalebar.setFFrameDependence(fframeview);
575 7304 caballero
                                                fframescalebar.setBarColor(barcolor);
576
                                                fframescalebar.setTextColor(textcolor);
577
                                                fframescalebar.setShowNameUnits(getChbMostrarUnidades()
578
                                                                                                                        .isSelected());
579
                                                fframescalebar.setShowDescription(getJCheckBox()
580
                                                                                                                          .isSelected());
581
                                                fframescalebar.setAboveDescription(getChbSobreDescripcion()
582
                                                                                                                           .isSelected());
583
                                                fframescalebar.setAboveIntervals(getChbEtiquetas()
584
                                                                                                                         .isSelected());
585
                                                fframescalebar.setAboveName(getChbSobreUnidades()
586
                                                                                                                .isSelected());
587
                                                fframescalebar.setRotation(getPRotation().getRotation());
588
                                                fframescalebar.setNumDec(Integer.parseInt(getNumDec().getText()));
589 10505 caballero
                                                fframescalebar.setNumLeft(Integer.parseInt(getTDivIzquierda().getText()));
590 7304 caballero
                                                PluginServices.getMDIManager().closeWindow(FFrameScaleBarDialog.this);
591 9245 caballero
                                                //m_layout.refresh();
592 7304 caballero
                                                isAcepted = true;
593
                                        }
594
                                });
595
                }
596
597
                return bAceptar;
598
        }
599
600
        /**
601
         * This method initializes bCancelar
602
         *
603
         * @return javax.swing.JButton
604
         */
605
        private javax.swing.JButton getBCancelar() {
606
                if (bCancelar == null) {
607
                        bCancelar = new javax.swing.JButton();
608
                        bCancelar.setSize(85, 26);
609
                        bCancelar.setText(PluginServices.getText(this, "Cancelar"));
610
                        bCancelar.setLocation(297, 347);
611
                        bCancelar.setPreferredSize(new java.awt.Dimension(85, 23));
612
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
613
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
614 9245 caballero
                                                fframescalebar=null;
615 7304 caballero
                                                PluginServices.getMDIManager().closeWindow(FFrameScaleBarDialog.this);
616
                                        }
617
                                });
618
                }
619
620
                return bCancelar;
621
        }
622
623
        /* (non-Javadoc)
624
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
625
         */
626
        public WindowInfo getWindowInfo() {
627
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
628
                m_viewinfo.setTitle(PluginServices.getText(this,
629
                                "Propiedades_escala_grafica"));
630
631
                return m_viewinfo;
632
        }
633
634
        /**
635
         * @see com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
636
         */
637
        public boolean getIsAcepted() {
638
                return isAcepted;
639
        }
640
641
        /**
642
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
643
         */
644
        public void viewActivated() {
645
        }
646
647
        /**
648
         * This method initializes bFuente
649
         *
650
         * @return javax.swing.JButton
651
         */
652
        private javax.swing.JButton getBFuente() {
653
                if (bFuente == null) {
654
                        bFuente = new javax.swing.JButton();
655
                        bFuente.setText(PluginServices.getText(this, "fuente"));
656
                        bFuente.addActionListener(new java.awt.event.ActionListener() {
657
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
658
                                                fframescalebar.setFont(FontChooser.showDialog(
659
                                                                PluginServices.getText(this, "seleccion_fuente"),
660
                                                                fframescalebar.getFont())); // fchoser=new FontChooser();
661
                                        }
662
                                });
663
                }
664
665
                return bFuente;
666
        }
667
668
        /**
669
         * This method initializes pMarcoVista
670
         *
671
         * @return javax.swing.JPanel
672
         */
673
        private JPanel getPMarcoVista() {
674
                if (pMarcoVista == null) {
675
                        pMarcoVista = new JPanel();
676 7671 caballero
                        pMarcoVista.setBounds(7, 9, 263, 86);
677 7304 caballero
                        pMarcoVista.setBorder(javax.swing.BorderFactory.createTitledBorder(
678 7671 caballero
                                        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));
679 7304 caballero
                        pMarcoVista.add(getJScrollPane(), null);
680
                }
681
682
                return pMarcoVista;
683
        }
684
685
        /**
686
         * This method initializes pDescripcion
687
         *
688
         * @return javax.swing.JPanel
689
         */
690
        private JPanel getPDescripcion() {
691
                if (pDescripcion == null) {
692 7671 caballero
                        FlowLayout flowLayout1 = new FlowLayout();
693
                        flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
694 7304 caballero
                        pDescripcion = new JPanel();
695 7671 caballero
                        pDescripcion.setLayout(flowLayout1);
696
                        pDescripcion.setBounds(275, 9, 204, 110);
697 7304 caballero
                        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));
698
                        pDescripcion.add(getTfNumberScale(), null);
699
                        pDescripcion.add(getJCheckBox(), null);
700
                        pDescripcion.add(getChbSobreDescripcion(), null);
701
                }
702
703
                return pDescripcion;
704
        }
705
706
        /**
707
         * This method initializes tfDescripcion
708
         *
709
         * @return javax.swing.JTextField
710
         */
711
        private JTextField getTfNumberScale() {
712
                if (tfDescripcion == null) {
713
                        tfDescripcion = new JTextField();
714 7671 caballero
                        tfDescripcion.setPreferredSize(new java.awt.Dimension(180,20));
715 7304 caballero
716
                        tfDescripcion.setEditable(false);
717
                        /*if (fframeview!=null){
718
                           getTfDescripcion().setText("escala 1:"+String.valueOf(fframeview.getScale()));
719
                           }
720
                         */
721
                        tfDescripcion.setText(fframescalebar.getDescription());
722
                }
723
724
                return tfDescripcion;
725
        }
726
727
        /**
728
         * This method initializes pUnidades
729
         *
730
         * @return javax.swing.JPanel
731
         */
732
        private JPanel getPUnidades() {
733
                if (pUnidades == null) {
734 7671 caballero
                        FlowLayout flowLayout = new FlowLayout();
735
                        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
736 7304 caballero
                        pUnidades = new JPanel();
737 7671 caballero
                        pUnidades.setLayout(flowLayout);
738
                        pUnidades.setLocation(274, 122);
739
                        pUnidades.setSize(204, 110);
740 7304 caballero
                        pUnidades.setBorder(javax.swing.BorderFactory.createTitledBorder(
741 7671 caballero
                                        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));
742 7304 caballero
                        pUnidades.add(getCbUnidades(), null);
743
                        pUnidades.add(getChbMostrarUnidades(), null);
744
                        pUnidades.add(getChbSobreUnidades(), null);
745
                }
746
747
                return pUnidades;
748
        }
749
750
        /**
751
         * This method initializes chbSobreDescripcion
752
         *
753
         * @return javax.swing.JCheckBox
754
         */
755
        private JCheckBox getChbSobreDescripcion() {
756
                if (chbSobreDescripcion == null) {
757
                        chbSobreDescripcion = new JCheckBox();
758
                        chbSobreDescripcion.setSelected(fframescalebar.isAboveDescription());
759 7671 caballero
                        chbSobreDescripcion.setPreferredSize(new java.awt.Dimension(180,24));
760 7304 caballero
                        chbSobreDescripcion.setText(PluginServices.getText(this,"sobre_la_barra"));
761
                }
762
763
                return chbSobreDescripcion;
764
        }
765
766
        /**
767
         * This method initializes chbMostrarUnidades
768
         *
769
         * @return javax.swing.JCheckBox
770
         */
771
        private JCheckBox getChbMostrarUnidades() {
772
                if (chbMostrarUnidades == null) {
773
                        chbMostrarUnidades = new JCheckBox();
774
                        chbMostrarUnidades.setText(PluginServices.getText(this,"mostrar_unidades"));
775
                        chbMostrarUnidades.setSelected(fframescalebar.isShowNameUnits());
776
                        chbMostrarUnidades.setPreferredSize(new java.awt.Dimension(150, 24));
777
                }
778
779
                return chbMostrarUnidades;
780
        }
781
782
        /**
783
         * This method initializes chbSobreUnidades
784
         *
785
         * @return javax.swing.JCheckBox
786
         */
787
        private JCheckBox getChbSobreUnidades() {
788
                if (chbSobreUnidades == null) {
789
                        chbSobreUnidades = new JCheckBox();
790
                        chbSobreUnidades.setSelected(fframescalebar.isAboveName());
791
                        chbSobreUnidades.setText(PluginServices.getText(this,"sobre_la_barra"));
792
                        chbSobreUnidades.setPreferredSize(new java.awt.Dimension(150, 24));
793
                }
794
795
                return chbSobreUnidades;
796
        }
797
798
        /**
799
         * This method initializes pEtiquetas
800
         *
801
         * @return javax.swing.JPanel
802
         */
803
        private JPanel getPEtiquetas() {
804
                if (pEtiquetas == null) {
805 7671 caballero
                        FlowLayout flowLayout2 = new FlowLayout();
806
                        flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
807 7304 caballero
                        pEtiquetas = new JPanel();
808 7671 caballero
                        pEtiquetas.setLayout(flowLayout2);
809 7304 caballero
                        pEtiquetas.setBorder(javax.swing.BorderFactory.createTitledBorder(
810 7671 caballero
                                        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));
811
                        pEtiquetas.setBounds(276, 235, 204, 104);
812 7304 caballero
                        pEtiquetas.add(getChbEtiquetas(), null);
813
                        pEtiquetas.add(getJPanel2(), null);
814
                }
815
816
                return pEtiquetas;
817
        }
818
819
        /**
820
         * This method initializes chbEtiquetas
821
         *
822
         * @return javax.swing.JCheckBox
823
         */
824
        private JCheckBox getChbEtiquetas() {
825
                if (chbEtiquetas == null) {
826
                        chbEtiquetas = new JCheckBox();
827
                        chbEtiquetas.setSelected(fframescalebar.isAboveIntervals());
828
                        chbEtiquetas.setText(PluginServices.getText(this,"sobre_la_barra"));
829
                }
830
831
                return chbEtiquetas;
832
        }
833
834
        /**
835
         * This method initializes pBarra
836
         *
837
         * @return javax.swing.JPanel
838
         */
839
        private JPanel getPBarra() {
840
                if (pBarra == null) {
841 7671 caballero
                        FlowLayout flowLayout3 = new FlowLayout();
842
                        flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
843 7304 caballero
                        lblNumDec = new JLabel();
844 7671 caballero
                        lblNumDec.setText(PluginServices.getText(this,"numero_decimales_mostrar"));
845 7304 caballero
                        lblBarColor = new JLabel();
846
                        lblBarColor.setText(PluginServices.getText(this,"color"));
847
                        pBarra = new JPanel();
848 7671 caballero
                        pBarra.setLayout(flowLayout3);
849
                        pBarra.setBounds(8, 98, 263, 241);
850 7304 caballero
                        pBarra.setBorder(javax.swing.BorderFactory.createTitledBorder(
851 7671 caballero
                                        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));
852 7304 caballero
                        pBarra.add(getChbMantenerIntervalo(), null);
853
                        pBarra.add(getCbEscala(), null);
854
                        pBarra.add(lblNumDec, null);
855
                        pBarra.add(getNumDec(), null);
856
                        pBarra.add(getJPanel5(), null);
857
                        pBarra.add(getJPanel7(), null);
858
                        pBarra.add(getJPanel6(), null);
859
                        pBarra.add(lblBarColor, null);
860
                        pBarra.add(getBBarraColor(), null);
861
                }
862
863
                return pBarra;
864
        }
865
866
        /**
867
         * This method initializes jPanel5
868
         *
869
         * @return javax.swing.JPanel
870
         */
871
        private JPanel getJPanel5() {
872
                if (jPanel5 == null) {
873
                        jPanel5 = new JPanel();
874 7671 caballero
                        jPanel5.setPreferredSize(new java.awt.Dimension(245,30));
875 7304 caballero
                        jPanel5.add(getLIntervalo(), null);
876
                        jPanel5.add(getTIntervalo(), null);
877
                }
878
879
                return jPanel5;
880
        }
881
882
        /**
883
         * This method initializes jPanel6
884
         *
885
         * @return javax.swing.JPanel
886
         */
887
        private JPanel getJPanel6() {
888
                if (jPanel6 == null) {
889
                        jPanel6 = new JPanel();
890 7671 caballero
                        jPanel6.setPreferredSize(new java.awt.Dimension(245,30));
891 7304 caballero
                        jPanel6.add(getLDivIzquierda(), null);
892
                        jPanel6.add(getTDivIzquierda(), null);
893
                }
894
895
                return jPanel6;
896
        }
897
898
        /**
899
         * This method initializes jPanel7
900
         *
901
         * @return javax.swing.JPanel
902
         */
903
        private JPanel getJPanel7() {
904
                if (jPanel7 == null) {
905
                        jPanel7 = new JPanel();
906 7671 caballero
                        jPanel7.setPreferredSize(new java.awt.Dimension(245,30));
907 7304 caballero
                        jPanel7.add(getLNumIntervalos(), null);
908
                        jPanel7.add(getTNumIntervalos(), null);
909
                }
910
911
                return jPanel7;
912
        }
913
914
        /**
915
         * This method initializes bUnidadesColor
916
         *
917
         * @return javax.swing.JButton
918
         */
919
        private ColorChooserPanel getBUnidadesColor() {
920
                if (bUnidadesColor == null) {
921
                        bUnidadesColor = new ColorChooserPanel();
922
                        bUnidadesColor.setAlpha(255);
923
                        bUnidadesColor.setColor(textcolor);
924
                        bUnidadesColor.setPreferredSize(new java.awt.Dimension(100,25));
925
                        bUnidadesColor.addActionListener(new java.awt.event.ActionListener() {
926
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
927
                                                textcolor = getBUnidadesColor().getColor();
928
                                        }
929
                                });
930
                }
931
932
                return bUnidadesColor;
933
        }
934
935
        /**
936
         * This method initializes bBarraColor
937
         *
938
         * @return javax.swing.JButton
939
         */
940
        private ColorChooserPanel getBBarraColor() {
941
                if (bBarraColor == null) {
942
                        bBarraColor = new ColorChooserPanel();
943
                        bBarraColor.setPreferredSize(new java.awt.Dimension(100,25));
944
                        bBarraColor.setAlpha(255);
945
                        bBarraColor.setColor(barcolor);
946
                        bBarraColor.addActionListener(new java.awt.event.ActionListener() {
947
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
948
//                                                JDialog dlg;
949
//                                                JColorChooser colorChooser;
950
//                                                colorChooser = new JColorChooser();
951
//                                                dlg = JColorChooser.createDialog((JFrame) null,
952
//                                                                PluginServices.getText(this, "Elegir_Color"),
953
//                                                                true, colorChooser, null, null);
954
//                                                dlg.show(true);
955
//
956
                                                barcolor = getBBarraColor().getColor();
957
958
//                                                bBarraColor.setBackground(barcolor);
959
//                                                bBarraColor.setForeground(barcolor);
960
                                        }
961
                                });
962
                }
963
964
                return bBarraColor;
965
        }
966
967
        /**
968
         * This method initializes jPanel
969
         *
970
         * @return javax.swing.JPanel
971
         */
972
973
        /*private JPanel getJPanel() {
974
           if (jPanel == null) {
975
                   jPanel = new JPanel();
976
                   jPanel.setPreferredSize(new java.awt.Dimension(44,24));
977
                   jPanel.setForeground(barcolor);
978
                   jPanel.setBackground(barcolor);
979
           }
980
           return jPanel;
981
           }
982
         */
983
984
        /**
985
         * This method initializes jPanel1
986
         *
987
         * @return javax.swing.JPanel
988
         */
989
990
        /*        private JPanel getJPanel1() {
991
           if (jPanel1 == null) {
992
                   jPanel1 = new JPanel();
993
                   jPanel1.setBackground(textcolor);
994
                   jPanel1.setPreferredSize(new java.awt.Dimension(44,24));
995
           }
996
           return jPanel1;
997
           }
998
         */
999
1000
        /**
1001
         * This method initializes jPanel2
1002
         *
1003
         * @return javax.swing.JPanel
1004
         */
1005
        private JPanel getJPanel2() {
1006
                if (jPanel2 == null) {
1007
                        jPanel2 = new JPanel();
1008
                        jPanel2.add(getBFuente(), null);
1009
                        jPanel2.add(getBUnidadesColor(), null);
1010
1011
                        //jPanel2.add(getJPanel1(), null);
1012
                }
1013
1014
                return jPanel2;
1015
        }
1016
1017
        /**
1018
         * This method initializes jCheckBox
1019
         *
1020
         * @return javax.swing.JCheckBox
1021
         */
1022
        private JCheckBox getJCheckBox() {
1023
                if (jCheckBox == null) {
1024
                        jCheckBox = new JCheckBox();
1025
                        jCheckBox.setSelected(fframescalebar.isShowDescription());
1026 7671 caballero
                        jCheckBox.setPreferredSize(new java.awt.Dimension(180,24));
1027 7304 caballero
                        jCheckBox.setText(PluginServices.getText(this,"mostrar_escala_numerica"));
1028
                }
1029
1030
                return jCheckBox;
1031
        }
1032
1033
        /**
1034
         * DOCUMENT ME!
1035
         *
1036
         * @author Vicente Caballero Navarro
1037
         */
1038
        class ComboBoxRenderer extends JLabel implements ListCellRenderer {
1039
                /**
1040
                 * Crea un nuevo ComboBoxRenderer.
1041
                 */
1042
                public ComboBoxRenderer() {
1043
                        setOpaque(true);
1044
                        setHorizontalAlignment(CENTER);
1045
                        setVerticalAlignment(CENTER);
1046
                }
1047
1048
                /*
1049
                 * This method finds the image and text corresponding
1050
                 * to the selected value and returns the label, set up
1051
                 * to display the text and image.
1052
                 */
1053
                public Component getListCellRendererComponent(JList list, Object value,
1054
                        int index, boolean isSelected, boolean cellHasFocus) {
1055
                        //Get the selected index. (The index param isn't
1056
                        //always valid, so just use the value.)
1057
                        ///int selectedIndex = ((Integer)value).intValue();
1058
                        if (isSelected) {
1059
                                setBackground(list.getSelectionBackground());
1060
                                setForeground(list.getSelectionForeground());
1061
                        } else {
1062
                                setBackground(list.getBackground());
1063
                                setForeground(list.getForeground());
1064
                        }
1065
1066
                        ImageIcon icon = images[Integer.parseInt((String) value)];
1067
                        setIcon(icon);
1068
1069
                        return this;
1070
                }
1071
        }
1072
1073
        /**
1074
         * This method initializes pRotation
1075
         *
1076
         * @return javax.swing.JPanel
1077
         */
1078
        private JPRotation getPRotation() {
1079
                if (pRotation == null) {
1080
                        pRotation = new JPRotation();
1081
                        pRotation.setBounds(480, 10, 120, 120);
1082
                }
1083
                return pRotation;
1084
        }
1085
1086
        /**
1087
         * This method initializes numDec
1088
         *
1089
         * @return javax.swing.JTextField
1090
         */
1091
        private JTextField getNumDec() {
1092
                if (txtNumDec == null) {
1093
                        txtNumDec = new JTextField();
1094
                        txtNumDec.setPreferredSize(new java.awt.Dimension(30,20));
1095
                        txtNumDec.setText(String.valueOf(fframescalebar.getNumDec()));
1096
                        txtNumDec.addKeyListener(new java.awt.event.KeyAdapter() {
1097
                                public void keyReleased(KeyEvent arg0) {
1098
                                        super.keyReleased(arg0);
1099
                                        if (!getNumDec().getText().toString().equals("")) {
1100
                                                fframescalebar.setNumDec(Integer.parseInt(
1101
                                                                getNumDec().getText().toString()));
1102
                                                getTIntervalo().setText(fframescalebar.obtainInterval());
1103
                                        }
1104
                                }
1105
                        });
1106
                }
1107
                return txtNumDec;
1108
        }
1109 9245 caballero
1110
        public IFFrame getFFrame() {
1111
                return fframescalebar;
1112
        }
1113 7304 caballero
} //  @jve:decl-index=0:visual-constraint="17,10"
1114
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"