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   
7   /***
8    * @author mag
9    * @Date 6 mars 2008
10   */
11  public class OverlapGlyphsVisitor implements GlyphsVisitors {
12  
13      private double overlapPixels=0;
14  
15      public OverlapGlyphsVisitor(double overlapPixels) {
16          this.overlapPixels = overlapPixels;
17      }
18  
19      public void visit(Glyphs gv, Rectangle2D backroundBounds) {
20  
21          for(int i=1;i<gv.size();i++){
22              double tx =gv.getBoundsX(i-1)+gv.getBoundsWidth(i-1)-gv.getBoundsX(i)
23                      -Math.abs(gv.getRSB(i-1))
24                      -Math.abs(gv.getLSB(i))
25                      -overlapPixels;
26              double ty = 0;
27              //System.out.println(gv.getRSB(i-1)+" ; " +gv.getLSB(i-1));
28              //System.out.println(gv.getRSB(i)+" ; " +gv.getLSB(i));
29              //System.out.println("tx="+tx+",ty="+ty);
30              gv.translate(i,tx,ty);
31          }
32      }
33  
34  
35  
36  }