int x = (width - iwidth) / 2;
int y = (height - iheight) / 2;
if (highlighted) {
if (highlightedIcon == null) {
ImageFilter filter = new HighlightedFilter();
ImageProducer producer = new FilteredImageSource(icon.getSource(), filter);
highlightedIcon = createImage(producer);
}
g.drawImage(highlightedIcon, x, y, this);
} else
g.drawImage(icon, x, y, this);
}
int[] lineBreaks = new int[3];
int[] offx = new int[lineBreaks.length];
int lbi = 0;
Font font = new Font("SansSerif", Font.PLAIN, 11);
g.setFont(font);
FontMetrics fm = g.getFontMetrics();
int em = fm.charWidth('m');
int emlen = width / em;
char[] nameChars = name.toCharArray();
int chi = 0;
while (chi < nameChars.length && lbi < lineBreaks.length) {
int len = emlen;
if (chi + len > nameChars.length)
len = nameChars.length - chi;
int chw = fm.charsWidth(nameChars, chi, len);
if (chw > width) {
while (len > 1) {
len--;
chw = fm.charsWidth(nameChars, chi, len);
if (chw <= width)
break;
}
} else {
while (chi + len < nameChars.length) {
len++;
int chw1 = fm.charsWidth(nameChars, chi, len);
if (chw1 > width) {
len--;
break;
}
chw = chw1;
}
}
chi += len;
offx[lbi] = (width - chw) / 2;
lineBreaks[lbi++] = chi;
}
chi = 0;
if (highlighted) {
// g.setColor(new Color(0x4070C0));
g2d.setPaint(new Color(0, 0.2f, 0.8f, 0.75f));
Rectangle rect = new Rectangle(0, getHeight() - lineBreaks.length * fm.getHeight(), width, lbi
* fm.getHeight());
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
g2d.fill(rect);
g.setColor(Color.white);
}
for (int line = 0; line < lbi; line++) {
int chi1 = lineBreaks[line];
int ty = getHeight() - fm.getDescent() - (lineBreaks.length - 1 - line) * fm.getHeight();
g.drawString(name.substring(chi, chi1), offx[line], ty);
chi = chi1;
}
if (group != null) {
g.dispose();
AlphaFilter filter = new AlphaFilter();
filter.setLevel(0.5f);
ImageProducer producer = new FilteredImageSource(group.getSource(), filter);
Image filtered = createImage(producer);
baseG.drawImage(filtered, 0, 0, null);
}
}