private Rectangle2D.Double DrawText(Graphics2D g2, Font font, Rectangle2D.Double r1, String text) {
        Rectangle d = font.getStringBounds(text, g2.getFontRenderContext()).getBounds();
        Rectangle2D.Double r2;
        if (r1 == null)
            r2 = new Rectangle2D.Double(width / 2 - d.width / 2 - (int) (0.04 * height),
                height / 2 - d.height / 2, d.width + 2 * (int) (0.04 * height), d.height + (int) (0.04 * height));
        else
            r2 = new Rectangle2D.Double(r1.x,
                r1.y + d.height + g2.getFontMetrics().getAscent() * 2, r1.width, r1.height);
        g2.setPaint(Color.black);
        g2.fill(r2);
        g2.setColor(Color.WHITE);
        g2.draw(r2);
        g2.drawString(text, width / 2 - d.width / 2, (int) (r2.y + r2.height - d.height / 2));
        return r2;
    }