Revision 38095 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/gui/utils/FontChooser.java

View differences:

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

  
45 2
package org.gvsig.app.gui.utils;
46 3

  
47
/*
48
 * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
49
 * for visualizing and manipulating spatial features with geometry and attributes.
50
 *
51
 * Copyright (C) 2003 Vivid Solutions
52
 *
53
 * This program is free software; you can redistribute it and/or
54
 * modify it under the terms of the GNU General Public License
55
 * as published by the Free Software Foundation; either version 2
56
 * of the License, or (at your option) any later version.
57
 *
58
 * This program is distributed in the hope that it will be useful,
59
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
60
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
61
 * GNU General Public License for more details.
62
 *
63
 * You should have received a copy of the GNU General Public License
64
 * along with this program; if not, write to the Free Software
65
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
66
 *
67
 * For more information, contact:
68
 *
69
 * Vivid Solutions
70
 * Suite #1A
71
 * 2328 Government Street
72
 * Victoria BC  V8T 5G5
73
 * Canada
74
 *
75
 * (250)385-6040
76
 * www.vividsolutions.com
77
 */
78

  
79

  
4
import java.awt.Dialog;
80 5
import java.awt.Font;
81
import java.awt.GraphicsEnvironment;
82
import java.awt.GridBagConstraints;
83
import java.awt.Insets;
84
import java.awt.event.KeyEvent;
85
import java.util.StringTokenizer;
86 6

  
87
import javax.swing.DefaultListModel;
88
import javax.swing.JList;
89
import javax.swing.JPanel;
90
import javax.swing.JScrollPane;
7
import org.jfree.ui.FontChooserDialog;
91 8

  
92
import org.gvsig.andami.PluginServices;
93
import org.gvsig.andami.ui.mdiManager.IWindow;
94
import org.gvsig.andami.ui.mdiManager.WindowInfo;
95 9

  
96 10

  
97

  
98
/**
99
 * Based on FontChooser by Janos Szatmary. Posted on the Sun Java forums.
100
 *
101
 * Szatmary, Janos. "A FontChooser Class (source included)." April 2001.
102
 * Available from http://forum.java.sun.com/thread.jsp?forum=57&thread=124810.
103
 * Internet; accessed 6 November 2002.
104
 *
105
*/
106
public class FontChooser extends JPanel implements IWindow{
107
    private String sampleText = "The quick brown fox jumped over the lazy dog.";
108
    String[] styleList = new String[] { PluginServices.getText(this,"Plain"),
109
    		PluginServices.getText(this,"Bold"), PluginServices.getText(this,"Italic") };
110
    String[] sizeList = new String[] {
111
            "2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "22", "24",
112
            "30", "36", "48", "72"
113
        };
114
    String currentFont = null;
115
    int currentStyle = -1;
116
    int currentSize = -1;
117
    public boolean ok = false;
118

  
119
    // Variables declaration - do not modify
120
    private javax.swing.JPanel jPanel3;
121
    private javax.swing.JTextField jFont;
122
    private javax.swing.JScrollPane jScrollPane1;
123
    private javax.swing.JList jFontList;
124
    private javax.swing.JPanel jPanel4;
125
    private javax.swing.JTextField jStyle;
126
    private javax.swing.JScrollPane jScrollPane2;
127
    private javax.swing.JList jStyleList;
128
    private javax.swing.JPanel jPanel5;
129
    private javax.swing.JTextField jSize;
130
    private javax.swing.JScrollPane jScrollPane3;
131
    private javax.swing.JList jSizeList;
132
    private javax.swing.JPanel jPanel1;
133
    private javax.swing.JScrollPane jScrollPane4;
134
    private javax.swing.JTextArea jSample;
135
    private javax.swing.JPanel jButtons;
136
    private javax.swing.JButton jOk;
137
    private javax.swing.JButton jCancel;
138
    private javax.swing.JLabel jLabel6;
139
	private String m_title;
140
	/* ------------------------------------------------------------- */
141
    private FontChooser() {
142
        //super(parent, modal);
143
        jbInit();
144
        setListValues(jFontList,
145
            GraphicsEnvironment.getLocalGraphicsEnvironment()
146
                               .getAvailableFontFamilyNames());
147
        setListValues(jStyleList, styleList);
148
        setListValues(jSizeList, sizeList);
149
        setCurrentFont(jSample.getFont());
150
       // pack();
151
    }
152

  
153
    private FontChooser(Font font) {
154
        this();
155
        setCurrentFont(font);
156
    }
157

  
158
    /* ------------------------------------------------------------- */
159
    private void setListValues(JList list, String[] values) {
160
        if (list.getModel() instanceof DefaultListModel) {
161
            DefaultListModel model = (DefaultListModel) list.getModel();
162
            model.removeAllElements();
163

  
164
            for (int j = 0; j < values.length; j++) {
165
                model.addElement(values[j]);
166
            }
167
        }
168
    }
169

  
170
    /* ------------------------------------------------------------- */
171
    private void setSampleFont() {
172
        if ((currentFont != null) && (currentStyle >= 0) && (currentSize > 0)) {
173
            jSample.setFont(new Font(currentFont, currentStyle, currentSize));
174
        }
175
    }
176

  
177
    private String styleToString(int style) {
178
        String str = "";
179

  
180
        if ((style & Font.BOLD) == Font.BOLD) {
181
            if (str.length() > 0) {
182
                str += ",";
183
            }
184

  
185
            str += PluginServices.getText(this,"Bold");
186
        }
187

  
188
        if ((style & Font.ITALIC) == Font.ITALIC) {
189
            if (str.length() > 0) {
190
                str += ",";
191
            }
192

  
193
            str += PluginServices.getText(this,"Italic");
194
        }
195

  
196
        if ((str.length() <= 0) && ((style & Font.PLAIN) == Font.PLAIN)) {
197
            str = PluginServices.getText(this,"Plain");
198
        }
199

  
200
        return str;
201
    }
202

  
203
    /* ------------------------------------------------------------- */
204
    public Font getCurrentFont() {
205
        return jSample.getFont();
206
    }
207

  
208
    /* ------------------------------------------------------------- */
209
    public void setCurrentFont(Font font) {
210
        if (font == null) {
211
            font = jSample.getFont();
212
        }
213

  
214
        jFont.setText(font.getName());
215
        jFontActionPerformed(null);
216

  
217
        jStyle.setText(styleToString(font.getStyle()));
218
        jStyleActionPerformed(null);
219

  
220
        jSize.setText(Integer.toString(font.getSize()));
221
        jSizeActionPerformed(null);
222
    }
223

  
224
    /* ------------------------------------------------------------- */
11
public class FontChooser {
225 12
    public static Font showDialog(String title, Font font) {
226
        FontChooser dialog = new FontChooser(font);
227
        PluginServices.getMDIManager().addWindow(dialog);
228
        /*Point p1 = parent.getLocation();
229
        Dimension d1 = parent.getSize();
230
        Dimension d2 = dialog.getSize();
231

  
232
        int x = p1.x + ((d1.width - d2.width) / 2);
233
        int y = p1.y + ((d1.height - d2.height) / 2);
234

  
235
        if (x < 0) {
236
            x = 0;
237
        }
238

  
239
        if (y < 0) {
240
            y = 0;
241
        }
242
*/
243
        if (title != null) {
244
            dialog.m_title=title;
245
        }
246

  
247
      //  dialog.setLocation(x, y);
248
      //  dialog.setVisible(true);
249

  
250
        Font newfont = null;
251

  
252
        if (dialog.ok) {
253
            newfont = dialog.getCurrentFont();
254
        }
255

  
256
        //dialog.dispose();
257

  
258
        return newfont;
13
    	
14
    	FontChooserDialog dlg = new FontChooserDialog((Dialog)null,title, true,font);
15
    	dlg.setVisible(true);
16
    	if( dlg.isCancelled() ) {
17
    		return null;
18
    	}
19
    	return dlg.getSelectedFont();
259 20
    }
260

  
261
    /** This method is called from within the constructor to
262
    * initialize the form.
263
    * WARNING: Do NOT modify this code. The content of this
264
    method is
265
    * always regenerated by the FormEditor.
266
    */
267
    private void jbInit() {
268
    	GridBagConstraints gridBagConstraints = new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 3, 3, 3), 0, 0);
269
        gridBagConstraints.weighty = 1.0D;
270
    	jPanel3 = new javax.swing.JPanel();
271
        jFont = new javax.swing.JTextField();
272
        jScrollPane1 = new javax.swing.JScrollPane();
273
        jFontList = new javax.swing.JList();
274
        jPanel4 = new javax.swing.JPanel();
275
        jStyle = new javax.swing.JTextField();
276
        jScrollPane2 = new javax.swing.JScrollPane();
277
        jStyleList = new javax.swing.JList();
278
        jPanel5 = new javax.swing.JPanel();
279
        jSize = new javax.swing.JTextField();
280
        jScrollPane3 = new javax.swing.JScrollPane();
281
        jSizeList = new javax.swing.JList();
282
        jPanel1 = new javax.swing.JPanel();
283
        jScrollPane4 = new javax.swing.JScrollPane();
284
        jScrollPane4.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
285
        jScrollPane4.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
286
        jSample = new javax.swing.JTextArea();
287
        jSample.setEditable(false);
288
        jButtons = new javax.swing.JPanel();
289
        jOk = new javax.swing.JButton();
290
        jCancel = new javax.swing.JButton();
291
        jLabel6 = new javax.swing.JLabel();
292
        setLayout(new java.awt.GridBagLayout());
293

  
294
        this.setPreferredSize(new java.awt.Dimension(600,400));
295
        java.awt.GridBagConstraints gridBagConstraints1;
296
        //setTitle("Font Chooser");
297
        /*addWindowListener(new java.awt.event.WindowAdapter() {
298
                public void windowClosing(java.awt.event.WindowEvent evt) {
299
                    closeDialog(evt);
300
                }
301
            });
302
*/
303
        jPanel3.setLayout(new java.awt.GridBagLayout());
304

  
305
        java.awt.GridBagConstraints gridBagConstraints2;
306
        jPanel3.setBorder(new javax.swing.border.TitledBorder(
307
                new javax.swing.border.EtchedBorder(), " "+PluginServices.getText(this,"Font")+" "));
308

  
309
        jFont.setEditable(false);
310
        jFont.setColumns(24);
311
        jFont.addActionListener(new java.awt.event.ActionListener() {
312
                public void actionPerformed(java.awt.event.ActionEvent evt) {
313
                    jFontActionPerformed(evt);
314
                }
315
            });
316
        gridBagConstraints2 = new java.awt.GridBagConstraints();
317
        gridBagConstraints2.gridwidth = 0;
318
        gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
319
        gridBagConstraints2.insets = new java.awt.Insets(0, 3, 0, 3);
320
        gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
321
        gridBagConstraints2.weightx = 1.0;
322
        jStyle.setEditable(false);
323
        jPanel3.add(jFont, gridBagConstraints2);
324

  
325
        jFontList.setModel(new DefaultListModel());
326
        jFontList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
327
        jFontList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
328
                public void valueChanged(
329
                    javax.swing.event.ListSelectionEvent evt) {
330
                    jFontListValueChanged(evt);
331
                }
332
            });
333
        jScrollPane1.setViewportView(jFontList);
334

  
335
        gridBagConstraints2 = new java.awt.GridBagConstraints();
336
        gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
337
        gridBagConstraints2.insets = new java.awt.Insets(3, 3, 3, 3);
338
        gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
339
        gridBagConstraints2.weightx = 1.0;
340
        gridBagConstraints2.weighty = 1.0;
341
        jPanel3.add(jScrollPane1, gridBagConstraints2);
342

  
343
        gridBagConstraints1 = new java.awt.GridBagConstraints();
344
        gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
345
        gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0);
346
        gridBagConstraints1.weightx = 0.5;
347
        gridBagConstraints1.weighty = 1.0;
348
        add(jPanel3, gridBagConstraints1);
349

  
350
        jPanel4.setLayout(new java.awt.GridBagLayout());
351

  
352
        java.awt.GridBagConstraints gridBagConstraints3;
353
        jPanel4.setBorder(new javax.swing.border.TitledBorder(
354
                new javax.swing.border.EtchedBorder(), " "+PluginServices.getText(this,"Style")+" "));
355

  
356
        jStyle.setColumns(18);
357
        jStyle.addActionListener(new java.awt.event.ActionListener() {
358
                public void actionPerformed(java.awt.event.ActionEvent evt) {
359
                    jStyleActionPerformed(evt);
360
                }
361
            });
362
        gridBagConstraints3 = new java.awt.GridBagConstraints();
363
        gridBagConstraints3.gridwidth = 0;
364
        gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
365
        gridBagConstraints3.insets = new java.awt.Insets(0, 3, 0, 3);
366
        gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;
367
        gridBagConstraints3.weightx = 1.0;
368
        jPanel4.add(jStyle, gridBagConstraints3);
369

  
370
        jStyleList.setModel(new DefaultListModel());
371
        jStyleList.setVisibleRowCount(4);
372
        jStyleList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
373
                public void valueChanged(
374
                    javax.swing.event.ListSelectionEvent evt) {
375
                    jStyleListValueChanged(evt);
376
                }
377
            });
378
        jScrollPane2.setViewportView(jStyleList);
379

  
380
        gridBagConstraints3 = new java.awt.GridBagConstraints();
381
        gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;
382
        gridBagConstraints3.insets = new java.awt.Insets(3, 3, 3, 3);
383
        gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;
384
        gridBagConstraints3.weightx = 0.5;
385
        gridBagConstraints3.weighty = 1.0;
386
        jPanel4.add(jScrollPane2, gridBagConstraints3);
387

  
388
        gridBagConstraints1 = new java.awt.GridBagConstraints();
389
        gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
390
        gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0);
391
        gridBagConstraints1.weightx = 0.375;
392
        gridBagConstraints1.weighty = 1.0;
393
        add(jPanel4, gridBagConstraints1);
394

  
395
        jPanel5.setLayout(new java.awt.GridBagLayout());
396

  
397
        java.awt.GridBagConstraints gridBagConstraints4;
398
        jPanel5.setBorder(new javax.swing.border.TitledBorder(
399
                new javax.swing.border.EtchedBorder(), " "+PluginServices.getText(this,"Size")+" "));
400

  
401
        jSize.setColumns(6);
402
        jSize.addActionListener(new java.awt.event.ActionListener() {
403
                public void actionPerformed(java.awt.event.ActionEvent evt) {
404
                    jSizeActionPerformed(evt);
405
                }
406
            });
407
        gridBagConstraints4 = new java.awt.GridBagConstraints();
408
        gridBagConstraints4.gridwidth = 0;
409
        gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
410
        gridBagConstraints4.insets = new java.awt.Insets(0, 3, 0, 3);
411
        gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;
412
        gridBagConstraints4.weightx = 1.0;
413
        jPanel5.add(jSize, gridBagConstraints4);
414

  
415
        jSizeList.setModel(new DefaultListModel());
416
        jSizeList.setVisibleRowCount(4);
417
        jSizeList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
418
        jSizeList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
419
                public void valueChanged(
420
                    javax.swing.event.ListSelectionEvent evt) {
421
                    jSizeListValueChanged(evt);
422
                }
423
            });
424
        jScrollPane3.setViewportView(jSizeList);
425

  
426
        gridBagConstraints4 = new java.awt.GridBagConstraints();
427
        gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;
428
        gridBagConstraints4.insets = new java.awt.Insets(3, 3, 3, 3);
429
        gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;
430
        gridBagConstraints4.weightx = 0.25;
431
        gridBagConstraints4.weighty = 1.0;
432
        jPanel5.add(jScrollPane3, gridBagConstraints4);
433

  
434
        gridBagConstraints1 = new java.awt.GridBagConstraints();
435
        gridBagConstraints1.gridwidth = 0;
436
        gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
437
        gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 5);
438
        gridBagConstraints1.weightx = 0.125;
439
        gridBagConstraints1.weighty = 1.0;
440

  
441
        //    getContentPane().add(jPanel5, gridBagConstraints1);
442
        jPanel1.setLayout(new java.awt.GridBagLayout());
443

  
444
        java.awt.GridBagConstraints gridBagConstraints5;
445
        jPanel1.setBorder(new javax.swing.border.TitledBorder(
446
                new javax.swing.border.EtchedBorder(), " "+PluginServices.getText(this,"Sample")+" "));
447

  
448
        jSample.setWrapStyleWord(true);
449
        jSample.setLineWrap(true);
450
        jSample.setColumns(20);
451
        jSample.setRows(3);
452
        jSample.setText(sampleText);
453
        jScrollPane4.setViewportView(jSample);
454

  
455
        gridBagConstraints5 = new java.awt.GridBagConstraints();
456
        gridBagConstraints5.fill = java.awt.GridBagConstraints.BOTH;
457
        gridBagConstraints5.insets = new java.awt.Insets(0, 3, 3, 3);
458
        gridBagConstraints5.weightx = 1.0;
459
        gridBagConstraints5.weighty = 1.0;
460
        jPanel1.add(jScrollPane4, gridBagConstraints5);
461

  
462
        gridBagConstraints1 = new java.awt.GridBagConstraints();
463
        gridBagConstraints1.gridwidth = 0;
464
        gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
465
        gridBagConstraints1.insets = new java.awt.Insets(0, 5, 0, 5);
466
        gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
467
        gridBagConstraints1.weightx = 1.0;
468

  
469

  
470
        jButtons.setLayout(new java.awt.GridBagLayout());
471

  
472
        jOk.setMnemonic(KeyEvent.VK_O);
473
        jOk.setText(PluginServices.getText(this,"Aceptar"));
474
        jOk.setRequestFocusEnabled(false);
475
        jOk.addActionListener(new java.awt.event.ActionListener() {
476
                public void actionPerformed(java.awt.event.ActionEvent evt) {
477
                    jOkActionPerformed(evt);
478
                }
479
            });
480
        jButtons.add(jOk,
481
            new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
482
                GridBagConstraints.WEST, GridBagConstraints.NONE,
483
                new Insets(5, 5, 5, 0), 0, 0));
484

  
485
        jCancel.setMnemonic(KeyEvent.VK_C);
486
        jCancel.setText(PluginServices.getText(this,"Cancelar"));
487
        jCancel.setRequestFocusEnabled(false);
488
        jCancel.addActionListener(new java.awt.event.ActionListener() {
489
                public void actionPerformed(java.awt.event.ActionEvent evt) {
490
                    jCancelActionPerformed(evt);
491
                }
492
            });
493

  
494
        jButtons.add(jCancel,
495
            new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
496
                GridBagConstraints.WEST, GridBagConstraints.NONE,
497
                new Insets(5, 5, 5, 5), 0, 0));
498

  
499
        gridBagConstraints1 = new java.awt.GridBagConstraints();
500
        gridBagConstraints1.gridwidth = 0;
501
        gridBagConstraints1.anchor = java.awt.GridBagConstraints.SOUTHWEST;
502
        gridBagConstraints1.weightx = 1.0;
503
        this.add(jPanel1, gridBagConstraints);
504
        add(jButtons,
505
            new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0,
506
                GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE,
507
                new Insets(0, 0, 0, 0), 0, 0));
508
    }
509

  
510
    private void jCancelActionPerformed(java.awt.event.ActionEvent evt) {
511
        // Add your handling code here:
512
    	PluginServices.getMDIManager().closeWindow(FontChooser.this);
513
    }
514

  
515
    private void jOkActionPerformed(java.awt.event.ActionEvent evt) {
516
        // Add your handling code here:
517
        ok = true;
518
        PluginServices.getMDIManager().closeWindow(FontChooser.this);
519
    }
520

  
521
    private void jSizeActionPerformed(java.awt.event.ActionEvent evt) {
522
        // Add your handling code here:
523
        int size = 0;
524

  
525
        try {
526
            size = Integer.parseInt(jSize.getText());
527
        } catch (Exception e) {
528
        }
529

  
530
        if (size > 0) {
531
            currentSize = size;
532
            setSampleFont();
533
        }
534
    }
535

  
536
    private void jStyleActionPerformed(java.awt.event.ActionEvent evt) {
537
        // Add your handling code here:
538
        StringTokenizer st = new StringTokenizer(jStyle.getText(), ",");
539
        int style = 0;
540

  
541
        while (st.hasMoreTokens()) {
542
            String str = st.nextToken().trim();
543

  
544
            if (str.equalsIgnoreCase(PluginServices.getText(this,"Plain"))) {
545
                style |= Font.PLAIN;
546
            } else if (str.equalsIgnoreCase(PluginServices.getText(this,"Bold"))) {
547
                style |= Font.BOLD;
548
            } else if (str.equalsIgnoreCase(PluginServices.getText(this,"Italic"))) {
549
                style |= Font.ITALIC;
550
            }
551
        }
552

  
553
        if (style >= 0) {
554
            currentStyle = style;
555
            setSampleFont();
556
        }
557
    }
558

  
559
    private void jFontActionPerformed(java.awt.event.ActionEvent evt) {
560
        // Add your handling code here:
561
        DefaultListModel model = (DefaultListModel) jFontList.getModel();
562

  
563
        if (model.indexOf(jFont.getText()) >= 0) {
564
            currentFont = jFont.getText();
565
            setSampleFont();
566
        }
567
    }
568

  
569
    private void jStyleListValueChanged(
570
        javax.swing.event.ListSelectionEvent evt) {
571
        // Add your handling code here:
572
        String str = new String();
573
        Object[] values = jStyleList.getSelectedValues();
574

  
575
        if (values.length > 0) {
576
            int j;
577

  
578
            for (j = 0; j < values.length; j++) {
579
                String s = (String) values[j];
580

  
581
                if (s.equalsIgnoreCase(PluginServices.getText(this,"Plain"))) {
582
                    str = PluginServices.getText(this,"Plain");
583

  
584
                    break;
585
                }
586

  
587
                if (str.length() > 0) {
588
                    str += ",";
589
                }
590

  
591
                str += (String) values[j];
592
            }
593
        } else {
594
            str = styleToString(currentStyle);
595
        }
596

  
597
        jStyle.setText(str);
598
        jStyleActionPerformed(null);
599
    }
600

  
601
    private void jSizeListValueChanged(javax.swing.event.ListSelectionEvent evt) {
602
        // Add your handling code here:
603
        String str = (String) jSizeList.getSelectedValue();
604

  
605
        if ((str == null) || (str.length() <= 0)) {
606
            str = Integer.toString(currentSize);
607
        }
608

  
609
        jSize.setText(str);
610
        jSizeActionPerformed(null);
611
    }
612

  
613
    private void jFontListValueChanged(javax.swing.event.ListSelectionEvent evt) {
614
        // Add your handling code here:
615
        String str = (String) jFontList.getSelectedValue();
616

  
617
        if ((str == null) || (str.length() <= 0)) {
618
            str = currentFont;
619
        }
620

  
621
        jFont.setText(str);
622
        jFontActionPerformed(null);
623
    }
624

  
625

  
626

  
627
	/* (non-Javadoc)
628
	 * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
629
	 */
630
public WindowInfo getWindowInfo() {
631
	WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
632
	m_viewinfo.setWidth(500);
633
	m_viewinfo.setHeight(300);
634
	//vi.setResizable(false);
635
	m_viewinfo.setTitle(PluginServices.getText(this,"Elegir_Fuente"));
636

  
637
	return m_viewinfo;
638 21
}
639

  
640
/**
641
 * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
642
 */
643
public void viewActivated() {
644
}
645

  
646
	public Object getWindowProfile() {
647
		return WindowInfo.DIALOG_PROFILE;
648
	}
649
    // End of variables declaration
650
}

Also available in: Unified diff