类 Captcha

java.lang.Object
com.wf.captcha.base.Randoms
com.wf.captcha.base.Captcha
直接已知子类:
ArithmeticCaptchaAbstract, ChineseCaptchaAbstract, GifCaptcha, SpecCaptcha

public abstract class Captcha extends Randoms
验证码抽象类
作者:
Created by 王帆 on 2018-07-27 上午 10:08.
  • 字段详细资料

    • COLOR

      public static final int[][] COLOR
    • TYPE_DEFAULT

      public static final int TYPE_DEFAULT
      另请参阅:
    • TYPE_ONLY_NUMBER

      public static final int TYPE_ONLY_NUMBER
      另请参阅:
    • TYPE_ONLY_CHAR

      public static final int TYPE_ONLY_CHAR
      另请参阅:
    • TYPE_ONLY_UPPER

      public static final int TYPE_ONLY_UPPER
      另请参阅:
    • TYPE_ONLY_LOWER

      public static final int TYPE_ONLY_LOWER
      另请参阅:
    • TYPE_NUM_AND_UPPER

      public static final int TYPE_NUM_AND_UPPER
      另请参阅:
    • FONT_1

      public static final int FONT_1
      另请参阅:
    • FONT_2

      public static final int FONT_2
      另请参阅:
    • FONT_3

      public static final int FONT_3
      另请参阅:
    • FONT_4

      public static final int FONT_4
      另请参阅:
    • FONT_5

      public static final int FONT_5
      另请参阅:
    • FONT_6

      public static final int FONT_6
      另请参阅:
    • FONT_7

      public static final int FONT_7
      另请参阅:
    • FONT_8

      public static final int FONT_8
      另请参阅:
    • FONT_9

      public static final int FONT_9
      另请参阅:
    • FONT_10

      public static final int FONT_10
      另请参阅:
    • len

      protected int len
    • width

      protected int width
    • height

      protected int height
    • charType

      protected int charType
    • chars

      protected String chars
  • 构造器详细资料

    • Captcha

      public Captcha()
  • 方法详细资料

    • alphas

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

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

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

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

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

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

      public String toBase64(String type)
      输出base64编码
      参数:
      type - 编码头
      返回:
      base64编码字符串
    • text

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

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

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

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

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

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

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

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

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

      public Font getFont()
    • setFont

      public void setFont(Font font)
    • setFont

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

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

      public void setFont(int font, int style, float size) throws IOException, FontFormatException
      抛出:
      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)