View Javadoc

1   package com.octo.captcha.component.image.textpaster.glyphsvisitor;
2   
3   import com.octo.captcha.component.image.textpaster.Glyphs;
4   
5   import java.awt.geom.Rectangle2D;
6   import java.util.Random;
7   import java.security.SecureRandom;
8   
9   /***
10   * @author mag
11   * @Date 6 mars 2008
12   */
13  public class RotateGlyphsRandomVisitor implements GlyphsVisitors {
14  
15      private double maxAngle =Math.PI/8;
16      private Random myRandom = new SecureRandom();
17  
18      public RotateGlyphsRandomVisitor() {
19      }
20  
21      public RotateGlyphsRandomVisitor(double maxAngle) {
22          this.maxAngle = maxAngle;
23      }
24  
25      public void visit(Glyphs gv, Rectangle2D backroundBounds) {
26  
27          for(int i=0;i<gv.size();i++){
28              gv.rotate(i,maxAngle*myRandom.nextGaussian());
29          }
30      }
31  }