com.flagstone.transform.shape
Class ShapeData

java.lang.Object
  extended by com.flagstone.transform.shape.ShapeData
All Implemented Interfaces:
Copyable<ShapeRecord>, SWFEncodeable, ShapeRecord

public final class ShapeData
extends Object
implements ShapeRecord

ShapeData is a convenience class for holding a set of encoded ShapeRecords so that a Shape can be lazily decoded.


Constructor Summary
ShapeData(byte[] bytes)
          Create a new ShapeData object with an array of encoded ShapeRecords.
ShapeData(int size, SWFDecoder coder)
          Create a new ShapeData object initialised with an array of bytes containing the encoded records for a shape.
ShapeData(ShapeData object)
          Creates and initialises a ShapeData object using the values copied from another ShapeData object.
 
Method Summary
 ShapeData copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 byte[] getData()
          Get a copy of the encoded data for the action.
 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ShapeData

public ShapeData(int size,
                 SWFDecoder coder)
          throws IOException
Create a new ShapeData object initialised with an array of bytes containing the encoded records for a shape.

Parameters:
size - the number of bytes to read for the encoded shape data.
coder - an SWFDecoder object that contains the encoded Flash data.
Throws:
IOException - if an error occurs while reading the encoded shape data.

ShapeData

public ShapeData(byte[] bytes)
Create a new ShapeData object with an array of encoded ShapeRecords.

Parameters:
bytes - the encoded ShapeRecords.

ShapeData

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

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

getData

public byte[] getData()
Get a copy of the encoded data for the action.

Returns:
a copy of the encoded shape.

copy

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

Specified by:
copy in interface Copyable<ShapeRecord>
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.