com.octo.captcha.component.image.wordtoimage
Class AbstractWordToImage
java.lang.Object
com.octo.captcha.component.image.wordtoimage.AbstractWordToImage
- All Implemented Interfaces:
- WordToImage
- Direct Known Subclasses:
- ComposedWordToImage, SimpleWordToImage
public abstract class AbstractWordToImage
- extends java.lang.Object
- implements WordToImage
Implementation skeleton for the WordToImage component
Basically this class implements the imageFromWord method
proceding as folow : - Checks the word length
- Creates an java.text.AttributedString from the
word
- Apply font to the AttributedString using the abstract method getFont
- Create an image for the
background using the abstact method getBackround
- Put the text on the backround using the abstact method
pasteText
- Return the newly created image
This class implements the Template method pattern
from the GOF design patterns.
Method Summary |
java.awt.image.BufferedImage |
getImage(java.lang.String word)
Creates an image of the provided String This method is a skeleton for creation algorithm. it proceeds as folows :
Checks the word length Creates an java.text.AttributedString from the word Apply font
to the AttributedString using the abstract method getFont Create an image for the background using the
abstact method getBackround Put the text on the backround using the abstact method pasteText
Return the newly created image |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractWordToImage
protected AbstractWordToImage()
AbstractWordToImage
protected AbstractWordToImage(boolean manageFontByCharacter)
getImage
public java.awt.image.BufferedImage getImage(java.lang.String word)
throws CaptchaException
- Creates an image of the provided String This method is a skeleton for creation algorithm. it proceeds as folows :
- Checks the word length
- Creates an java.text.AttributedString from the word
- Apply font
to the AttributedString using the abstract method getFont
- Create an image for the background using the
abstact method getBackround
- Put the text on the backround using the abstact method pasteText
- Return the newly created image
- Specified by:
getImage
in interface WordToImage
- Returns:
- an image representation of the word
- Throws:
CaptchaException
- if word is invalid or if image generation fails.
Copyright 2003-2009 JCaptcha. All Rights Reserved.