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 HorizontalSpaceGlyphsVisitor implements GlyphsVisitors {
12
13 private int spaceBetweenGlyphs=0;
14
15 public HorizontalSpaceGlyphsVisitor(int spaceBetweenGlyphs) {
16 this.spaceBetweenGlyphs = spaceBetweenGlyphs;
17 }
18
19 public void visit(Glyphs glyphs, Rectangle2D backroundBounds) {
20
21 for(int i=1;i< glyphs.size();i++){
22 double tx = glyphs.getBoundsX(i-1)+ glyphs.getBoundsWidth(i-1)- glyphs.getBoundsX(i)+spaceBetweenGlyphs;
23 double ty = 0;
24 glyphs.translate(i,tx,ty);
25
26 }
27 }
28 }