/** Overriden to paint properly the button on vertical sides.
*/
public void paint(Graphics g, JComponent comp){
AutoHideButton btn = (AutoHideButton) comp;
int zone = btn.getZone();
if (zone == DockingConstants.INT_HIDE_TOP || zone == DockingConstants.INT_SPLIT_BOTTOM){
super.paint(g, comp);
} else {
// vertical button : we have to rely on a custom paint
if (btn.isOpaque()) {
g.setColor(btn.getBackground());
g.fillRect(0, 0, btn.getWidth(), btn.getHeight());
}
double pid2 = Math.PI / 2d;
Graphics2D g2 = ( (Graphics2D) g.create());
g2.setFont(btn.getFont());
g2.setColor(btn.getForeground());
FontMetrics fm = btn.getFontMetrics(btn.getFont());
Icon icon = btn.getIcon();
Insets i = btn.getInsets();
String text = btn.getText(); // 2005/07/12 added text != null controls
if (zone == DockingConstants.INT_HIDE_LEFT) {
g2.translate(0, btn.getHeight());
g2.rotate( -pid2);
if (icon != null) {
icon.paintIcon(btn, g2, i.bottom, i.left);
if (text != null){
g2.drawString(text,
i.bottom + icon.getIconWidth() + btn.getIconTextGap(),
i.left + btn.getWidth() / 2 +
fm.getAscent() / 2 /* fm.getAscent()*/);
}
} else {
if (text != null){
g2.drawString(text, i.bottom,
i.left + btn.getWidth() / 2 + fm.getAscent() / 2);
}
}
} else {
g2.translate(btn.getWidth(), 0);
g2.rotate(pid2);
if (icon != null) {
icon.paintIcon(btn, g2, 1, 1);
if (text != null){
g2.drawString(text, i.top + icon.getIconWidth() + btn.getIconTextGap(),
btn.getWidth() / 2 + fm.getAscent() / 2);
}
} else {
if (text != null){
g2.drawString(text, i.top,
btn.getWidth() / 2 + fm.getAscent() / 2);
}
}
}
}
}