类 Captcha
java.lang.Object
com.wf.captcha.base.Randoms
com.wf.captcha.base.Captcha
验证码抽象类
- 作者:
- Created by 王帆 on 2018-07-27 上午 10:08.
-
字段概要
字段修饰符和类型字段说明protected Stringprotected intstatic final int[][]static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprotected intprotected intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprotected int从类继承的字段 com.wf.captcha.base.Randoms
ALPHA, charMaxIndex, charMinIndex, lowerMaxIndex, lowerMinIndex, numMaxIndex, RANDOM, upperMaxIndex, upperMinIndex -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected char[]alphas()生成随机验证码void检查验证码是否生成,没有则立即生成protected Colorcolor()获取随机常用颜色protected Colorcolor(int fc, int bc) 给定范围获得随机颜色voiddrawBesselLine(int num, Color color, Graphics2D g) 随机画贝塞尔曲线voiddrawBesselLine(int num, Graphics2D g) 随机画贝塞尔曲线voiddrawLine(int num, Color color, Graphics2D g) 随机画干扰线voiddrawLine(int num, Graphics2D g) 随机画干扰线voiddrawOval(int num, Color color, Graphics2D g) 随机画干扰圆voiddrawOval(int num, Graphics2D g) 随机画干扰圆intabstract String获取图片类型getFont()intintgetLen()intgetWidth()abstract booleanout(OutputStream os) 验证码输出,抽象方法,由子类实现voidsetCharType(int charType) voidsetFont(int font) voidsetFont(int font, float size) voidsetFont(int font, int style, float size) voidvoidsetHeight(int height) voidsetLen(int len) voidsetWidth(int width) text()获取当前的验证码char[]textChar()获取当前验证码的字符数组abstract StringtoBase64()输出base64编码输出base64编码
-
字段详细资料
-
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
-
-
构造器详细资料
-
Captcha
public Captcha()
-
-
方法详细资料
-
alphas
protected char[] alphas()生成随机验证码- 返回:
- 验证码字符数组
-
color
给定范围获得随机颜色- 参数:
fc- 0-255bc- 0-255- 返回:
- 随机颜色
-
color
获取随机常用颜色- 返回:
- 随机颜色
-
out
验证码输出,抽象方法,由子类实现- 参数:
os- 输出流- 返回:
- 是否成功
-
toBase64
输出base64编码- 返回:
- base64编码字符串
-
getContentType
获取图片类型- 返回:
- 图片格式,MIME类型
-
toBase64
输出base64编码- 参数:
type- 编码头- 返回:
- base64编码字符串
-
text
获取当前的验证码- 返回:
- 字符串
-
textChar
public char[] textChar()获取当前验证码的字符数组- 返回:
- 字符数组
-
checkAlpha
public void checkAlpha()检查验证码是否生成,没有则立即生成 -
drawLine
随机画干扰线- 参数:
num- 数量g- Graphics2D
-
drawLine
随机画干扰线- 参数:
num- 数量color- 颜色g- Graphics2D
-
drawOval
随机画干扰圆- 参数:
num- 数量g- Graphics2D
-
drawOval
随机画干扰圆- 参数:
num- 数量color- 颜色g- Graphics2D
-
drawBesselLine
随机画贝塞尔曲线- 参数:
num- 数量g- Graphics2D
-
drawBesselLine
随机画贝塞尔曲线- 参数:
num- 数量color- 颜色g- Graphics2D
-
getFont
-
setFont
-
setFont
-
setFont
-
setFont
-
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)
-