public abstract class BaseCaptcha extends Randoms
| Modifier and Type | Field and Description |
|---|---|
protected String |
chars |
protected int |
charType |
static int[][] |
COLOR |
protected Font |
font |
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 |
|---|
BaseCaptcha() |
| 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()
获取当前验证码的字符数组
|
protected Font font
protected int len
protected int width
protected int height
protected String chars
protected int charType
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 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.