public class TextSprite
extends java.lang.Object
This class represents text which will be rendered to the a graphics context. This class was created to act as a wrapper for painting text using the Phelphs font library as well as painting using java.awt.Font.
Objects of this type are created by the content parser when "TJ" or "Tj" operands are encountered in a page's content stream. Each TextSprite object is comprised of a list of CharSprites which can be painted by the Shapes class at render time.
| Constructor and Description |
|---|
TextSprite(FontFile font,
int size,
java.awt.geom.AffineTransform graphicStateTransform,
java.awt.geom.AffineTransform tmTransform)
Creates a new TextSprit object.
|
| Modifier and Type | Method and Description |
|---|---|
GlyphText |
addText(java.lang.String cid,
java.lang.String unicode,
float x,
float y,
float width)
Adds a new text char to the TextSprite which will pe painted at x, y under
the current CTM
|
java.awt.geom.Rectangle2D.Float |
getBounds()
Getst the bounds of the text that makes up this sprite.
|
FontFile |
getFont() |
java.lang.String |
getFontName() |
int |
getFontSize() |
java.awt.geom.Area |
getGlyphOutline()
Gets the glyph outline as an Area.
|
java.util.ArrayList<GlyphText> |
getGlyphSprites()
Gets the character bounds of each glyph found in the TextSprite.
|
java.awt.geom.AffineTransform |
getGraphicStateTransform() |
java.awt.Color |
getStrokeColor() |
boolean |
intersects(java.awt.Shape shape)
Tests if the interior of the
TextSprite bounds intersects the
interior of a specified shape. |
void |
paint(java.awt.Graphics g)
Paints all the character elements in this TextSprite to the graphics
context
|
void |
setFontName(java.lang.String fontName) |
void |
setFontSize(int fontSize) |
void |
setGraphicStateTransform(java.awt.geom.AffineTransform graphicStateTransform)
Set the graphic state transform on all child sprites, This is used for
xForm object parsing and text selection.
|
void |
setRMode(int rmode)
Set the rmode for all the characters being in this object.
|
void |
setStrokeColor(java.awt.Color color) |
java.lang.String |
toString() |
public TextSprite(FontFile font, int size, java.awt.geom.AffineTransform graphicStateTransform, java.awt.geom.AffineTransform tmTransform)
Creates a new TextSprit object.
font - font used when painting glyphs.size - size of the font in user spacepublic GlyphText addText(java.lang.String cid, java.lang.String unicode, float x, float y, float width)
Adds a new text char to the TextSprite which will pe painted at x, y under the current CTM
cid - cid to paint.unicode - unicode represention of cid.x - x-coordinate to paint.y - y-coordinate to paint.width - width of cid from font.public java.util.ArrayList<GlyphText> getGlyphSprites()
public java.awt.geom.AffineTransform getGraphicStateTransform()
public void setGraphicStateTransform(java.awt.geom.AffineTransform graphicStateTransform)
graphicStateTransform - public void setRMode(int rmode)
Set the rmode for all the characters being in this object. Rmode can have the following values:
rmode - valid rmode from 0-7public java.lang.String toString()
toString in class java.lang.Objectpublic void setStrokeColor(java.awt.Color color)
public java.awt.geom.Rectangle2D.Float getBounds()
public void paint(java.awt.Graphics g)
Paints all the character elements in this TextSprite to the graphics context
g - graphics context to which the characters will be painted to.public java.awt.geom.Area getGlyphOutline()
public FontFile getFont()
public java.awt.Color getStrokeColor()
public java.lang.String getFontName()
public void setFontName(java.lang.String fontName)
public int getFontSize()
public void setFontSize(int fontSize)
public boolean intersects(java.awt.Shape shape)
TextSprite bounds intersects the
interior of a specified shape.shape - shape to calculate intersection againstTextSprite bounds intersects shape;
otherwise; false.