|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.riotfamily.website.txt2img.TextRenderer
public class TextRenderer
Class to render text as image. Supports resampling to improve the kerning at small font sizes.
Constructor Summary | |
---|---|
TextRenderer()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
protected int |
checkSize(int size)
|
protected Graphics2D |
createGraphics(BufferedImage image)
|
protected BufferedImage |
createImage(Dimension size)
|
protected void |
drawText(String text,
float maxWidth,
String color,
float fontSize,
BufferedImage image)
|
BufferedImage |
generate(String text,
int maxWidth,
String color)
|
protected Font |
getFont(String text)
|
protected Dimension |
getSize(String text,
float fontSize,
float maxWidth)
|
protected Dimension |
layout(String text,
float maxWidth,
String color,
float fontSize,
BufferedImage image,
boolean draw)
|
void |
setAntiAlias(boolean antiAlias)
Turns anti-aliasing off or on (default). |
void |
setColor(String color)
Sets the text foreground color. |
void |
setFont(Resource res)
Sets the font to use. |
void |
setInternalFontSize(int internalFontSize)
Sets the font size at which the text is rendered internally when resampling is enabled. |
void |
setLineSpacing(int lineSpacing)
Sets the interline spacing in pixels. |
void |
setMaxWidth(Integer maxWidth)
Sets the maximum image width. |
void |
setPaddingBottom(int paddingBottom)
Sets the padding at the bottom of the image in pixels. |
void |
setPaddingLeft(int paddingLeft)
Sets the padding at the left side of the image in pixels. |
void |
setPaddingRight(int paddingRight)
Sets the padding at the right side of the image in pixels. |
void |
setPaddingTop(int paddingTop)
Sets the padding at the top of the image in pixels. |
void |
setResample(boolean resample)
If set to true, the text will be rendered at a larger size internally and scaled down to the requested size. |
void |
setShrinkToFit(boolean shrinkToFit)
Sets whether the font-size should be reduced if the text does not fit within the max-width. |
void |
setSize(float size)
Sets the font size. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TextRenderer()
Method Detail |
---|
public void setFont(Resource res) throws FontFormatException, IOException
FontFormatException
IOException
protected Font getFont(String text)
public void setColor(String color)
#fff #fffff rgb(255,255,255) rgb(100%, 100%, 100%)
public void setSize(float size)
public void setAntiAlias(boolean antiAlias)
public void setLineSpacing(int lineSpacing)
TextLayout.getLeading()
is used.
public void setMaxWidth(Integer maxWidth)
public void setShrinkToFit(boolean shrinkToFit)
public void setPaddingTop(int paddingTop)
0
.
public void setPaddingRight(int paddingRight)
0
.
public void setPaddingBottom(int paddingBottom)
0
.
public void setPaddingLeft(int paddingLeft)
0
.
public void setResample(boolean resample)
public void setInternalFontSize(int internalFontSize)
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
public BufferedImage generate(String text, int maxWidth, String color)
protected Dimension getSize(String text, float fontSize, float maxWidth)
protected void drawText(String text, float maxWidth, String color, float fontSize, BufferedImage image)
protected Dimension layout(String text, float maxWidth, String color, float fontSize, BufferedImage image, boolean draw)
protected int checkSize(int size)
protected Graphics2D createGraphics(BufferedImage image)
protected BufferedImage createImage(Dimension size)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |