58 |
public class SwingUtilities implements SwingConstants |
public class SwingUtilities implements SwingConstants |
59 |
{ |
{ |
60 |
public static FontMetrics getFontMetrics (Font font) |
public static FontMetrics getFontMetrics (Font font) |
61 |
{ |
{ |
62 |
return Toolkit.getDefaultToolkit().getFontMetrics(font); |
return Toolkit.getDefaultToolkit ().getFontMetrics (font); |
63 |
} |
} |
64 |
|
|
65 |
public static JRootPane getRootPane (Component a) |
public static JRootPane getRootPane (Component a) |
66 |
{ |
{ |
67 |
if (a instanceof JRootPane) |
if (a instanceof JRootPane) |
68 |
return (JRootPane) a; |
return (JRootPane) a; |
69 |
|
|
70 |
a = a.getParent(); |
a = a.getParent(); |
|
|
|
|
if (a != null) |
|
|
{ |
|
|
return getRootPane(a); |
|
|
} |
|
71 |
|
|
72 |
return null; |
if (a != null) |
73 |
} |
{ |
74 |
|
return getRootPane(a); |
75 |
|
} |
76 |
|
|
77 |
|
return null; |
78 |
|
} |
79 |
|
|
80 |
public static void updateComponentTreeUI(JFrame comp) |
public static void updateComponentTreeUI(JFrame comp) |
81 |
{ |
{ |
82 |
} |
} |
83 |
|
|
84 |
public static String layoutCompoundLabel(JComponent c, |
public static String layoutCompoundLabel(JComponent c, |
85 |
FontMetrics fm, |
FontMetrics fm, |
86 |
String text, |
String text, |
87 |
Icon i, |
Icon i, |
88 |
int vert_a, |
int vert_a, |
89 |
int hor_i, |
int hor_i, |
90 |
int vert_text_pos, |
int vert_text_pos, |
91 |
int hor_text_pos, |
int hor_text_pos, |
92 |
Rectangle vr, |
Rectangle vr, |
93 |
Rectangle ir, |
Rectangle ir, |
94 |
Rectangle tr, |
Rectangle tr, |
95 |
int gap) |
int gap) |
96 |
{ |
{ |
97 |
// view rect 'vr' already ok, |
// view rect 'vr' already ok, |
98 |
// we need to compute ir (icon rect) and tr (text-rect) |
// we need to compute ir (icon rect) and tr (text-rect) |
99 |
|
|
100 |
int next_x = 0;//vr.x; |
int next_x = 0;//vr.x; |
101 |
int next_y = 0;//vr.y; |
int next_y = 0;//vr.y; |
102 |
|
|
103 |
ir.height = ir.width = ir.y = ir.x = 0; |
ir.height = ir.width = ir.y = ir.x = 0; |
104 |
|
|
105 |
if (i != null) |
if (i != null) |
106 |
{ |
{ |
107 |
ir.x = vr.x; |
ir.x = vr.x; |
108 |
ir.y = vr.y; |
ir.y = vr.y; |
109 |
ir.width = i.getIconWidth(); |
ir.width = i.getIconWidth(); |
110 |
ir.height = i.getIconWidth(); |
ir.height = i.getIconWidth(); |
111 |
|
|
112 |
|
|
113 |
next_x += gap + i.getIconWidth(); |
next_x += gap + i.getIconWidth(); |
114 |
next_y += gap + i.getIconHeight(); |
next_y += gap + i.getIconHeight(); |
115 |
} |
} |
116 |
|
|
117 |
tr.x = next_x; |
tr.x = next_x; |
118 |
tr.y = vr.y + (vr.height/2); |
tr.y = vr.y + (vr.height/2); |
119 |
|
|
120 |
|
tr.width = fm.stringWidth(text); |
121 |
|
tr.height = fm.getHeight() + fm.getAscent()/2; |
122 |
|
|
123 |
tr.width = fm.stringWidth(text); |
return text; |
124 |
tr.height = fm.getHeight() + fm.getAscent()/2; |
} |
125 |
|
|
|
return text; |
|
|
} |
|
126 |
} |
} |
127 |
|
|
128 |
|
|