Statistics
| Revision:

svn-gvsig-desktop / tags / gvSIGv0_6_1RELEASE / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / dialogs / FFrameTextDialog.java @ 5222

History | View | Annotate | Download (25.1 KB)

1 312 fernando
/*
2
 * Created on 22-jun-2004
3
 *
4
 */
5 1103 fjp
/* 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 312 fernando
package com.iver.cit.gvsig.gui.layout.fframes.dialogs;
46
47 1551 vcaballero
import java.awt.Color;
48 1500 fjp
import java.awt.geom.Rectangle2D;
49
50
import javax.swing.ImageIcon;
51 1551 vcaballero
import javax.swing.JColorChooser;
52
import javax.swing.JDialog;
53
import javax.swing.JFrame;
54 1500 fjp
import javax.swing.JPanel;
55
import javax.swing.JToggleButton;
56
57 596 fernando
import com.iver.andami.PluginServices;
58
import com.iver.andami.ui.mdiManager.ViewInfo;
59 2268 fjp
import com.iver.cit.gvsig.AddLayer;
60 312 fernando
import com.iver.cit.gvsig.gui.Dialogs.FontChooser;
61
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities;
62
import com.iver.cit.gvsig.gui.layout.Layout;
63
import com.iver.cit.gvsig.gui.layout.fframes.FFrameText;
64 3450 jaume
import java.lang.Double;
65 312 fernando
66 1074 vcaballero
67 1551 vcaballero
import javax.swing.JButton;
68 2239 jaume
import javax.swing.JCheckBox;
69
import javax.swing.JTextField;
70
import javax.swing.JLabel;
71 312 fernando
/**
72
 * Dialogo para a?adir texto al Layout.
73 1074 vcaballero
 *
74 312 fernando
 * @author Vicente Caballero Navarro
75
 */
76
public class FFrameTextDialog extends JPanel implements IFFrameDialog {
77 2268 fjp
        public static final ImageIcon ileft = new ImageIcon(AddLayer.class.getClassLoader()
78 1500 fjp
                                                                                                                                   .getResource("images/left.PNG")); //$NON-NLS-1$
79 2268 fjp
        public static final ImageIcon icenterV = new ImageIcon(AddLayer.class.getClassLoader()
80 1500 fjp
                                                                                                                                          .getResource("images/centerV.PNG")); //$NON-NLS-1$
81 2268 fjp
        public static final ImageIcon iright = new ImageIcon(AddLayer.class.getClassLoader()
82 1500 fjp
                                                                                                                                        .getResource("images/right.PNG")); //$NON-NLS-1$
83 1074 vcaballero
        private javax.swing.JPanel jContentPane = null; //  @jve:visual-info  decl-index=0 visual-constraint="593,10"
84 312 fernando
        private javax.swing.JScrollPane jScrollPane = null;
85
        private javax.swing.JTextArea taTexto = null;
86
        private javax.swing.JLabel lAlinear = null;
87
        private JToggleButton bIzquierda = null;
88
        private JToggleButton bCentro = null;
89
        private JToggleButton bDerecha = null;
90 2239 jaume
        private javax.swing.JCheckBox chkEscalaVista = null;
91 312 fernando
        private javax.swing.JButton bAceptar = null;
92
        private javax.swing.JButton bCancelar = null;
93 1074 vcaballero
        private Layout m_layout = null;
94
        private Rectangle2D rect = new Rectangle2D.Double();
95
        private FFrameText fframetext = null; //new FFrameText();
96
        private boolean isAcepted = false;
97 312 fernando
        private javax.swing.JButton bFuente = null;
98 1551 vcaballero
        private Color textcolor = null;
99 2239 jaume
        private Color frameColor =null;
100
        private Color titleColor =null;
101 1551 vcaballero
        private JButton jButton = null;
102 2239 jaume
        private JCheckBox chkSurroundingRectangle = null;
103
        private JTextField txtCellPadding = null;
104
        private JLabel jLabel = null;
105
        private JCheckBox chkFontSize = null;
106
        private JTextField txtFontSize = null;
107
        private JCheckBox chkTitle = null;
108
        private JTextField txtTitle = null;
109
        private JPanel jPanel = null;
110
        private JTextField txtTitleSize = null;
111
        private JLabel jLabel3 = null;
112
    private JLabel jLabel4;
113
        private JPanel jPanel1 = null;
114
        private JTextField txtFrameSize = null;
115
        private JLabel jLabel5 = null;
116
        private JLabel jLabel6 = null;
117
        private JLabel jLabel7 = null;
118
        private JButton jButton1 = null;
119
        private JButton jButton2 = null;
120 2305 vcaballero
        private JPRotation pRotation = null;
121 312 fernando
        /**
122
         * This is the default constructor
123 1074 vcaballero
         *
124
         * @param layout Referencia al Layout.
125
         * @param fframe Referencia al fframe de texto.
126 312 fernando
         */
127 1074 vcaballero
        public FFrameTextDialog(Layout layout, FFrameText fframe) {
128 312 fernando
                super();
129 1074 vcaballero
                fframetext = fframe;
130
                m_layout = layout;
131 1551 vcaballero
                textcolor = fframe.getTextColor();
132 2239 jaume
                frameColor = fframe.getFrameColor();
133
                titleColor = fframe.getTitleColor();
134 312 fernando
                initialize();
135
        }
136 1074 vcaballero
137 312 fernando
        /**
138
         * This method initializes this
139
         */
140
        private void initialize() {
141
                this.setLayout(null);
142
                this.add(getJContentPane(), null);
143 2305 vcaballero
                this.setSize(419, 429);
144
                getPRotation().setRotation(fframetext.getRotation());
145 312 fernando
        }
146 1074 vcaballero
147
        /**
148
         * Inserta el rect?ngulo a ocupar por el fframe de texto.
149
         *
150
         * @param r Rect?ngulo.
151
         */
152
        public void setRectangle(Rectangle2D r) {
153 312 fernando
                rect.setRect(r);
154
        }
155 1074 vcaballero
156 312 fernando
        /**
157
         * This method initializes jContentPane
158 1074 vcaballero
         *
159 312 fernando
         * @return javax.swing.JPanel
160
         */
161
        private javax.swing.JPanel getJContentPane() {
162
                if (jContentPane == null) {
163 2239 jaume
                        jLabel = new JLabel();
164 312 fernando
                        jContentPane = new javax.swing.JPanel();
165
                        jContentPane.setLayout(null);
166
                        jContentPane.add(getJScrollPane(), null);
167
                        jContentPane.add(getLAlinear(), null);
168
                        jContentPane.add(getBIzquierda(), null);
169
                        jContentPane.add(getBCentro(), null);
170
                        jContentPane.add(getBDerecha(), null);
171 1074 vcaballero
172 312 fernando
                        //jContentPane.add(getJLabel1(), null);
173
                        //jContentPane.add(getJComboBox(), null);
174
                        //jContentPane.add(getJLabel2(), null);
175 2239 jaume
                        jContentPane.add(getChkEscalaVista(), null);
176 312 fernando
                        jContentPane.add(getBAceptar(), null);
177
                        jContentPane.add(getBCancelar(), null);
178
                        jContentPane.add(getBFuente(), null);
179 2305 vcaballero
                        jContentPane.setSize(412, 422);
180 2239 jaume
                        jContentPane.setLocation(3, 4);
181 1551 vcaballero
                        jContentPane.add(getJButton(), null);
182 2239 jaume
                        // jaume
183 3278 caballero
                        jLabel.setText(PluginServices.getText(this, "Milimetros"));
184
                        jLabel.setSize(56, 16);
185
                        jLabel.setLocation(215, 74);
186 2239 jaume
                        jContentPane.add(getJPanel1(), null);
187
                        jContentPane.add(getJPanel(), null);
188
                        jContentPane.add(getChkFontSize(), null);
189
                        jContentPane.add(getTxtFontSize(), null);
190 2305 vcaballero
                        jContentPane.add(getPRotation(), null);
191 312 fernando
                }
192 1074 vcaballero
193 312 fernando
                return jContentPane;
194
        }
195 1074 vcaballero
196 312 fernando
        /**
197
         * This method initializes jScrollPane
198 1074 vcaballero
         *
199 312 fernando
         * @return javax.swing.JScrollPane
200
         */
201
        private javax.swing.JScrollPane getJScrollPane() {
202 1074 vcaballero
                if (jScrollPane == null) {
203 312 fernando
                        jScrollPane = new javax.swing.JScrollPane();
204
                        jScrollPane.setViewportView(getTaTexto());
205
                        jScrollPane.setSize(261, 83);
206
                        jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
207
                        jScrollPane.setLocation(5, 5);
208
                }
209 1074 vcaballero
210 312 fernando
                return jScrollPane;
211
        }
212 1074 vcaballero
213 312 fernando
        /**
214
         * This method initializes taTexto
215 1074 vcaballero
         *
216 312 fernando
         * @return javax.swing.JTextArea
217
         */
218
        private javax.swing.JTextArea getTaTexto() {
219 1074 vcaballero
                if (taTexto == null) {
220 312 fernando
                        taTexto = new javax.swing.JTextArea();
221 1074 vcaballero
222
                        for (int i = 0; i < fframetext.getText().size(); i++) {
223 1500 fjp
                                if (!((String) fframetext.getText().get(i)).equals("")) { //$NON-NLS-1$
224 1074 vcaballero
                                        taTexto.append((String) fframetext.getText().get(i));
225 312 fernando
                                }
226
                        }
227
                }
228 1074 vcaballero
229 312 fernando
                return taTexto;
230
        }
231 1074 vcaballero
232 312 fernando
        /**
233
         * This method initializes lAlinear
234 1074 vcaballero
         *
235 312 fernando
         * @return javax.swing.JLabel
236
         */
237
        private javax.swing.JLabel getLAlinear() {
238 1074 vcaballero
                if (lAlinear == null) {
239 312 fernando
                        lAlinear = new javax.swing.JLabel();
240 1551 vcaballero
                        lAlinear.setSize(52, 27);
241 1500 fjp
                        lAlinear.setText(PluginServices.getText(this, "alinear")); //$NON-NLS-1$
242 312 fernando
                        lAlinear.setLocation(5, 98);
243
                }
244 1074 vcaballero
245 312 fernando
                return lAlinear;
246
        }
247 1074 vcaballero
248 312 fernando
        /**
249
         * This method initializes bIzquierda
250 1074 vcaballero
         *
251 312 fernando
         * @return javax.swing.JButton
252
         */
253
        private JToggleButton getBIzquierda() {
254 1074 vcaballero
                if (bIzquierda == null) {
255 312 fernando
                        bIzquierda = new JToggleButton();
256
                        bIzquierda.setSize(30, 27);
257 1074 vcaballero
                        bIzquierda.setPreferredSize(new java.awt.Dimension(28, 20));
258 1551 vcaballero
                        bIzquierda.setLocation(60, 98);
259 1074 vcaballero
260
                        if (fframetext.getPos() == FFrameText.LEFT) {
261
                                bIzquierda.setSelected(true);
262 312 fernando
                        }
263 1074 vcaballero
264 312 fernando
                        bIzquierda.setIcon(ileft);
265 1074 vcaballero
                        bIzquierda.addActionListener(new java.awt.event.ActionListener() {
266
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
267
                                                fframetext.setPos(FFrameText.LEFT);
268
                                                getBIzquierda().setSelected(true);
269
                                                getBCentro().setSelected(false);
270
                                                getBDerecha().setSelected(false);
271
                                        }
272
                                });
273 312 fernando
                }
274 1074 vcaballero
275 312 fernando
                return bIzquierda;
276
        }
277 1074 vcaballero
278 312 fernando
        /**
279
         * This method initializes bCentro
280 1074 vcaballero
         *
281 312 fernando
         * @return javax.swing.JButton
282
         */
283
        private JToggleButton getBCentro() {
284 1074 vcaballero
                if (bCentro == null) {
285 312 fernando
                        bCentro = new JToggleButton();
286
                        bCentro.setSize(30, 27);
287 1074 vcaballero
                        bCentro.setPreferredSize(new java.awt.Dimension(28, 20));
288 1551 vcaballero
                        bCentro.setLocation(93, 98);
289 1074 vcaballero
290
                        if (fframetext.getPos() == FFrameText.CENTER) {
291 312 fernando
                                bCentro.setSelected(true);
292
                        }
293 1074 vcaballero
294 312 fernando
                        bCentro.setIcon(icenterV);
295 1074 vcaballero
                        bCentro.addActionListener(new java.awt.event.ActionListener() {
296
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
297
                                                fframetext.setPos(FFrameText.CENTER);
298
                                                getBIzquierda().setSelected(false);
299
                                                getBCentro().setSelected(true);
300
                                                getBDerecha().setSelected(false);
301
                                        }
302
                                });
303 312 fernando
                }
304 1074 vcaballero
305 312 fernando
                return bCentro;
306
        }
307 1074 vcaballero
308 312 fernando
        /**
309
         * This method initializes bDerecha
310 1074 vcaballero
         *
311 312 fernando
         * @return javax.swing.JButton
312
         */
313
        private JToggleButton getBDerecha() {
314 1074 vcaballero
                if (bDerecha == null) {
315 312 fernando
                        bDerecha = new JToggleButton();
316
                        bDerecha.setSize(30, 27);
317 1074 vcaballero
                        bDerecha.setPreferredSize(new java.awt.Dimension(28, 20));
318 1551 vcaballero
                        bDerecha.setLocation(126, 98);
319 1074 vcaballero
320
                        if (fframetext.getPos() == FFrameText.RIGTH) {
321 312 fernando
                                bDerecha.setSelected(true);
322
                        }
323 1074 vcaballero
324 312 fernando
                        bDerecha.setIcon(iright);
325 1074 vcaballero
                        bDerecha.addActionListener(new java.awt.event.ActionListener() {
326
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
327
                                                fframetext.setPos(FFrameText.RIGTH);
328
                                                getBIzquierda().setSelected(false);
329
                                                getBCentro().setSelected(false);
330
                                                getBDerecha().setSelected(true);
331
                                        }
332
                                });
333 312 fernando
                }
334 1074 vcaballero
335 312 fernando
                return bDerecha;
336
        }
337 1074 vcaballero
338 312 fernando
        /**
339
         * This method initializes chbEscalaVista
340 1074 vcaballero
         *
341 312 fernando
         * @return javax.swing.JCheckBox
342
         */
343 2239 jaume
        private javax.swing.JCheckBox getChkEscalaVista() {
344
                if (chkEscalaVista == null) {
345
                        chkEscalaVista = new javax.swing.JCheckBox();
346
                        chkEscalaVista.setSize(280, 20);
347
                        chkEscalaVista.setText(
348 1500 fjp
                                PluginServices.getText(this, "__redimensionar_texto_escala")); //$NON-NLS-1$
349 2239 jaume
                        chkEscalaVista.setSelected(fframetext.isSizeFixed());
350
                        chkEscalaVista.setLocation(6, 153);
351
                        chkEscalaVista.setEnabled(true);
352 312 fernando
                }
353 1074 vcaballero
354 2239 jaume
                return chkEscalaVista;
355 312 fernando
        }
356 1074 vcaballero
357 312 fernando
        /**
358
         * This method initializes bAceptar
359 1074 vcaballero
         *
360 312 fernando
         * @return javax.swing.JButton
361
         */
362
        private javax.swing.JButton getBAceptar() {
363 1074 vcaballero
                if (bAceptar == null) {
364 312 fernando
                        bAceptar = new javax.swing.JButton();
365
                        bAceptar.setSize(79, 26);
366 1500 fjp
                        bAceptar.setText(PluginServices.getText(this, "Aceptar")); //$NON-NLS-1$
367 2239 jaume
                        bAceptar.setLocation(39, 388);
368 1074 vcaballero
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
369
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
370
                                                fframetext.setBoundBox(FLayoutUtilities.toSheetRect(
371
                                                                rect, m_layout.getAT()));
372 312 fernando
                                                fframetext.getText().clear();
373 1074 vcaballero
374
                                                for (int i = 0; i < getTaTexto().getLineCount(); i++) {
375
                                                        try {
376
                                                                String s = getTaTexto().getText(getTaTexto()
377
                                                                                                                                        .getLineStartOffset(i),
378
                                                                                getTaTexto().getLineEndOffset(i) -
379
                                                                                getTaTexto().getLineStartOffset(i));
380
381 1500 fjp
                                                                if (!s.equals("")) { //$NON-NLS-1$
382 4126 jaume
                                                                        fframetext.addText(s.trim());
383 1074 vcaballero
                                                                }
384
                                                        } catch (Exception ex) {
385 312 fernando
                                                        }
386
                                                }
387 1551 vcaballero
                                                fframetext.setTextColor(textcolor);
388 2239 jaume
                                                fframetext.setSizeFixed(!getChkEscalaVista().isSelected());
389
390
                                                // jaume
391
                                                boolean b = getChkSurroundingRectangle().isSelected();
392
                                                fframetext.setSurrounded(getChkSurroundingRectangle().isSelected());
393
394
                                                if (b){
395
                                                    // Hay rect?ngulo
396 3278 caballero
                                                    fframetext.setCellPadding(Double.parseDouble(getTxtCellPadding().getText())/100);
397
                                                    double i;
398 2391 jaume
                                                    try{
399 3450 jaume
                                                            i = Double.parseDouble(getTxtFrameSize().getText());
400 2391 jaume
                                                    } catch (Exception ex){
401
                                                            i = 0;
402
                                                    }
403 2239 jaume
                                                    if (i==0) i = 1;
404 3278 caballero
                                                    fframetext.setFrameBorderSize(i/100);
405 2239 jaume
                                                    fframetext.setFrameColor(frameColor);
406
                                                }
407
                                                b=getChkFontSize().isSelected();
408
                                                fframetext.setFixedFontSize(b);
409
410
                                                if (b){
411
                                                    // El tama?o de la fuente es fijo
412 2391 jaume
                                                        int i;
413
                                                    try{
414
                                                            i = Integer.parseInt(getTxtFontSize().getText());
415
                                                    } catch (Exception ex){
416
                                                            i = 12;
417
                                                    }
418
                                                    fframetext.setFontSize(i);
419 2239 jaume
                                                }
420
                                                b=getChkTitle().isSelected();
421
                                                fframetext.setHasTitle(b);
422
                                                if (b){
423
                                                    // Hay t?tulo
424
                                                    fframetext.setTitle(getTxtTitle().getText());
425 2391 jaume
                                                    int i;
426
                                                    try{
427
                                                            i = Integer.parseInt(getTxtTitleSize().getText());
428
                                                    } catch (Exception ex){
429
                                                            i = 12;
430
                                                    }
431
                                                        fframetext.setTitleSize(i);
432
433 2239 jaume
                                                    fframetext.setTitleColor(titleColor);
434
                                                }
435
436 2305 vcaballero
                                        fframetext.setRotation(getPRotation().getRotation());
437
                                        PluginServices.getMDIManager().closeView(FFrameTextDialog.this);
438 312 fernando
                                                m_layout.refresh();
439 1074 vcaballero
                                                isAcepted = true;
440
                                        }
441
                                });
442 312 fernando
                }
443 1074 vcaballero
444 312 fernando
                return bAceptar;
445
        }
446 1074 vcaballero
447 312 fernando
        /**
448
         * This method initializes bCancelar
449 1074 vcaballero
         *
450 312 fernando
         * @return javax.swing.JButton
451
         */
452
        private javax.swing.JButton getBCancelar() {
453 1074 vcaballero
                if (bCancelar == null) {
454 312 fernando
                        bCancelar = new javax.swing.JButton();
455
                        bCancelar.setSize(85, 26);
456 1500 fjp
                        bCancelar.setText(PluginServices.getText(this, "Cancelar")); //$NON-NLS-1$
457 2239 jaume
                        bCancelar.setLocation(144, 388);
458 1074 vcaballero
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
459
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
460
                                                PluginServices.getMDIManager().closeView(FFrameTextDialog.this);
461
                                        }
462
                                });
463 312 fernando
                }
464 1074 vcaballero
465 312 fernando
                return bCancelar;
466
        }
467 1074 vcaballero
468 312 fernando
        /* (non-Javadoc)
469
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
470
         */
471
        public ViewInfo getViewInfo() {
472 1074 vcaballero
                ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
473
474
                //vi.setResizable(false);
475 1500 fjp
                m_viewinfo.setTitle(PluginServices.getText(this, "Propiedades_texto")); //$NON-NLS-1$
476 1074 vcaballero
477
                return m_viewinfo;
478
        }
479
480 312 fernando
        /**
481
         * @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
482
         */
483
        public boolean getIsAcepted() {
484
                return isAcepted;
485
        }
486 1074 vcaballero
487 312 fernando
        /**
488
         * This method initializes bFuente
489 1074 vcaballero
         *
490 312 fernando
         * @return javax.swing.JButton
491
         */
492
        private javax.swing.JButton getBFuente() {
493 1074 vcaballero
                if (bFuente == null) {
494 312 fernando
                        bFuente = new javax.swing.JButton();
495 1551 vcaballero
                        bFuente.setBounds(157, 98, 73, 27);
496 1500 fjp
                        bFuente.setText(PluginServices.getText(this, "fuente")); //$NON-NLS-1$
497 1074 vcaballero
                        bFuente.addActionListener(new java.awt.event.ActionListener() {
498
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
499
                                                fframetext.setFont(FontChooser.showDialog(
500 1500 fjp
                                                                PluginServices.getText(this, "__seleccion_de_fuente"), fframetext.getFont())); // fchoser=new FontChooser();         //$NON-NLS-1$
501 1074 vcaballero
                                        }
502
                                });
503 312 fernando
                }
504 1074 vcaballero
505 312 fernando
                return bFuente;
506 1074 vcaballero
        }
507
508
        /**
509 312 fernando
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
510
         */
511
        public void viewActivated() {
512
        }
513 1551 vcaballero
        /**
514
         * This method initializes jButton
515
         *
516
         * @return javax.swing.JButton
517
         */
518
        private JButton getJButton() {
519
                if (jButton == null) {
520
                        jButton = new JButton();
521
                        jButton.setForeground(Color.white);
522
                        jButton.setBackground(textcolor);
523
                        jButton.setBounds(235, 98, 32, 27);
524
                        jButton.addActionListener(new java.awt.event.ActionListener() {
525
                                public void actionPerformed(java.awt.event.ActionEvent e) {
526
                                        JDialog dlg;
527
                                        JColorChooser colorChooser;
528
                                        colorChooser = new JColorChooser();
529
                                        dlg = JColorChooser.createDialog((JFrame) null,
530
                                                        PluginServices.getText(this, "Elegir_Color"),
531
                                                        true, colorChooser, null, null);
532
                                        dlg.show(true);
533
534
                                        textcolor = (Color) colorChooser.getColor();
535
536
                                        //getJPanel1().setBackground(textcolor);
537
                                        jButton.setBackground(textcolor);
538
539
                                }
540
                        });
541
                }
542
                return jButton;
543
        }
544 2239 jaume
        /**
545
         * This method initializes chbSurroundingRectangle
546
         *
547
         * @return javax.swing.JCheckBox
548
         * @author jaume
549
         */
550
        private JCheckBox getChkSurroundingRectangle() {
551
                if (chkSurroundingRectangle == null) {
552
                        chkSurroundingRectangle = new JCheckBox();
553
                        chkSurroundingRectangle.setText(PluginServices.getText(this, "usar_marco"));
554
                        chkSurroundingRectangle.setSelected(fframetext.isSurrounded());
555
                        chkSurroundingRectangle.setBounds(5, 20, 143, 19);
556
                        chkSurroundingRectangle.addItemListener(new java.awt.event.ItemListener() {
557
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
558
                                        getTxtCellPadding().setEnabled(getChkSurroundingRectangle().isSelected());
559
                                        getTxtFrameSize().setEnabled(getChkSurroundingRectangle().isSelected());
560
                                }
561
                        });
562
                }
563
                return chkSurroundingRectangle;
564
        }
565
        /**
566
         * This method initializes txtCellPadding
567
         *
568
         * @author jaume
569
         *
570
         * @return javax.swing.JTextField
571
         */
572
        private JTextField getTxtCellPadding() {
573
                if (txtCellPadding == null) {
574
                        txtCellPadding = new JTextField();
575
                        txtCellPadding.setEnabled(fframetext.isSurrounded());
576 3278 caballero
                        txtCellPadding.setText(fframetext.getCellPadding()*100+"");
577 2239 jaume
                        txtCellPadding.setSize(60, 20);
578 3278 caballero
                        txtCellPadding.setLocation(140, 74);
579 2239 jaume
                        txtCellPadding.addKeyListener(new java.awt.event.KeyAdapter() {
580
                                public void keyReleased(java.awt.event.KeyEvent e) {
581
                                        ensureInteger(txtCellPadding);
582
                                }
583
                        });
584
585
                }
586
                return txtCellPadding;
587
        }
588
        /**
589
         * This method initializes chkFontSize
590
         *
591
         * @return javax.swing.JCheckBox
592
         */
593
        private JCheckBox getChkFontSize() {
594
                if (chkFontSize == null) {
595
                        chkFontSize = new JCheckBox();
596
                        chkFontSize.setBounds(6, 174, 143, 19);
597 2391 jaume
                        chkFontSize.setText(PluginServices.getText(this, "tamanyo_fuente"));
598 2239 jaume
                        chkFontSize.setSelected(fframetext.isFontSizeFixed());
599
                        chkFontSize.addItemListener(new java.awt.event.ItemListener() {
600
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
601
                                    getTxtFontSize().setEnabled(getChkFontSize().isSelected());
602
                                }
603
                        });
604
                }
605
                return chkFontSize;
606
        }
607
        /**
608
         * This method initializes txtFontSize
609
         *
610
         * @return javax.swing.JTextField
611
         */
612
        private JTextField getTxtFontSize() {
613
                if (txtFontSize == null) {
614
                        txtFontSize = new JTextField();
615
                        txtFontSize.setBounds(153, 176, 64, 17);
616
                        txtFontSize.setEnabled(fframetext.isFontSizeFixed());
617
                        if (txtFontSize.isEnabled()) txtFontSize.setText(fframetext.getFontSize()+"");
618
                        txtFontSize.addKeyListener(new java.awt.event.KeyAdapter() {
619
                                public void keyReleased(java.awt.event.KeyEvent e) {
620
                                        ensureInteger(txtFontSize);
621
                                }
622
                        });
623
                }
624
                return txtFontSize;
625
        }
626
        /**
627
         * This method initializes chkTitle2
628
         *
629
         * @return javax.swing.JCheckBox
630
         */
631
        private JCheckBox getChkTitle() {
632
                if (chkTitle == null) {
633
                        chkTitle = new JCheckBox();
634
                        chkTitle.setText(PluginServices.getText(this, "usar_titulo"));
635
                        chkTitle.setSelected(fframetext.hasTitle());
636
                        chkTitle.setBounds(6, 17, 85, 19);
637
                        chkTitle.addChangeListener(new javax.swing.event.ChangeListener() {
638
                                public void stateChanged(javax.swing.event.ChangeEvent e) {
639
                                        getTxtTitle().setEnabled(chkTitle.isSelected());
640
                                        getTxtTitleSize().setEnabled(chkTitle.isSelected());
641
                                        jLabel3.setEnabled(chkTitle.isSelected());
642
                                }
643
                        });
644
                }
645
                return chkTitle;
646
        }
647
        /**
648
         * This method initializes txtTitle
649
         *
650
         * @return javax.swing.JTextField
651
         */
652
        private JTextField getTxtTitle() {
653
                if (txtTitle == null) {
654
                        txtTitle = new JTextField();
655
                        txtTitle.setEnabled(fframetext.hasTitle());
656
                        if (fframetext.hasTitle())
657
                            txtTitle.setText(fframetext.getTitle());
658
                        txtTitle.setBounds(92, 17, 175, 20);
659
                }
660
                return txtTitle;
661
        }
662
        /**
663
         * This method initializes jPanel
664
         *
665
         * @return javax.swing.JPanel
666
         */
667
        private JPanel getJPanel() {
668
                if (jPanel == null) {
669
                    jPanel = new JPanel();
670
                    jLabel3 = new JLabel();
671
                        jPanel.setLayout(null);
672
                        jPanel.setBounds(4, 307, 273, 76);
673
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
674
                                        null, PluginServices.getText(this, "titulo_fframetext"),
675
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
676
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
677
                        jLabel3.setBounds(9, 45, 109, 22);
678 2391 jaume
                        jLabel3.setText(PluginServices.getText(this, "tamanyo_fuente"));
679 2239 jaume
                        jLabel3.setEnabled(fframetext.hasTitle());
680
                        jPanel.add(getTxtTitleSize(), null);
681
                        jPanel.add(jLabel3, null);
682
                        jPanel.add(getChkTitle(), null);
683
                        jPanel.add(getTxtTitle(), null);
684
                        jLabel4 = new JLabel();
685
                        jLabel4.setBounds(190, 45, 40, 16);
686
                        jPanel.add(jLabel4, null);
687
                        jLabel4.setText(PluginServices.getText(this, "pixeles"));
688
                        jPanel.add(getJButton2(), null);
689
690
                }
691
                return jPanel;
692
        }
693
        /**
694
         * This method initializes txtTitleSize
695
         *
696
         * @return javax.swing.JTextField
697
         */
698
        private JTextField getTxtTitleSize() {
699
                if (txtTitleSize == null) {
700
                        txtTitleSize = new JTextField();
701
                        txtTitleSize.setBounds(121, 45, 64, 20);
702
                        txtTitleSize.setEnabled(fframetext.hasTitle());
703
                        int i = fframetext.getTitleSize();
704 2308 jaume
                        if (i == 0 && !txtTitleSize.isEnabled()) i = 5;
705 2239 jaume
                        txtTitleSize.setText(i+"");
706
                        txtTitleSize.addKeyListener(new java.awt.event.KeyAdapter() {
707
                                public void keyReleased(java.awt.event.KeyEvent e) {
708
                                        ensureInteger(txtTitleSize);
709
                                }
710
                        });
711
                }
712
                return txtTitleSize;
713
        }
714
715
        /**
716
         * Asegura cutremente que no se meten valores que no sean.
717
         * El funcionamiento consiste en si el ?ltimo car?cter escrito
718
         * no vale para formar un int entonces se elimina.
719
         *
720
         * enteros.
721
         * @param tf
722
         */
723
        private void ensureInteger(JTextField tf){
724
            String s = tf.getText();
725
            try {
726
                Integer.parseInt(s);
727
            } catch (Exception e){
728
                if (s.length()!=0)
729
                    tf.setText(s.substring(0, s.length()-1));
730
                else tf.setText("");
731
            }
732
        }
733
        /**
734
         * This method initializes jPanel1
735
         *
736
         * @return javax.swing.JPanel
737
         */
738
        private JPanel getJPanel1() {
739
                if (jPanel1 == null) {
740
                        jPanel1 = new JPanel();
741
                        jLabel5 = new JLabel();
742
                        jLabel6 = new JLabel();
743
                        jLabel7 = new JLabel();
744
                        jPanel1.setLayout(null);
745
                        jPanel1.setBounds(4, 199, 273, 106);
746
                        jPanel1.add(getTxtCellPadding(), null);
747
                        jPanel1.add(getChkSurroundingRectangle(), null);
748
                        jPanel1.add(jLabel, null);
749
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
750
                                        null, PluginServices.getText(this, "marco"),
751
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
752
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
753 3278 caballero
                        jLabel5.setText(PluginServices.getText(this, "Milimetros"));
754
                        jLabel5.setLocation(215, 46);
755
                        jLabel5.setSize(56, 16);
756 2239 jaume
                        jLabel5.setPreferredSize(new java.awt.Dimension(40,16));
757 3278 caballero
                        jLabel6.setBounds(35, 47, 100, 20);
758 2391 jaume
                        jLabel6.setText(PluginServices.getText(this, "tamanyo_borde"));
759 2239 jaume
                        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
760 3278 caballero
                        jLabel7.setBounds(35, 73, 100, 20);
761 2239 jaume
                        jLabel7.setText(PluginServices.getText(this, "margenes"));
762
                        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
763
                        jPanel1.add(getTxtFrameSize(), null);
764
                        jPanel1.add(jLabel6, null);
765
                        jPanel1.add(jLabel7, null);
766
                        jPanel1.add(jLabel5, null);
767
                        jPanel1.add(getJButton1(), null);
768
                }
769
                return jPanel1;
770
        }
771
        /**
772
         * This method initializes txtFrameSize
773
         *
774
         * @return javax.swing.JTextField
775
         */
776
        private JTextField getTxtFrameSize() {
777
                if (txtFrameSize == null) {
778
                        txtFrameSize = new JTextField();
779
                        txtFrameSize.setEnabled(fframetext.isSurrounded());
780
                        //if (txtFrameSize.isEnabled()){
781 3278 caballero
                            double i = fframetext.getFrameBorderSize()*100;
782 2239 jaume
                            if (i==0) i = 1;
783
                            txtFrameSize.setText(i+"");
784
                        //}
785 3278 caballero
                        txtFrameSize.setLocation(140, 47);
786 2239 jaume
                        txtFrameSize.setSize(60, 20);
787
                }
788
                return txtFrameSize;
789
        }
790
        /**
791
         * This method initializes jButton1
792
         *
793
         * @return javax.swing.JButton
794
         */
795
        private JButton getJButton1() {
796
                if (jButton1 == null) {
797
                        jButton1 = new JButton();
798
                        jButton1.setForeground(fframetext.getFrameColor());
799
                        jButton1.setBackground(fframetext.getFrameColor());
800
                        jButton1.setBounds(229, 12, 32, 27);
801
                        jButton1.addActionListener(new java.awt.event.ActionListener() {
802
                                public void actionPerformed(java.awt.event.ActionEvent e) {
803
                                    // color del marco
804
                                    JDialog dlg;
805
                                        JColorChooser colorChooser;
806
                                        colorChooser = new JColorChooser();
807
                                        dlg = JColorChooser.createDialog((JFrame) null,
808
                                                        PluginServices.getText(this, "Elegir_Color"),
809
                                                        true, colorChooser, null, null);
810
                                        dlg.show(true);
811
812
                                        frameColor = (Color) colorChooser.getColor();
813
814
                                        //getJPanel1().setBackground(textcolor);
815
                                        jButton1.setBackground(frameColor);
816
                                }
817
                        });
818
                }
819
                return jButton1;
820
        }
821
        /**
822
         * This method initializes jButton2
823
         *
824
         * @return javax.swing.JButton
825
         */
826
        private JButton getJButton2() {
827
                if (jButton2 == null) {
828
                        jButton2 = new JButton();
829
                        jButton2.setForeground(fframetext.getTitleColor());
830
                        jButton2.setBackground(fframetext.getTitleColor());
831
                        jButton2.addActionListener(new java.awt.event.ActionListener() {
832
                                public void actionPerformed(java.awt.event.ActionEvent e) {
833
                                    // color del t?tulo
834
                                    JDialog dlg;
835
                                        JColorChooser colorChooser;
836
                                        colorChooser = new JColorChooser();
837
                                        dlg = JColorChooser.createDialog((JFrame) null,
838
                                                        PluginServices.getText(this, "Elegir_Color"),
839
                                                        true, colorChooser, null, null);
840
                                        dlg.show(true);
841
842
                                        titleColor = (Color) colorChooser.getColor();
843
                                        jButton2.setBackground(titleColor);
844
                                }
845
                        });
846
847
                        jButton2.setBounds(235, 40, 32, 27);
848
                }
849
                return jButton2;
850
        }
851 2305 vcaballero
852
        /**
853
         * This method initializes pRotation
854
         *
855
         * @return javax.swing.JPanel
856
         */
857
        private JPRotation getPRotation() {
858
                if (pRotation == null) {
859
                        pRotation = new JPRotation();
860
                        pRotation.setBounds(281, 13, 125, 131);
861
                }
862
                return pRotation;
863
        }
864 2239 jaume
}  //  @jve:decl-index=0:visual-constraint="10,10"