private void paintButton(Graphics2D graphics, RadioButton radioButton, int height) {
Paint buttonPaint;
Color buttonBorderColor = null;
Color buttonSelectionColor = null;
Ellipse2D buttonBackgroundCircle = new Ellipse2D.Double(1, 1,
BUTTON_DIAMETER - 3, BUTTON_DIAMETER - 3);
if (radioButton.isEnabled()) {
buttonPaint = new RadialGradientPaint((float)buttonBackgroundCircle.getCenterX(),
(float)buttonBackgroundCircle.getCenterY(),
(float)buttonBackgroundCircle.getWidth() * 2 / 3,
new float[] {0f, 1f}, new Color[] {TerraTheme.darken(buttonColor), buttonColor});
buttonBorderColor = this.buttonBorderColor;
buttonSelectionColor = this.buttonSelectionColor;
}
else {
buttonPaint = disabledButtonColor;
buttonBorderColor = disabledButtonBorderColor;
buttonSelectionColor = disabledButtonSelectionColor;
}
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
// Center the button vertically
graphics.translate(0, (height - BUTTON_DIAMETER) / 2);
// Paint the border
graphics.setColor(buttonBorderColor);
graphics.fillOval(0, 0, BUTTON_DIAMETER - 1, BUTTON_DIAMETER - 1);
// Paint the background
graphics.setPaint(buttonPaint);
graphics.fill(buttonBackgroundCircle);
// Paint the selection
if (radioButton.isSelected()) {
Ellipse2D buttonSelectionCircle = new Ellipse2D.Double((BUTTON_DIAMETER
- (BUTTON_SELECTION_DIAMETER - 1)) / 2,
(BUTTON_DIAMETER - (BUTTON_SELECTION_DIAMETER - 1)) / 2,
BUTTON_SELECTION_DIAMETER - 1, BUTTON_SELECTION_DIAMETER - 1);
graphics.setColor(buttonSelectionColor);
graphics.fill(buttonSelectionCircle);