@Override
    public void paint(Graphics g) {
        super.paint(g);

        Graphics2D g2 = (Graphics2D) g;
        int size = Math.min(
                MAX_SIZE,
                Math.min(getWidth() - this.imagePadding.left - this.imagePadding.right, getHeight() - this.imagePadding.top
                        - this.imagePadding.bottom));

        g2.translate((getWidth() / 2) - (size / 2), (getHeight() / 2) - (size / 2));
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        Shape shape;

        if ((this.mode == ColorPicker.SAT) || (this.mode == ColorPicker.BRI)) {
            shape = new Ellipse2D.Float(0, 0, size, size);
        } else {
            Rectangle r = new Rectangle(0, 0, size, size);
            shape = r;
        }

        if (hasFocus()) {
            PlafPaintUtils.paintFocus(g2, shape, 3);
        }

        if (!(shape instanceof Rectangle)) {
            // paint a circular shadow
            g2.translate(2, 2);
            g2.setColor(new Color(0, 0, 0, 20));
            g2.fill(new Ellipse2D.Float(-2, -2, size + 4, size + 4));
            g2.setColor(new Color(0, 0, 0, 40));
            g2.fill(new Ellipse2D.Float(-1, -1, size + 2, size + 2));
            g2.setColor(new Color(0, 0, 0, 80));
            g2.fill(new Ellipse2D.Float(0, 0, size, size));
            g2.translate(-2, -2);
        }

        g2.drawImage(this.image, 0, 0, size, size, 0, 0, size, size, null);

        g2.setStroke(new BasicStroke(1));
        if (shape instanceof Rectangle) {
            Rectangle r = (Rectangle) shape;
            PlafPaintUtils.drawBevel(g2, r);
        } else {
            g2.setColor(new Color(0, 0, 0, 120));
            g2.draw(shape);
        }

        g2.setColor(Color.white);
        g2.setStroke(new BasicStroke(1));
        g2.draw(new Ellipse2D.Float(this.point.x - 3, this.point.y - 3, 6, 6));
        g2.setColor(Color.black);
        g2.draw(new Ellipse2D.Float(this.point.x - 4, this.point.y - 4, 8, 8));

        g.translate(-this.imagePadding.left, -this.imagePadding.top);
    }