    001// License: GPL. For details, see LICENSE file.
    002package org.openstreetmap.josm.plugins.streetside.gui.boilerplate;
    003
    004import java.awt.Color;
    005import java.awt.Graphics;
    006import java.awt.Graphics2D;
    007import java.awt.RenderingHints;
    008
    009import javax.swing.Action;
    010import javax.swing.BorderFactory;
    011import javax.swing.JButton;
    012
    013import org.openstreetmap.josm.plugins.streetside.utils.StreetsideColorScheme;
    014
    015
    016public class StreetsideButton extends JButton {
    017
    018  private static final long serialVersionUID = -3060978712233067368L;
    019
    020  public StreetsideButton(final Action action) {
    021    this(action, false);
    022  }
    023
    024  public StreetsideButton(final Action action, boolean slim) {
    025    super(action);
    026    setForeground(Color.WHITE);
    027    setBorder(slim ? BorderFactory.createEmptyBorder(3, 4, 3, 4) : BorderFactory.createEmptyBorder(7, 10, 7, 10));
    028  }
    029
    030  @Override
    031  protected void paintComponent(final Graphics g) {
    032    if (!isEnabled()) {
    033      g.setColor(StreetsideColorScheme.TOOLBAR_DARK_GREY);
    034    } else if (getModel().isPressed()) {
    035      g.setColor(StreetsideColorScheme.STREETSIDE_BLUE.darker().darker());
    036    } else if (getModel().isRollover()) {
    037      g.setColor(StreetsideColorScheme.STREETSIDE_BLUE.darker());
    038    } else {
    039      g.setColor(StreetsideColorScheme.STREETSIDE_BLUE);
    040    }
    041    ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    042    g.fillRoundRect(0, 0, getWidth(), getHeight(), 3, 3);
    043    super.paintComponent(g);
    044  }
    045
    046  @Override
    047  public boolean isContentAreaFilled() {
    048    return false;
    049  }
    050}