}
@Override
public void paint(Graphics2D graphics) {
Menu.Item menuItem = (Menu.Item)getComponent();
Menu menu = (Menu)menuItem.getParent();
int width = getWidth();
int height = getHeight();
boolean highlight = menuItem.isActive();
// Paint highlight state
if (highlight) {
Color activeBackgroundColor = (Color)menu.getStyles().get("activeBackgroundColor");
graphics.setPaint(new GradientPaint(width / 2f, 0, TerraTheme.brighten(activeBackgroundColor),
width / 2f, height, activeBackgroundColor));
graphics.fillRect(0, 0, width, height);
}
// Paint the content
Button.DataRenderer dataRenderer = menuItem.getDataRenderer();
dataRenderer.render(menuItem.getButtonData(), menuItem, highlight);
dataRenderer.setSize(Math.max(width - EXPANDER_SIZE, 0), height);
dataRenderer.paint(graphics);
// Paint the expander
if (menuItem.getMenu() != null) {
Color color = (Color)(highlight ?
menu.getStyles().get("activeColor") : menu.getStyles().get("color"));
graphics.setColor(color);
graphics.setStroke(new BasicStroke(0));
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);