svn-document-layout / trunk / org.gvsig.layout / org.gvsig.layout.app / org.gvsig.layout.app.configurablelegend / src / main / java / org / gvsig / tools / swing / impl / pickercontroller / FontPickerControllerImpl.java @ 793
History | View | Annotate | Download (3.45 KB)
1 |
|
---|---|
2 |
package org.gvsig.tools.swing.impl.pickercontroller; |
3 |
|
4 |
import java.awt.Font; |
5 |
import java.net.URL; |
6 |
import javax.swing.ImageIcon; |
7 |
import javax.swing.JButton; |
8 |
import javax.swing.JComboBox; |
9 |
import javax.swing.JToggleButton; |
10 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
11 |
import org.gvsig.tools.swing.api.pickercontroller.AbstractPickerController; |
12 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
13 |
import org.gvsig.tools.swing.icontheme.IconThemeManager; |
14 |
|
15 |
|
16 |
public class FontPickerControllerImpl |
17 |
extends AbstractPickerController<Font> { |
18 |
|
19 |
private final JComboBox cboFontName; |
20 |
private final JComboBox cboFontSize; |
21 |
private final JToggleButton btnBold; |
22 |
private final JToggleButton btnItalic; |
23 |
private final JToggleButton btnUnderline; |
24 |
|
25 |
public static void selfRegister() { |
26 |
URL imageResource = DatePickerControllerImpl.class.getClassLoader().getResource("org/gvsig/tools/swing/picker/picker-font-bold.png"); |
27 |
if (imageResource != null) { |
28 |
IconThemeManager iconThemeManager = ToolsSwingLocator.getIconThemeManager(); |
29 |
IconTheme theme = iconThemeManager.getCurrent(); |
30 |
ImageIcon icon = new ImageIcon(imageResource); |
31 |
theme.registerDefault("tools", "picker", "picker-font-bold", icon, imageResource); |
32 |
} |
33 |
imageResource = DatePickerControllerImpl.class.getClassLoader().getResource("org/gvsig/tools/swing/picker/picker-font-italic.png");
|
34 |
if (imageResource != null) { |
35 |
IconThemeManager iconThemeManager = ToolsSwingLocator.getIconThemeManager(); |
36 |
IconTheme theme = iconThemeManager.getCurrent(); |
37 |
ImageIcon icon = new ImageIcon(imageResource); |
38 |
theme.registerDefault("tools", "picker", "picker-font-italic", icon, imageResource); |
39 |
} |
40 |
imageResource = DatePickerControllerImpl.class.getClassLoader().getResource("org/gvsig/tools/swing/picker/picker-font-underline.png");
|
41 |
if (imageResource != null) { |
42 |
IconThemeManager iconThemeManager = ToolsSwingLocator.getIconThemeManager(); |
43 |
IconTheme theme = iconThemeManager.getCurrent(); |
44 |
ImageIcon icon = new ImageIcon(imageResource); |
45 |
theme.registerDefault("tools", "picker", "picker-font-underline", icon, imageResource); |
46 |
} |
47 |
} |
48 |
|
49 |
public FontPickerControllerImpl(
|
50 |
JComboBox cboFontName,
|
51 |
JComboBox cboFontSize,
|
52 |
JToggleButton btnBold,
|
53 |
JToggleButton btnItalic,
|
54 |
JToggleButton btnUnderline
|
55 |
) { |
56 |
this.cboFontName = cboFontName;
|
57 |
this.cboFontSize = cboFontSize;
|
58 |
this.btnBold = btnBold;
|
59 |
this.btnItalic = btnItalic;
|
60 |
this.btnUnderline = btnUnderline;
|
61 |
|
62 |
this.btnBold.setIcon(this.getIcon("picker-font-bold")); |
63 |
this.btnItalic.setIcon(this.getIcon("picker-font-italic")); |
64 |
this.btnUnderline.setIcon(this.getIcon("picker-font-underline")); |
65 |
} |
66 |
|
67 |
@Override
|
68 |
public Font get() { |
69 |
return null; |
70 |
} |
71 |
|
72 |
@Override
|
73 |
public void set(Font t) { |
74 |
} |
75 |
|
76 |
@Override
|
77 |
public void coerceAndSet(Object font) { |
78 |
} |
79 |
|
80 |
@Override
|
81 |
public void setEnabled(boolean enabled) { |
82 |
this.cboFontName.setEnabled(enabled);
|
83 |
this.cboFontSize.setEnabled(enabled);
|
84 |
this.btnBold.setEnabled(enabled);
|
85 |
this.btnItalic.setEnabled(enabled);
|
86 |
this.btnUnderline.setEnabled(enabled);
|
87 |
} |
88 |
|
89 |
@Override
|
90 |
public boolean isEnabled() { |
91 |
return this.cboFontName.isEnabled(); |
92 |
} |
93 |
|
94 |
} |