public class Text2PngFactory extends Object
Constructor and Description |
---|
Text2PngFactory()
Construct factory without setting font.
|
Text2PngFactory(String fontname,
int fontsize)
Construct factory with given font face and size.
|
Text2PngFactory(String fontname,
int fontsize,
String text)
Construct factory with given font face and size.
|
Modifier and Type | Method and Description |
---|---|
RenderedImage |
createImage()
Renders the current text in the current font fontname, fontsize and color.
|
void |
createPngFile(File location)
Renders the current text to a .png file.
|
void |
createPngFile(String location)
Renders the current text to a .png file.
|
void |
setBackgroundRGB(int r,
int g,
int b)
Set 8-bit RGB values for background colour.
|
void |
setFontFace(String fontname)
Set the TrueType font to render with.
|
void |
setFontSize(int fontsize)
Set the point size of the font.
|
void |
setText(String text)
Set the text to be rendered by the Txt2PngFactory.
|
void |
setTextRGB(int r,
int g,
int b)
Set 8-bit RGB values for text colour.
|
String |
toString() |
public Text2PngFactory()
public Text2PngFactory(String fontname, int fontsize) throws IOException, FontFormatException
fontname
- Name of TrueType fontfontsize
- Point size of fontIOException
- if font can't be loadedFontFormatException
- if font is not a valid TTFpublic Text2PngFactory(String fontname, int fontsize, String text) throws IOException, FontFormatException
fontname
- Name of TrueType fontfontsize
- Point size of fonttext
- The text to renderIOException
- if font can't be loadedFontFormatException
- if font is not a valid TTFpublic void createPngFile(String location) throws IOException
location
- Location to write the file out toIOException
- if file cannot be createdpublic void createPngFile(File location) throws IOException
location
- Location to write the file out toIOException
- if file cannot be createdpublic RenderedImage createImage() throws IOException
IOException
- if no font name has been specified yetpublic void setText(String text)
text
- The text to renderpublic void setTextRGB(int r, int g, int b)
r
- Red component (0-255)g
- Green component (0-255)b
- Blue component (0-255)public void setBackgroundRGB(int r, int g, int b)
r
- Red component (0-255)g
- Green component (0-255)b
- Blue component (0-255)public void setFontFace(String fontname) throws IOException, FontFormatException
fontname
- The name of the font to useIOException
FontFormatException
public void setFontSize(int fontsize)
fontsize
- The point size of the fontCopyright © 2003–2015 Magnolia International Ltd.. All rights reserved.