public void draw(
     Graphics2D g,
     Color stringColor,
     Color foreground,
     Color background,
     String info,
     double x,
     double y) {
   FontMetrics fm = g.getFontMetrics();
   int h = fm.getHeight();
   int w = fm.stringWidth(info);
   r1.setRect(
       x - w / 2 - in.left, y - in.top - h / 2, w + in.right + in.left, h + in.bottom + in.top);
   g.setColor(background);
   g.fill(r1);
   g.setColor(stringColor);
   g.draw(r1);
   g.setColor(foreground);
   r2.setRect(r1.getX() + 1, r1.getY() + 1, r1.getWidth() - 2, r1.getHeight() - 2);
   g.draw(r2);
   g.setColor(stringColor);
   g.drawString(
       info, (float) (r2.getX() + in.left), (float) (r2.getY() + h - (r2.getHeight() - h) / 2));
 }
  public void paintValue(Graphics g, Rectangle box) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(
        RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    double[] values = (double[]) getValue();
    StringBuilder s = new StringBuilder();
    for (int i = 0; i < 3; i++) {
      if (values.length > i) s.append(values[i]);
      if (values.length > i + 1) s.append(", ");
    }
    if (values.length > 3) s.append("...");

    g2.setPaint(Color.white);
    g2.fill(box);
    g2.setPaint(Color.black);
    FontRenderContext context = g2.getFontRenderContext();
    Rectangle2D stringBounds = g2.getFont().getStringBounds(s.toString(), context);
    double w = stringBounds.getWidth();
    double x = box.x;
    if (w < box.width) x += (box.width - w) / 2;
    double ascent = -stringBounds.getY();
    double y = box.y + (box.height - stringBounds.getHeight()) / 2 + ascent;
    g2.drawString(s.toString(), (float) x, (float) y);
  }