|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.github.cage.image.Painter
public class Painter
This class does most of the captcha drawing. This class is thread safe.
| Nested Class Summary | |
|---|---|
static class |
Painter.Quality
Enumeration for different image quality levels. |
| Field Summary | |
|---|---|
static int |
DEFAULT_HEIGHT
Default image height. |
static int |
DEFAULT_WIDTH
Default image width. |
| Constructor Summary | |
|---|---|
Painter()
Constructor. |
|
Painter(int width,
int height,
Color bGround,
Painter.Quality quality,
EffectConfig effectConfig,
Random rnd)
Constructor. |
|
Painter(Random rnd)
Constructor. |
|
| Method Summary | |
|---|---|
protected Graphics2D |
configureGraphics(Graphics g,
Font font,
Color fGround)
Configures graphics object before drawing text on it. |
protected void |
configureGraphicsQuality(Graphics2D g2)
Sets quality related hints based on the quality field of this object. |
protected BufferedImage |
createImage()
Creates a new image to draw upon. |
BufferedImage |
draw(Font font,
Color fGround,
String text)
Generates a new captcha image. |
protected void |
draw(Graphics2D g,
String text)
Does some of the text transformation (calls transform(Graphics2D, String, GlyphVector)), scales, transforms
and draws the result (also the outline if needed). |
protected void |
fillBlurArray(float[] array)
Generates a random probability distribution. |
Color |
getBackground()
|
EffectConfig |
getEffectConfig()
|
int |
getHeight()
|
Painter.Quality |
getQuality()
|
int |
getWidth()
|
protected BufferedImage |
postProcess(BufferedImage img)
Does some post processing on the generated image if needed. |
protected void |
transform(Graphics2D g,
String text,
GlyphVector v)
Does some of the text transformation (like rotation and symbol crowding). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_WIDTH
public static final int DEFAULT_HEIGHT
| Constructor Detail |
|---|
public Painter()
public Painter(Random rnd)
rnd - random generator to be used, can be null
public Painter(int width,
int height,
Color bGround,
Painter.Quality quality,
EffectConfig effectConfig,
Random rnd)
width - captcha image width, default DEFAULT_WIDTHheight - captcha image height, default DEFAULT_HEIGHTbGround - background color of captcha image, default white, can be nullquality - captcha image quality, default Painter.Quality.MAX, should use
max it does not have measurable speed penalty on modern jvm-s
(1.6u23), can be nulleffectConfig - used to define what effects should be used, can be nullrnd - random generator to be used, can be null| Method Detail |
|---|
public BufferedImage draw(Font font,
Color fGround,
String text)
font - will be used for text, not nullfGround - will be used for text, not nulltext - this will be rendered on the image, not null, not 0 length
protected BufferedImage createImage()
protected Graphics2D configureGraphics(Graphics g,
Font font,
Color fGround)
g - to be configured must be an instance of Graphics2D,
not nullfont - to be used for the text, not nullfGround - to be used for the text, not null
Graphics2D or throws exception if g is not
instance of Graphics2D.protected void configureGraphicsQuality(Graphics2D g2)
g2 - to be configured, not null
protected void draw(Graphics2D g,
String text)
transform(Graphics2D, String, GlyphVector)), scales, transforms
and draws the result (also the outline if needed).
g - to be drawn upontext - to be drawn
protected void transform(Graphics2D g,
String text,
GlyphVector v)
g - to be drawn upontext - to be drawnv - graphical representation of text, to be transformedprotected BufferedImage postProcess(BufferedImage img)
img - to be post prosessed.
protected void fillBlurArray(float[] array)
array - filled with random values. The values in array sum up to 1.public int getWidth()
public int getHeight()
public Color getBackground()
public Painter.Quality getQuality()
public EffectConfig getEffectConfig()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||