public SimpleCaptchaService(int width, int height, Color textColor, Color backgroundColor, int fontSize, String[] fontNames, FilterFactory ff) { backgroundFactory = new SingleColorBackgroundFactory(backgroundColor); wordFactory = new AdaptiveRandomWordFactory(); fontFactory = new RandomFontFactory(fontNames); textRenderer = new BestFitTextRender(); colorFactory = new SingleColorFactory(textColor); filterFactory = ff; this.width = width; this.height = height; }
protected TextString convertToCharacters(String text, Graphics2D g, FontFactory fontFactory, ColorFactory colorFactory) { TextString characters = new TextString(); FontRenderContext frc = g.getFontRenderContext(); double lastx = 0; for (int i = 0; i < text.length(); i++) { Font font = fontFactory.getFont(i); char c = text.charAt(i); FontMetrics fm = g.getFontMetrics(font); Rectangle2D bounds = font.getStringBounds(String.valueOf(c), frc); TextCharacter tc = new TextCharacter(); tc.setCharacter(c); tc.setFont(font); tc.setWidth(fm.charWidth(c)); tc.setHeight(fm.getAscent() + fm.getDescent()); tc.setAscent(fm.getAscent()); tc.setDescent(fm.getDescent()); tc.setX(lastx); tc.setY(0); tc.setFont(font); tc.setColor(colorFactory.getColor(i)); lastx += bounds.getWidth(); characters.addCharacter(tc); } return characters; }
fontFactory = new RandomFontFactory(); fontFactory.setMaxSize(font_max_size); fontFactory.setMinSize(font_min_size); configurableCaptchaService.setFontFactory(fontFactory);
public SimpleCaptchaService(int width, int height, Color textColor, Color backgroundColor, int fontSize, FilterFactory ff) { backgroundFactory = new SingleColorBackgroundFactory(backgroundColor); wordFactory = new AdaptiveRandomWordFactory(); fontFactory = new RandomFontFactory(); textRenderer = new BestFitTextRender(); colorFactory = new SingleColorFactory(textColor); filterFactory = ff; this.width = width; this.height = height; }
protected TextString convertToCharacters(String text, Graphics2D g, FontFactory fontFactory, ColorFactory colorFactory) { TextString characters = new TextString(); FontRenderContext frc = g.getFontRenderContext(); double lastx = 0; for (int i = 0; i < text.length(); i++) { Font font = fontFactory.getFont(i); char c = text.charAt(i); FontMetrics fm = g.getFontMetrics(font); Rectangle2D bounds = font.getStringBounds(String.valueOf(c), frc); TextCharacter tc = new TextCharacter(); tc.setCharacter(c); tc.setFont(font); tc.setWidth(fm.charWidth(c)); tc.setHeight(fm.getAscent() + fm.getDescent()); tc.setAscent(fm.getAscent()); tc.setDescent(fm.getDescent()); tc.setX(lastx); tc.setY(0); tc.setFont(font); tc.setColor(colorFactory.getColor(i)); lastx += bounds.getWidth(); characters.addCharacter(tc); } return characters; }
public ConfigurableCaptchaService() { wordFactory = new AdaptiveRandomWordFactory(); fontFactory = new RandomFontFactory(); textRenderer = new BestFitTextRender(); colorFactory = new RandomColorFactory(); backgroundFactory = new RandomColorBackgroundFactory(colorFactory); filterFactory = new CurvesRippleFilterFactory(); width = 160; height = 70; }
public SimpleCaptchaService(int width, int height, Color textColor, Color backgroundColor, int fontSize, String[] fontNames, FilterFactory ff) { backgroundFactory = new SingleColorBackgroundFactory(backgroundColor); wordFactory = new AdaptiveRandomWordFactory(); fontFactory = new RandomFontFactory(fontNames); textRenderer = new BestFitTextRenderer(); colorFactory = new SingleColorFactory(textColor); filterFactory = ff; this.width = width; this.height = height; }
public SimpleCaptchaService(int width, int height, Color textColor, Color backgroundColor, int fontSize, FilterFactory ff) { backgroundFactory = new SingleColorBackgroundFactory(backgroundColor); wordFactory = new AdaptiveRandomWordFactory(); fontFactory = new RandomFontFactory(); textRenderer = new BestFitTextRenderer(); colorFactory = new SingleColorFactory(textColor); filterFactory = ff; this.width = width; this.height = height; }
public ConfigurableCaptchaService() { backgroundFactory = new SingleColorBackgroundFactory(); wordFactory = new AdaptiveRandomWordFactory(); fontFactory = new RandomFontFactory(); textRenderer = new BestFitTextRenderer(); colorFactory = new SingleColorFactory(); filterFactory = new CurvesRippleFilterFactory(colorFactory); textRenderer.setLeftMargin(10); textRenderer.setRightMargin(10); width = 160; height = 70; }