1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.octo.captcha.engine.image.gimpy;
20
21 import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator;
22 import com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator;
23 import com.octo.captcha.component.image.deformation.ImageDeformation;
24 import com.octo.captcha.component.image.deformation.ImageDeformationByFilters;
25 import com.octo.captcha.component.image.fontgenerator.FontGenerator;
26 import com.octo.captcha.component.image.fontgenerator.TwistedAndShearedRandomFontGenerator;
27 import com.octo.captcha.component.image.textpaster.TextPaster;
28 import com.octo.captcha.component.image.textpaster.DecoratedRandomTextPaster;
29 import com.octo.captcha.component.image.textpaster.textdecorator.TextDecorator;
30 import com.octo.captcha.component.image.textpaster.textdecorator.BaffleTextDecorator;
31 import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage;
32 import com.octo.captcha.component.image.wordtoimage.DeformedComposedWordToImage;
33 import com.octo.captcha.component.image.wordtoimage.WordToImage;
34 import com.octo.captcha.component.image.color.SingleColorGenerator;
35 import com.octo.captcha.component.word.wordgenerator.DictionaryWordGenerator;
36 import com.octo.captcha.component.word.wordgenerator.WordGenerator;
37 import com.octo.captcha.engine.image.ListImageCaptchaEngine;
38 import com.octo.captcha.image.gimpy.GimpyFactory;
39
40 import java.awt.*;
41 import java.awt.image.ImageFilter;
42
43 /***
44 * <p><ul><li></li></ul></p>
45 *
46 * @author <a href="mailto:mag@jcaptcha.net">Marc-Antoine Garrigue</a>
47 * @version 1.0
48 */
49 public class DeformedBaffleListGimpyEngine extends ListImageCaptchaEngine {
50
51 protected void buildInitialFactories() {
52
53
54 com.jhlabs.image.EmbossFilter emboss = new com.jhlabs.image.EmbossFilter();
55 com.jhlabs.image.SphereFilter sphere = new com.jhlabs.image.SphereFilter();
56 com.jhlabs.image.RippleFilter rippleBack = new com.jhlabs.image.RippleFilter();
57 com.jhlabs.image.RippleFilter ripple = new com.jhlabs.image.RippleFilter();
58 com.jhlabs.image.TwirlFilter twirl = new com.jhlabs.image.TwirlFilter();
59 com.jhlabs.image.WaterFilter water = new com.jhlabs.image.WaterFilter();
60
61 com.jhlabs.image.WeaveFilter weaves = new com.jhlabs.image.WeaveFilter();
62
63
64
65
66 ripple.setWaveType(com.jhlabs.image.RippleFilter.NOISE);
67 ripple.setXAmplitude(3);
68 ripple.setYAmplitude(3);
69 ripple.setXWavelength(20);
70 ripple.setYWavelength(10);
71 ripple.setEdgeAction(com.jhlabs.image.TransformFilter.CLAMP);
72
73 rippleBack.setWaveType(com.jhlabs.image.RippleFilter.NOISE);
74 rippleBack.setXAmplitude(5);
75 rippleBack.setYAmplitude(5);
76 rippleBack.setXWavelength(10);
77 rippleBack.setYWavelength(10);
78 rippleBack.setEdgeAction(com.jhlabs.image.TransformFilter.CLAMP);
79
80 water.setAmplitude(1);
81
82 water.setWavelength(20);
83
84 twirl.setAngle(3 / 360);
85
86 sphere.setRefractionIndex(1);
87
88 weaves.setUseImageColors(true);
89
90
91
92 ImageDeformation rippleDef = new ImageDeformationByFilters(
93 new ImageFilter[]{});
94 ImageDeformation waterDef = new ImageDeformationByFilters(
95 new ImageFilter[]{});
96 ImageDeformation embossDef = new ImageDeformationByFilters(
97 new ImageFilter[]{});
98 ImageDeformation rippleDefBack = new ImageDeformationByFilters(
99 new ImageFilter[]{});
100
101 ImageDeformation weavesDef = new ImageDeformationByFilters(
102 new ImageFilter[]{});
103
104 ImageDeformation none = new ImageDeformationByFilters(null);
105
106 WordGenerator words = new DictionaryWordGenerator(
107 new com.octo.captcha.component.word.FileDictionary(
108 "toddlist"));
109
110 TextPaster paster = new DecoratedRandomTextPaster(new Integer(6), new Integer(
111 7), new SingleColorGenerator(Color.black)
112 , new TextDecorator[]{new BaffleTextDecorator(new Integer(1), Color.white)});
113 BackgroundGenerator back = new UniColorBackgroundGenerator(
114 new Integer(200), new Integer(100), Color.white);
115
116 FontGenerator font = new TwistedAndShearedRandomFontGenerator(
117 new Integer(30), new Integer(40));
118
119 WordToImage word2image = new ComposedWordToImage(font, back, paster);
120 this.addFactory(
121 new com.octo.captcha.image.gimpy.GimpyFactory(words,
122 word2image));
123
124 word2image = new DeformedComposedWordToImage(font, back, paster,
125 rippleDef,
126 waterDef,
127 embossDef);
128 this.addFactory(new GimpyFactory(words, word2image));
129
130 word2image = new DeformedComposedWordToImage(font, back, paster,
131 rippleDefBack,null,
132 rippleDef);
133 this.addFactory(new GimpyFactory(words, word2image));
134
135 word2image = new DeformedComposedWordToImage(font, back, paster,
136 rippleDefBack,
137 none,
138 weavesDef);
139 this.addFactory(new GimpyFactory(words, word2image));
140
141 }
142 }