|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.gif4j.TextPainter
This java class is intended for drawing the text across the single or multiple lines
on the BufferedImage(s).
It can be very convenient for adding some text information to images,
creation text-based watermarks (Watermark) etc.
TextPainter class in its basis uses Java 2D lays and supports
some Java 2D API concepts such as Paint etc.
This class actually represents a small superstructure above Java2D and uses only a small part of Java2D functionality.
TextPainter context contains the next attributes:
BufferedImage| Constructor Summary | |
TextPainter(java.awt.Font font)
Constructs TextPainter object with the specified Font
and set by default foreground Paint attribute to Color.BLACK,
outline Paint attribute to Color.WHITE,
background Color attribute to full-TRANSPARENT_COLOR Color
and anti-aliased to 'TRUE'. |
|
TextPainter(java.awt.Font font,
boolean antialiased)
Constructs TextPainter object with the specified Font
and the specified anti-aliased attribute.
|
|
TextPainter(java.awt.Font font,
java.awt.Paint foregroundPaint,
java.awt.Paint outlinePaint,
java.awt.Color backgroundColor,
boolean antialiased)
Constructs TextPainter object with the specified Font attribute,
foreground Paint attribute, outline Paint attribute,
background Color attribute and anti-aliased attribute. |
|
| Method Summary | |
java.awt.Color |
getBackgroundColor()
Returns the current background Color of the TextPainter context. |
java.awt.Font |
getFont()
Gets the current font. |
java.awt.Paint |
getForegroundPaint()
Returns the current foreground Paint of the TextPainter context. |
java.awt.Paint |
getOutlinePaint()
Returns the current outline Paint of the TextPainter context. |
boolean |
isAntialiased()
Gets the current antialiased attribute |
java.awt.image.BufferedImage |
renderString(java.lang.String str)
Renders single string using the specified attributes from the TextPainter context.
|
java.awt.image.BufferedImage |
renderString(java.lang.String str,
boolean outline)
Renders single string using the specified attributes from the TextPainter context.
|
java.awt.image.BufferedImage |
renderText(java.lang.String text,
int width,
boolean outline,
boolean centralized)
Renders line-wraped to the specified width text using the specified attributes from the TextPainter context.
|
void |
setAntialiased(boolean antialiased)
Sets this painter context's antialiased attribute to the specified value. |
void |
setBackgroundColor(java.awt.Color backgroundColor)
Sets the background Color attribute for the TextPainter context.
|
void |
setFont(java.awt.Font font)
Sets this painter context's font to the specified font. |
void |
setForegroundPaint(java.awt.Paint foregroundPaint)
Sets the foreground Paint attribute for the TextPainter context.
|
void |
setOutlinePaint(java.awt.Paint outlinePaint)
Sets the outline Paint attribute for the TextPainter context.
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public TextPainter(java.awt.Font font)
TextPainter object with the specified Font
and set by default foreground Paint attribute to Color.BLACK,
outline Paint attribute to Color.WHITE,
background Color attribute to full-TRANSPARENT_COLOR Color
and anti-aliased to 'TRUE'.
font - this painter context's font
java.lang.NullPointerException - If font is nullFont
public TextPainter(java.awt.Font font,
boolean antialiased)
TextPainter object with the specified Font
and the specified anti-aliased attribute.
Set by default foreground Paint attribute to Color.BLACK,
outline Paint attribute to Color.WHITE,
background Color attribute to full-TRANSPARENT_COLOR Color.
font - this painter context's fontantialiased - if true then render anti-aliased text
java.lang.NullPointerException - If font is nullFont
public TextPainter(java.awt.Font font,
java.awt.Paint foregroundPaint,
java.awt.Paint outlinePaint,
java.awt.Color backgroundColor,
boolean antialiased)
TextPainter object with the specified Font attribute,
foreground Paint attribute, outline Paint attribute,
background Color attribute and anti-aliased attribute.
font - this painter context's fontforegroundPaint - the Paint object to be used to generate color or pattern during the text rendering process, or nulloutlinePaint - the Paint object to be used to generate color or pattern during the outline rendering process, or nullbackgroundColor - the Color object to be used to generate color during the background rendering process, or nullantialiased - if true then render anti-aliased text
java.lang.NullPointerException - If font is nullFont,
Paint| Method Detail |
public java.awt.Color getBackgroundColor()
Color of the TextPainter context.
Color.Colorpublic java.awt.Font getFont()
Fontpublic java.awt.Paint getForegroundPaint()
Paint of the TextPainter context.
Paint, which defines a color or pattern.Paintpublic java.awt.Paint getOutlinePaint()
Paint of the TextPainter context.
Paint, which defines a color or pattern.Paintpublic boolean isAntialiased()
antialiased attribute
antialiased attributepublic java.awt.image.BufferedImage renderString(java.lang.String str)
TextPainter context.
Outline Paint attribute is ignored.
Size of the returned BufferedImage object is equal to visual bounds of the rendered string.
str - string to render
BufferedImage object which contains the specified rendered string
java.lang.NullPointerException - If string to render is nullsetFont(java.awt.Font),
setForegroundPaint(java.awt.Paint),
setAntialiased(boolean),
setBackgroundColor(java.awt.Color)
public java.awt.image.BufferedImage renderString(java.lang.String str,
boolean outline)
TextPainter context.
Size of the returned BufferedImage object is equal to visual bounds of the specified string to render.
str - string to renderoutline - if true then render the string outlined
BufferedImage object which contains the specified rendered string
java.lang.NullPointerException - If string to render is nullsetFont(java.awt.Font),
setForegroundPaint(java.awt.Paint),
setOutlinePaint(java.awt.Paint),
setAntialiased(boolean),
setBackgroundColor(java.awt.Color)
public java.awt.image.BufferedImage renderText(java.lang.String text,
int width,
boolean outline,
boolean centralized)
TextPainter context.
Width of the returned BufferedImage object is equal to the specified width.
Height is automatically extended to contain all text lines.
text - text to renderwidth - the specified width to line-wrap textoutline - if true then render the string outlinedcentralized - if true then the specified text is centralized
BufferedImage object which contains the specified rendered text
java.lang.NullPointerException - If text to render is nullsetFont(java.awt.Font),
setForegroundPaint(java.awt.Paint),
setOutlinePaint(java.awt.Paint),
setAntialiased(boolean),
setBackgroundColor(java.awt.Color)public void setAntialiased(boolean antialiased)
antialiased attribute to the specified value.
antialiased - public void setBackgroundColor(java.awt.Color backgroundColor)
Color attribute for the TextPainter context.
Calling this method with a null Color object does not have any effect on the current background Color attribute of this TextPainter.
backgroundColor - the Color object to be used to generate color during the rendering process, or nullgetBackgroundColor(),
Colorpublic void setFont(java.awt.Font font)
font - Font to renderFontpublic void setForegroundPaint(java.awt.Paint foregroundPaint)
Paint attribute for the TextPainter context.
Calling this method with a null Paint object does not have any effect on the current foreground Paint attribute of this TextPainter.
foregroundPaint - the Paint object to be used to generate color during the rendering process, or nullgetForegroundPaint(),
Paintpublic void setOutlinePaint(java.awt.Paint outlinePaint)
Paint attribute for the TextPainter context.
Calling this method with a null Paint object does not have any effect on the current outline Paint attribute of this TextPainter.
outlinePaint - the Paint object to be used to generate color during the rendering process, or nullgetOutlinePaint(),
Paint
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||