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.awt.geom.AffineTransform; 7 import java.util.Random; 8 import java.security.SecureRandom; 9 10 /*** 11 * @author mag 12 * @Date 6 mars 2008 13 */ 14 public class ShearGlyphsRandomVisitor implements GlyphsVisitors { 15 16 private double maxShearX; 17 private double maxShearY; 18 private Random myRandom = new SecureRandom(); 19 20 public ShearGlyphsRandomVisitor(double maxShearX, double maxShearY) { 21 this.maxShearX = maxShearX; 22 this.maxShearY = maxShearY; 23 } 24 25 public void visit(Glyphs gv, Rectangle2D backroundBounds) { 26 27 for(int i=0;i<gv.size();i++){ 28 AffineTransform af = new AffineTransform(); 29 af.setToShear(maxShearX*myRandom.nextGaussian(),maxShearY*myRandom.nextGaussian()); 30 gv.addAffineTransform(i, af); 31 } 32 } 33 }