com.flagstone.transform.text
Class GlyphIndex

java.lang.Object
  extended by com.flagstone.transform.text.GlyphIndex
All Implemented Interfaces:
SWFEncodeable

public final class GlyphIndex
extends Object
implements SWFEncodeable

GlyphIndex is used to display a text character in a span of text. Each GlyphIndex specifies the glyph to be displayed (rather than the character code) along with the distance to the next Character to be displayed, if any.

A single lines of text is displayed using an TextSpan object which contains a list of Character objects. Blocks of text can be created by combining one or more TextSpan objects which specify the size, colour and relative position of each line.

See Also:
TextSpan

Constructor Summary
GlyphIndex(int anIndex, int anAdvance)
          Creates a Character specifying the index of the glyph to be displayed and the spacing to the next glyph.
GlyphIndex(SWFDecoder coder, Context context)
          Creates and initialises a GlyphIndex object using values encoded in the Flash binary format.
 
Method Summary
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 boolean equals(Object other)
           
 int getAdvance()
          Get the spacing in twips between the glyph representing this character and the next.
 int getGlyphIndex()
          Get the index of the glyph, in a font definition object, that will displayed to represent this character.
 int hashCode()
           
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GlyphIndex

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

GlyphIndex

public GlyphIndex(int anIndex,
                  int anAdvance)
Creates a Character specifying the index of the glyph to be displayed and the spacing to the next glyph.

Parameters:
anIndex - the index into the list of Shapes in a font definition object that defines the glyph that represents the character to be displayed.
anAdvance - the relative position in twips, from the origin of the glyph representing this character to the next glyph to be displayed.
Method Detail

getGlyphIndex

public int getGlyphIndex()
Get the index of the glyph, in a font definition object, that will displayed to represent this character.

Returns:
the glyph index.

getAdvance

public int getAdvance()
Get the spacing in twips between the glyph representing this character and the next.

Returns:
the advance to the next character.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode 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.