// Figure
//
////////////////////////////////////////////////////////////////////////////
@Override
protected Figure createFigure() {
Figure newFigure = new Figure() {
@Override
protected void paintClientArea(Graphics graphics) {
Rectangle r = getClientArea();
// draw rectangle
graphics.setForegroundColor(IColorConstants.buttonDarker);
graphics.drawLine(r.x, r.y, r.x, r.bottom());
graphics.drawLine(r.right() - 1, r.y, r.right() - 1, r.bottom());
// draw column index
int titleLeft;
{
String title = "" + getIndex();
Dimension textExtents = graphics.getTextExtent(title);
if (r.width < 3 + textExtents.width + 3) {
return;
}
// draw title
titleLeft = r.x + (r.width - textExtents.width) / 2;
int y = r.y + (r.height - textExtents.height) / 2;
graphics.setForegroundColor(IColorConstants.black);
graphics.drawText(title, titleLeft, y);
}
// draw alignment indicator
if (titleLeft - r.x > 3 + 7 + 3) {
Image image = m_column.getAlignment().getSmallImage();
if (image != null) {
int x = r.x + 2;
drawCentered(graphics, image, x);
}
}
}
private void drawCentered(Graphics graphics, Image image, int x) {
int y = (getBounds().height - image.getBounds().height) / 2;
graphics.drawImage(image, x, y);
}
};
//
newFigure.setFont(DEFAULT_FONT);
newFigure.setOpaque(true);
return newFigure;
}