com.flagstone.transform.text
Class DefineText

java.lang.Object
  extended by com.flagstone.transform.text.DefineText
All Implemented Interfaces:
Copyable<MovieTag>, SWFEncodeable, DefineTag, MovieTag, StaticTextTag

public final class DefineText
extends Object
implements StaticTextTag

DefineText defines one or more lines of text.

The characters, style and layout information is defined using TextSpan objects. The DefineText 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.

The bounding rectangle and transform controls how the text is laid out. Each Text object in the list of TextSpans 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.

See Also:
TextSpan

Constructor Summary
DefineText(DefineText object)
          Creates and initialises a DefineText object using the values copied from another DefineText object.
DefineText(int uid, Bounds rect, CoordTransform matrix, List<TextSpan> list)
          Creates a DefineText object with the specified bounding rectangle, coordinate transform and text records.
DefineText(SWFDecoder coder, Context context)
          Creates and initialises a DefineText object using values encoded in the Flash binary format.
 
Method Summary
 DefineText add(TextSpan obj)
          Add a TextSpan object to the list of text spans.
 DefineText copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 Bounds getBounds()
          Get the bounding rectangle that completely encloses the text to be displayed.
 int getIdentifier()
          Get the unique identifier assigned to this object.
 List<TextSpan> getSpans()
          Get the list of text spans that define the text to be displayed.
 CoordTransform getTransform()
          Get the coordinate transform that controls the size, location and orientation of the text when it is displayed.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setBounds(Bounds rect)
          Sets the bounding rectangle that encloses the text being displayed.
 void setIdentifier(int uid)
          Sets the unique identifier for an object within a given Movie.
 void setSpans(List<TextSpan> list)
          Sets the list of text spans that define the text to be displayed.
 void setTransform(CoordTransform matrix)
          Sets the coordinate transform that changes the orientation and size of the text displayed.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefineText

public DefineText(SWFDecoder coder,
                  Context context)
           throws IOException
Creates and initialises a DefineText object using values encoded in the Flash binary format.

Parameters:
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.
Throws:
IOException - if an error occurs while decoding the data.

DefineText

public DefineText(int uid,
                  Bounds rect,
                  CoordTransform matrix,
                  List<TextSpan> list)
Creates a DefineText object with the specified bounding rectangle, coordinate transform and text records.

Parameters:
uid - the unique identifier for this object. Must be in the range 1..65535
rect - the bounding rectangle enclosing the text. Must not be null.
matrix - an CoordTransform to change the size and orientation of the text. Must not be null.
list - a list of Text objects that define the text to be displayed. Must not be null.

DefineText

public DefineText(DefineText object)
Creates and initialises a DefineText object using the values copied from another DefineText object.

Parameters:
object - a DefineText object from which the values will be copied.
Method Detail

getIdentifier

public int getIdentifier()
Get the unique identifier assigned to this object.

Specified by:
getIdentifier in interface DefineTag
Returns:
the unique identifier used by the Flash Player to reference this definition.

setIdentifier

public void setIdentifier(int uid)
Sets the unique identifier for an object within a given Movie.

Specified by:
setIdentifier in interface DefineTag
Parameters:
uid - a unique identifier for the object. Must be in the range 1..65535.

add

public DefineText add(TextSpan obj)
Add a TextSpan object to the list of text spans.

Parameters:
obj - an TextSpan object. Must not be null.
Returns:
this object.

getBounds

public Bounds getBounds()
Get the bounding rectangle that completely encloses the text to be displayed.

Specified by:
getBounds in interface StaticTextTag
Returns:
the bounding box that encloses the text.

getTransform

public CoordTransform getTransform()
Get the coordinate transform that controls the size, location and orientation of the text when it is displayed.

Specified by:
getTransform in interface StaticTextTag
Returns:
the coordinate transform used to position the text.

getSpans

public List<TextSpan> getSpans()
Get the list of text spans that define the text to be displayed.

Specified by:
getSpans in interface StaticTextTag
Returns:
the list of text blocks.

setBounds

public void setBounds(Bounds rect)
Sets the bounding rectangle that encloses the text being displayed.

Specified by:
setBounds in interface StaticTextTag
Parameters:
rect - the bounding rectangle enclosing the text. Must not be null.

setTransform

public void setTransform(CoordTransform matrix)
Sets the coordinate transform that changes the orientation and size of the text displayed.

Specified by:
setTransform in interface StaticTextTag
Parameters:
matrix - an CoordTransform to change the size and orientation of the text. Must not be null.

setSpans

public void setSpans(List<TextSpan> list)
Sets the list of text spans that define the text to be displayed.

Specified by:
setSpans in interface StaticTextTag
Parameters:
list - a list of TextSpan objects that define the text to be displayed. Must not be null.

copy

public DefineText copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<MovieTag>
Returns:
a deep-copy of this object. New instances of mutable objects are copied and immutable instances are shared.

toString

public String toString()
Overrides:
toString in class Object

prepareToEncode

public int prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. This method also used to initialise variables, such as offsets and flags that will be used when the object is encoded. Generally the method returns the size in bytes, however when called on objects that use bit fields such as shapes the methods will return the size in bits.

Specified by:
prepareToEncode in interface SWFEncodeable
Parameters:
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Returns:
the size of the object when it is encoded.

encode

public void encode(SWFEncoder coder,
                   Context context)
            throws IOException
Encode an object to the Flash binary format.

Specified by:
encode in interface SWFEncodeable
Parameters:
coder - an SWFEncoder object.
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Throws:
IOException - if an error occurs while encoding the object.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.