View Javadoc

1   /*
2    * JCaptcha, the open source java framework for captcha definition and integration
3    * Copyright (c)  2007 jcaptcha.net. All Rights Reserved.
4    * See the LICENSE.txt file distributed with this package.
5    */
6   
7   /*
8    * jcaptcha, the open source java framework for captcha definition and integration
9    * copyright (c)  2007 jcaptcha.net. All Rights Reserved.
10   * See the LICENSE.txt file distributed with this package.
11   */
12  
13  /*
14   * jcaptcha, the open source java framework for captcha definition and integration
15   * copyright (c)  2007 jcaptcha.net. All Rights Reserved.
16   * See the LICENSE.txt file distributed with this package.
17   */
18  
19  package com.octo.captcha.engine.image.gimpy;
20  
21  import java.awt.Color;
22  
23  import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator;
24  import com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator;
25  import com.octo.captcha.component.image.fontgenerator.FontGenerator;
26  import com.octo.captcha.component.image.fontgenerator.RandomFontGenerator;
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.BaffleTextDecorator;
30  import com.octo.captcha.component.image.textpaster.textdecorator.TextDecorator;
31  import com.octo.captcha.component.image.color.SingleColorGenerator;
32  import com.octo.captcha.engine.image.ListImageCaptchaEngine;
33  import com.sun.jndi.ldap.Ber;
34  
35  /***
36   * <p>Description: </p>
37   *
38   * @author <a href="mailto:mag@jcaptcha.net">Marc-Antoine Garrigue</a>
39   * @version 1.0
40   */
41  public class BaffleListGimpyEngine extends ListImageCaptchaEngine {
42  
43      protected void buildInitialFactories() {
44          //word generator
45          com.octo.captcha.component.word.wordgenerator.WordGenerator dictionnaryWords = new com.octo.captcha.component.word.wordgenerator.ComposeDictionaryWordGenerator(
46                  new com.octo.captcha.component.word.FileDictionary(
47                          "toddlist"));
48          //wordtoimage components
49          TextPaster randomPaster = new DecoratedRandomTextPaster(
50                  new Integer(8), new Integer(15),
51                  new SingleColorGenerator(Color.BLACK),
52                  new TextDecorator[]{new BaffleTextDecorator(2,Color.black)});
53          BackgroundGenerator back = new UniColorBackgroundGenerator(
54                  new Integer(200), new Integer(100), Color.white);
55          //BackgroundGenerator back = new FunkyBackgroundGenerator(new Integer(200), new Integer(100));
56          FontGenerator shearedFont = new RandomFontGenerator(new Integer(20),
57                  new Integer(25));
58          //word2image 1
59          com.octo.captcha.component.image.wordtoimage.WordToImage word2image = new com.octo.captcha.component.image.wordtoimage.ComposedWordToImage(
60                  shearedFont, back, randomPaster);
61  
62          this.addFactory(
63                  new com.octo.captcha.image.gimpy.GimpyFactory(dictionnaryWords,
64                          word2image));
65      }
66  }