code: private String drawString(BufferedImage image) {
          Random r = new Random();
          Graphics2D g2 = (Graphics2D) image.getGraphics();
          // 记录生成的文本
          StringBuilder sb = new StringBuilder();
          // 向图片中画指定个数字符
          for (int i = 0; i < this.textLength; i++) {
              String s = randomChar() + "";
              sb.append(s);
              // 字符的x坐标在[minX,maxX]范围内
              int cw = this.w / this.textLength;//每个字符占的宽度
              int minX = cw * i;
              int maxX = minX + cw * 2 / 3;
              int x = r.nextInt(maxX - minX + 1) + minX;
              //字符的y坐标在[minY,maxY]范围内
              Font font = randomFont();
              int minY = this.h * font.getSize() / 48;
              int maxY = this.h * font.getSize() * 3 / 80;
              minY = minY >= this.h ? this.h / 2 : minY;
              maxY = maxY >= this.h ? this.h * 9 / 10 : maxY;
              int y = r.nextInt(maxY - minY + 1) + minY;
              //字符旋转度数在[0,360']范围内
  //            double rotate = Math.toRadians(30);//转换成theta值
  //            g2.rotate(rotate, x + 12, y + 12);
              g2.setFont(font);
              g2.setColor(randomColor());
              g2.drawString(s, x, y);
          }
          return sb.toString();
      }
docs: 随机画字符
  
  @param image 图片
  @return 返回画的字符串