11package com .blade .patchca ;
22
3- import java .awt .Color ;
4- import java .io .File ;
5- import java .io .FileNotFoundException ;
6- import java .io .FileOutputStream ;
7- import java .io .IOException ;
8- import java .io .OutputStream ;
9- import java .util .Random ;
10-
113import com .blade .kit .StringKit ;
12- import com .blade .kit .json .ParseException ;
134import com .blade .mvc .http .Request ;
145import com .blade .mvc .http .Response ;
156import com .blade .mvc .http .wrapper .Session ;
2314import org .slf4j .Logger ;
2415import org .slf4j .LoggerFactory ;
2516
17+ import java .awt .*;
18+ import java .io .*;
19+ import java .util .Random ;
20+
2621/**
2722 * DefaultPatchca
2823 */
@@ -36,9 +31,7 @@ public class DefaultPatchca implements Patchca {
3631 private RandomWordFactory wf ;
3732
3833 public DefaultPatchca () {
39- cs = new ConfigurableCaptchaService ();
40- // cs.setColorFactory(new SingleColorFactory(new Color(25, 60, 170)));
41- cs .setColorFactory (new ColorFactory () {
34+ this (new ColorFactory () {
4235 @ Override
4336 public Color getColor (int x ) {
4437 int [] c = new int [3 ];
@@ -53,6 +46,11 @@ public Color getColor(int x) {
5346 return new Color (c [0 ], c [1 ], c [2 ]);
5447 }
5548 });
49+ }
50+
51+ public DefaultPatchca (ColorFactory colorFactory ) {
52+ cs = new ConfigurableCaptchaService ();
53+ cs .setColorFactory (colorFactory );
5654 wf = new RandomWordFactory ();
5755 wf .setCharacters ("23456789abcdefghigkmnpqrstuvwxyzABCDEFGHIGKLMNPQRSTUVWXYZ" );
5856 wf .setMinLength (4 );
@@ -61,37 +59,37 @@ public Color getColor(int x) {
6159 cs .setFilterFactory (new DiffuseRippleFilterFactory ());
6260 }
6361
64- public DefaultPatchca length (int lenth ){
62+ public Patchca length (int lenth ){
6563 wf .setMaxLength (lenth );
6664 wf .setMinLength (lenth );
6765 cs .setWordFactory (wf );
6866 return this ;
6967 }
7068
71- public DefaultPatchca length (int min , int max ){
69+ public Patchca length (int min , int max ){
7270 wf .setMinLength (min );
7371 wf .setMaxLength (max );
7472 cs .setWordFactory (wf );
7573 return this ;
7674 }
7775
78- public DefaultPatchca size (int width , int height ){
76+ public Patchca size (int width , int height ){
7977 cs .setWidth (width );
8078 cs .setHeight (height );
8179 return this ;
8280 }
8381
84- public DefaultPatchca color (ColorFactory colorFactory ){
82+ public Patchca color (ColorFactory colorFactory ){
8583 cs .setColorFactory (colorFactory );
8684 return this ;
8785 }
8886
89- public DefaultPatchca word (WordFactory wordFactory ){
87+ public Patchca word (WordFactory wordFactory ){
9088 cs .setWordFactory (wordFactory );
9189 return this ;
9290 }
9391
94- public DefaultPatchca filter (FilterFactory filterFactory ){
92+ public Patchca filter (FilterFactory filterFactory ){
9593 cs .setFilterFactory (filterFactory );
9694 return this ;
9795 }
0 commit comments