svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / utils / PartialFontChooserDialog.java @ 41065
History | View | Annotate | Download (3.97 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.gui.utils; |
25 |
|
26 |
|
27 |
import java.awt.BorderLayout; |
28 |
import java.awt.Dialog; |
29 |
import java.awt.Font; |
30 |
import java.awt.Frame; |
31 |
import javax.swing.BorderFactory; |
32 |
import javax.swing.JPanel; |
33 |
|
34 |
import org.jfree.ui.StandardDialog; |
35 |
|
36 |
/**
|
37 |
* A dialog for choosing a font from the available system fonts.
|
38 |
* Allows hiding size and/or style (bold, etc)
|
39 |
*
|
40 |
* @author jldominguez
|
41 |
*/
|
42 |
public class PartialFontChooserDialog extends StandardDialog { |
43 |
|
44 |
/** The panel within the dialog that contains the font selection controls. */
|
45 |
private PartialFontChooserPanel fontChooserPanel;
|
46 |
|
47 |
private boolean allowStyle = true; |
48 |
private boolean allowSize = true; |
49 |
|
50 |
/**
|
51 |
* Standard constructor - builds a font chooser dialog owned by another dialog.
|
52 |
*
|
53 |
* @param owner the dialog that 'owns' this dialog.
|
54 |
* @param title the title for the dialog.
|
55 |
* @param modal a boolean that indicates whether or not the dialog is modal.
|
56 |
* @param font the initial font displayed.
|
57 |
*/
|
58 |
public PartialFontChooserDialog(
|
59 |
final Dialog owner, |
60 |
final String title, |
61 |
final boolean modal, |
62 |
final Font font, |
63 |
boolean style,
|
64 |
boolean size) {
|
65 |
|
66 |
super(owner, title, modal);
|
67 |
allowStyle = style; |
68 |
allowSize = size; |
69 |
setContentPane(createContent(font)); |
70 |
} |
71 |
|
72 |
/**
|
73 |
* Standard constructor - builds a font chooser dialog owned by a frame.
|
74 |
*
|
75 |
* @param owner the frame that 'owns' this dialog.
|
76 |
* @param title the title for the dialog.
|
77 |
* @param modal a boolean that indicates whether or not the dialog is modal.
|
78 |
* @param font the initial font displayed.
|
79 |
*/
|
80 |
public PartialFontChooserDialog(
|
81 |
final Frame owner, |
82 |
final String title, |
83 |
final boolean modal, |
84 |
final Font font, |
85 |
boolean style,
|
86 |
boolean size) {
|
87 |
|
88 |
super(owner, title, modal);
|
89 |
allowStyle = style; |
90 |
allowSize = size; |
91 |
setContentPane(createContent(font)); |
92 |
} |
93 |
|
94 |
|
95 |
/**
|
96 |
* Returns the selected font.
|
97 |
*
|
98 |
* @return the font.
|
99 |
*/
|
100 |
public Font getSelectedFont() { |
101 |
return this.fontChooserPanel.getSelectedFont(); |
102 |
} |
103 |
|
104 |
/**
|
105 |
* Returns the panel that is the user interface.
|
106 |
*
|
107 |
* @param font the font.
|
108 |
*
|
109 |
* @return the panel.
|
110 |
*/
|
111 |
private JPanel createContent(Font font) { |
112 |
final JPanel content = new JPanel(new BorderLayout()); |
113 |
content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); |
114 |
if (font == null) { |
115 |
font = new Font("Dialog", 10, Font.PLAIN); |
116 |
} |
117 |
this.fontChooserPanel =
|
118 |
new PartialFontChooserPanel(font, allowStyle, allowSize);
|
119 |
content.add(this.fontChooserPanel);
|
120 |
|
121 |
final JPanel buttons = createButtonPanel(); |
122 |
buttons.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0)); |
123 |
content.add(buttons, BorderLayout.SOUTH);
|
124 |
|
125 |
return content;
|
126 |
} |
127 |
|
128 |
} |