public abstract class AbstractCaptcha extends Randoms
| Modifier and Type | Field and Description |
|---|---|
protected String |
chars
当前验证码
|
protected int |
charType
验证码类型,1字母数字混合,2纯数字,3纯字母
|
static int[][] |
COLOR
常用颜色
|
protected Font |
font
字体Verdana
|
protected int |
height
验证码显示高度
|
protected int |
len
验证码随机字符长度
|
static int |
TYPE_DEFAULT
字母数字混合
|
static int |
TYPE_NUM_AND_UPPER
数字大写字母
|
static int |
TYPE_ONLY_CHAR
纯字母
|
static int |
TYPE_ONLY_LOWER
纯小写字母
|
static int |
TYPE_ONLY_NUMBER
纯数字
|
static int |
TYPE_ONLY_UPPER
纯大写字母
|
protected int |
width
验证码显示宽度
|
ALPHA, charMaxIndex, charMinIndex, lowerMaxIndex, lowerMinIndex, numMaxIndex, RANDOM, upperMaxIndex, upperMinIndex| Constructor and Description |
|---|
AbstractCaptcha() |
| Modifier and Type | Method and Description |
|---|---|
protected char[] |
alphas()
生成随机验证码
|
void |
checkAlpha()
检查验证码是否生成,没有这立即生成
|
protected Color |
color()
获取随机常用颜色
|
protected Color |
color(int fc,
int bc)
给定范围获得随机颜色
|
void |
drawLine(int num,
Color color,
Graphics2D g)
随机画干扰线
|
void |
drawLine(int num,
Graphics2D g)
随机画干扰线
|
void |
drawOval(int num,
Color color,
Graphics2D g)
随机画干扰圆
|
void |
drawOval(int num,
Graphics2D g)
随机画干扰圆
|
int |
getCharType() |
Font |
getFont() |
int |
getHeight() |
int |
getLen() |
int |
getWidth() |
abstract boolean |
out(OutputStream os)
验证码输出,抽象方法,由子类实现
|
void |
setCharType(int charType) |
void |
setFont(Font font) |
void |
setHeight(int height) |
void |
setLen(int len) |
void |
setWidth(int width) |
String |
text()
获取当前的验证码
|
char[] |
textChar()
获取当前验证码的字符数组
|
public static final int TYPE_DEFAULT
public static final int TYPE_ONLY_NUMBER
public static final int TYPE_ONLY_CHAR
public static final int TYPE_ONLY_UPPER
public static final int TYPE_ONLY_LOWER
public static final int TYPE_NUM_AND_UPPER
public static final int[][] COLOR
protected Font font
protected int len
protected int width
protected int height
protected String chars
protected int charType
protected char[] alphas()
protected Color color(int fc, int bc)
fc - 0-255bc - 0-255protected Color color()
public abstract boolean out(OutputStream os)
os - 输出流public String text()
public char[] textChar()
public void checkAlpha()
public void drawLine(int num,
Graphics2D g)
num - 数量g - Graphics2Dpublic void drawLine(int num,
Color color,
Graphics2D g)
num - 数量color - 颜色g - Graphics2Dpublic void drawOval(int num,
Graphics2D g)
num - 数量g - Graphics2Dpublic void drawOval(int num,
Color color,
Graphics2D g)
num - 数量color - 颜色g - Graphics2Dpublic Font getFont()
public void setFont(Font font)
public int getLen()
public void setLen(int len)
public int getWidth()
public void setWidth(int width)
public int getHeight()
public void setHeight(int height)
public int getCharType()
public void setCharType(int charType)
Copyright © 2020. All rights reserved.