Class CaptchaConfig.Builder
java.lang.Object
cloud.opencode.base.captcha.CaptchaConfig.Builder
- Enclosing class:
CaptchaConfig
Configuration Builder
配置构建器
- Since:
- JDK 25, opencode-base-captcha V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Method Summary
Modifier and TypeMethodDescriptionaudioSpeedVariation(float audioSpeedVariation) Sets the audio speed variation range.backgroundColor(Color backgroundColor) Sets the background color.bezierNoiseEnabled(boolean bezierNoiseEnabled) Sets whether Bezier curve noise is enabled.build()Builds the configuration after validating all parameters.caseSensitive(boolean caseSensitive) Sets case sensitivity.charOverlapRatio(float charOverlapRatio) Sets the character overlap ratio.customFontPath(String path) Adds a single custom font path.customFontPaths(List<String> paths) Sets the custom font paths.expireTime(Duration expireTime) Sets the expiration time.fontColors(Color... fontColors) Sets the font colors.Sets the font name.fontSize(float fontSize) Sets the font size.gifDelay(int gifDelay) Sets the GIF frame delay.gifFrameCount(int gifFrameCount) Sets the GIF frame count.height(int height) Sets the image height.length(int length) Sets the CAPTCHA code length.noiseDots(int noiseDots) Sets the number of noise dots.noiseLines(int noiseLines) Sets the number of noise lines.outlineShadowEnabled(boolean outlineShadowEnabled) Sets whether character outline shadow is enabled.powDifficulty(int powDifficulty) Sets the PoW (Proof-of-Work) difficulty.randomFontPerChar(boolean randomFontPerChar) Sets whether each character uses a random different font.sineWarpEnabled(boolean sineWarpEnabled) Sets whether sine wave warp is enabled.type(CaptchaType type) Sets the CAPTCHA type.width(int width) Sets the image width.
-
Method Details
-
width
Sets the image width. 设置图像宽度。- Parameters:
width- the width | 宽度- Returns:
- this builder | 此构建器
-
height
Sets the image height. 设置图像高度。- Parameters:
height- the height | 高度- Returns:
- this builder | 此构建器
-
length
Sets the CAPTCHA code length. 设置验证码长度。- Parameters:
length- the length | 长度- Returns:
- this builder | 此构建器
-
type
Sets the CAPTCHA type. 设置验证码类型。- Parameters:
type- the type | 类型- Returns:
- this builder | 此构建器
-
expireTime
Sets the expiration time. 设置过期时间。- Parameters:
expireTime- the expire time | 过期时间- Returns:
- this builder | 此构建器
-
noiseLines
Sets the number of noise lines. 设置干扰线数量。- Parameters:
noiseLines- the noise lines count | 干扰线数量- Returns:
- this builder | 此构建器
-
noiseDots
Sets the number of noise dots. 设置干扰点数量。- Parameters:
noiseDots- the noise dots count | 干扰点数量- Returns:
- this builder | 此构建器
-
fontSize
Sets the font size. 设置字体大小。- Parameters:
fontSize- the font size | 字体大小- Returns:
- this builder | 此构建器
-
fontName
Sets the font name. 设置字体名称。- Parameters:
fontName- the font name | 字体名称- Returns:
- this builder | 此构建器
-
backgroundColor
Sets the background color. 设置背景颜色。- Parameters:
backgroundColor- the background color | 背景颜色- Returns:
- this builder | 此构建器
-
fontColors
Sets the font colors. 设置字体颜色。- Parameters:
fontColors- the font colors | 字体颜色数组- Returns:
- this builder | 此构建器
-
caseSensitive
Sets case sensitivity. 设置区分大小写。- Parameters:
caseSensitive- true for case sensitive | true 表示区分大小写- Returns:
- this builder | 此构建器
-
gifFrameCount
Sets the GIF frame count. 设置 GIF 帧数。- Parameters:
gifFrameCount- the frame count | 帧数- Returns:
- this builder | 此构建器
-
gifDelay
Sets the GIF frame delay. 设置 GIF 帧延迟。- Parameters:
gifDelay- the delay in milliseconds | 延迟(毫秒)- Returns:
- this builder | 此构建器
-
customFontPaths
Sets the custom font paths. 设置自定义字体路径列表。- Parameters:
paths- the font paths | 字体路径列表- Returns:
- this builder | 此构建器
-
customFontPath
Adds a single custom font path. 追加单个自定义字体路径。- Parameters:
path- the font path | 字体路径- Returns:
- this builder | 此构建器
-
randomFontPerChar
Sets whether each character uses a random different font. 设置每个字符是否使用随机不同字体。- Parameters:
randomFontPerChar- true to enable | true 表示启用- Returns:
- this builder | 此构建器
-
charOverlapRatio
Sets the character overlap ratio. 设置字符重叠比例。- Parameters:
charOverlapRatio- the ratio (0.0-0.5) | 重叠比例(0.0-0.5)- Returns:
- this builder | 此构建器
-
sineWarpEnabled
Sets whether sine wave warp is enabled. 设置是否启用正弦波变形。- Parameters:
sineWarpEnabled- true to enable | true 表示启用- Returns:
- this builder | 此构建器
-
outlineShadowEnabled
Sets whether character outline shadow is enabled. 设置是否启用字符轮廓阴影。- Parameters:
outlineShadowEnabled- true to enable | true 表示启用- Returns:
- this builder | 此构建器
-
bezierNoiseEnabled
Sets whether Bezier curve noise is enabled. 设置是否启用贝塞尔穿字噪声。- Parameters:
bezierNoiseEnabled- true to enable | true 表示启用- Returns:
- this builder | 此构建器
-
powDifficulty
Sets the PoW (Proof-of-Work) difficulty. 设置 PoW(工作量证明)难度。- Parameters:
powDifficulty- the number of leading zero bits (1-32) | 前导零位数(1-32)- Returns:
- this builder | 此构建器
-
audioSpeedVariation
Sets the audio speed variation range. 设置音频语速变化范围。- Parameters:
audioSpeedVariation- the variation (0.0-0.5) | 变化范围(0.0-0.5)- Returns:
- this builder | 此构建器
-
build
Builds the configuration after validating all parameters. 验证所有参数后构建配置。Bounds are enforced to prevent resource exhaustion (e.g., OOM from oversized
BufferedImageallocation).强制边界检查以防止资源耗尽(例如,过大的
BufferedImage分配导致 OOM)。- Returns:
- the configuration | 配置
- Throws:
NullPointerException- if type, expireTime, or fontName is null | 如果 type、expireTime 或 fontName 为 nullIllegalArgumentException- if any numeric parameter is out of bounds | 如果任何数值参数超出范围
-