net.jot.captcha.generators
Class JOTSTDCaptchaGenerator

java.lang.Object
  extended by net.jot.captcha.generators.JOTSTDCaptchaGenerator
All Implemented Interfaces:
JOTCaptchaGeneratorInterface

public class JOTSTDCaptchaGenerator
extends java.lang.Object
implements JOTCaptchaGeneratorInterface

My own captcha impl, called "drunk" because of the way the letters look (wavy) Generate 200x60 captcha containing 5 characters characters used are listed in CHARS (others can be confusing) Background of image is white Characters use Random colors We add some random lines of the same color as the characters to the background(1 pixel thick) Characters "size" varies a bit between (scale: 3 to 5) Characters lines thickness vary from 3 to 5 Characters are drown using "wavy" lines (wavyness: 1 to 4) Wavy lines will also have holes in them (sometimes)

Author:
thibautc

Field Summary
static int BG_LINES
           
static int BG_LINES_LENGTH
           
static int CHAR_THICKNESS_MAX
           
static int CHAR_THICKNESS_MIN
           
static int CODE_LENGTH_MAX
           
static int CODE_LENGTH_MIN
           
static int FG_LINES
           
static int FG_LINES_LENGTH
           
static int HEIGHT
           
static int MAX_CHAR_COLORS
           
static int MAX_CHAR_SCALE
           
static int MIN_CHAR_COLORS
           
static int MIN_CHAR_SCALE
           
static int WAVYNESS_MAX
           
static int WAVYNESS_MIN
           
static int WIDTH
           
 
Constructor Summary
JOTSTDCaptchaGenerator()
           
 
Method Summary
 java.lang.String getChars()
          Return a string contatining all the possible chars that can might be in the captcha
 java.lang.String writeToBrowser(JOTAbstractImageWriterInterface writer, javax.servlet.http.HttpServletResponse response)
          Sends the captchca straight to the browser (sets headers etc..).
 java.lang.String writeToFile(JOTAbstractImageWriterInterface writer, java.io.File imageFile)
          Creates a captcha image Return captcha code
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WIDTH

public static final int WIDTH
See Also:
Constant Field Values

HEIGHT

public static final int HEIGHT
See Also:
Constant Field Values

CODE_LENGTH_MIN

public static final int CODE_LENGTH_MIN
See Also:
Constant Field Values

CODE_LENGTH_MAX

public static final int CODE_LENGTH_MAX
See Also:
Constant Field Values

MIN_CHAR_SCALE

public static final int MIN_CHAR_SCALE
See Also:
Constant Field Values

MAX_CHAR_SCALE

public static final int MAX_CHAR_SCALE
See Also:
Constant Field Values

MIN_CHAR_COLORS

public static final int MIN_CHAR_COLORS
See Also:
Constant Field Values

MAX_CHAR_COLORS

public static final int MAX_CHAR_COLORS
See Also:
Constant Field Values

BG_LINES

public static final int BG_LINES
See Also:
Constant Field Values

BG_LINES_LENGTH

public static final int BG_LINES_LENGTH
See Also:
Constant Field Values

FG_LINES

public static final int FG_LINES
See Also:
Constant Field Values

FG_LINES_LENGTH

public static final int FG_LINES_LENGTH
See Also:
Constant Field Values

CHAR_THICKNESS_MIN

public static final int CHAR_THICKNESS_MIN
See Also:
Constant Field Values

CHAR_THICKNESS_MAX

public static final int CHAR_THICKNESS_MAX
See Also:
Constant Field Values

WAVYNESS_MIN

public static final int WAVYNESS_MIN
See Also:
Constant Field Values

WAVYNESS_MAX

public static final int WAVYNESS_MAX
See Also:
Constant Field Values
Constructor Detail

JOTSTDCaptchaGenerator

public JOTSTDCaptchaGenerator()
Method Detail

getChars

public java.lang.String getChars()
Description copied from interface: JOTCaptchaGeneratorInterface
Return a string contatining all the possible chars that can might be in the captcha

Specified by:
getChars in interface JOTCaptchaGeneratorInterface

writeToFile

public java.lang.String writeToFile(JOTAbstractImageWriterInterface writer,
                                    java.io.File imageFile)
                             throws java.lang.Exception
Description copied from interface: JOTCaptchaGeneratorInterface
Creates a captcha image Return captcha code

Specified by:
writeToFile in interface JOTCaptchaGeneratorInterface
Throws:
java.lang.Exception

writeToBrowser

public java.lang.String writeToBrowser(JOTAbstractImageWriterInterface writer,
                                       javax.servlet.http.HttpServletResponse response)
                                throws java.lang.Exception
Description copied from interface: JOTCaptchaGeneratorInterface
Sends the captchca straight to the browser (sets headers etc..). Note that it will close(commit) the response. ex: writeBrowser(writer,responset,"CAPTCHA_CODE"); returns the captcha code.

Specified by:
writeToBrowser in interface JOTCaptchaGeneratorInterface
Throws:
java.lang.Exception