Class Captcha

java.lang.Object
com.wf.captcha.base.Randoms
com.wf.captcha.base.Captcha
Direct Known Subclasses:
ArithmeticCaptchaAbstract, ChineseCaptchaAbstract, GifCaptcha, SpecCaptcha

public abstract class Captcha extends Randoms
验证码抽象类
Author:
Created by 王帆 on 2018-07-27 上午 10:08.
  • Field Details

  • Constructor Details

    • Captcha

      public Captcha()
  • Method Details

    • alphas

      protected char[] alphas()
      生成随机验证码
      Returns:
      验证码字符数组
    • color

      protected Color color(int fc, int bc)
      给定范围获得随机颜色
      Parameters:
      fc - 0-255
      bc - 0-255
      Returns:
      随机颜色
    • color

      protected Color color()
      获取随机常用颜色
      Returns:
      随机颜色
    • out

      public abstract boolean out(OutputStream os)
      验证码输出,抽象方法,由子类实现
      Parameters:
      os - 输出流
      Returns:
      是否成功
    • toBase64

      public abstract String toBase64()
      输出base64编码
      Returns:
      base64编码字符串
    • getContentType

      public abstract String getContentType()
      获取图片类型
      Returns:
      图片格式,MIME类型
    • toBase64

      public String toBase64(String type)
      输出base64编码
      Parameters:
      type - 编码头
      Returns:
      base64编码字符串
    • text

      public String text()
      获取当前的验证码
      Returns:
      字符串
    • textChar

      public char[] textChar()
      获取当前验证码的字符数组
      Returns:
      字符数组
    • checkAlpha

      public void checkAlpha()
      检查验证码是否生成,没有则立即生成
    • drawLine

      public void drawLine(int num, Graphics2D g)
      随机画干扰线
      Parameters:
      num - 数量
      g - Graphics2D
    • drawLine

      public void drawLine(int num, Color color, Graphics2D g)
      随机画干扰线
      Parameters:
      num - 数量
      color - 颜色
      g - Graphics2D
    • drawOval

      public void drawOval(int num, Graphics2D g)
      随机画干扰圆
      Parameters:
      num - 数量
      g - Graphics2D
    • drawOval

      public void drawOval(int num, Color color, Graphics2D g)
      随机画干扰圆
      Parameters:
      num - 数量
      color - 颜色
      g - Graphics2D
    • drawBesselLine

      public void drawBesselLine(int num, Graphics2D g)
      随机画贝塞尔曲线
      Parameters:
      num - 数量
      g - Graphics2D
    • drawBesselLine

      public void drawBesselLine(int num, Color color, Graphics2D g)
      随机画贝塞尔曲线
      Parameters:
      num - 数量
      color - 颜色
      g - Graphics2D
    • getFont

      public Font getFont()
    • setFont

      public void setFont(Font font)
    • setFont

      public void setFont(int font) throws IOException, FontFormatException
      Throws:
      IOException
      FontFormatException
    • setFont

      public void setFont(int font, float size) throws IOException, FontFormatException
      Throws:
      IOException
      FontFormatException
    • setFont

      public void setFont(int font, int style, float size) throws IOException, FontFormatException
      Throws:
      IOException
      FontFormatException
    • getLen

      public int getLen()
    • setLen

      public void setLen(int len)
    • getWidth

      public int getWidth()
    • setWidth

      public void setWidth(int width)
    • getHeight

      public int getHeight()
    • setHeight

      public void setHeight(int height)
    • getCharType

      public int getCharType()
    • setCharType

      public void setCharType(int charType)