|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.text.TextSpan
public final class TextSpan
TextSpan is used to display a group of characters with a selected font and
colour. TextSpan objects are used in DefineText
and
DefineText2
to display a line or block of text.
TextSpan contains a list of Character objects which identify the glyphs that will be displayed along with style information that sets the colour of the text, the size of the font and the relative placement of the line within a block of text.
Whether the alpha channel in the colour needs to be specified depends on the class the Text is added to. The DefineText2 class supports transparent text while DefineText class does not.
The x and y offsets are used to control how several TextSpan objects are laid out to create a block of text. The y offset is specified relative to the bottom edge of the bounding rectangle, which is actually closer to the top of the screen as the direction of the y-axis is from the top to the bottom of the screen. In this respect Flash is counter-intuitive. Lines with higher offset values are displayed below lines with lower offsets.
The x and y offsets are also optional and may be set to the constant VALUE_NOT_SET when more than one TextSpan object is created. If the y offset is not specified then a TextSpan object is displayed on the same line as the previous TextSpan. If the x offset is not specified then the TextSpan is displayed after the previous TextSpan. This makes it easy to lay text out on a single line.
Similarly the font and colour information is optional. The values from a previous TextSpan object will be used if they are not set.
The creation and layout of the glyphs to create the text is too onerous to
perform from scratch. It is easier and more convenient to use the
TextTable
class to create the
TextSpan objects.
DefineText
,
DefineText2
,
TextTable
,
Font
Constructor Summary | |
---|---|
TextSpan(Integer uid,
Integer aHeight,
Color aColor,
Integer xOffset,
Integer yOffset,
List<GlyphIndex> list)
Creates a Text object, specifying the colour and position of the following Text. |
|
TextSpan(SWFDecoder coder,
Context context)
Creates and initialises a TextSpan object using values encoded in the Flash binary format. |
|
TextSpan(TextSpan object)
Creates and initialises a TextSpan object using the values copied from another TextSpan object. |
Method Summary | |
---|---|
TextSpan |
add(GlyphIndex aCharacter)
Adds an Character object to the list of characters. |
protected int |
advanceBits()
The number of bits used to encode the advances. |
TextSpan |
copy()
Creates a complete copy of this object. |
void |
encode(SWFEncoder coder,
Context context)
Encode an object to the Flash binary format. |
List<GlyphIndex> |
getCharacters()
Returns the list of characters to be displayed. |
Color |
getColor()
Get the colour used to display the text. |
Integer |
getHeight()
Get the height of the text. |
Integer |
getIdentifier()
Get the identifier of the font in which the text will be displayed. |
Integer |
getOffsetX()
Get the location of the start of the text relative to the left edge of the bounding rectangle in twips. |
Integer |
getOffsetY()
Get the location of the start of the text relative to the bottom edge of the bounding rectangle in twips. |
protected int |
glyphBits()
The number of bits used to encode the glyph indices. |
int |
prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. |
void |
setCharacters(List<GlyphIndex> list)
Sets the list of characters to be displayed. |
void |
setColor(Color aColor)
Sets the colour of the font in which the text will be displayed. |
void |
setHeight(Integer aHeight)
Sets the height of the text in twips. |
void |
setIdentifier(Integer uid)
Sets the identifier of the font in which the text will be displayed. |
void |
setOffsetX(Integer offset)
Sets the location of the start of the text relative to the left edge of the bounding rectangle in twips. |
void |
setOffsetY(Integer offset)
Sets the location of the start of the text relative to the bottom edge of the bounding rectangle in twips. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TextSpan(SWFDecoder coder, Context context) throws IOException
coder
- an SWFDecoder object that contains the encoded Flash data.context
- a Context object used to manage the decoders for different
type of object and to pass information on how objects are
decoded.
IOException
- if an error occurs while decoding the data.public TextSpan(Integer uid, Integer aHeight, Color aColor, Integer xOffset, Integer yOffset, List<GlyphIndex> list)
uid
- the identifier of the font that the text will be rendered in.
Must be in the range 1..65535.aHeight
- the height of the text in the chosen font. Must be in the
range 1..65535.aColor
- the colour of the text.xOffset
- the location of the text relative to the left edge of the
bounding rectangle enclosing the text.yOffset
- the location of the text relative to the bottom edge of the
bounding rectangle enclosing the text.list
- a list of Character objects. Must not be null.public TextSpan(TextSpan object)
object
- a TextSpan object from which the values will be
copied.Method Detail |
---|
public Integer getIdentifier()
public Color getColor()
public Integer getOffsetX()
public Integer getOffsetY()
public Integer getHeight()
public void setIdentifier(Integer uid)
uid
- the identifier of the font that the text will be rendered in.
Must be in the range 1..65535.public void setColor(Color aColor)
aColor
- the colour of the text.public void setOffsetX(Integer offset)
offset
- the location of the text relative to the left edge of the
bounding rectangle enclosing the text. Must be in the range
-32768..32767 or null if no offset is specified.public void setOffsetY(Integer offset)
offset
- the location of the text relative to the bottom edge of the
bounding rectangle enclosing the text. Must be in the range
-32768..32767 or null if no offset is specified.public void setHeight(Integer aHeight)
aHeight
- the height of the text in the chosen font. Must be in the
range 0..65535.public TextSpan add(GlyphIndex aCharacter)
aCharacter
- an Character object. Must not be null.
public List<GlyphIndex> getCharacters()
public void setCharacters(List<GlyphIndex> list)
list
- a list of Character objects. Must not be null.public TextSpan copy()
copy
in interface Copyable<TextSpan>
public String toString()
toString
in class Object
public int prepareToEncode(Context context)
prepareToEncode
in interface SWFEncodeable
context
- an Context that allows information to be passed between
objects to control how they are initialised for encoding.
public void encode(SWFEncoder coder, Context context) throws IOException
encode
in interface SWFEncodeable
coder
- an SWFEncoder object.context
- an Context that allows information to be passed between
objects to control how they are initialised for encoding.
IOException
- if an error occurs while encoding the object.protected int glyphBits()
protected int advanceBits()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |