com.flagstone.transform.text
Class DefineText2

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

public final class DefineText2
extends Object
implements StaticTextTag

DefineText2 defines one or more lines of transparent text.

It extends the functionality provided by the DefineText class by encoding the alpha channel of the colour objects used to set the text color.

DefineText2 class acts as a container for the text. The bounding rectangle and transform controls how the text is laid out. Each TextSpan object 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, DefineText

Constructor Summary
DefineText2(DefineText2 object)
          Creates and initialises a DefineText2 object using the values copied from another DefineText2 object.
DefineText2(int uid, Bounds rect, CoordTransform matrix, List<TextSpan> list)
          Creates a DefineText2 object with the specified bounding rectangle, coordinate transform and text records.
DefineText2(SWFDecoder coder, Context context)
          Creates and initialises a DefineText2 object using values encoded in the Flash binary format.
 
Method Summary
 DefineText2 add(TextSpan obj)
          Add a TextSpan object to the list of text spans.
 DefineText2 copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 Bounds getBounds()
          Returns 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

DefineText2

public DefineText2(SWFDecoder coder,
                   Context context)
            throws IOException
Creates and initialises a DefineText2 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.

DefineText2

public DefineText2(int uid,
                   Bounds rect,
                   CoordTransform matrix,
                   List<TextSpan> list)
Creates a DefineText2 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 TextSpan objects that define the text to be displayed. Must not be null.

DefineText2

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

Parameters:
object - a DefineText2 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 DefineText2 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()
Returns the bounding rectangle that completely encloses the text to be displayed.

Specified by:
getBounds in interface StaticTextTag
Returns:
the bounding rectangle of 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 DefineText2 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.