*/
private void paint(SeaGlassContext context, Graphics g) {
String title = getTitle();
if (title != null) {
SynthStyle style = context.getStyle();
Color color = style.getColor(context, ColorType.TEXT_FOREGROUND);
// TODO style.getColor returns improper color for state? Why?
if ((context.getComponentState() & 512) != 0) {
Object obj = style.get(context, "[WindowFocused].textForeground");
if (obj != null && obj instanceof Color) {
color = (Color) obj;
}
// FIXME The state *still* doesn't get the color right!!!
color = Color.BLACK;
}
g.setColor(color);
g.setFont(style.getFont(context));
// Center text vertically.
FontMetrics fm = SwingUtilities2.getFontMetrics(rootPane, g);
int baseline = (getHeight() + fm.getAscent() - fm.getLeading() - fm.getDescent()) / 2;
JButton lastButton = null;
if (isParentIconifiable()) {
lastButton = iconButton;
} else if (isParentMaximizable()) {
lastButton = maxButton;
} else if (isParentClosable()) {
lastButton = closeButton;
}
int maxX;
int minX;
boolean ltr = isParentLeftToRight();
if (ltr) {
if (lastButton != null) {
maxX = lastButton.getX() - titleSpacing;
} else {
maxX = getParentWidth() - getParentInsets().right - titleSpacing;
}
minX = menuButton.getX() + menuButton.getWidth() + titleSpacing;
} else {
if (lastButton != null) {
minX = lastButton.getX() + lastButton.getWidth() + titleSpacing;
} else {
minX = getParentInsets().left + titleSpacing;
}
maxX = getParentWidth() - getParentInsets().right - menuButton.getX() - titleSpacing;
}
String clippedTitle = getTitle(title, fm, maxX - minX);
if (clippedTitle == title) {
int width = style.getGraphicsUtils(context).computeStringWidth(context, g.getFont(), fm, title);
minX = Math.max(minX, (getWidth() - width) / 2);
minX = Math.min(maxX - width, minX);
}
// style.getGraphicsUtils(context).paintText(context, g,
// clippedTitle, minX, baseline - fm.getAscent(), -1);
((SeaGlassGraphicsUtils) style.getGraphicsUtils(context)).drawEmphasizedText(g, color, DEFAULT_EMPHASIS_COLOR, clippedTitle,
minX, baseline); // - fm.getAscent());
}
}