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.GradientBackgroundGenerator;
25  import com.octo.captcha.component.image.color.RandomListColorGenerator;
26  import com.octo.captcha.component.image.fontgenerator.DeformedRandomFontGenerator;
27  import com.octo.captcha.component.image.fontgenerator.FontGenerator;
28  import com.octo.captcha.component.image.textpaster.NonLinearTextPaster;
29  import com.octo.captcha.component.image.textpaster.TextPaster;
30  import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage;
31  import com.octo.captcha.component.image.wordtoimage.WordToImage;
32  import com.octo.captcha.engine.image.ListImageCaptchaEngine;
33  
34  /***
35   * Use the non-linear text paster
36   * @date 19 mars 2007
37   * @author <a href="mailto:antoine.veret@gmail.com">Antoine Véret</a>
38   */
39  public class NonLinearTextGimpyEngine extends ListImageCaptchaEngine {
40  
41      protected void buildInitialFactories() {
42          
43          com.octo.captcha.component.word.wordgenerator.WordGenerator wordGenerator =
44                  new com.octo.captcha.component.word.wordgenerator.RandomWordGenerator(
45                  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
46  
47          TextPaster textPaster = new NonLinearTextPaster(new Integer(5),
48                  new Integer(7), new RandomListColorGenerator(new Color[] {Color.BLACK, Color.YELLOW,
49                  Color.WHITE}), Boolean.TRUE);
50  
51          BackgroundGenerator backgroundGenerator = new GradientBackgroundGenerator(
52                  new Integer(200), new Integer(100), Color.CYAN, Color.GRAY);
53  
54          FontGenerator fontGenerator = new DeformedRandomFontGenerator(
55                  new Integer(25), new Integer(30));
56  
57          WordToImage wordToImage = new ComposedWordToImage(fontGenerator,
58                  backgroundGenerator, textPaster);
59  
60          this.addFactory(new com.octo.captcha.image.gimpy.GimpyFactory(wordGenerator, wordToImage));
61      }
62  }