|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.jsp.tagext.SimpleTagSupport
info.magnolia.cms.taglibs.util.BaseImageTag
info.magnolia.cms.taglibs.util.TextToImageTag
public class TextToImageTag
Tag that converts text into PNG images, and outputs a div element containing a set of img elements. The font face,
text color, text size and background color can be set via the tag attributes.
The images are saved under the node specified by the attribute parentContentNodeName. Under this parent node, a new
node is created, with the name specified by the attribute imageContentNodeName. Under this node, each image will have
it own node. The names of the image node are based on the text that they contain. (Special characters such as &, /,
chinese characters, etc. are replaces by codes to ensure that these names are legal.)
If the images for the specified text do not exist in the repository under the specified parent node, then the this
tag will create the images and save them. If the images for the text already exist, then they will not be recreated.
The text to be converted into images can be split in three ways. If the attribute textSplit is null or is set to
TEXT_SPLIT_NONE, then a single image will be created of the text on one line. If textSplit is set to
TEXT_SPLIT_WORDS, then the text is plit into words (i.e. wherever there is a space). Finally, if textSplit is set to
TEXT_SPLIT_CHARACTERS, then a seperate image is created for each letter.
The tag outputs a div that contains one or more img's. The CSS class applied to the div is specified by the divCSS
attribute. The CSS applied to the images depends on how the text was split. For text that was not split, the CSS
applied is set to CSS_TEXT_IMAGE, for words it is CSS_WORD_IMAGE, and for characters it is CSS_CHARACTER_IMAGE. Any
spacing that is required between images will need to be set in your css stylesheet.
The textFontFace attribute may either be a font name of a font installed on the server, or it may be a path to a TTF
file. The class to generate PNG images from TrueType font strings is originally by Philip McCarthy -
http://chimpen.com (http://chimpen.com/things/archives/001139.php). I have made a couple of small changes.
Field Summary |
---|
Fields inherited from class info.magnolia.cms.taglibs.util.BaseImageTag |
---|
imageContentNodeName, parentContentNodeName, PROPERTIES_CONTENTTYPE_VALUE, PROPERTIES_EXTENSION_VALUE |
Constructor Summary | |
---|---|
TextToImageTag()
|
Method Summary | |
---|---|
void |
cleanUp()
Set objects to null. |
void |
doTag()
|
protected String |
getFilename()
|
void |
setDivCSS(String divCSS)
The CSS class that will be applied to the div that contains these text images. |
void |
setImageContentNodeName(String imageContentNodeName)
The name of the new contentNode to create, under which all image nodes will be saved. |
void |
setParentContentNodeName(String parentContentNodeName)
The name of the parent of the new contentNode. |
void |
setText(String text)
The text to be converted. |
void |
setTextBackColor(String textBackColor)
The color of the background in hexadecimal format, e.g. |
void |
setTextFontColor(String textFontColor)
The color of the text in hexadecimal format, e.g. |
void |
setTextFontFace(String textFontFace)
The font face of the text, e.g. |
void |
setTextFontSize(int textFontSize)
The size of the text, in points, e.g. |
void |
setTextSplit(String textSplit)
The method used to split the text into sub-strings: 'none', 'words', or 'characters'. |
void |
setUp()
Initialize settings. |
Methods inherited from class info.magnolia.cms.taglibs.util.BaseImageTag |
---|
convertHexToColor, convertHexToRGB, convertToSimpleString, createImageNode, getImageContentNode, getRequest |
Methods inherited from class javax.servlet.jsp.tagext.SimpleTagSupport |
---|
findAncestorWithClass, getJspBody, getJspContext, getParent, setJspBody, setJspContext, setParent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TextToImageTag()
Method Detail |
---|
public void setText(String text)
public void setImageContentNodeName(String imageContentNodeName)
setImageContentNodeName
in class BaseImageTag
public void setParentContentNodeName(String parentContentNodeName)
setParentContentNodeName
in class BaseImageTag
public void setTextFontFace(String textFontFace)
public void setTextFontSize(int textFontSize)
public void setTextFontColor(String textFontColor)
public void setTextBackColor(String textBackColor)
public void setTextSplit(String textSplit)
public void setDivCSS(String divCSS)
protected String getFilename()
getFilename
in class BaseImageTag
BaseImageTag.getFilename()
public void setUp()
public void doTag() throws javax.servlet.jsp.JspException
doTag
in interface javax.servlet.jsp.tagext.SimpleTag
doTag
in class javax.servlet.jsp.tagext.SimpleTagSupport
javax.servlet.jsp.JspException
public void cleanUp()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |