com.flagstone.transform.shape
Class Shape

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

public final class Shape
extends Object
implements SWFEncodeable, Copyable<Shape>

Shape is a container class for the shape objects (Line, Curve, ShapeStyle and ShapeStyle2 objects) that describe how a particular shape is drawn.

Shapes are used in shape and font definitions. The Shape class is used to simplify the design of these classes and provides no added functionality other than acting as a container class.


Field Summary
static int MAX_COORD
          The maximum coordinate in along the x or y axes.
static int MIN_COORD
          The minimum coordinate in along the x or y axes.
 
Constructor Summary
Shape()
          Constructs an empty Shape.
Shape(List<ShapeRecord> list)
          Creates a Shape object, specifying the Objects that describe how the shape is drawn.
Shape(Shape object)
          Creates and initialises a Shape object using the values copied from another Shape object.
Shape(SWFDecoder coder, Context context)
          Creates and initialises a Shape object using values encoded in the Flash binary format.
 
Method Summary
 Shape add(ShapeRecord anObject)
          Adds the object to the list of shape records.
 Shape copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 List<ShapeRecord> getObjects()
          Get the list of shape records that define the shape.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setObjects(List<ShapeRecord> list)
          Sets the list of shape records.
static Shape shapeFromData(ShapeData shapeData)
          Decode a ShapeData object into the set of ShapeRecord objects that describe how a shape is drawn.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_COORD

public static final int MIN_COORD
The minimum coordinate in along the x or y axes.

See Also:
Constant Field Values

MAX_COORD

public static final int MAX_COORD
The maximum coordinate in along the x or y axes.

See Also:
Constant Field Values
Constructor Detail

Shape

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

Shape

public Shape()
Constructs an empty Shape.


Shape

public Shape(List<ShapeRecord> list)
Creates a Shape object, specifying the Objects that describe how the shape is drawn.

Parameters:
list - the list of shape records. Must not be null.

Shape

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

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

shapeFromData

public static Shape shapeFromData(ShapeData shapeData)
                           throws IOException
Decode a ShapeData object into the set of ShapeRecord objects that describe how a shape is drawn.

Parameters:
shapeData - a ShapeData object containing the encoded shape.
Returns:
the decoded Shape.
Throws:
IOException - if there is an error decoding the shape.

add

public Shape add(ShapeRecord anObject)
Adds the object to the list of shape records.

Parameters:
anObject - an instance of ShapeStyle, Line or Curve. Must not be null.
Returns:
this object.

getObjects

public List<ShapeRecord> getObjects()
Get the list of shape records that define the shape.

Returns:
the list of shape records.

setObjects

public void setObjects(List<ShapeRecord> list)
Sets the list of shape records.

Parameters:
list - the list of shape records. Must not be null.

copy

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

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