org.opengts.util
Class Captcha

java.lang.Object
  extended by org.opengts.util.Captcha

public class Captcha
extends java.lang.Object

Captcha Image Generator


Field Summary
static java.lang.String DEFAULT_ALPHA
           
static java.lang.String DEFAULT_FONT_NAME
           
static int DEFAULT_FONT_SIZE
           
static int DEFAULT_FONT_STYLE
           
static int DEFAULT_HEIGHT
           
static boolean DEFAULT_IGNORE_CASE
           
static int DEFAULT_SYMBOL_COUNT
           
static int DEFAULT_WIDTH
           
 
Constructor Summary
Captcha()
          Constructor
Captcha(int symCount)
          Constructor
Captcha(java.lang.String alphabet, boolean ignoreCase, int symCount)
          Constructor
 
Method Summary
protected  java.awt.Font getFont(int size)
          Gets the captch font
 byte[] getImageBytes()
          Creates/returns the Captch image as a byte array
 byte[] getImageBytes(java.awt.Color bgColor, int width, int height)
          Creates/returns the Captch image as a byte array
 byte[] getImageBytes(int width, int height)
          Creates/returns the Captch image as a byte array
protected  java.util.Random getRandom()
          Gets the Captcha value randomizer
 java.lang.String getValue()
          Gets the target value of this captcha
static void main(java.lang.String[] argv)
           
 java.io.OutputStream writeImage(java.awt.Color bgColor, int width, int height, java.io.OutputStream output)
          Writes the captcha image to the specified OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ALPHA

public static final java.lang.String DEFAULT_ALPHA
See Also:
Constant Field Values

DEFAULT_IGNORE_CASE

public static final boolean DEFAULT_IGNORE_CASE
See Also:
Constant Field Values

DEFAULT_SYMBOL_COUNT

public static final int DEFAULT_SYMBOL_COUNT
See Also:
Constant Field Values

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
See Also:
Constant Field Values

DEFAULT_HEIGHT

public static final int DEFAULT_HEIGHT
See Also:
Constant Field Values

DEFAULT_FONT_NAME

public static final java.lang.String DEFAULT_FONT_NAME
See Also:
Constant Field Values

DEFAULT_FONT_STYLE

public static final int DEFAULT_FONT_STYLE
See Also:
Constant Field Values

DEFAULT_FONT_SIZE

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

Captcha

public Captcha()
Constructor


Captcha

public Captcha(int symCount)
Constructor


Captcha

public Captcha(java.lang.String alphabet,
               boolean ignoreCase,
               int symCount)
Constructor

Method Detail

getRandom

protected java.util.Random getRandom()
Gets the Captcha value randomizer


getFont

protected java.awt.Font getFont(int size)
Gets the captch font


getValue

public java.lang.String getValue()
Gets the target value of this captcha


writeImage

public java.io.OutputStream writeImage(java.awt.Color bgColor,
                                       int width,
                                       int height,
                                       java.io.OutputStream output)
Writes the captcha image to the specified OutputStream. If null is specified for the OutputStream, and new ByteArrayOutputStream will be created.

Parameters:
bgColor - The background color
width - The captcha image width
height - The captcha image height
output - The OutputStream to which the image is written
Returns:
The OutputStream to which the image was written

getImageBytes

public byte[] getImageBytes()
Creates/returns the Captch image as a byte array

Returns:
The image byte array

getImageBytes

public byte[] getImageBytes(int width,
                            int height)
Creates/returns the Captch image as a byte array

Parameters:
width - The captcha image width
height - The captcha image height
Returns:
The image byte array

getImageBytes

public byte[] getImageBytes(java.awt.Color bgColor,
                            int width,
                            int height)
Creates/returns the Captch image as a byte array

Parameters:
bgColor - The background color
width - The captcha image width
height - The captcha image height
Returns:
The image byte array

main

public static void main(java.lang.String[] argv)