|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.FSTransformObject
com.flagstone.transform.FSMovieObject
com.flagstone.transform.FSDefineObject
com.flagstone.transform.FSDefineText2
public class FSDefineText2
FSDefineText2 defines one or more lines of transparent text.
It extends the functionality provided by the FSDefineText class by supporting transparent colours. The characters, style and layout information is defined using FSText objects. The FSDefineText2 class acts as a container for the text, defining the bounding rectangle that encloses the text along with a coordinate transform that can be used to change the size and orientation of the text when it is displayed.
Attributes | |
---|---|
type | Identifies the data structure when it is encoded. Read-only. |
identifier | An unique identifier for this object in the range 1..65535. |
bounds | A bounding rectangle for the entire block of text defined in the object. |
transform | A coordinate transform describing the placement, size and rotation of the text block. |
objects | An array of FSText objects describing the characters to be displayed and their attributes. |
The bounding rectangle and transform controls how the text is laid out. Each FSText object in the textRecords array specifies an offset from the left and bottom edges of the bounding rectangle, allowing successive lines of text to be arranged as a block or paragraph. The coordinate transform can be used to control the size and orientation of the text when it is displayed.
Creating a simple string. 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 existing font definitions either by parsing an existing Flash file or by converting a font definition from a specification such as TrueType in order to obtain the glyphs and layout information.
This examples assumes a font definition that contains glyphs for the following set of characters ' ', 'a', 'b', 'c' .... 'x', 'y', 'z'. The font used fixed size for the spacing between glyphs .e.g. Courier.
int fontSize = 240; int leading = 80; ArrayList characters = new ArrayList(); ArrayList lines = new ArrayList(); characters.add(new FSCharacter(1, 120)); // 'a' characters.add(new FSCharacter(0, 120)); // ' ' characters.add(new FSCharacter(19, 120)); // 's' characters.add(new FSCharacter(10, 120)); // 't' characters.add(new FSCharacter(18, 120)); // 'r' characters.add(new FSCharacter(9, 120)); // 'i' characters.add(new FSCharacter(14, 120)); // 'n' characters.add(new FSCharacter(6, 120)); // 'g' // Create the string setting the height to be 12-point (240 twips) and displaying the characters in black. // the text is not indented or offset. lines.add(new FSText(font.getIdentifier, FSColor.black()), 0, 0, fontSize, characters); // Calculate the bounding rectangle that encloses the text. // The width of the text by summing all the advances. int width = 0; int height = fontSize + leading; for (Iterator i = characters.iterator(); i.hasNext();) width += ((FSCharacter) i.next()).getAdvance(); FSBounds bounds = new FSBounds(0, 0, width, height); // Define the text with no coordinate transformation (use the default unity transform which leaves // the text unchanged. FSDefineText text = new FSDefineText(movie.newIdentifier(), bounds, new FSCoordTransform(), lines);
The FSDefineText2 class represents the DefineText2 tag from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 3.
Field Summary |
---|
Fields inherited from class com.flagstone.transform.FSDefineObject |
---|
identifier |
Constructor Summary | |
---|---|
FSDefineText2(FSCoder coder)
Construct an FSDefineText2 object, initialising it with values decoded from an encoded object. |
|
FSDefineText2(FSDefineText2 obj)
Constructs an FSDefineText object by copying values from an existing object. |
|
FSDefineText2(int anIdentifier,
FSBounds aBounds,
FSCoordTransform aTransform,
java.util.ArrayList textRecordArray)
Constructs an FSDefineText2 object with the specified bounding rectangle, coordinate transform and text records. |
Method Summary | |
---|---|
void |
add(FSText anObject)
Add a FSText object to the array of text records. |
void |
appendDescription(java.lang.StringBuffer buffer,
int depth)
AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. |
java.lang.Object |
clone()
Creates a deep copy of the entire object. |
void |
decode(FSCoder coder)
|
void |
encode(FSCoder coder)
|
boolean |
equals(java.lang.Object anObject)
Returns true if anObject is equal to this one. |
FSBounds |
getBounds()
Gets the bounding rectangle that completely encloses the text to be displayed. |
java.util.ArrayList |
getObjects()
Gets the array of text records that define the text to be displayed as its attributes. |
FSCoordTransform |
getTransform()
Gets the coordinate transform that controls how the text is displayed. |
int |
length(FSCoder coder)
|
void |
setBounds(FSBounds aBounds)
Sets the bounding rectangle that encloses the text being displayed. |
void |
setObjects(java.util.ArrayList anArray)
Sets the array of text records that define the text to be displayed. |
void |
setTransform(FSCoordTransform aTransform)
Sets the coordinate transform that changes the orientation and size of the text displayed. |
Methods inherited from class com.flagstone.transform.FSDefineObject |
---|
getIdentifier, setIdentifier |
Methods inherited from class com.flagstone.transform.FSMovieObject |
---|
getType |
Methods inherited from class com.flagstone.transform.FSTransformObject |
---|
name, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FSDefineText2(FSCoder coder)
coder
- an FSCoder containing the binary data.public FSDefineText2(int anIdentifier, FSBounds aBounds, FSCoordTransform aTransform, java.util.ArrayList textRecordArray)
anIdentifier
- the unique identifier for this object.aBounds
- the bounding rectangle enclosing the text.aTransform
- an FSCoordTransform to change the size and orientation of the
text.textRecordArray
- an array of text record (FSTextStyle and FSText) object that
define the text to be displayed.public FSDefineText2(FSDefineText2 obj)
obj
- an FSDefineText object.Method Detail |
---|
public void add(FSText anObject)
anObject
- an FSText object.public FSBounds getBounds()
public FSCoordTransform getTransform()
public java.util.ArrayList getObjects()
public void setBounds(FSBounds aBounds)
aBounds
- the bounding rectangle enclosing the text.public void setTransform(FSCoordTransform aTransform)
aTransform
- an FSCoordTransform to change the size and orientation of the
text.public void setObjects(java.util.ArrayList anArray)
anArray
- an array of FSText objects that define the text to be
displayed.public java.lang.Object clone()
FSTransformObject
clone
in class FSTransformObject
public boolean equals(java.lang.Object anObject)
FSMovieObject
equals
in class FSMovieObject
public void appendDescription(java.lang.StringBuffer buffer, int depth)
FSTransformObject
appendDescription
in class FSDefineObject
buffer
- a StringBuffer to which the description of each object is
appended.depth
- the maximum level of nesting up to which objects will be
displayed.public int length(FSCoder coder)
length
in class FSDefineObject
public void encode(FSCoder coder)
encode
in class FSDefineObject
public void decode(FSCoder coder)
decode
in class FSDefineObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |