// No-op
}
@Override
public void paint(Graphics2D graphics) {
ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
int width = getWidth();
int height = getHeight();
Color backgroundColorLocal = null;
Color bevelColorLocal = null;
Color borderColorLocal = null;
if (colorChooserButton.isEnabled()) {
backgroundColorLocal = this.backgroundColor;
bevelColorLocal = (pressed || (colorChooserPopup.isOpen() && !colorChooserPopup.isClosing())) ?
pressedBevelColor : this.bevelColor;
borderColorLocal = this.borderColor;
} else {
backgroundColorLocal = disabledBackgroundColor;
bevelColorLocal = disabledBevelColor;
borderColorLocal = disabledBorderColor;
}
// Paint the background
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setPaint(new GradientPaint(width / 2f, 0, bevelColorLocal,
width / 2f, height / 2f, backgroundColorLocal));
graphics.fill(new RoundRectangle2D.Double(0.5, 0.5, width - 1, height - 1,
CORNER_RADIUS, CORNER_RADIUS));
// Paint the content
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
Bounds contentBounds = new Bounds(0, 0,
Math.max(width - TRIGGER_WIDTH - 1, 0), Math.max(height - 1, 0));
Button.DataRenderer dataRenderer = colorChooserButton.getDataRenderer();
dataRenderer.render(colorChooserButton.getButtonData(), colorChooserButton, false);
dataRenderer.setSize(Math.max(contentBounds.width - (padding.left + padding.right + 2) + 1, 0),
Math.max(contentBounds.height - (padding.top + padding.bottom + 2) + 1, 0));
Graphics2D contentGraphics = (Graphics2D)graphics.create();
contentGraphics.translate(padding.left + 1, padding.top + 1);
contentGraphics.clipRect(0, 0, dataRenderer.getWidth(), dataRenderer.getHeight());
dataRenderer.paint(contentGraphics);
contentGraphics.dispose();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
// Paint the border
if (borderColorLocal != null) {
graphics.setPaint(borderColorLocal);
graphics.setStroke(new BasicStroke(1));
graphics.draw(new RoundRectangle2D.Double(0.5, 0.5, width - 1, height - 1,
CORNER_RADIUS, CORNER_RADIUS));
}
// Paint the focus state
if (colorChooserButton.isFocused()) {
BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND, 1.0f, new float[] {0.0f, 2.0f}, 0.0f);
graphics.setStroke(dashStroke);
graphics.setColor(this.borderColor);
graphics.draw(new RoundRectangle2D.Double(2.5, 2.5, Math.max(width - 5, 0),
Math.max(height - 5, 0), CORNER_RADIUS / 2, CORNER_RADIUS / 2));
}
// Paint the focus state
if (colorChooserButton.isFocused()) {
BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND, 1.0f, new float[] {0.0f, 2.0f}, 0.0f);
graphics.setStroke(dashStroke);
graphics.setColor(this.borderColor);
graphics.draw(new RoundRectangle2D.Double(2.5, 2.5, Math.max(width - 5, 0),