|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zul.impl.XulElement
org.zkoss.zul.Image
org.zkoss.zul.Captcha
public class Captcha
The generic captcha component.
Captcha requires an implementation of an engine (CaptchaEngine
).
The default engine is based on JHLabs and available in ZK PE and ZK EE.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.zkoss.zul.Image |
---|
Image.ExtraCtrl |
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent |
---|
AbstractComponent.Children |
Field Summary |
---|
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
---|
_height, _left, _top, _width, _zclass |
Fields inherited from class org.zkoss.zk.ui.AbstractComponent |
---|
_visible |
Fields inherited from interface org.zkoss.zk.ui.Component |
---|
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE |
Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl |
---|
CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE |
Constructor Summary | |
---|---|
Captcha()
|
Method Summary | |
---|---|
void |
addFont(java.awt.Font font)
Add fonts into fonts list. |
java.lang.String |
getBgColor()
Get the background color of the captcha box (in string as #RRGGBB). |
int |
getBgRGB()
Get the background color in int array (0: red, 1: green, 2:blue). |
CaptchaEngine |
getCaptchaEngine()
Get the captcha engine. |
java.awt.Font[] |
getDefaultFonts()
Gets the default font list. |
java.lang.String |
getExclude()
Get exclude characters. |
java.awt.Font |
getFont(int j)
Get nth Font. |
java.lang.String |
getFontColor()
Gets font color. |
int |
getFontRGB()
Get the font color in int array (0: red, 1: green, 2:blue). |
java.util.List |
getFonts()
Gets fonts list, default provide two fonts. |
int |
getIntHeight()
Get the captcha int height in pixel; to be used by the derived subclass. |
int |
getIntWidth()
Get the captcha int width in pixel; to be used by the derived subclass. |
int |
getLength()
Get length of the autogenerated text value; default to 5. |
java.lang.String |
getValue()
Returns the text value of this captcha. |
boolean |
isBorder()
Returns whether generate border. |
boolean |
isNoise()
Returns whether generate noise; default to false. |
protected CaptchaEngine |
newCaptchaEngine()
Instantiates the default captcha engine. |
java.lang.String |
randomValue()
Regenerates new captcha text value and redraw. |
void |
setBgColor(java.lang.String color)
Set the background color of the chart. |
void |
setBorder(boolean b)
Sets whether generate border. |
void |
setEngine(CaptchaEngine engine)
Set the captcha engine. |
void |
setEngine(java.lang.String clsnm)
Sets the captcha engine by use of a class name. |
void |
setExclude(java.lang.String exclude)
Set exclude characters that will not be generated. |
void |
setFontColor(java.lang.String color)
Set font color. |
void |
setHeight(java.lang.String h)
Override super class to prepare the int height. |
void |
setLength(int len)
Set length of the autogenerated text value; default to 5. |
void |
setNoise(boolean b)
Sets whether generate noise; default to false. |
void |
setValue(java.lang.String text)
Sets the text value to be shown as the distortion captcha. |
void |
setWidth(java.lang.String w)
Override super class to prepare the int width. |
protected void |
smartDrawCaptcha()
mark a draw flag to inform that this Chart needs update. |
Methods inherited from class org.zkoss.zul.Image |
---|
getAlign, getBorder, getContent, getHover, getHspace, getSrc, getVspace, isChildable, newExtraCtrl, renderProperties, setAlign, setBorder, setContent, setContent, setHover, setHoverContent, setHoverContent, setHspace, setSrc, setVspace |
Methods inherited from class org.zkoss.zul.impl.XulElement |
---|
getAction, getContext, getCtrlKeys, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip |
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
---|
focus, getDraggable, getDroppable, getHeight, getHflex, getLeft, getSclass, getStyle, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, service, setClass, setDraggable, setDroppable, setFocus, setHflex, setLeft, setSclass, setStyle, setTooltiptext, setTop, setVflex, setZclass, setZindex, setZIndex |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.zkoss.zul.api.Image |
---|
getAlign, getBorder, getContent, getHover, getHspace, getSrc, getVspace, setAlign, setBorder, setContent, setContent, setHover, setHoverContent, setHoverContent, setHspace, setSrc, setVspace |
Methods inherited from interface org.zkoss.zul.impl.api.XulElement |
---|
getAction, getContext, getCtrlKeys, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip |
Methods inherited from interface org.zkoss.zk.ui.api.HtmlBasedComponent |
---|
focus, getHeight, getLeft, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZclass, getZindex, getZIndex, setDraggable, setDroppable, setFocus, setLeft, setSclass, setStyle, setTooltiptext, setTop, setZclass, setZindex, setZIndex |
Methods inherited from interface org.zkoss.zk.ui.ext.Scope |
---|
addScopeListener, getAttribute, hasAttribute, removeAttribute, removeScopeListener, setAttribute |
Constructor Detail |
---|
public Captcha()
Method Detail |
---|
public java.util.List getFonts()
getFonts
in interface Captcha
public java.awt.Font[] getDefaultFonts()
getDefaultFonts
in interface Captcha
public java.awt.Font getFont(int j)
getFont
in interface Captcha
public void addFont(java.awt.Font font)
addFont
in interface Captcha
public void setFontColor(java.lang.String color)
setFontColor
in interface Captcha
public java.lang.String getFontColor()
getFontColor
in interface Captcha
public int getFontRGB()
getFontRGB
in interface Captcha
public void setBgColor(java.lang.String color)
setBgColor
in interface Captcha
color
- in #RRGGBB format (hexdecimal).public java.lang.String getBgColor()
getBgColor
in interface Captcha
public int getBgRGB()
getBgRGB
in interface Captcha
public void setWidth(java.lang.String w)
setWidth
in interface HtmlBasedComponent
setWidth
in class HtmlBasedComponent
public int getIntWidth()
getIntWidth
in interface Captcha
public void setHeight(java.lang.String h)
setHeight
in interface HtmlBasedComponent
setHeight
in class HtmlBasedComponent
public int getIntHeight()
getIntHeight
in interface Captcha
public java.lang.String getValue()
Default: an empty string.
Deriving class can override it to return whatever it wants other than null.
getValue
in interface Captcha
public void setValue(java.lang.String text) throws WrongValueException
setValue
in interface Captcha
text
- the captcha text value
WrongValueException
public void setLength(int len)
setLength
in interface Captcha
public int getLength()
getLength
in interface Captcha
public void setExclude(java.lang.String exclude)
setExclude
in interface Captcha
public java.lang.String getExclude()
getExclude
in interface Captcha
public void setNoise(boolean b)
setNoise
in interface Captcha
public boolean isNoise()
isNoise
in interface Captcha
public void setBorder(boolean b)
Default to false.
public boolean isBorder()
Default to false.
public java.lang.String randomValue()
randomValue
in interface Captcha
public void setEngine(java.lang.String clsnm) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException
setEngine
in interface Captcha
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
public void setEngine(CaptchaEngine engine)
setEngine
in interface Captcha
public CaptchaEngine getCaptchaEngine() throws UiException
getCaptchaEngine
in interface Captcha
UiException
- if failed to load the engine.protected CaptchaEngine newCaptchaEngine() throws UiException
setEngine(java.lang.String)
is not called with non-null
engine.
By default, it looks up the component attribute called
captcha-engine. If found, the value is assumed to be the class
or the class name of the default engine (it must implement
CaptchaEngine
.
If not found, UiException
is thrown.
Derived class might override this method to provide your own default class.
UiException
- if failed to instantiate the engineprotected void smartDrawCaptcha()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |