g2d.setComposite(AlphaComposite.SrcOver);
// the taskbar panel is not at the zero X coordinate of the
// ribbon
g2d.translate(-this.getBounds().x, 0);
for (int i = 0; i < ribbon.getContextualTaskGroupCount(); i++) {
RibbonContextualTaskGroup taskGroup = ribbon
.getContextualTaskGroup(i);
if (!ribbon.isVisible(taskGroup))
continue;
Rectangle taskGroupBounds = getContextualTaskGroupBounds(taskGroup);
Color hueColor = taskGroup.getHueColor();
Paint paint = new GradientPaint(
0,
0,
FlamingoUtilities.getAlphaColor(hueColor, 0),
0,
height,
FlamingoUtilities
.getAlphaColor(
hueColor,
(int) (255 * RibbonContextualTaskGroup.HUE_ALPHA)));
// translucent gradient paint
g2d.setPaint(paint);
int startX = ltr ? taskGroupBounds.x : Math.min(
contourMinX, taskGroupBounds.x);
int width = ltr ? taskGroupBounds.x + taskGroupBounds.width
- startX : Math.min(taskGroupBounds.x
+ taskGroupBounds.width, contourMinX)
- startX;
if (width > 0) {
g2d.fillRect(startX, 0, width, height);
// and a solid line at the bottom
g2d.setColor(hueColor);
g2d.drawLine(startX + 1, height - 1, startX + width,
height - 1);
// task group title
g2d.setColor(FlamingoUtilities.getColor(Color.black,
"Button.foreground"));
FontMetrics fm = this.getFontMetrics(ribbon.getFont());
int yOffset = (height + fm.getHeight()) / 2
- fm.getDescent();
int availableTextWidth = width - 10;
String titleToShow = taskGroup.getTitle();
if (fm.stringWidth(titleToShow) > availableTextWidth) {
while (true) {
if (titleToShow.length() == 0)
break;
if (fm.stringWidth(titleToShow + "...") <= availableTextWidth)